documentation.d.ts 2.9 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212
  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. * Class containing a set of static utilities functions for arrays.
  52. */
  53. export class ArrayTools {
  54. /**
  55. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56. * @param size the number of element to construct and put in the array
  57. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58. * @returns a new array filled with new objects
  59. */
  60. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  61. }
  62. }
  63. declare module BABYLON {
  64. /**
  65. * Scalar computation library
  66. */
  67. export class Scalar {
  68. /**
  69. * Two pi constants convenient for computation.
  70. */
  71. static TwoPi: number;
  72. /**
  73. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74. * @param a number
  75. * @param b number
  76. * @param epsilon (default = 1.401298E-45)
  77. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78. */
  79. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80. /**
  81. * Returns a string : the upper case translation of the number i to hexadecimal.
  82. * @param i number
  83. * @returns the upper case translation of the number i to hexadecimal.
  84. */
  85. static ToHex(i: number): string;
  86. /**
  87. * Returns -1 if value is negative and +1 is value is positive.
  88. * @param value the value
  89. * @returns the value itself if it's equal to zero.
  90. */
  91. static Sign(value: number): number;
  92. /**
  93. * Returns the value itself if it's between min and max.
  94. * Returns min if the value is lower than min.
  95. * Returns max if the value is greater than max.
  96. * @param value the value to clmap
  97. * @param min the min value to clamp to (default: 0)
  98. * @param max the max value to clamp to (default: 1)
  99. * @returns the clamped value
  100. */
  101. static Clamp(value: number, min?: number, max?: number): number;
  102. /**
  103. * the log2 of value.
  104. * @param value the value to compute log2 of
  105. * @returns the log2 of value.
  106. */
  107. static Log2(value: number): number;
  108. /**
  109. * Loops the value, so that it is never larger than length and never smaller than 0.
  110. *
  111. * This is similar to the modulo operator but it works with floating point numbers.
  112. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  113. * With t = 5 and length = 2.5, the result would be 0.0.
  114. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  115. * @param value the value
  116. * @param length the length
  117. * @returns the looped value
  118. */
  119. static Repeat(value: number, length: number): number;
  120. /**
  121. * Normalize the value between 0.0 and 1.0 using min and max values
  122. * @param value value to normalize
  123. * @param min max to normalize between
  124. * @param max min to normalize between
  125. * @returns the normalized value
  126. */
  127. static Normalize(value: number, min: number, max: number): number;
  128. /**
  129. * Denormalize the value from 0.0 and 1.0 using min and max values
  130. * @param normalized value to denormalize
  131. * @param min max to denormalize between
  132. * @param max min to denormalize between
  133. * @returns the denormalized value
  134. */
  135. static Denormalize(normalized: number, min: number, max: number): number;
  136. /**
  137. * Calculates the shortest difference between two given angles given in degrees.
  138. * @param current current angle in degrees
  139. * @param target target angle in degrees
  140. * @returns the delta
  141. */
  142. static DeltaAngle(current: number, target: number): number;
  143. /**
  144. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  145. * @param tx value
  146. * @param length length
  147. * @returns The returned value will move back and forth between 0 and length
  148. */
  149. static PingPong(tx: number, length: number): number;
  150. /**
  151. * Interpolates between min and max with smoothing at the limits.
  152. *
  153. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  154. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  155. * @param from from
  156. * @param to to
  157. * @param tx value
  158. * @returns the smooth stepped value
  159. */
  160. static SmoothStep(from: number, to: number, tx: number): number;
  161. /**
  162. * Moves a value current towards target.
  163. *
  164. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  165. * Negative values of maxDelta pushes the value away from target.
  166. * @param current current value
  167. * @param target target value
  168. * @param maxDelta max distance to move
  169. * @returns resulting value
  170. */
  171. static MoveTowards(current: number, target: number, maxDelta: number): number;
  172. /**
  173. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  174. *
  175. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  176. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  177. * @param current current value
  178. * @param target target value
  179. * @param maxDelta max distance to move
  180. * @returns resulting angle
  181. */
  182. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  183. /**
  184. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  185. * @param start start value
  186. * @param end target value
  187. * @param amount amount to lerp between
  188. * @returns the lerped value
  189. */
  190. static Lerp(start: number, end: number, amount: number): number;
  191. /**
  192. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  193. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  194. * @param start start value
  195. * @param end target value
  196. * @param amount amount to lerp between
  197. * @returns the lerped value
  198. */
  199. static LerpAngle(start: number, end: number, amount: number): number;
  200. /**
  201. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  202. * @param a start value
  203. * @param b target value
  204. * @param value value between a and b
  205. * @returns the inverseLerp value
  206. */
  207. static InverseLerp(a: number, b: number, value: number): number;
  208. /**
  209. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  210. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  211. * @param value1 spline value
  212. * @param tangent1 spline value
  213. * @param value2 spline value
  214. * @param tangent2 spline value
  215. * @param amount input value
  216. * @returns hermite result
  217. */
  218. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  219. /**
  220. * Returns a random float number between and min and max values
  221. * @param min min value of random
  222. * @param max max value of random
  223. * @returns random value
  224. */
  225. static RandomRange(min: number, max: number): number;
  226. /**
  227. * This function returns percentage of a number in a given range.
  228. *
  229. * RangeToPercent(40,20,60) will return 0.5 (50%)
  230. * RangeToPercent(34,0,100) will return 0.34 (34%)
  231. * @param number to convert to percentage
  232. * @param min min range
  233. * @param max max range
  234. * @returns the percentage
  235. */
  236. static RangeToPercent(number: number, min: number, max: number): number;
  237. /**
  238. * This function returns number that corresponds to the percentage in a given range.
  239. *
  240. * PercentToRange(0.34,0,100) will return 34.
  241. * @param percent to convert to number
  242. * @param min min range
  243. * @param max max range
  244. * @returns the number
  245. */
  246. static PercentToRange(percent: number, min: number, max: number): number;
  247. /**
  248. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  249. * @param angle The angle to normalize in radian.
  250. * @return The converted angle.
  251. */
  252. static NormalizeRadians(angle: number): number;
  253. }
  254. }
  255. declare module BABYLON {
  256. /**
  257. * Constant used to convert a value to gamma space
  258. * @ignorenaming
  259. */
  260. export const ToGammaSpace: number;
  261. /**
  262. * Constant used to convert a value to linear space
  263. * @ignorenaming
  264. */
  265. export const ToLinearSpace = 2.2;
  266. /**
  267. * Constant used to define the minimal number value in Babylon.js
  268. * @ignorenaming
  269. */
  270. let Epsilon: number;
  271. /**
  272. * Class used to hold a RBG color
  273. */
  274. export class Color3 {
  275. /**
  276. * Defines the red component (between 0 and 1, default is 0)
  277. */
  278. r: number;
  279. /**
  280. * Defines the green component (between 0 and 1, default is 0)
  281. */
  282. g: number;
  283. /**
  284. * Defines the blue component (between 0 and 1, default is 0)
  285. */
  286. b: number;
  287. /**
  288. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  289. * @param r defines the red component (between 0 and 1, default is 0)
  290. * @param g defines the green component (between 0 and 1, default is 0)
  291. * @param b defines the blue component (between 0 and 1, default is 0)
  292. */
  293. constructor(
  294. /**
  295. * Defines the red component (between 0 and 1, default is 0)
  296. */
  297. r?: number,
  298. /**
  299. * Defines the green component (between 0 and 1, default is 0)
  300. */
  301. g?: number,
  302. /**
  303. * Defines the blue component (between 0 and 1, default is 0)
  304. */
  305. b?: number);
  306. /**
  307. * Creates a string with the Color3 current values
  308. * @returns the string representation of the Color3 object
  309. */
  310. toString(): string;
  311. /**
  312. * Returns the string "Color3"
  313. * @returns "Color3"
  314. */
  315. getClassName(): string;
  316. /**
  317. * Compute the Color3 hash code
  318. * @returns an unique number that can be used to hash Color3 objects
  319. */
  320. getHashCode(): number;
  321. /**
  322. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  323. * @param array defines the array where to store the r,g,b components
  324. * @param index defines an optional index in the target array to define where to start storing values
  325. * @returns the current Color3 object
  326. */
  327. toArray(array: FloatArray, index?: number): Color3;
  328. /**
  329. * Returns a new Color4 object from the current Color3 and the given alpha
  330. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  331. * @returns a new Color4 object
  332. */
  333. toColor4(alpha?: number): Color4;
  334. /**
  335. * Returns a new array populated with 3 numeric elements : red, green and blue values
  336. * @returns the new array
  337. */
  338. asArray(): number[];
  339. /**
  340. * Returns the luminance value
  341. * @returns a float value
  342. */
  343. toLuminance(): number;
  344. /**
  345. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  346. * @param otherColor defines the second operand
  347. * @returns the new Color3 object
  348. */
  349. multiply(otherColor: DeepImmutable<Color3>): Color3;
  350. /**
  351. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  352. * @param otherColor defines the second operand
  353. * @param result defines the Color3 object where to store the result
  354. * @returns the current Color3
  355. */
  356. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  357. /**
  358. * Determines equality between Color3 objects
  359. * @param otherColor defines the second operand
  360. * @returns true if the rgb values are equal to the given ones
  361. */
  362. equals(otherColor: DeepImmutable<Color3>): boolean;
  363. /**
  364. * Determines equality between the current Color3 object and a set of r,b,g values
  365. * @param r defines the red component to check
  366. * @param g defines the green component to check
  367. * @param b defines the blue component to check
  368. * @returns true if the rgb values are equal to the given ones
  369. */
  370. equalsFloats(r: number, g: number, b: number): boolean;
  371. /**
  372. * Multiplies in place each rgb value by scale
  373. * @param scale defines the scaling factor
  374. * @returns the updated Color3
  375. */
  376. scale(scale: number): Color3;
  377. /**
  378. * Multiplies the rgb values by scale and stores the result into "result"
  379. * @param scale defines the scaling factor
  380. * @param result defines the Color3 object where to store the result
  381. * @returns the unmodified current Color3
  382. */
  383. scaleToRef(scale: number, result: Color3): Color3;
  384. /**
  385. * Scale the current Color3 values by a factor and add the result to a given Color3
  386. * @param scale defines the scale factor
  387. * @param result defines color to store the result into
  388. * @returns the unmodified current Color3
  389. */
  390. scaleAndAddToRef(scale: number, result: Color3): Color3;
  391. /**
  392. * Clamps the rgb values by the min and max values and stores the result into "result"
  393. * @param min defines minimum clamping value (default is 0)
  394. * @param max defines maximum clamping value (default is 1)
  395. * @param result defines color to store the result into
  396. * @returns the original Color3
  397. */
  398. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  399. /**
  400. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  401. * @param otherColor defines the second operand
  402. * @returns the new Color3
  403. */
  404. add(otherColor: DeepImmutable<Color3>): Color3;
  405. /**
  406. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  407. * @param otherColor defines the second operand
  408. * @param result defines Color3 object to store the result into
  409. * @returns the unmodified current Color3
  410. */
  411. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  412. /**
  413. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  414. * @param otherColor defines the second operand
  415. * @returns the new Color3
  416. */
  417. subtract(otherColor: DeepImmutable<Color3>): Color3;
  418. /**
  419. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  420. * @param otherColor defines the second operand
  421. * @param result defines Color3 object to store the result into
  422. * @returns the unmodified current Color3
  423. */
  424. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  425. /**
  426. * Copy the current object
  427. * @returns a new Color3 copied the current one
  428. */
  429. clone(): Color3;
  430. /**
  431. * Copies the rgb values from the source in the current Color3
  432. * @param source defines the source Color3 object
  433. * @returns the updated Color3 object
  434. */
  435. copyFrom(source: DeepImmutable<Color3>): Color3;
  436. /**
  437. * Updates the Color3 rgb values from the given floats
  438. * @param r defines the red component to read from
  439. * @param g defines the green component to read from
  440. * @param b defines the blue component to read from
  441. * @returns the current Color3 object
  442. */
  443. copyFromFloats(r: number, g: number, b: number): Color3;
  444. /**
  445. * Updates the Color3 rgb values from the given floats
  446. * @param r defines the red component to read from
  447. * @param g defines the green component to read from
  448. * @param b defines the blue component to read from
  449. * @returns the current Color3 object
  450. */
  451. set(r: number, g: number, b: number): Color3;
  452. /**
  453. * Compute the Color3 hexadecimal code as a string
  454. * @returns a string containing the hexadecimal representation of the Color3 object
  455. */
  456. toHexString(): string;
  457. /**
  458. * Computes a new Color3 converted from the current one to linear space
  459. * @returns a new Color3 object
  460. */
  461. toLinearSpace(): Color3;
  462. /**
  463. * Converts current color in rgb space to HSV values
  464. * @returns a new color3 representing the HSV values
  465. */
  466. toHSV(): Color3;
  467. /**
  468. * Converts current color in rgb space to HSV values
  469. * @param result defines the Color3 where to store the HSV values
  470. */
  471. toHSVToRef(result: Color3): void;
  472. /**
  473. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  474. * @param convertedColor defines the Color3 object where to store the linear space version
  475. * @returns the unmodified Color3
  476. */
  477. toLinearSpaceToRef(convertedColor: Color3): Color3;
  478. /**
  479. * Computes a new Color3 converted from the current one to gamma space
  480. * @returns a new Color3 object
  481. */
  482. toGammaSpace(): Color3;
  483. /**
  484. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  485. * @param convertedColor defines the Color3 object where to store the gamma space version
  486. * @returns the unmodified Color3
  487. */
  488. toGammaSpaceToRef(convertedColor: Color3): Color3;
  489. private static _BlackReadOnly;
  490. /**
  491. * Convert Hue, saturation and value to a Color3 (RGB)
  492. * @param hue defines the hue
  493. * @param saturation defines the saturation
  494. * @param value defines the value
  495. * @param result defines the Color3 where to store the RGB values
  496. */
  497. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  498. /**
  499. * Creates a new Color3 from the string containing valid hexadecimal values
  500. * @param hex defines a string containing valid hexadecimal values
  501. * @returns a new Color3 object
  502. */
  503. static FromHexString(hex: string): Color3;
  504. /**
  505. * Creates a new Color3 from the starting index of the given array
  506. * @param array defines the source array
  507. * @param offset defines an offset in the source array
  508. * @returns a new Color3 object
  509. */
  510. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  511. /**
  512. * Creates a new Color3 from integer values (< 256)
  513. * @param r defines the red component to read from (value between 0 and 255)
  514. * @param g defines the green component to read from (value between 0 and 255)
  515. * @param b defines the blue component to read from (value between 0 and 255)
  516. * @returns a new Color3 object
  517. */
  518. static FromInts(r: number, g: number, b: number): Color3;
  519. /**
  520. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  521. * @param start defines the start Color3 value
  522. * @param end defines the end Color3 value
  523. * @param amount defines the gradient value between start and end
  524. * @returns a new Color3 object
  525. */
  526. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  527. /**
  528. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  529. * @param left defines the start value
  530. * @param right defines the end value
  531. * @param amount defines the gradient factor
  532. * @param result defines the Color3 object where to store the result
  533. */
  534. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  535. /**
  536. * Returns a Color3 value containing a red color
  537. * @returns a new Color3 object
  538. */
  539. static Red(): Color3;
  540. /**
  541. * Returns a Color3 value containing a green color
  542. * @returns a new Color3 object
  543. */
  544. static Green(): Color3;
  545. /**
  546. * Returns a Color3 value containing a blue color
  547. * @returns a new Color3 object
  548. */
  549. static Blue(): Color3;
  550. /**
  551. * Returns a Color3 value containing a black color
  552. * @returns a new Color3 object
  553. */
  554. static Black(): Color3;
  555. /**
  556. * Gets a Color3 value containing a black color that must not be updated
  557. */
  558. static readonly BlackReadOnly: DeepImmutable<Color3>;
  559. /**
  560. * Returns a Color3 value containing a white color
  561. * @returns a new Color3 object
  562. */
  563. static White(): Color3;
  564. /**
  565. * Returns a Color3 value containing a purple color
  566. * @returns a new Color3 object
  567. */
  568. static Purple(): Color3;
  569. /**
  570. * Returns a Color3 value containing a magenta color
  571. * @returns a new Color3 object
  572. */
  573. static Magenta(): Color3;
  574. /**
  575. * Returns a Color3 value containing a yellow color
  576. * @returns a new Color3 object
  577. */
  578. static Yellow(): Color3;
  579. /**
  580. * Returns a Color3 value containing a gray color
  581. * @returns a new Color3 object
  582. */
  583. static Gray(): Color3;
  584. /**
  585. * Returns a Color3 value containing a teal color
  586. * @returns a new Color3 object
  587. */
  588. static Teal(): Color3;
  589. /**
  590. * Returns a Color3 value containing a random color
  591. * @returns a new Color3 object
  592. */
  593. static Random(): Color3;
  594. }
  595. /**
  596. * Class used to hold a RBGA color
  597. */
  598. export class Color4 {
  599. /**
  600. * Defines the red component (between 0 and 1, default is 0)
  601. */
  602. r: number;
  603. /**
  604. * Defines the green component (between 0 and 1, default is 0)
  605. */
  606. g: number;
  607. /**
  608. * Defines the blue component (between 0 and 1, default is 0)
  609. */
  610. b: number;
  611. /**
  612. * Defines the alpha component (between 0 and 1, default is 1)
  613. */
  614. a: number;
  615. /**
  616. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  617. * @param r defines the red component (between 0 and 1, default is 0)
  618. * @param g defines the green component (between 0 and 1, default is 0)
  619. * @param b defines the blue component (between 0 and 1, default is 0)
  620. * @param a defines the alpha component (between 0 and 1, default is 1)
  621. */
  622. constructor(
  623. /**
  624. * Defines the red component (between 0 and 1, default is 0)
  625. */
  626. r?: number,
  627. /**
  628. * Defines the green component (between 0 and 1, default is 0)
  629. */
  630. g?: number,
  631. /**
  632. * Defines the blue component (between 0 and 1, default is 0)
  633. */
  634. b?: number,
  635. /**
  636. * Defines the alpha component (between 0 and 1, default is 1)
  637. */
  638. a?: number);
  639. /**
  640. * Adds in place the given Color4 values to the current Color4 object
  641. * @param right defines the second operand
  642. * @returns the current updated Color4 object
  643. */
  644. addInPlace(right: DeepImmutable<Color4>): Color4;
  645. /**
  646. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  647. * @returns the new array
  648. */
  649. asArray(): number[];
  650. /**
  651. * Stores from the starting index in the given array the Color4 successive values
  652. * @param array defines the array where to store the r,g,b components
  653. * @param index defines an optional index in the target array to define where to start storing values
  654. * @returns the current Color4 object
  655. */
  656. toArray(array: number[], index?: number): Color4;
  657. /**
  658. * Determines equality between Color4 objects
  659. * @param otherColor defines the second operand
  660. * @returns true if the rgba values are equal to the given ones
  661. */
  662. equals(otherColor: DeepImmutable<Color4>): boolean;
  663. /**
  664. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  665. * @param right defines the second operand
  666. * @returns a new Color4 object
  667. */
  668. add(right: DeepImmutable<Color4>): Color4;
  669. /**
  670. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  671. * @param right defines the second operand
  672. * @returns a new Color4 object
  673. */
  674. subtract(right: DeepImmutable<Color4>): Color4;
  675. /**
  676. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  677. * @param right defines the second operand
  678. * @param result defines the Color4 object where to store the result
  679. * @returns the current Color4 object
  680. */
  681. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  682. /**
  683. * Creates a new Color4 with the current Color4 values multiplied by scale
  684. * @param scale defines the scaling factor to apply
  685. * @returns a new Color4 object
  686. */
  687. scale(scale: number): Color4;
  688. /**
  689. * Multiplies the current Color4 values by scale and stores the result in "result"
  690. * @param scale defines the scaling factor to apply
  691. * @param result defines the Color4 object where to store the result
  692. * @returns the current unmodified Color4
  693. */
  694. scaleToRef(scale: number, result: Color4): Color4;
  695. /**
  696. * Scale the current Color4 values by a factor and add the result to a given Color4
  697. * @param scale defines the scale factor
  698. * @param result defines the Color4 object where to store the result
  699. * @returns the unmodified current Color4
  700. */
  701. scaleAndAddToRef(scale: number, result: Color4): Color4;
  702. /**
  703. * Clamps the rgb values by the min and max values and stores the result into "result"
  704. * @param min defines minimum clamping value (default is 0)
  705. * @param max defines maximum clamping value (default is 1)
  706. * @param result defines color to store the result into.
  707. * @returns the cuurent Color4
  708. */
  709. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  710. /**
  711. * Multipy an Color4 value by another and return a new Color4 object
  712. * @param color defines the Color4 value to multiply by
  713. * @returns a new Color4 object
  714. */
  715. multiply(color: Color4): Color4;
  716. /**
  717. * Multipy a Color4 value by another and push the result in a reference value
  718. * @param color defines the Color4 value to multiply by
  719. * @param result defines the Color4 to fill the result in
  720. * @returns the result Color4
  721. */
  722. multiplyToRef(color: Color4, result: Color4): Color4;
  723. /**
  724. * Creates a string with the Color4 current values
  725. * @returns the string representation of the Color4 object
  726. */
  727. toString(): string;
  728. /**
  729. * Returns the string "Color4"
  730. * @returns "Color4"
  731. */
  732. getClassName(): string;
  733. /**
  734. * Compute the Color4 hash code
  735. * @returns an unique number that can be used to hash Color4 objects
  736. */
  737. getHashCode(): number;
  738. /**
  739. * Creates a new Color4 copied from the current one
  740. * @returns a new Color4 object
  741. */
  742. clone(): Color4;
  743. /**
  744. * Copies the given Color4 values into the current one
  745. * @param source defines the source Color4 object
  746. * @returns the current updated Color4 object
  747. */
  748. copyFrom(source: Color4): Color4;
  749. /**
  750. * Copies the given float values into the current one
  751. * @param r defines the red component to read from
  752. * @param g defines the green component to read from
  753. * @param b defines the blue component to read from
  754. * @param a defines the alpha component to read from
  755. * @returns the current updated Color4 object
  756. */
  757. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  758. /**
  759. * Copies the given float values into the current one
  760. * @param r defines the red component to read from
  761. * @param g defines the green component to read from
  762. * @param b defines the blue component to read from
  763. * @param a defines the alpha component to read from
  764. * @returns the current updated Color4 object
  765. */
  766. set(r: number, g: number, b: number, a: number): Color4;
  767. /**
  768. * Compute the Color4 hexadecimal code as a string
  769. * @returns a string containing the hexadecimal representation of the Color4 object
  770. */
  771. toHexString(): string;
  772. /**
  773. * Computes a new Color4 converted from the current one to linear space
  774. * @returns a new Color4 object
  775. */
  776. toLinearSpace(): Color4;
  777. /**
  778. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  779. * @param convertedColor defines the Color4 object where to store the linear space version
  780. * @returns the unmodified Color4
  781. */
  782. toLinearSpaceToRef(convertedColor: Color4): Color4;
  783. /**
  784. * Computes a new Color4 converted from the current one to gamma space
  785. * @returns a new Color4 object
  786. */
  787. toGammaSpace(): Color4;
  788. /**
  789. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  790. * @param convertedColor defines the Color4 object where to store the gamma space version
  791. * @returns the unmodified Color4
  792. */
  793. toGammaSpaceToRef(convertedColor: Color4): Color4;
  794. /**
  795. * Creates a new Color4 from the string containing valid hexadecimal values
  796. * @param hex defines a string containing valid hexadecimal values
  797. * @returns a new Color4 object
  798. */
  799. static FromHexString(hex: string): Color4;
  800. /**
  801. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  802. * @param left defines the start value
  803. * @param right defines the end value
  804. * @param amount defines the gradient factor
  805. * @returns a new Color4 object
  806. */
  807. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  808. /**
  809. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  810. * @param left defines the start value
  811. * @param right defines the end value
  812. * @param amount defines the gradient factor
  813. * @param result defines the Color4 object where to store data
  814. */
  815. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  816. /**
  817. * Creates a new Color4 from a Color3 and an alpha value
  818. * @param color3 defines the source Color3 to read from
  819. * @param alpha defines the alpha component (1.0 by default)
  820. * @returns a new Color4 object
  821. */
  822. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  823. /**
  824. * Creates a new Color4 from the starting index element of the given array
  825. * @param array defines the source array to read from
  826. * @param offset defines the offset in the source array
  827. * @returns a new Color4 object
  828. */
  829. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  830. /**
  831. * Creates a new Color3 from integer values (< 256)
  832. * @param r defines the red component to read from (value between 0 and 255)
  833. * @param g defines the green component to read from (value between 0 and 255)
  834. * @param b defines the blue component to read from (value between 0 and 255)
  835. * @param a defines the alpha component to read from (value between 0 and 255)
  836. * @returns a new Color3 object
  837. */
  838. static FromInts(r: number, g: number, b: number, a: number): Color4;
  839. /**
  840. * Check the content of a given array and convert it to an array containing RGBA data
  841. * If the original array was already containing count * 4 values then it is returned directly
  842. * @param colors defines the array to check
  843. * @param count defines the number of RGBA data to expect
  844. * @returns an array containing count * 4 values (RGBA)
  845. */
  846. static CheckColors4(colors: number[], count: number): number[];
  847. }
  848. /**
  849. * Class representing a vector containing 2 coordinates
  850. */
  851. export class Vector2 {
  852. /** defines the first coordinate */
  853. x: number;
  854. /** defines the second coordinate */
  855. y: number;
  856. /**
  857. * Creates a new Vector2 from the given x and y coordinates
  858. * @param x defines the first coordinate
  859. * @param y defines the second coordinate
  860. */
  861. constructor(
  862. /** defines the first coordinate */
  863. x?: number,
  864. /** defines the second coordinate */
  865. y?: number);
  866. /**
  867. * Gets a string with the Vector2 coordinates
  868. * @returns a string with the Vector2 coordinates
  869. */
  870. toString(): string;
  871. /**
  872. * Gets class name
  873. * @returns the string "Vector2"
  874. */
  875. getClassName(): string;
  876. /**
  877. * Gets current vector hash code
  878. * @returns the Vector2 hash code as a number
  879. */
  880. getHashCode(): number;
  881. /**
  882. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  883. * @param array defines the source array
  884. * @param index defines the offset in source array
  885. * @returns the current Vector2
  886. */
  887. toArray(array: FloatArray, index?: number): Vector2;
  888. /**
  889. * Copy the current vector to an array
  890. * @returns a new array with 2 elements: the Vector2 coordinates.
  891. */
  892. asArray(): number[];
  893. /**
  894. * Sets the Vector2 coordinates with the given Vector2 coordinates
  895. * @param source defines the source Vector2
  896. * @returns the current updated Vector2
  897. */
  898. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  899. /**
  900. * Sets the Vector2 coordinates with the given floats
  901. * @param x defines the first coordinate
  902. * @param y defines the second coordinate
  903. * @returns the current updated Vector2
  904. */
  905. copyFromFloats(x: number, y: number): Vector2;
  906. /**
  907. * Sets the Vector2 coordinates with the given floats
  908. * @param x defines the first coordinate
  909. * @param y defines the second coordinate
  910. * @returns the current updated Vector2
  911. */
  912. set(x: number, y: number): Vector2;
  913. /**
  914. * Add another vector with the current one
  915. * @param otherVector defines the other vector
  916. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  917. */
  918. add(otherVector: DeepImmutable<Vector2>): Vector2;
  919. /**
  920. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  921. * @param otherVector defines the other vector
  922. * @param result defines the target vector
  923. * @returns the unmodified current Vector2
  924. */
  925. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  926. /**
  927. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  928. * @param otherVector defines the other vector
  929. * @returns the current updated Vector2
  930. */
  931. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  932. /**
  933. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  934. * @param otherVector defines the other vector
  935. * @returns a new Vector2
  936. */
  937. addVector3(otherVector: Vector3): Vector2;
  938. /**
  939. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  940. * @param otherVector defines the other vector
  941. * @returns a new Vector2
  942. */
  943. subtract(otherVector: Vector2): Vector2;
  944. /**
  945. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  946. * @param otherVector defines the other vector
  947. * @param result defines the target vector
  948. * @returns the unmodified current Vector2
  949. */
  950. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  951. /**
  952. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  953. * @param otherVector defines the other vector
  954. * @returns the current updated Vector2
  955. */
  956. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  957. /**
  958. * Multiplies in place the current Vector2 coordinates by the given ones
  959. * @param otherVector defines the other vector
  960. * @returns the current updated Vector2
  961. */
  962. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  963. /**
  964. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  965. * @param otherVector defines the other vector
  966. * @returns a new Vector2
  967. */
  968. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  969. /**
  970. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  971. * @param otherVector defines the other vector
  972. * @param result defines the target vector
  973. * @returns the unmodified current Vector2
  974. */
  975. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  976. /**
  977. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  978. * @param x defines the first coordinate
  979. * @param y defines the second coordinate
  980. * @returns a new Vector2
  981. */
  982. multiplyByFloats(x: number, y: number): Vector2;
  983. /**
  984. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  985. * @param otherVector defines the other vector
  986. * @returns a new Vector2
  987. */
  988. divide(otherVector: Vector2): Vector2;
  989. /**
  990. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  991. * @param otherVector defines the other vector
  992. * @param result defines the target vector
  993. * @returns the unmodified current Vector2
  994. */
  995. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  996. /**
  997. * Divides the current Vector2 coordinates by the given ones
  998. * @param otherVector defines the other vector
  999. * @returns the current updated Vector2
  1000. */
  1001. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1002. /**
  1003. * Gets a new Vector2 with current Vector2 negated coordinates
  1004. * @returns a new Vector2
  1005. */
  1006. negate(): Vector2;
  1007. /**
  1008. * Multiply the Vector2 coordinates by scale
  1009. * @param scale defines the scaling factor
  1010. * @returns the current updated Vector2
  1011. */
  1012. scaleInPlace(scale: number): Vector2;
  1013. /**
  1014. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1015. * @param scale defines the scaling factor
  1016. * @returns a new Vector2
  1017. */
  1018. scale(scale: number): Vector2;
  1019. /**
  1020. * Scale the current Vector2 values by a factor to a given Vector2
  1021. * @param scale defines the scale factor
  1022. * @param result defines the Vector2 object where to store the result
  1023. * @returns the unmodified current Vector2
  1024. */
  1025. scaleToRef(scale: number, result: Vector2): Vector2;
  1026. /**
  1027. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1028. * @param scale defines the scale factor
  1029. * @param result defines the Vector2 object where to store the result
  1030. * @returns the unmodified current Vector2
  1031. */
  1032. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1033. /**
  1034. * Gets a boolean if two vectors are equals
  1035. * @param otherVector defines the other vector
  1036. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1037. */
  1038. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1039. /**
  1040. * Gets a boolean if two vectors are equals (using an epsilon value)
  1041. * @param otherVector defines the other vector
  1042. * @param epsilon defines the minimal distance to consider equality
  1043. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1044. */
  1045. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1046. /**
  1047. * Gets a new Vector2 from current Vector2 floored values
  1048. * @returns a new Vector2
  1049. */
  1050. floor(): Vector2;
  1051. /**
  1052. * Gets a new Vector2 from current Vector2 floored values
  1053. * @returns a new Vector2
  1054. */
  1055. fract(): Vector2;
  1056. /**
  1057. * Gets the length of the vector
  1058. * @returns the vector length (float)
  1059. */
  1060. length(): number;
  1061. /**
  1062. * Gets the vector squared length
  1063. * @returns the vector squared length (float)
  1064. */
  1065. lengthSquared(): number;
  1066. /**
  1067. * Normalize the vector
  1068. * @returns the current updated Vector2
  1069. */
  1070. normalize(): Vector2;
  1071. /**
  1072. * Gets a new Vector2 copied from the Vector2
  1073. * @returns a new Vector2
  1074. */
  1075. clone(): Vector2;
  1076. /**
  1077. * Gets a new Vector2(0, 0)
  1078. * @returns a new Vector2
  1079. */
  1080. static Zero(): Vector2;
  1081. /**
  1082. * Gets a new Vector2(1, 1)
  1083. * @returns a new Vector2
  1084. */
  1085. static One(): Vector2;
  1086. /**
  1087. * Gets a new Vector2 set from the given index element of the given array
  1088. * @param array defines the data source
  1089. * @param offset defines the offset in the data source
  1090. * @returns a new Vector2
  1091. */
  1092. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1093. /**
  1094. * Sets "result" from the given index element of the given array
  1095. * @param array defines the data source
  1096. * @param offset defines the offset in the data source
  1097. * @param result defines the target vector
  1098. */
  1099. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1100. /**
  1101. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1102. * @param value1 defines 1st point of control
  1103. * @param value2 defines 2nd point of control
  1104. * @param value3 defines 3rd point of control
  1105. * @param value4 defines 4th point of control
  1106. * @param amount defines the interpolation factor
  1107. * @returns a new Vector2
  1108. */
  1109. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1110. /**
  1111. * 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".
  1112. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1113. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1114. * @param value defines the value to clamp
  1115. * @param min defines the lower limit
  1116. * @param max defines the upper limit
  1117. * @returns a new Vector2
  1118. */
  1119. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1120. /**
  1121. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1122. * @param value1 defines the 1st control point
  1123. * @param tangent1 defines the outgoing tangent
  1124. * @param value2 defines the 2nd control point
  1125. * @param tangent2 defines the incoming tangent
  1126. * @param amount defines the interpolation factor
  1127. * @returns a new Vector2
  1128. */
  1129. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1130. /**
  1131. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1132. * @param start defines the start vector
  1133. * @param end defines the end vector
  1134. * @param amount defines the interpolation factor
  1135. * @returns a new Vector2
  1136. */
  1137. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1138. /**
  1139. * Gets the dot product of the vector "left" and the vector "right"
  1140. * @param left defines first vector
  1141. * @param right defines second vector
  1142. * @returns the dot product (float)
  1143. */
  1144. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1145. /**
  1146. * Returns a new Vector2 equal to the normalized given vector
  1147. * @param vector defines the vector to normalize
  1148. * @returns a new Vector2
  1149. */
  1150. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1151. /**
  1152. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1153. * @param left defines 1st vector
  1154. * @param right defines 2nd vector
  1155. * @returns a new Vector2
  1156. */
  1157. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1158. /**
  1159. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1160. * @param left defines 1st vector
  1161. * @param right defines 2nd vector
  1162. * @returns a new Vector2
  1163. */
  1164. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1165. /**
  1166. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1167. * @param vector defines the vector to transform
  1168. * @param transformation defines the matrix to apply
  1169. * @returns a new Vector2
  1170. */
  1171. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1172. /**
  1173. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1174. * @param vector defines the vector to transform
  1175. * @param transformation defines the matrix to apply
  1176. * @param result defines the target vector
  1177. */
  1178. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1179. /**
  1180. * Determines if a given vector is included in a triangle
  1181. * @param p defines the vector to test
  1182. * @param p0 defines 1st triangle point
  1183. * @param p1 defines 2nd triangle point
  1184. * @param p2 defines 3rd triangle point
  1185. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1186. */
  1187. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1188. /**
  1189. * Gets the distance between the vectors "value1" and "value2"
  1190. * @param value1 defines first vector
  1191. * @param value2 defines second vector
  1192. * @returns the distance between vectors
  1193. */
  1194. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1195. /**
  1196. * Returns the squared distance between the vectors "value1" and "value2"
  1197. * @param value1 defines first vector
  1198. * @param value2 defines second vector
  1199. * @returns the squared distance between vectors
  1200. */
  1201. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1202. /**
  1203. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1204. * @param value1 defines first vector
  1205. * @param value2 defines second vector
  1206. * @returns a new Vector2
  1207. */
  1208. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1209. /**
  1210. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1211. * @param p defines the middle point
  1212. * @param segA defines one point of the segment
  1213. * @param segB defines the other point of the segment
  1214. * @returns the shortest distance
  1215. */
  1216. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1217. }
  1218. /**
  1219. * Classed used to store (x,y,z) vector representation
  1220. * A Vector3 is the main object used in 3D geometry
  1221. * It can represent etiher the coordinates of a point the space, either a direction
  1222. * Reminder: js uses a left handed forward facing system
  1223. */
  1224. export class Vector3 {
  1225. /**
  1226. * Defines the first coordinates (on X axis)
  1227. */
  1228. x: number;
  1229. /**
  1230. * Defines the second coordinates (on Y axis)
  1231. */
  1232. y: number;
  1233. /**
  1234. * Defines the third coordinates (on Z axis)
  1235. */
  1236. z: number;
  1237. private static _UpReadOnly;
  1238. private static _ZeroReadOnly;
  1239. /**
  1240. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1241. * @param x defines the first coordinates (on X axis)
  1242. * @param y defines the second coordinates (on Y axis)
  1243. * @param z defines the third coordinates (on Z axis)
  1244. */
  1245. constructor(
  1246. /**
  1247. * Defines the first coordinates (on X axis)
  1248. */
  1249. x?: number,
  1250. /**
  1251. * Defines the second coordinates (on Y axis)
  1252. */
  1253. y?: number,
  1254. /**
  1255. * Defines the third coordinates (on Z axis)
  1256. */
  1257. z?: number);
  1258. /**
  1259. * Creates a string representation of the Vector3
  1260. * @returns a string with the Vector3 coordinates.
  1261. */
  1262. toString(): string;
  1263. /**
  1264. * Gets the class name
  1265. * @returns the string "Vector3"
  1266. */
  1267. getClassName(): string;
  1268. /**
  1269. * Creates the Vector3 hash code
  1270. * @returns a number which tends to be unique between Vector3 instances
  1271. */
  1272. getHashCode(): number;
  1273. /**
  1274. * Creates an array containing three elements : the coordinates of the Vector3
  1275. * @returns a new array of numbers
  1276. */
  1277. asArray(): number[];
  1278. /**
  1279. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1280. * @param array defines the destination array
  1281. * @param index defines the offset in the destination array
  1282. * @returns the current Vector3
  1283. */
  1284. toArray(array: FloatArray, index?: number): Vector3;
  1285. /**
  1286. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1287. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1288. */
  1289. toQuaternion(): Quaternion;
  1290. /**
  1291. * Adds the given vector to the current Vector3
  1292. * @param otherVector defines the second operand
  1293. * @returns the current updated Vector3
  1294. */
  1295. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1296. /**
  1297. * Adds the given coordinates to the current Vector3
  1298. * @param x defines the x coordinate of the operand
  1299. * @param y defines the y coordinate of the operand
  1300. * @param z defines the z coordinate of the operand
  1301. * @returns the current updated Vector3
  1302. */
  1303. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1304. /**
  1305. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1306. * @param otherVector defines the second operand
  1307. * @returns the resulting Vector3
  1308. */
  1309. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1310. /**
  1311. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1312. * @param otherVector defines the second operand
  1313. * @param result defines the Vector3 object where to store the result
  1314. * @returns the current Vector3
  1315. */
  1316. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1317. /**
  1318. * Subtract the given vector from the current Vector3
  1319. * @param otherVector defines the second operand
  1320. * @returns the current updated Vector3
  1321. */
  1322. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1323. /**
  1324. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1325. * @param otherVector defines the second operand
  1326. * @returns the resulting Vector3
  1327. */
  1328. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1329. /**
  1330. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1331. * @param otherVector defines the second operand
  1332. * @param result defines the Vector3 object where to store the result
  1333. * @returns the current Vector3
  1334. */
  1335. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1336. /**
  1337. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1338. * @param x defines the x coordinate of the operand
  1339. * @param y defines the y coordinate of the operand
  1340. * @param z defines the z coordinate of the operand
  1341. * @returns the resulting Vector3
  1342. */
  1343. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1344. /**
  1345. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1346. * @param x defines the x coordinate of the operand
  1347. * @param y defines the y coordinate of the operand
  1348. * @param z defines the z coordinate of the operand
  1349. * @param result defines the Vector3 object where to store the result
  1350. * @returns the current Vector3
  1351. */
  1352. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1353. /**
  1354. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1355. * @returns a new Vector3
  1356. */
  1357. negate(): Vector3;
  1358. /**
  1359. * Multiplies the Vector3 coordinates by the float "scale"
  1360. * @param scale defines the multiplier factor
  1361. * @returns the current updated Vector3
  1362. */
  1363. scaleInPlace(scale: number): Vector3;
  1364. /**
  1365. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1366. * @param scale defines the multiplier factor
  1367. * @returns a new Vector3
  1368. */
  1369. scale(scale: number): Vector3;
  1370. /**
  1371. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1372. * @param scale defines the multiplier factor
  1373. * @param result defines the Vector3 object where to store the result
  1374. * @returns the current Vector3
  1375. */
  1376. scaleToRef(scale: number, result: Vector3): Vector3;
  1377. /**
  1378. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1379. * @param scale defines the scale factor
  1380. * @param result defines the Vector3 object where to store the result
  1381. * @returns the unmodified current Vector3
  1382. */
  1383. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1384. /**
  1385. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1386. * @param otherVector defines the second operand
  1387. * @returns true if both vectors are equals
  1388. */
  1389. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1390. /**
  1391. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1392. * @param otherVector defines the second operand
  1393. * @param epsilon defines the minimal distance to define values as equals
  1394. * @returns true if both vectors are distant less than epsilon
  1395. */
  1396. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1397. /**
  1398. * Returns true if the current Vector3 coordinates equals the given floats
  1399. * @param x defines the x coordinate of the operand
  1400. * @param y defines the y coordinate of the operand
  1401. * @param z defines the z coordinate of the operand
  1402. * @returns true if both vectors are equals
  1403. */
  1404. equalsToFloats(x: number, y: number, z: number): boolean;
  1405. /**
  1406. * Multiplies the current Vector3 coordinates by the given ones
  1407. * @param otherVector defines the second operand
  1408. * @returns the current updated Vector3
  1409. */
  1410. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1411. /**
  1412. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1413. * @param otherVector defines the second operand
  1414. * @returns the new Vector3
  1415. */
  1416. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1417. /**
  1418. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1419. * @param otherVector defines the second operand
  1420. * @param result defines the Vector3 object where to store the result
  1421. * @returns the current Vector3
  1422. */
  1423. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1424. /**
  1425. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1426. * @param x defines the x coordinate of the operand
  1427. * @param y defines the y coordinate of the operand
  1428. * @param z defines the z coordinate of the operand
  1429. * @returns the new Vector3
  1430. */
  1431. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1432. /**
  1433. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1434. * @param otherVector defines the second operand
  1435. * @returns the new Vector3
  1436. */
  1437. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1438. /**
  1439. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1440. * @param otherVector defines the second operand
  1441. * @param result defines the Vector3 object where to store the result
  1442. * @returns the current Vector3
  1443. */
  1444. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1445. /**
  1446. * Divides the current Vector3 coordinates by the given ones.
  1447. * @param otherVector defines the second operand
  1448. * @returns the current updated Vector3
  1449. */
  1450. divideInPlace(otherVector: Vector3): Vector3;
  1451. /**
  1452. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1453. * @param other defines the second operand
  1454. * @returns the current updated Vector3
  1455. */
  1456. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1457. /**
  1458. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1459. * @param other defines the second operand
  1460. * @returns the current updated Vector3
  1461. */
  1462. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1463. /**
  1464. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1465. * @param x defines the x coordinate of the operand
  1466. * @param y defines the y coordinate of the operand
  1467. * @param z defines the z coordinate of the operand
  1468. * @returns the current updated Vector3
  1469. */
  1470. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1471. /**
  1472. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1473. * @param x defines the x coordinate of the operand
  1474. * @param y defines the y coordinate of the operand
  1475. * @param z defines the z coordinate of the operand
  1476. * @returns the current updated Vector3
  1477. */
  1478. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1479. /**
  1480. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1481. * Check if is non uniform within a certain amount of decimal places to account for this
  1482. * @param epsilon the amount the values can differ
  1483. * @returns if the the vector is non uniform to a certain number of decimal places
  1484. */
  1485. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1486. /**
  1487. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1488. */
  1489. readonly isNonUniform: boolean;
  1490. /**
  1491. * Gets a new Vector3 from current Vector3 floored values
  1492. * @returns a new Vector3
  1493. */
  1494. floor(): Vector3;
  1495. /**
  1496. * Gets a new Vector3 from current Vector3 floored values
  1497. * @returns a new Vector3
  1498. */
  1499. fract(): Vector3;
  1500. /**
  1501. * Gets the length of the Vector3
  1502. * @returns the length of the Vecto3
  1503. */
  1504. length(): number;
  1505. /**
  1506. * Gets the squared length of the Vector3
  1507. * @returns squared length of the Vector3
  1508. */
  1509. lengthSquared(): number;
  1510. /**
  1511. * Normalize the current Vector3.
  1512. * Please note that this is an in place operation.
  1513. * @returns the current updated Vector3
  1514. */
  1515. normalize(): Vector3;
  1516. /**
  1517. * Reorders the x y z properties of the vector in place
  1518. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1519. * @returns the current updated vector
  1520. */
  1521. reorderInPlace(order: string): this;
  1522. /**
  1523. * Rotates the vector around 0,0,0 by a quaternion
  1524. * @param quaternion the rotation quaternion
  1525. * @param result vector to store the result
  1526. * @returns the resulting vector
  1527. */
  1528. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1529. /**
  1530. * Rotates a vector around a given point
  1531. * @param quaternion the rotation quaternion
  1532. * @param point the point to rotate around
  1533. * @param result vector to store the result
  1534. * @returns the resulting vector
  1535. */
  1536. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1537. /**
  1538. * Normalize the current Vector3 with the given input length.
  1539. * Please note that this is an in place operation.
  1540. * @param len the length of the vector
  1541. * @returns the current updated Vector3
  1542. */
  1543. normalizeFromLength(len: number): Vector3;
  1544. /**
  1545. * Normalize the current Vector3 to a new vector
  1546. * @returns the new Vector3
  1547. */
  1548. normalizeToNew(): Vector3;
  1549. /**
  1550. * Normalize the current Vector3 to the reference
  1551. * @param reference define the Vector3 to update
  1552. * @returns the updated Vector3
  1553. */
  1554. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1555. /**
  1556. * Creates a new Vector3 copied from the current Vector3
  1557. * @returns the new Vector3
  1558. */
  1559. clone(): Vector3;
  1560. /**
  1561. * Copies the given vector coordinates to the current Vector3 ones
  1562. * @param source defines the source Vector3
  1563. * @returns the current updated Vector3
  1564. */
  1565. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1566. /**
  1567. * Copies the given floats to the current Vector3 coordinates
  1568. * @param x defines the x coordinate of the operand
  1569. * @param y defines the y coordinate of the operand
  1570. * @param z defines the z coordinate of the operand
  1571. * @returns the current updated Vector3
  1572. */
  1573. copyFromFloats(x: number, y: number, z: number): Vector3;
  1574. /**
  1575. * Copies the given floats to the current Vector3 coordinates
  1576. * @param x defines the x coordinate of the operand
  1577. * @param y defines the y coordinate of the operand
  1578. * @param z defines the z coordinate of the operand
  1579. * @returns the current updated Vector3
  1580. */
  1581. set(x: number, y: number, z: number): Vector3;
  1582. /**
  1583. * Copies the given float to the current Vector3 coordinates
  1584. * @param v defines the x, y and z coordinates of the operand
  1585. * @returns the current updated Vector3
  1586. */
  1587. setAll(v: number): Vector3;
  1588. /**
  1589. * Get the clip factor between two vectors
  1590. * @param vector0 defines the first operand
  1591. * @param vector1 defines the second operand
  1592. * @param axis defines the axis to use
  1593. * @param size defines the size along the axis
  1594. * @returns the clip factor
  1595. */
  1596. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1597. /**
  1598. * Get angle between two vectors
  1599. * @param vector0 angle between vector0 and vector1
  1600. * @param vector1 angle between vector0 and vector1
  1601. * @param normal direction of the normal
  1602. * @return the angle between vector0 and vector1
  1603. */
  1604. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1605. /**
  1606. * Returns a new Vector3 set from the index "offset" of the given array
  1607. * @param array defines the source array
  1608. * @param offset defines the offset in the source array
  1609. * @returns the new Vector3
  1610. */
  1611. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1612. /**
  1613. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1614. * This function is deprecated. Use FromArray instead
  1615. * @param array defines the source array
  1616. * @param offset defines the offset in the source array
  1617. * @returns the new Vector3
  1618. */
  1619. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1620. /**
  1621. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1622. * @param array defines the source array
  1623. * @param offset defines the offset in the source array
  1624. * @param result defines the Vector3 where to store the result
  1625. */
  1626. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1627. /**
  1628. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1629. * This function is deprecated. Use FromArrayToRef instead.
  1630. * @param array defines the source array
  1631. * @param offset defines the offset in the source array
  1632. * @param result defines the Vector3 where to store the result
  1633. */
  1634. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1635. /**
  1636. * Sets the given vector "result" with the given floats.
  1637. * @param x defines the x coordinate of the source
  1638. * @param y defines the y coordinate of the source
  1639. * @param z defines the z coordinate of the source
  1640. * @param result defines the Vector3 where to store the result
  1641. */
  1642. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1643. /**
  1644. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1645. * @returns a new empty Vector3
  1646. */
  1647. static Zero(): Vector3;
  1648. /**
  1649. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1650. * @returns a new unit Vector3
  1651. */
  1652. static One(): Vector3;
  1653. /**
  1654. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1655. * @returns a new up Vector3
  1656. */
  1657. static Up(): Vector3;
  1658. /**
  1659. * Gets a up Vector3 that must not be updated
  1660. */
  1661. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1662. /**
  1663. * Gets a zero Vector3 that must not be updated
  1664. */
  1665. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  1666. /**
  1667. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1668. * @returns a new down Vector3
  1669. */
  1670. static Down(): Vector3;
  1671. /**
  1672. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1673. * @returns a new forward Vector3
  1674. */
  1675. static Forward(): Vector3;
  1676. /**
  1677. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1678. * @returns a new forward Vector3
  1679. */
  1680. static Backward(): Vector3;
  1681. /**
  1682. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1683. * @returns a new right Vector3
  1684. */
  1685. static Right(): Vector3;
  1686. /**
  1687. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1688. * @returns a new left Vector3
  1689. */
  1690. static Left(): Vector3;
  1691. /**
  1692. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1693. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1694. * @param vector defines the Vector3 to transform
  1695. * @param transformation defines the transformation matrix
  1696. * @returns the transformed Vector3
  1697. */
  1698. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1699. /**
  1700. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1701. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1702. * @param vector defines the Vector3 to transform
  1703. * @param transformation defines the transformation matrix
  1704. * @param result defines the Vector3 where to store the result
  1705. */
  1706. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1707. /**
  1708. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1709. * This method computes tranformed coordinates only, not transformed direction vectors
  1710. * @param x define the x coordinate of the source vector
  1711. * @param y define the y coordinate of the source vector
  1712. * @param z define the z coordinate of the source vector
  1713. * @param transformation defines the transformation matrix
  1714. * @param result defines the Vector3 where to store the result
  1715. */
  1716. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1717. /**
  1718. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1719. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1720. * @param vector defines the Vector3 to transform
  1721. * @param transformation defines the transformation matrix
  1722. * @returns the new Vector3
  1723. */
  1724. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1725. /**
  1726. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1727. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1728. * @param vector defines the Vector3 to transform
  1729. * @param transformation defines the transformation matrix
  1730. * @param result defines the Vector3 where to store the result
  1731. */
  1732. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1733. /**
  1734. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1735. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1736. * @param x define the x coordinate of the source vector
  1737. * @param y define the y coordinate of the source vector
  1738. * @param z define the z coordinate of the source vector
  1739. * @param transformation defines the transformation matrix
  1740. * @param result defines the Vector3 where to store the result
  1741. */
  1742. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1743. /**
  1744. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1745. * @param value1 defines the first control point
  1746. * @param value2 defines the second control point
  1747. * @param value3 defines the third control point
  1748. * @param value4 defines the fourth control point
  1749. * @param amount defines the amount on the spline to use
  1750. * @returns the new Vector3
  1751. */
  1752. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1753. /**
  1754. * 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"
  1755. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1756. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1757. * @param value defines the current value
  1758. * @param min defines the lower range value
  1759. * @param max defines the upper range value
  1760. * @returns the new Vector3
  1761. */
  1762. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1763. /**
  1764. * 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"
  1765. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1766. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1767. * @param value defines the current value
  1768. * @param min defines the lower range value
  1769. * @param max defines the upper range value
  1770. * @param result defines the Vector3 where to store the result
  1771. */
  1772. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1773. /**
  1774. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1775. * @param value1 defines the first control point
  1776. * @param tangent1 defines the first tangent vector
  1777. * @param value2 defines the second control point
  1778. * @param tangent2 defines the second tangent vector
  1779. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1780. * @returns the new Vector3
  1781. */
  1782. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1783. /**
  1784. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1785. * @param start defines the start value
  1786. * @param end defines the end value
  1787. * @param amount max defines amount between both (between 0 and 1)
  1788. * @returns the new Vector3
  1789. */
  1790. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1791. /**
  1792. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1793. * @param start defines the start value
  1794. * @param end defines the end value
  1795. * @param amount max defines amount between both (between 0 and 1)
  1796. * @param result defines the Vector3 where to store the result
  1797. */
  1798. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1799. /**
  1800. * Returns the dot product (float) between the vectors "left" and "right"
  1801. * @param left defines the left operand
  1802. * @param right defines the right operand
  1803. * @returns the dot product
  1804. */
  1805. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1806. /**
  1807. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1808. * The cross product is then orthogonal to both "left" and "right"
  1809. * @param left defines the left operand
  1810. * @param right defines the right operand
  1811. * @returns the cross product
  1812. */
  1813. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1814. /**
  1815. * Sets the given vector "result" with the cross product of "left" and "right"
  1816. * The cross product is then orthogonal to both "left" and "right"
  1817. * @param left defines the left operand
  1818. * @param right defines the right operand
  1819. * @param result defines the Vector3 where to store the result
  1820. */
  1821. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1822. /**
  1823. * Returns a new Vector3 as the normalization of the given vector
  1824. * @param vector defines the Vector3 to normalize
  1825. * @returns the new Vector3
  1826. */
  1827. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1828. /**
  1829. * Sets the given vector "result" with the normalization of the given first vector
  1830. * @param vector defines the Vector3 to normalize
  1831. * @param result defines the Vector3 where to store the result
  1832. */
  1833. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1834. /**
  1835. * Project a Vector3 onto screen space
  1836. * @param vector defines the Vector3 to project
  1837. * @param world defines the world matrix to use
  1838. * @param transform defines the transform (view x projection) matrix to use
  1839. * @param viewport defines the screen viewport to use
  1840. * @returns the new Vector3
  1841. */
  1842. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1843. /** @hidden */
  1844. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1845. /**
  1846. * Unproject from screen space to object space
  1847. * @param source defines the screen space Vector3 to use
  1848. * @param viewportWidth defines the current width of the viewport
  1849. * @param viewportHeight defines the current height of the viewport
  1850. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1851. * @param transform defines the transform (view x projection) matrix to use
  1852. * @returns the new Vector3
  1853. */
  1854. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1855. /**
  1856. * Unproject from screen space to object space
  1857. * @param source defines the screen space Vector3 to use
  1858. * @param viewportWidth defines the current width of the viewport
  1859. * @param viewportHeight defines the current height of the viewport
  1860. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1861. * @param view defines the view matrix to use
  1862. * @param projection defines the projection matrix to use
  1863. * @returns the new Vector3
  1864. */
  1865. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1866. /**
  1867. * Unproject from screen space to object space
  1868. * @param source defines the screen space Vector3 to use
  1869. * @param viewportWidth defines the current width of the viewport
  1870. * @param viewportHeight defines the current height of the viewport
  1871. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1872. * @param view defines the view matrix to use
  1873. * @param projection defines the projection matrix to use
  1874. * @param result defines the Vector3 where to store the result
  1875. */
  1876. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1877. /**
  1878. * Unproject from screen space to object space
  1879. * @param sourceX defines the screen space x coordinate to use
  1880. * @param sourceY defines the screen space y coordinate to use
  1881. * @param sourceZ defines the screen space z coordinate to use
  1882. * @param viewportWidth defines the current width of the viewport
  1883. * @param viewportHeight defines the current height of the viewport
  1884. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1885. * @param view defines the view matrix to use
  1886. * @param projection defines the projection matrix to use
  1887. * @param result defines the Vector3 where to store the result
  1888. */
  1889. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1890. /**
  1891. * Gets the minimal coordinate values between two Vector3
  1892. * @param left defines the first operand
  1893. * @param right defines the second operand
  1894. * @returns the new Vector3
  1895. */
  1896. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1897. /**
  1898. * Gets the maximal coordinate values between two Vector3
  1899. * @param left defines the first operand
  1900. * @param right defines the second operand
  1901. * @returns the new Vector3
  1902. */
  1903. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1904. /**
  1905. * Returns the distance between the vectors "value1" and "value2"
  1906. * @param value1 defines the first operand
  1907. * @param value2 defines the second operand
  1908. * @returns the distance
  1909. */
  1910. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1911. /**
  1912. * Returns the squared distance between the vectors "value1" and "value2"
  1913. * @param value1 defines the first operand
  1914. * @param value2 defines the second operand
  1915. * @returns the squared distance
  1916. */
  1917. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1918. /**
  1919. * Returns a new Vector3 located at the center between "value1" and "value2"
  1920. * @param value1 defines the first operand
  1921. * @param value2 defines the second operand
  1922. * @returns the new Vector3
  1923. */
  1924. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1925. /**
  1926. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1927. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1928. * to something in order to rotate it from its local system to the given target system
  1929. * Note: axis1, axis2 and axis3 are normalized during this operation
  1930. * @param axis1 defines the first axis
  1931. * @param axis2 defines the second axis
  1932. * @param axis3 defines the third axis
  1933. * @returns a new Vector3
  1934. */
  1935. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1936. /**
  1937. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1938. * @param axis1 defines the first axis
  1939. * @param axis2 defines the second axis
  1940. * @param axis3 defines the third axis
  1941. * @param ref defines the Vector3 where to store the result
  1942. */
  1943. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1944. }
  1945. /**
  1946. * Vector4 class created for EulerAngle class conversion to Quaternion
  1947. */
  1948. export class Vector4 {
  1949. /** x value of the vector */
  1950. x: number;
  1951. /** y value of the vector */
  1952. y: number;
  1953. /** z value of the vector */
  1954. z: number;
  1955. /** w value of the vector */
  1956. w: number;
  1957. /**
  1958. * Creates a Vector4 object from the given floats.
  1959. * @param x x value of the vector
  1960. * @param y y value of the vector
  1961. * @param z z value of the vector
  1962. * @param w w value of the vector
  1963. */
  1964. constructor(
  1965. /** x value of the vector */
  1966. x: number,
  1967. /** y value of the vector */
  1968. y: number,
  1969. /** z value of the vector */
  1970. z: number,
  1971. /** w value of the vector */
  1972. w: number);
  1973. /**
  1974. * Returns the string with the Vector4 coordinates.
  1975. * @returns a string containing all the vector values
  1976. */
  1977. toString(): string;
  1978. /**
  1979. * Returns the string "Vector4".
  1980. * @returns "Vector4"
  1981. */
  1982. getClassName(): string;
  1983. /**
  1984. * Returns the Vector4 hash code.
  1985. * @returns a unique hash code
  1986. */
  1987. getHashCode(): number;
  1988. /**
  1989. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1990. * @returns the resulting array
  1991. */
  1992. asArray(): number[];
  1993. /**
  1994. * Populates the given array from the given index with the Vector4 coordinates.
  1995. * @param array array to populate
  1996. * @param index index of the array to start at (default: 0)
  1997. * @returns the Vector4.
  1998. */
  1999. toArray(array: FloatArray, index?: number): Vector4;
  2000. /**
  2001. * Adds the given vector to the current Vector4.
  2002. * @param otherVector the vector to add
  2003. * @returns the updated Vector4.
  2004. */
  2005. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2006. /**
  2007. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2008. * @param otherVector the vector to add
  2009. * @returns the resulting vector
  2010. */
  2011. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2012. /**
  2013. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2014. * @param otherVector the vector to add
  2015. * @param result the vector to store the result
  2016. * @returns the current Vector4.
  2017. */
  2018. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2019. /**
  2020. * Subtract in place the given vector from the current Vector4.
  2021. * @param otherVector the vector to subtract
  2022. * @returns the updated Vector4.
  2023. */
  2024. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2025. /**
  2026. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2027. * @param otherVector the vector to add
  2028. * @returns the new vector with the result
  2029. */
  2030. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2031. /**
  2032. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2033. * @param otherVector the vector to subtract
  2034. * @param result the vector to store the result
  2035. * @returns the current Vector4.
  2036. */
  2037. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2038. /**
  2039. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2040. */
  2041. /**
  2042. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2043. * @param x value to subtract
  2044. * @param y value to subtract
  2045. * @param z value to subtract
  2046. * @param w value to subtract
  2047. * @returns new vector containing the result
  2048. */
  2049. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2050. /**
  2051. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2052. * @param x value to subtract
  2053. * @param y value to subtract
  2054. * @param z value to subtract
  2055. * @param w value to subtract
  2056. * @param result the vector to store the result in
  2057. * @returns the current Vector4.
  2058. */
  2059. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2060. /**
  2061. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2062. * @returns a new vector with the negated values
  2063. */
  2064. negate(): Vector4;
  2065. /**
  2066. * Multiplies the current Vector4 coordinates by scale (float).
  2067. * @param scale the number to scale with
  2068. * @returns the updated Vector4.
  2069. */
  2070. scaleInPlace(scale: number): Vector4;
  2071. /**
  2072. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2073. * @param scale the number to scale with
  2074. * @returns a new vector with the result
  2075. */
  2076. scale(scale: number): Vector4;
  2077. /**
  2078. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2079. * @param scale the number to scale with
  2080. * @param result a vector to store the result in
  2081. * @returns the current Vector4.
  2082. */
  2083. scaleToRef(scale: number, result: Vector4): Vector4;
  2084. /**
  2085. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2086. * @param scale defines the scale factor
  2087. * @param result defines the Vector4 object where to store the result
  2088. * @returns the unmodified current Vector4
  2089. */
  2090. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2091. /**
  2092. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2093. * @param otherVector the vector to compare against
  2094. * @returns true if they are equal
  2095. */
  2096. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2097. /**
  2098. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2099. * @param otherVector vector to compare against
  2100. * @param epsilon (Default: very small number)
  2101. * @returns true if they are equal
  2102. */
  2103. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2104. /**
  2105. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2106. * @param x x value to compare against
  2107. * @param y y value to compare against
  2108. * @param z z value to compare against
  2109. * @param w w value to compare against
  2110. * @returns true if equal
  2111. */
  2112. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2113. /**
  2114. * Multiplies in place the current Vector4 by the given one.
  2115. * @param otherVector vector to multiple with
  2116. * @returns the updated Vector4.
  2117. */
  2118. multiplyInPlace(otherVector: Vector4): Vector4;
  2119. /**
  2120. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2121. * @param otherVector vector to multiple with
  2122. * @returns resulting new vector
  2123. */
  2124. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2125. /**
  2126. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2127. * @param otherVector vector to multiple with
  2128. * @param result vector to store the result
  2129. * @returns the current Vector4.
  2130. */
  2131. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2132. /**
  2133. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2134. * @param x x value multiply with
  2135. * @param y y value multiply with
  2136. * @param z z value multiply with
  2137. * @param w w value multiply with
  2138. * @returns resulting new vector
  2139. */
  2140. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2141. /**
  2142. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2143. * @param otherVector vector to devide with
  2144. * @returns resulting new vector
  2145. */
  2146. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2147. /**
  2148. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2149. * @param otherVector vector to devide with
  2150. * @param result vector to store the result
  2151. * @returns the current Vector4.
  2152. */
  2153. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2154. /**
  2155. * Divides the current Vector3 coordinates by the given ones.
  2156. * @param otherVector vector to devide with
  2157. * @returns the updated Vector3.
  2158. */
  2159. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2160. /**
  2161. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2162. * @param other defines the second operand
  2163. * @returns the current updated Vector4
  2164. */
  2165. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2166. /**
  2167. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2168. * @param other defines the second operand
  2169. * @returns the current updated Vector4
  2170. */
  2171. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2172. /**
  2173. * Gets a new Vector4 from current Vector4 floored values
  2174. * @returns a new Vector4
  2175. */
  2176. floor(): Vector4;
  2177. /**
  2178. * Gets a new Vector4 from current Vector3 floored values
  2179. * @returns a new Vector4
  2180. */
  2181. fract(): Vector4;
  2182. /**
  2183. * Returns the Vector4 length (float).
  2184. * @returns the length
  2185. */
  2186. length(): number;
  2187. /**
  2188. * Returns the Vector4 squared length (float).
  2189. * @returns the length squared
  2190. */
  2191. lengthSquared(): number;
  2192. /**
  2193. * Normalizes in place the Vector4.
  2194. * @returns the updated Vector4.
  2195. */
  2196. normalize(): Vector4;
  2197. /**
  2198. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2199. * @returns this converted to a new vector3
  2200. */
  2201. toVector3(): Vector3;
  2202. /**
  2203. * Returns a new Vector4 copied from the current one.
  2204. * @returns the new cloned vector
  2205. */
  2206. clone(): Vector4;
  2207. /**
  2208. * Updates the current Vector4 with the given one coordinates.
  2209. * @param source the source vector to copy from
  2210. * @returns the updated Vector4.
  2211. */
  2212. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2213. /**
  2214. * Updates the current Vector4 coordinates with the given floats.
  2215. * @param x float to copy from
  2216. * @param y float to copy from
  2217. * @param z float to copy from
  2218. * @param w float to copy from
  2219. * @returns the updated Vector4.
  2220. */
  2221. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2222. /**
  2223. * Updates the current Vector4 coordinates with the given floats.
  2224. * @param x float to set from
  2225. * @param y float to set from
  2226. * @param z float to set from
  2227. * @param w float to set from
  2228. * @returns the updated Vector4.
  2229. */
  2230. set(x: number, y: number, z: number, w: number): Vector4;
  2231. /**
  2232. * Copies the given float to the current Vector3 coordinates
  2233. * @param v defines the x, y, z and w coordinates of the operand
  2234. * @returns the current updated Vector3
  2235. */
  2236. setAll(v: number): Vector4;
  2237. /**
  2238. * Returns a new Vector4 set from the starting index of the given array.
  2239. * @param array the array to pull values from
  2240. * @param offset the offset into the array to start at
  2241. * @returns the new vector
  2242. */
  2243. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2244. /**
  2245. * Updates the given vector "result" from the starting index of the given array.
  2246. * @param array the array to pull values from
  2247. * @param offset the offset into the array to start at
  2248. * @param result the vector to store the result in
  2249. */
  2250. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2251. /**
  2252. * Updates the given vector "result" from the starting index of the given Float32Array.
  2253. * @param array the array to pull values from
  2254. * @param offset the offset into the array to start at
  2255. * @param result the vector to store the result in
  2256. */
  2257. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2258. /**
  2259. * Updates the given vector "result" coordinates from the given floats.
  2260. * @param x float to set from
  2261. * @param y float to set from
  2262. * @param z float to set from
  2263. * @param w float to set from
  2264. * @param result the vector to the floats in
  2265. */
  2266. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2267. /**
  2268. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2269. * @returns the new vector
  2270. */
  2271. static Zero(): Vector4;
  2272. /**
  2273. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2274. * @returns the new vector
  2275. */
  2276. static One(): Vector4;
  2277. /**
  2278. * Returns a new normalized Vector4 from the given one.
  2279. * @param vector the vector to normalize
  2280. * @returns the vector
  2281. */
  2282. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2283. /**
  2284. * Updates the given vector "result" from the normalization of the given one.
  2285. * @param vector the vector to normalize
  2286. * @param result the vector to store the result in
  2287. */
  2288. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2289. /**
  2290. * Returns a vector with the minimum values from the left and right vectors
  2291. * @param left left vector to minimize
  2292. * @param right right vector to minimize
  2293. * @returns a new vector with the minimum of the left and right vector values
  2294. */
  2295. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2296. /**
  2297. * Returns a vector with the maximum values from the left and right vectors
  2298. * @param left left vector to maximize
  2299. * @param right right vector to maximize
  2300. * @returns a new vector with the maximum of the left and right vector values
  2301. */
  2302. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2303. /**
  2304. * Returns the distance (float) between the vectors "value1" and "value2".
  2305. * @param value1 value to calulate the distance between
  2306. * @param value2 value to calulate the distance between
  2307. * @return the distance between the two vectors
  2308. */
  2309. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2310. /**
  2311. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2312. * @param value1 value to calulate the distance between
  2313. * @param value2 value to calulate the distance between
  2314. * @return the distance between the two vectors squared
  2315. */
  2316. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2317. /**
  2318. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2319. * @param value1 value to calulate the center between
  2320. * @param value2 value to calulate the center between
  2321. * @return the center between the two vectors
  2322. */
  2323. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2324. /**
  2325. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2326. * This methods computes transformed normalized direction vectors only.
  2327. * @param vector the vector to transform
  2328. * @param transformation the transformation matrix to apply
  2329. * @returns the new vector
  2330. */
  2331. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2332. /**
  2333. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2334. * This methods computes transformed normalized direction vectors only.
  2335. * @param vector the vector to transform
  2336. * @param transformation the transformation matrix to apply
  2337. * @param result the vector to store the result in
  2338. */
  2339. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2340. /**
  2341. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2342. * This methods computes transformed normalized direction vectors only.
  2343. * @param x value to transform
  2344. * @param y value to transform
  2345. * @param z value to transform
  2346. * @param w value to transform
  2347. * @param transformation the transformation matrix to apply
  2348. * @param result the vector to store the results in
  2349. */
  2350. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2351. /**
  2352. * Creates a new Vector4 from a Vector3
  2353. * @param source defines the source data
  2354. * @param w defines the 4th component (default is 0)
  2355. * @returns a new Vector4
  2356. */
  2357. static FromVector3(source: Vector3, w?: number): Vector4;
  2358. }
  2359. /**
  2360. * Interface for the size containing width and height
  2361. */
  2362. export interface ISize {
  2363. /**
  2364. * Width
  2365. */
  2366. width: number;
  2367. /**
  2368. * Heighht
  2369. */
  2370. height: number;
  2371. }
  2372. /**
  2373. * Size containing widht and height
  2374. */
  2375. export class Size implements ISize {
  2376. /**
  2377. * Width
  2378. */
  2379. width: number;
  2380. /**
  2381. * Height
  2382. */
  2383. height: number;
  2384. /**
  2385. * Creates a Size object from the given width and height (floats).
  2386. * @param width width of the new size
  2387. * @param height height of the new size
  2388. */
  2389. constructor(width: number, height: number);
  2390. /**
  2391. * Returns a string with the Size width and height
  2392. * @returns a string with the Size width and height
  2393. */
  2394. toString(): string;
  2395. /**
  2396. * "Size"
  2397. * @returns the string "Size"
  2398. */
  2399. getClassName(): string;
  2400. /**
  2401. * Returns the Size hash code.
  2402. * @returns a hash code for a unique width and height
  2403. */
  2404. getHashCode(): number;
  2405. /**
  2406. * Updates the current size from the given one.
  2407. * @param src the given size
  2408. */
  2409. copyFrom(src: Size): void;
  2410. /**
  2411. * Updates in place the current Size from the given floats.
  2412. * @param width width of the new size
  2413. * @param height height of the new size
  2414. * @returns the updated Size.
  2415. */
  2416. copyFromFloats(width: number, height: number): Size;
  2417. /**
  2418. * Updates in place the current Size from the given floats.
  2419. * @param width width to set
  2420. * @param height height to set
  2421. * @returns the updated Size.
  2422. */
  2423. set(width: number, height: number): Size;
  2424. /**
  2425. * Multiplies the width and height by numbers
  2426. * @param w factor to multiple the width by
  2427. * @param h factor to multiple the height by
  2428. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2429. */
  2430. multiplyByFloats(w: number, h: number): Size;
  2431. /**
  2432. * Clones the size
  2433. * @returns a new Size copied from the given one.
  2434. */
  2435. clone(): Size;
  2436. /**
  2437. * True if the current Size and the given one width and height are strictly equal.
  2438. * @param other the other size to compare against
  2439. * @returns True if the current Size and the given one width and height are strictly equal.
  2440. */
  2441. equals(other: Size): boolean;
  2442. /**
  2443. * The surface of the Size : width * height (float).
  2444. */
  2445. readonly surface: number;
  2446. /**
  2447. * Create a new size of zero
  2448. * @returns a new Size set to (0.0, 0.0)
  2449. */
  2450. static Zero(): Size;
  2451. /**
  2452. * Sums the width and height of two sizes
  2453. * @param otherSize size to add to this size
  2454. * @returns a new Size set as the addition result of the current Size and the given one.
  2455. */
  2456. add(otherSize: Size): Size;
  2457. /**
  2458. * Subtracts the width and height of two
  2459. * @param otherSize size to subtract to this size
  2460. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2461. */
  2462. subtract(otherSize: Size): Size;
  2463. /**
  2464. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2465. * @param start starting size to lerp between
  2466. * @param end end size to lerp between
  2467. * @param amount amount to lerp between the start and end values
  2468. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2469. */
  2470. static Lerp(start: Size, end: Size, amount: number): Size;
  2471. }
  2472. /**
  2473. * Class used to store quaternion data
  2474. * @see https://en.wikipedia.org/wiki/Quaternion
  2475. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2476. */
  2477. export class Quaternion {
  2478. /** defines the first component (0 by default) */
  2479. x: number;
  2480. /** defines the second component (0 by default) */
  2481. y: number;
  2482. /** defines the third component (0 by default) */
  2483. z: number;
  2484. /** defines the fourth component (1.0 by default) */
  2485. w: number;
  2486. /**
  2487. * Creates a new Quaternion from the given floats
  2488. * @param x defines the first component (0 by default)
  2489. * @param y defines the second component (0 by default)
  2490. * @param z defines the third component (0 by default)
  2491. * @param w defines the fourth component (1.0 by default)
  2492. */
  2493. constructor(
  2494. /** defines the first component (0 by default) */
  2495. x?: number,
  2496. /** defines the second component (0 by default) */
  2497. y?: number,
  2498. /** defines the third component (0 by default) */
  2499. z?: number,
  2500. /** defines the fourth component (1.0 by default) */
  2501. w?: number);
  2502. /**
  2503. * Gets a string representation for the current quaternion
  2504. * @returns a string with the Quaternion coordinates
  2505. */
  2506. toString(): string;
  2507. /**
  2508. * Gets the class name of the quaternion
  2509. * @returns the string "Quaternion"
  2510. */
  2511. getClassName(): string;
  2512. /**
  2513. * Gets a hash code for this quaternion
  2514. * @returns the quaternion hash code
  2515. */
  2516. getHashCode(): number;
  2517. /**
  2518. * Copy the quaternion to an array
  2519. * @returns a new array populated with 4 elements from the quaternion coordinates
  2520. */
  2521. asArray(): number[];
  2522. /**
  2523. * Check if two quaternions are equals
  2524. * @param otherQuaternion defines the second operand
  2525. * @return true if the current quaternion and the given one coordinates are strictly equals
  2526. */
  2527. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2528. /**
  2529. * Clone the current quaternion
  2530. * @returns a new quaternion copied from the current one
  2531. */
  2532. clone(): Quaternion;
  2533. /**
  2534. * Copy a quaternion to the current one
  2535. * @param other defines the other quaternion
  2536. * @returns the updated current quaternion
  2537. */
  2538. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2539. /**
  2540. * Updates the current quaternion with the given float coordinates
  2541. * @param x defines the x coordinate
  2542. * @param y defines the y coordinate
  2543. * @param z defines the z coordinate
  2544. * @param w defines the w coordinate
  2545. * @returns the updated current quaternion
  2546. */
  2547. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2548. /**
  2549. * Updates the current quaternion from the given float coordinates
  2550. * @param x defines the x coordinate
  2551. * @param y defines the y coordinate
  2552. * @param z defines the z coordinate
  2553. * @param w defines the w coordinate
  2554. * @returns the updated current quaternion
  2555. */
  2556. set(x: number, y: number, z: number, w: number): Quaternion;
  2557. /**
  2558. * Adds two quaternions
  2559. * @param other defines the second operand
  2560. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2561. */
  2562. add(other: DeepImmutable<Quaternion>): Quaternion;
  2563. /**
  2564. * Add a quaternion to the current one
  2565. * @param other defines the quaternion to add
  2566. * @returns the current quaternion
  2567. */
  2568. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2569. /**
  2570. * Subtract two quaternions
  2571. * @param other defines the second operand
  2572. * @returns a new quaternion as the subtraction result of the given one from the current one
  2573. */
  2574. subtract(other: Quaternion): Quaternion;
  2575. /**
  2576. * Multiplies the current quaternion by a scale factor
  2577. * @param value defines the scale factor
  2578. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2579. */
  2580. scale(value: number): Quaternion;
  2581. /**
  2582. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2583. * @param scale defines the scale factor
  2584. * @param result defines the Quaternion object where to store the result
  2585. * @returns the unmodified current quaternion
  2586. */
  2587. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2588. /**
  2589. * Multiplies in place the current quaternion by a scale factor
  2590. * @param value defines the scale factor
  2591. * @returns the current modified quaternion
  2592. */
  2593. scaleInPlace(value: number): Quaternion;
  2594. /**
  2595. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2596. * @param scale defines the scale factor
  2597. * @param result defines the Quaternion object where to store the result
  2598. * @returns the unmodified current quaternion
  2599. */
  2600. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2601. /**
  2602. * Multiplies two quaternions
  2603. * @param q1 defines the second operand
  2604. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2605. */
  2606. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2607. /**
  2608. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2609. * @param q1 defines the second operand
  2610. * @param result defines the target quaternion
  2611. * @returns the current quaternion
  2612. */
  2613. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2614. /**
  2615. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2616. * @param q1 defines the second operand
  2617. * @returns the currentupdated quaternion
  2618. */
  2619. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2620. /**
  2621. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2622. * @param ref defines the target quaternion
  2623. * @returns the current quaternion
  2624. */
  2625. conjugateToRef(ref: Quaternion): Quaternion;
  2626. /**
  2627. * Conjugates in place (1-q) the current quaternion
  2628. * @returns the current updated quaternion
  2629. */
  2630. conjugateInPlace(): Quaternion;
  2631. /**
  2632. * Conjugates in place (1-q) the current quaternion
  2633. * @returns a new quaternion
  2634. */
  2635. conjugate(): Quaternion;
  2636. /**
  2637. * Gets length of current quaternion
  2638. * @returns the quaternion length (float)
  2639. */
  2640. length(): number;
  2641. /**
  2642. * Normalize in place the current quaternion
  2643. * @returns the current updated quaternion
  2644. */
  2645. normalize(): Quaternion;
  2646. /**
  2647. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2648. * @param order is a reserved parameter and is ignore for now
  2649. * @returns a new Vector3 containing the Euler angles
  2650. */
  2651. toEulerAngles(order?: string): Vector3;
  2652. /**
  2653. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2654. * @param result defines the vector which will be filled with the Euler angles
  2655. * @param order is a reserved parameter and is ignore for now
  2656. * @returns the current unchanged quaternion
  2657. */
  2658. toEulerAnglesToRef(result: Vector3): Quaternion;
  2659. /**
  2660. * Updates the given rotation matrix with the current quaternion values
  2661. * @param result defines the target matrix
  2662. * @returns the current unchanged quaternion
  2663. */
  2664. toRotationMatrix(result: Matrix): Quaternion;
  2665. /**
  2666. * Updates the current quaternion from the given rotation matrix values
  2667. * @param matrix defines the source matrix
  2668. * @returns the current updated quaternion
  2669. */
  2670. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2671. /**
  2672. * Creates a new quaternion from a rotation matrix
  2673. * @param matrix defines the source matrix
  2674. * @returns a new quaternion created from the given rotation matrix values
  2675. */
  2676. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2677. /**
  2678. * Updates the given quaternion with the given rotation matrix values
  2679. * @param matrix defines the source matrix
  2680. * @param result defines the target quaternion
  2681. */
  2682. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2683. /**
  2684. * Returns the dot product (float) between the quaternions "left" and "right"
  2685. * @param left defines the left operand
  2686. * @param right defines the right operand
  2687. * @returns the dot product
  2688. */
  2689. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2690. /**
  2691. * Checks if the two quaternions are close to each other
  2692. * @param quat0 defines the first quaternion to check
  2693. * @param quat1 defines the second quaternion to check
  2694. * @returns true if the two quaternions are close to each other
  2695. */
  2696. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2697. /**
  2698. * Creates an empty quaternion
  2699. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2700. */
  2701. static Zero(): Quaternion;
  2702. /**
  2703. * Inverse a given quaternion
  2704. * @param q defines the source quaternion
  2705. * @returns a new quaternion as the inverted current quaternion
  2706. */
  2707. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2708. /**
  2709. * Inverse a given quaternion
  2710. * @param q defines the source quaternion
  2711. * @param result the quaternion the result will be stored in
  2712. * @returns the result quaternion
  2713. */
  2714. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2715. /**
  2716. * Creates an identity quaternion
  2717. * @returns the identity quaternion
  2718. */
  2719. static Identity(): Quaternion;
  2720. /**
  2721. * Gets a boolean indicating if the given quaternion is identity
  2722. * @param quaternion defines the quaternion to check
  2723. * @returns true if the quaternion is identity
  2724. */
  2725. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2726. /**
  2727. * Creates a quaternion from a rotation around an axis
  2728. * @param axis defines the axis to use
  2729. * @param angle defines the angle to use
  2730. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2731. */
  2732. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2733. /**
  2734. * Creates a rotation around an axis and stores it into the given quaternion
  2735. * @param axis defines the axis to use
  2736. * @param angle defines the angle to use
  2737. * @param result defines the target quaternion
  2738. * @returns the target quaternion
  2739. */
  2740. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2741. /**
  2742. * Creates a new quaternion from data stored into an array
  2743. * @param array defines the data source
  2744. * @param offset defines the offset in the source array where the data starts
  2745. * @returns a new quaternion
  2746. */
  2747. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2748. /**
  2749. * Create a quaternion from Euler rotation angles
  2750. * @param x Pitch
  2751. * @param y Yaw
  2752. * @param z Roll
  2753. * @returns the new Quaternion
  2754. */
  2755. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2756. /**
  2757. * Updates a quaternion from Euler rotation angles
  2758. * @param x Pitch
  2759. * @param y Yaw
  2760. * @param z Roll
  2761. * @param result the quaternion to store the result
  2762. * @returns the updated quaternion
  2763. */
  2764. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2765. /**
  2766. * Create a quaternion from Euler rotation vector
  2767. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2768. * @returns the new Quaternion
  2769. */
  2770. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2771. /**
  2772. * Updates a quaternion from Euler rotation vector
  2773. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2774. * @param result the quaternion to store the result
  2775. * @returns the updated quaternion
  2776. */
  2777. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2778. /**
  2779. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2780. * @param yaw defines the rotation around Y axis
  2781. * @param pitch defines the rotation around X axis
  2782. * @param roll defines the rotation around Z axis
  2783. * @returns the new quaternion
  2784. */
  2785. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2786. /**
  2787. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2788. * @param yaw defines the rotation around Y axis
  2789. * @param pitch defines the rotation around X axis
  2790. * @param roll defines the rotation around Z axis
  2791. * @param result defines the target quaternion
  2792. */
  2793. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2794. /**
  2795. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2796. * @param alpha defines the rotation around first axis
  2797. * @param beta defines the rotation around second axis
  2798. * @param gamma defines the rotation around third axis
  2799. * @returns the new quaternion
  2800. */
  2801. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2802. /**
  2803. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2804. * @param alpha defines the rotation around first axis
  2805. * @param beta defines the rotation around second axis
  2806. * @param gamma defines the rotation around third axis
  2807. * @param result defines the target quaternion
  2808. */
  2809. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2810. /**
  2811. * 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)
  2812. * @param axis1 defines the first axis
  2813. * @param axis2 defines the second axis
  2814. * @param axis3 defines the third axis
  2815. * @returns the new quaternion
  2816. */
  2817. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2818. /**
  2819. * 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
  2820. * @param axis1 defines the first axis
  2821. * @param axis2 defines the second axis
  2822. * @param axis3 defines the third axis
  2823. * @param ref defines the target quaternion
  2824. */
  2825. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2826. /**
  2827. * Interpolates between two quaternions
  2828. * @param left defines first quaternion
  2829. * @param right defines second quaternion
  2830. * @param amount defines the gradient to use
  2831. * @returns the new interpolated quaternion
  2832. */
  2833. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2834. /**
  2835. * Interpolates between two quaternions and stores it into a target quaternion
  2836. * @param left defines first quaternion
  2837. * @param right defines second quaternion
  2838. * @param amount defines the gradient to use
  2839. * @param result defines the target quaternion
  2840. */
  2841. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2842. /**
  2843. * Interpolate between two quaternions using Hermite interpolation
  2844. * @param value1 defines first quaternion
  2845. * @param tangent1 defines the incoming tangent
  2846. * @param value2 defines second quaternion
  2847. * @param tangent2 defines the outgoing tangent
  2848. * @param amount defines the target quaternion
  2849. * @returns the new interpolated quaternion
  2850. */
  2851. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2852. }
  2853. /**
  2854. * Class used to store matrix data (4x4)
  2855. */
  2856. export class Matrix {
  2857. private static _updateFlagSeed;
  2858. private static _identityReadOnly;
  2859. private _isIdentity;
  2860. private _isIdentityDirty;
  2861. private _isIdentity3x2;
  2862. private _isIdentity3x2Dirty;
  2863. /**
  2864. * Gets the update flag of the matrix which is an unique number for the matrix.
  2865. * It will be incremented every time the matrix data change.
  2866. * You can use it to speed the comparison between two versions of the same matrix.
  2867. */
  2868. updateFlag: number;
  2869. private readonly _m;
  2870. /**
  2871. * Gets the internal data of the matrix
  2872. */
  2873. readonly m: DeepImmutable<Float32Array>;
  2874. /** @hidden */
  2875. _markAsUpdated(): void;
  2876. /** @hidden */
  2877. private _updateIdentityStatus;
  2878. /**
  2879. * Creates an empty matrix (filled with zeros)
  2880. */
  2881. constructor();
  2882. /**
  2883. * Check if the current matrix is identity
  2884. * @returns true is the matrix is the identity matrix
  2885. */
  2886. isIdentity(): boolean;
  2887. /**
  2888. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2889. * @returns true is the matrix is the identity matrix
  2890. */
  2891. isIdentityAs3x2(): boolean;
  2892. /**
  2893. * Gets the determinant of the matrix
  2894. * @returns the matrix determinant
  2895. */
  2896. determinant(): number;
  2897. /**
  2898. * Returns the matrix as a Float32Array
  2899. * @returns the matrix underlying array
  2900. */
  2901. toArray(): DeepImmutable<Float32Array>;
  2902. /**
  2903. * Returns the matrix as a Float32Array
  2904. * @returns the matrix underlying array.
  2905. */
  2906. asArray(): DeepImmutable<Float32Array>;
  2907. /**
  2908. * Inverts the current matrix in place
  2909. * @returns the current inverted matrix
  2910. */
  2911. invert(): Matrix;
  2912. /**
  2913. * Sets all the matrix elements to zero
  2914. * @returns the current matrix
  2915. */
  2916. reset(): Matrix;
  2917. /**
  2918. * Adds the current matrix with a second one
  2919. * @param other defines the matrix to add
  2920. * @returns a new matrix as the addition of the current matrix and the given one
  2921. */
  2922. add(other: DeepImmutable<Matrix>): Matrix;
  2923. /**
  2924. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2925. * @param other defines the matrix to add
  2926. * @param result defines the target matrix
  2927. * @returns the current matrix
  2928. */
  2929. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2930. /**
  2931. * Adds in place the given matrix to the current matrix
  2932. * @param other defines the second operand
  2933. * @returns the current updated matrix
  2934. */
  2935. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2936. /**
  2937. * Sets the given matrix to the current inverted Matrix
  2938. * @param other defines the target matrix
  2939. * @returns the unmodified current matrix
  2940. */
  2941. invertToRef(other: Matrix): Matrix;
  2942. /**
  2943. * add a value at the specified position in the current Matrix
  2944. * @param index the index of the value within the matrix. between 0 and 15.
  2945. * @param value the value to be added
  2946. * @returns the current updated matrix
  2947. */
  2948. addAtIndex(index: number, value: number): Matrix;
  2949. /**
  2950. * mutiply the specified position in the current Matrix by a value
  2951. * @param index the index of the value within the matrix. between 0 and 15.
  2952. * @param value the value to be added
  2953. * @returns the current updated matrix
  2954. */
  2955. multiplyAtIndex(index: number, value: number): Matrix;
  2956. /**
  2957. * Inserts the translation vector (using 3 floats) in the current matrix
  2958. * @param x defines the 1st component of the translation
  2959. * @param y defines the 2nd component of the translation
  2960. * @param z defines the 3rd component of the translation
  2961. * @returns the current updated matrix
  2962. */
  2963. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2964. /**
  2965. * Adds the translation vector (using 3 floats) in the current matrix
  2966. * @param x defines the 1st component of the translation
  2967. * @param y defines the 2nd component of the translation
  2968. * @param z defines the 3rd component of the translation
  2969. * @returns the current updated matrix
  2970. */
  2971. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2972. /**
  2973. * Inserts the translation vector in the current matrix
  2974. * @param vector3 defines the translation to insert
  2975. * @returns the current updated matrix
  2976. */
  2977. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2978. /**
  2979. * Gets the translation value of the current matrix
  2980. * @returns a new Vector3 as the extracted translation from the matrix
  2981. */
  2982. getTranslation(): Vector3;
  2983. /**
  2984. * Fill a Vector3 with the extracted translation from the matrix
  2985. * @param result defines the Vector3 where to store the translation
  2986. * @returns the current matrix
  2987. */
  2988. getTranslationToRef(result: Vector3): Matrix;
  2989. /**
  2990. * Remove rotation and scaling part from the matrix
  2991. * @returns the updated matrix
  2992. */
  2993. removeRotationAndScaling(): Matrix;
  2994. /**
  2995. * Multiply two matrices
  2996. * @param other defines the second operand
  2997. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2998. */
  2999. multiply(other: DeepImmutable<Matrix>): Matrix;
  3000. /**
  3001. * Copy the current matrix from the given one
  3002. * @param other defines the source matrix
  3003. * @returns the current updated matrix
  3004. */
  3005. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3006. /**
  3007. * Populates the given array from the starting index with the current matrix values
  3008. * @param array defines the target array
  3009. * @param offset defines the offset in the target array where to start storing values
  3010. * @returns the current matrix
  3011. */
  3012. copyToArray(array: Float32Array, offset?: number): Matrix;
  3013. /**
  3014. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3015. * @param other defines the second operand
  3016. * @param result defines the matrix where to store the multiplication
  3017. * @returns the current matrix
  3018. */
  3019. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3020. /**
  3021. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3022. * @param other defines the second operand
  3023. * @param result defines the array where to store the multiplication
  3024. * @param offset defines the offset in the target array where to start storing values
  3025. * @returns the current matrix
  3026. */
  3027. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3028. /**
  3029. * Check equality between this matrix and a second one
  3030. * @param value defines the second matrix to compare
  3031. * @returns true is the current matrix and the given one values are strictly equal
  3032. */
  3033. equals(value: DeepImmutable<Matrix>): boolean;
  3034. /**
  3035. * Clone the current matrix
  3036. * @returns a new matrix from the current matrix
  3037. */
  3038. clone(): Matrix;
  3039. /**
  3040. * Returns the name of the current matrix class
  3041. * @returns the string "Matrix"
  3042. */
  3043. getClassName(): string;
  3044. /**
  3045. * Gets the hash code of the current matrix
  3046. * @returns the hash code
  3047. */
  3048. getHashCode(): number;
  3049. /**
  3050. * Decomposes the current Matrix into a translation, rotation and scaling components
  3051. * @param scale defines the scale vector3 given as a reference to update
  3052. * @param rotation defines the rotation quaternion given as a reference to update
  3053. * @param translation defines the translation vector3 given as a reference to update
  3054. * @returns true if operation was successful
  3055. */
  3056. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3057. /**
  3058. * Gets specific row of the matrix
  3059. * @param index defines the number of the row to get
  3060. * @returns the index-th row of the current matrix as a new Vector4
  3061. */
  3062. getRow(index: number): Nullable<Vector4>;
  3063. /**
  3064. * Sets the index-th row of the current matrix to the vector4 values
  3065. * @param index defines the number of the row to set
  3066. * @param row defines the target vector4
  3067. * @returns the updated current matrix
  3068. */
  3069. setRow(index: number, row: Vector4): Matrix;
  3070. /**
  3071. * Compute the transpose of the matrix
  3072. * @returns the new transposed matrix
  3073. */
  3074. transpose(): Matrix;
  3075. /**
  3076. * Compute the transpose of the matrix and store it in a given matrix
  3077. * @param result defines the target matrix
  3078. * @returns the current matrix
  3079. */
  3080. transposeToRef(result: Matrix): Matrix;
  3081. /**
  3082. * Sets the index-th row of the current matrix with the given 4 x float values
  3083. * @param index defines the row index
  3084. * @param x defines the x component to set
  3085. * @param y defines the y component to set
  3086. * @param z defines the z component to set
  3087. * @param w defines the w component to set
  3088. * @returns the updated current matrix
  3089. */
  3090. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3091. /**
  3092. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3093. * @param scale defines the scale factor
  3094. * @returns a new matrix
  3095. */
  3096. scale(scale: number): Matrix;
  3097. /**
  3098. * Scale the current matrix values by a factor to a given result matrix
  3099. * @param scale defines the scale factor
  3100. * @param result defines the matrix to store the result
  3101. * @returns the current matrix
  3102. */
  3103. scaleToRef(scale: number, result: Matrix): Matrix;
  3104. /**
  3105. * Scale the current matrix values by a factor and add the result to a given matrix
  3106. * @param scale defines the scale factor
  3107. * @param result defines the Matrix to store the result
  3108. * @returns the current matrix
  3109. */
  3110. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3111. /**
  3112. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3113. * @param ref matrix to store the result
  3114. */
  3115. toNormalMatrix(ref: Matrix): void;
  3116. /**
  3117. * Gets only rotation part of the current matrix
  3118. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3119. */
  3120. getRotationMatrix(): Matrix;
  3121. /**
  3122. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3123. * @param result defines the target matrix to store data to
  3124. * @returns the current matrix
  3125. */
  3126. getRotationMatrixToRef(result: Matrix): Matrix;
  3127. /**
  3128. * Toggles model matrix from being right handed to left handed in place and vice versa
  3129. */
  3130. toggleModelMatrixHandInPlace(): void;
  3131. /**
  3132. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3133. */
  3134. toggleProjectionMatrixHandInPlace(): void;
  3135. /**
  3136. * Creates a matrix from an array
  3137. * @param array defines the source array
  3138. * @param offset defines an offset in the source array
  3139. * @returns a new Matrix set from the starting index of the given array
  3140. */
  3141. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3142. /**
  3143. * Copy the content of an array into a given matrix
  3144. * @param array defines the source array
  3145. * @param offset defines an offset in the source array
  3146. * @param result defines the target matrix
  3147. */
  3148. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3149. /**
  3150. * Stores an array into a matrix after having multiplied each component by a given factor
  3151. * @param array defines the source array
  3152. * @param offset defines the offset in the source array
  3153. * @param scale defines the scaling factor
  3154. * @param result defines the target matrix
  3155. */
  3156. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3157. /**
  3158. * Gets an identity matrix that must not be updated
  3159. */
  3160. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3161. /**
  3162. * Stores a list of values (16) inside a given matrix
  3163. * @param initialM11 defines 1st value of 1st row
  3164. * @param initialM12 defines 2nd value of 1st row
  3165. * @param initialM13 defines 3rd value of 1st row
  3166. * @param initialM14 defines 4th value of 1st row
  3167. * @param initialM21 defines 1st value of 2nd row
  3168. * @param initialM22 defines 2nd value of 2nd row
  3169. * @param initialM23 defines 3rd value of 2nd row
  3170. * @param initialM24 defines 4th value of 2nd row
  3171. * @param initialM31 defines 1st value of 3rd row
  3172. * @param initialM32 defines 2nd value of 3rd row
  3173. * @param initialM33 defines 3rd value of 3rd row
  3174. * @param initialM34 defines 4th value of 3rd row
  3175. * @param initialM41 defines 1st value of 4th row
  3176. * @param initialM42 defines 2nd value of 4th row
  3177. * @param initialM43 defines 3rd value of 4th row
  3178. * @param initialM44 defines 4th value of 4th row
  3179. * @param result defines the target matrix
  3180. */
  3181. 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;
  3182. /**
  3183. * Creates new matrix from a list of values (16)
  3184. * @param initialM11 defines 1st value of 1st row
  3185. * @param initialM12 defines 2nd value of 1st row
  3186. * @param initialM13 defines 3rd value of 1st row
  3187. * @param initialM14 defines 4th value of 1st row
  3188. * @param initialM21 defines 1st value of 2nd row
  3189. * @param initialM22 defines 2nd value of 2nd row
  3190. * @param initialM23 defines 3rd value of 2nd row
  3191. * @param initialM24 defines 4th value of 2nd row
  3192. * @param initialM31 defines 1st value of 3rd row
  3193. * @param initialM32 defines 2nd value of 3rd row
  3194. * @param initialM33 defines 3rd value of 3rd row
  3195. * @param initialM34 defines 4th value of 3rd row
  3196. * @param initialM41 defines 1st value of 4th row
  3197. * @param initialM42 defines 2nd value of 4th row
  3198. * @param initialM43 defines 3rd value of 4th row
  3199. * @param initialM44 defines 4th value of 4th row
  3200. * @returns the new matrix
  3201. */
  3202. 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;
  3203. /**
  3204. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3205. * @param scale defines the scale vector3
  3206. * @param rotation defines the rotation quaternion
  3207. * @param translation defines the translation vector3
  3208. * @returns a new matrix
  3209. */
  3210. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3211. /**
  3212. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3213. * @param scale defines the scale vector3
  3214. * @param rotation defines the rotation quaternion
  3215. * @param translation defines the translation vector3
  3216. * @param result defines the target matrix
  3217. */
  3218. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3219. /**
  3220. * Creates a new identity matrix
  3221. * @returns a new identity matrix
  3222. */
  3223. static Identity(): Matrix;
  3224. /**
  3225. * Creates a new identity matrix and stores the result in a given matrix
  3226. * @param result defines the target matrix
  3227. */
  3228. static IdentityToRef(result: Matrix): void;
  3229. /**
  3230. * Creates a new zero matrix
  3231. * @returns a new zero matrix
  3232. */
  3233. static Zero(): Matrix;
  3234. /**
  3235. * Creates a new rotation matrix for "angle" radians around the X axis
  3236. * @param angle defines the angle (in radians) to use
  3237. * @return the new matrix
  3238. */
  3239. static RotationX(angle: number): Matrix;
  3240. /**
  3241. * Creates a new matrix as the invert of a given matrix
  3242. * @param source defines the source matrix
  3243. * @returns the new matrix
  3244. */
  3245. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3246. /**
  3247. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3248. * @param angle defines the angle (in radians) to use
  3249. * @param result defines the target matrix
  3250. */
  3251. static RotationXToRef(angle: number, result: Matrix): void;
  3252. /**
  3253. * Creates a new rotation matrix for "angle" radians around the Y axis
  3254. * @param angle defines the angle (in radians) to use
  3255. * @return the new matrix
  3256. */
  3257. static RotationY(angle: number): Matrix;
  3258. /**
  3259. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3260. * @param angle defines the angle (in radians) to use
  3261. * @param result defines the target matrix
  3262. */
  3263. static RotationYToRef(angle: number, result: Matrix): void;
  3264. /**
  3265. * Creates a new rotation matrix for "angle" radians around the Z axis
  3266. * @param angle defines the angle (in radians) to use
  3267. * @return the new matrix
  3268. */
  3269. static RotationZ(angle: number): Matrix;
  3270. /**
  3271. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3272. * @param angle defines the angle (in radians) to use
  3273. * @param result defines the target matrix
  3274. */
  3275. static RotationZToRef(angle: number, result: Matrix): void;
  3276. /**
  3277. * Creates a new rotation matrix for "angle" radians around the given axis
  3278. * @param axis defines the axis to use
  3279. * @param angle defines the angle (in radians) to use
  3280. * @return the new matrix
  3281. */
  3282. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3283. /**
  3284. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3285. * @param axis defines the axis to use
  3286. * @param angle defines the angle (in radians) to use
  3287. * @param result defines the target matrix
  3288. */
  3289. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3290. /**
  3291. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3292. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3293. * @param from defines the vector to align
  3294. * @param to defines the vector to align to
  3295. * @param result defines the target matrix
  3296. */
  3297. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3298. /**
  3299. * Creates a rotation matrix
  3300. * @param yaw defines the yaw angle in radians (Y axis)
  3301. * @param pitch defines the pitch angle in radians (X axis)
  3302. * @param roll defines the roll angle in radians (X axis)
  3303. * @returns the new rotation matrix
  3304. */
  3305. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3306. /**
  3307. * Creates a rotation matrix and stores it in a given matrix
  3308. * @param yaw defines the yaw angle in radians (Y axis)
  3309. * @param pitch defines the pitch angle in radians (X axis)
  3310. * @param roll defines the roll angle in radians (X axis)
  3311. * @param result defines the target matrix
  3312. */
  3313. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3314. /**
  3315. * Creates a scaling matrix
  3316. * @param x defines the scale factor on X axis
  3317. * @param y defines the scale factor on Y axis
  3318. * @param z defines the scale factor on Z axis
  3319. * @returns the new matrix
  3320. */
  3321. static Scaling(x: number, y: number, z: number): Matrix;
  3322. /**
  3323. * Creates a scaling matrix and stores it in a given matrix
  3324. * @param x defines the scale factor on X axis
  3325. * @param y defines the scale factor on Y axis
  3326. * @param z defines the scale factor on Z axis
  3327. * @param result defines the target matrix
  3328. */
  3329. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3330. /**
  3331. * Creates a translation matrix
  3332. * @param x defines the translation on X axis
  3333. * @param y defines the translation on Y axis
  3334. * @param z defines the translationon Z axis
  3335. * @returns the new matrix
  3336. */
  3337. static Translation(x: number, y: number, z: number): Matrix;
  3338. /**
  3339. * Creates a translation matrix and stores it in a given matrix
  3340. * @param x defines the translation on X axis
  3341. * @param y defines the translation on Y axis
  3342. * @param z defines the translationon Z axis
  3343. * @param result defines the target matrix
  3344. */
  3345. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3346. /**
  3347. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3348. * @param startValue defines the start value
  3349. * @param endValue defines the end value
  3350. * @param gradient defines the gradient factor
  3351. * @returns the new matrix
  3352. */
  3353. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3354. /**
  3355. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3356. * @param startValue defines the start value
  3357. * @param endValue defines the end value
  3358. * @param gradient defines the gradient factor
  3359. * @param result defines the Matrix object where to store data
  3360. */
  3361. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3362. /**
  3363. * Builds a new matrix whose values are computed by:
  3364. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3365. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3366. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3367. * @param startValue defines the first matrix
  3368. * @param endValue defines the second matrix
  3369. * @param gradient defines the gradient between the two matrices
  3370. * @returns the new matrix
  3371. */
  3372. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3373. /**
  3374. * Update a matrix to values which are computed by:
  3375. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3376. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3377. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3378. * @param startValue defines the first matrix
  3379. * @param endValue defines the second matrix
  3380. * @param gradient defines the gradient between the two matrices
  3381. * @param result defines the target matrix
  3382. */
  3383. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3384. /**
  3385. * 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"
  3386. * This function works in left handed mode
  3387. * @param eye defines the final position of the entity
  3388. * @param target defines where the entity should look at
  3389. * @param up defines the up vector for the entity
  3390. * @returns the new matrix
  3391. */
  3392. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3393. /**
  3394. * 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".
  3395. * This function works in left handed mode
  3396. * @param eye defines the final position of the entity
  3397. * @param target defines where the entity should look at
  3398. * @param up defines the up vector for the entity
  3399. * @param result defines the target matrix
  3400. */
  3401. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3402. /**
  3403. * 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"
  3404. * This function works in right handed mode
  3405. * @param eye defines the final position of the entity
  3406. * @param target defines where the entity should look at
  3407. * @param up defines the up vector for the entity
  3408. * @returns the new matrix
  3409. */
  3410. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3411. /**
  3412. * 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".
  3413. * This function works in right handed mode
  3414. * @param eye defines the final position of the entity
  3415. * @param target defines where the entity should look at
  3416. * @param up defines the up vector for the entity
  3417. * @param result defines the target matrix
  3418. */
  3419. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3420. /**
  3421. * Create a left-handed orthographic projection matrix
  3422. * @param width defines the viewport width
  3423. * @param height defines the viewport height
  3424. * @param znear defines the near clip plane
  3425. * @param zfar defines the far clip plane
  3426. * @returns a new matrix as a left-handed orthographic projection matrix
  3427. */
  3428. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3429. /**
  3430. * Store a left-handed orthographic projection to a given matrix
  3431. * @param width defines the viewport width
  3432. * @param height defines the viewport height
  3433. * @param znear defines the near clip plane
  3434. * @param zfar defines the far clip plane
  3435. * @param result defines the target matrix
  3436. */
  3437. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3438. /**
  3439. * Create a left-handed orthographic projection matrix
  3440. * @param left defines the viewport left coordinate
  3441. * @param right defines the viewport right coordinate
  3442. * @param bottom defines the viewport bottom coordinate
  3443. * @param top defines the viewport top coordinate
  3444. * @param znear defines the near clip plane
  3445. * @param zfar defines the far clip plane
  3446. * @returns a new matrix as a left-handed orthographic projection matrix
  3447. */
  3448. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3449. /**
  3450. * Stores a left-handed orthographic projection into a given matrix
  3451. * @param left defines the viewport left coordinate
  3452. * @param right defines the viewport right coordinate
  3453. * @param bottom defines the viewport bottom coordinate
  3454. * @param top defines the viewport top coordinate
  3455. * @param znear defines the near clip plane
  3456. * @param zfar defines the far clip plane
  3457. * @param result defines the target matrix
  3458. */
  3459. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3460. /**
  3461. * Creates a right-handed orthographic projection matrix
  3462. * @param left defines the viewport left coordinate
  3463. * @param right defines the viewport right coordinate
  3464. * @param bottom defines the viewport bottom coordinate
  3465. * @param top defines the viewport top coordinate
  3466. * @param znear defines the near clip plane
  3467. * @param zfar defines the far clip plane
  3468. * @returns a new matrix as a right-handed orthographic projection matrix
  3469. */
  3470. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3471. /**
  3472. * Stores a right-handed orthographic projection into a given matrix
  3473. * @param left defines the viewport left coordinate
  3474. * @param right defines the viewport right coordinate
  3475. * @param bottom defines the viewport bottom coordinate
  3476. * @param top defines the viewport top coordinate
  3477. * @param znear defines the near clip plane
  3478. * @param zfar defines the far clip plane
  3479. * @param result defines the target matrix
  3480. */
  3481. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3482. /**
  3483. * Creates a left-handed perspective projection matrix
  3484. * @param width defines the viewport width
  3485. * @param height defines the viewport height
  3486. * @param znear defines the near clip plane
  3487. * @param zfar defines the far clip plane
  3488. * @returns a new matrix as a left-handed perspective projection matrix
  3489. */
  3490. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3491. /**
  3492. * Creates a left-handed perspective projection matrix
  3493. * @param fov defines the horizontal field of view
  3494. * @param aspect defines the aspect ratio
  3495. * @param znear defines the near clip plane
  3496. * @param zfar defines the far clip plane
  3497. * @returns a new matrix as a left-handed perspective projection matrix
  3498. */
  3499. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3500. /**
  3501. * Stores a left-handed perspective projection into a given matrix
  3502. * @param fov defines the horizontal field of view
  3503. * @param aspect defines the aspect ratio
  3504. * @param znear defines the near clip plane
  3505. * @param zfar defines the far clip plane
  3506. * @param result defines the target matrix
  3507. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3508. */
  3509. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3510. /**
  3511. * Creates a right-handed perspective projection matrix
  3512. * @param fov defines the horizontal field of view
  3513. * @param aspect defines the aspect ratio
  3514. * @param znear defines the near clip plane
  3515. * @param zfar defines the far clip plane
  3516. * @returns a new matrix as a right-handed perspective projection matrix
  3517. */
  3518. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3519. /**
  3520. * Stores a right-handed perspective projection into a given matrix
  3521. * @param fov defines the horizontal field of view
  3522. * @param aspect defines the aspect ratio
  3523. * @param znear defines the near clip plane
  3524. * @param zfar defines the far clip plane
  3525. * @param result defines the target matrix
  3526. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3527. */
  3528. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3529. /**
  3530. * Stores a perspective projection for WebVR info a given matrix
  3531. * @param fov defines the field of view
  3532. * @param znear defines the near clip plane
  3533. * @param zfar defines the far clip plane
  3534. * @param result defines the target matrix
  3535. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3536. */
  3537. static PerspectiveFovWebVRToRef(fov: {
  3538. upDegrees: number;
  3539. downDegrees: number;
  3540. leftDegrees: number;
  3541. rightDegrees: number;
  3542. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3543. /**
  3544. * Computes a complete transformation matrix
  3545. * @param viewport defines the viewport to use
  3546. * @param world defines the world matrix
  3547. * @param view defines the view matrix
  3548. * @param projection defines the projection matrix
  3549. * @param zmin defines the near clip plane
  3550. * @param zmax defines the far clip plane
  3551. * @returns the transformation matrix
  3552. */
  3553. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3554. /**
  3555. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3556. * @param matrix defines the matrix to use
  3557. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3558. */
  3559. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3560. /**
  3561. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3562. * @param matrix defines the matrix to use
  3563. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3564. */
  3565. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3566. /**
  3567. * Compute the transpose of a given matrix
  3568. * @param matrix defines the matrix to transpose
  3569. * @returns the new matrix
  3570. */
  3571. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3572. /**
  3573. * Compute the transpose of a matrix and store it in a target matrix
  3574. * @param matrix defines the matrix to transpose
  3575. * @param result defines the target matrix
  3576. */
  3577. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3578. /**
  3579. * Computes a reflection matrix from a plane
  3580. * @param plane defines the reflection plane
  3581. * @returns a new matrix
  3582. */
  3583. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3584. /**
  3585. * Computes a reflection matrix from a plane
  3586. * @param plane defines the reflection plane
  3587. * @param result defines the target matrix
  3588. */
  3589. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3590. /**
  3591. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3592. * @param xaxis defines the value of the 1st axis
  3593. * @param yaxis defines the value of the 2nd axis
  3594. * @param zaxis defines the value of the 3rd axis
  3595. * @param result defines the target matrix
  3596. */
  3597. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3598. /**
  3599. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3600. * @param quat defines the quaternion to use
  3601. * @param result defines the target matrix
  3602. */
  3603. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3604. }
  3605. /**
  3606. * Represens a plane by the equation ax + by + cz + d = 0
  3607. */
  3608. export class Plane {
  3609. /**
  3610. * Normal of the plane (a,b,c)
  3611. */
  3612. normal: Vector3;
  3613. /**
  3614. * d component of the plane
  3615. */
  3616. d: number;
  3617. /**
  3618. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3619. * @param a a component of the plane
  3620. * @param b b component of the plane
  3621. * @param c c component of the plane
  3622. * @param d d component of the plane
  3623. */
  3624. constructor(a: number, b: number, c: number, d: number);
  3625. /**
  3626. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3627. */
  3628. asArray(): number[];
  3629. /**
  3630. * @returns a new plane copied from the current Plane.
  3631. */
  3632. clone(): Plane;
  3633. /**
  3634. * @returns the string "Plane".
  3635. */
  3636. getClassName(): string;
  3637. /**
  3638. * @returns the Plane hash code.
  3639. */
  3640. getHashCode(): number;
  3641. /**
  3642. * Normalize the current Plane in place.
  3643. * @returns the updated Plane.
  3644. */
  3645. normalize(): Plane;
  3646. /**
  3647. * Applies a transformation the plane and returns the result
  3648. * @param transformation the transformation matrix to be applied to the plane
  3649. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3650. */
  3651. transform(transformation: DeepImmutable<Matrix>): Plane;
  3652. /**
  3653. * Calcualtte the dot product between the point and the plane normal
  3654. * @param point point to calculate the dot product with
  3655. * @returns the dot product (float) of the point coordinates and the plane normal.
  3656. */
  3657. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3658. /**
  3659. * Updates the current Plane from the plane defined by the three given points.
  3660. * @param point1 one of the points used to contruct the plane
  3661. * @param point2 one of the points used to contruct the plane
  3662. * @param point3 one of the points used to contruct the plane
  3663. * @returns the updated Plane.
  3664. */
  3665. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3666. /**
  3667. * Checks if the plane is facing a given direction
  3668. * @param direction the direction to check if the plane is facing
  3669. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3670. * @returns True is the vector "direction" is the same side than the plane normal.
  3671. */
  3672. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3673. /**
  3674. * Calculates the distance to a point
  3675. * @param point point to calculate distance to
  3676. * @returns the signed distance (float) from the given point to the Plane.
  3677. */
  3678. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3679. /**
  3680. * Creates a plane from an array
  3681. * @param array the array to create a plane from
  3682. * @returns a new Plane from the given array.
  3683. */
  3684. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3685. /**
  3686. * Creates a plane from three points
  3687. * @param point1 point used to create the plane
  3688. * @param point2 point used to create the plane
  3689. * @param point3 point used to create the plane
  3690. * @returns a new Plane defined by the three given points.
  3691. */
  3692. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3693. /**
  3694. * Creates a plane from an origin point and a normal
  3695. * @param origin origin of the plane to be constructed
  3696. * @param normal normal of the plane to be constructed
  3697. * @returns a new Plane the normal vector to this plane at the given origin point.
  3698. * Note : the vector "normal" is updated because normalized.
  3699. */
  3700. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3701. /**
  3702. * Calculates the distance from a plane and a point
  3703. * @param origin origin of the plane to be constructed
  3704. * @param normal normal of the plane to be constructed
  3705. * @param point point to calculate distance to
  3706. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3707. */
  3708. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3709. }
  3710. /**
  3711. * Class used to represent a viewport on screen
  3712. */
  3713. export class Viewport {
  3714. /** viewport left coordinate */
  3715. x: number;
  3716. /** viewport top coordinate */
  3717. y: number;
  3718. /**viewport width */
  3719. width: number;
  3720. /** viewport height */
  3721. height: number;
  3722. /**
  3723. * Creates a Viewport object located at (x, y) and sized (width, height)
  3724. * @param x defines viewport left coordinate
  3725. * @param y defines viewport top coordinate
  3726. * @param width defines the viewport width
  3727. * @param height defines the viewport height
  3728. */
  3729. constructor(
  3730. /** viewport left coordinate */
  3731. x: number,
  3732. /** viewport top coordinate */
  3733. y: number,
  3734. /**viewport width */
  3735. width: number,
  3736. /** viewport height */
  3737. height: number);
  3738. /**
  3739. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3740. * @param renderWidth defines the rendering width
  3741. * @param renderHeight defines the rendering height
  3742. * @returns a new Viewport
  3743. */
  3744. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3745. /**
  3746. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3747. * @param renderWidth defines the rendering width
  3748. * @param renderHeight defines the rendering height
  3749. * @param ref defines the target viewport
  3750. * @returns the current viewport
  3751. */
  3752. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3753. /**
  3754. * Returns a new Viewport copied from the current one
  3755. * @returns a new Viewport
  3756. */
  3757. clone(): Viewport;
  3758. }
  3759. /**
  3760. * Reprasents a camera frustum
  3761. */
  3762. export class Frustum {
  3763. /**
  3764. * Gets the planes representing the frustum
  3765. * @param transform matrix to be applied to the returned planes
  3766. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3767. */
  3768. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3769. /**
  3770. * Gets the near frustum plane transformed by the transform matrix
  3771. * @param transform transformation matrix to be applied to the resulting frustum plane
  3772. * @param frustumPlane the resuling frustum plane
  3773. */
  3774. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3775. /**
  3776. * Gets the far frustum plane transformed by the transform matrix
  3777. * @param transform transformation matrix to be applied to the resulting frustum plane
  3778. * @param frustumPlane the resuling frustum plane
  3779. */
  3780. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3781. /**
  3782. * Gets the left frustum plane transformed by the transform matrix
  3783. * @param transform transformation matrix to be applied to the resulting frustum plane
  3784. * @param frustumPlane the resuling frustum plane
  3785. */
  3786. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3787. /**
  3788. * Gets the right frustum plane transformed by the transform matrix
  3789. * @param transform transformation matrix to be applied to the resulting frustum plane
  3790. * @param frustumPlane the resuling frustum plane
  3791. */
  3792. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3793. /**
  3794. * Gets the top frustum plane transformed by the transform matrix
  3795. * @param transform transformation matrix to be applied to the resulting frustum plane
  3796. * @param frustumPlane the resuling frustum plane
  3797. */
  3798. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3799. /**
  3800. * Gets the bottom frustum plane transformed by the transform matrix
  3801. * @param transform transformation matrix to be applied to the resulting frustum plane
  3802. * @param frustumPlane the resuling frustum plane
  3803. */
  3804. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3805. /**
  3806. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3807. * @param transform transformation matrix to be applied to the resulting frustum planes
  3808. * @param frustumPlanes the resuling frustum planes
  3809. */
  3810. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3811. }
  3812. /** Defines supported spaces */
  3813. export enum Space {
  3814. /** Local (object) space */
  3815. LOCAL = 0,
  3816. /** World space */
  3817. WORLD = 1,
  3818. /** Bone space */
  3819. BONE = 2
  3820. }
  3821. /** Defines the 3 main axes */
  3822. export class Axis {
  3823. /** X axis */
  3824. static X: Vector3;
  3825. /** Y axis */
  3826. static Y: Vector3;
  3827. /** Z axis */
  3828. static Z: Vector3;
  3829. }
  3830. /** Class used to represent a Bezier curve */
  3831. export class BezierCurve {
  3832. /**
  3833. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3834. * @param t defines the time
  3835. * @param x1 defines the left coordinate on X axis
  3836. * @param y1 defines the left coordinate on Y axis
  3837. * @param x2 defines the right coordinate on X axis
  3838. * @param y2 defines the right coordinate on Y axis
  3839. * @returns the interpolated value
  3840. */
  3841. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3842. }
  3843. /**
  3844. * Defines potential orientation for back face culling
  3845. */
  3846. export enum Orientation {
  3847. /**
  3848. * Clockwise
  3849. */
  3850. CW = 0,
  3851. /** Counter clockwise */
  3852. CCW = 1
  3853. }
  3854. /**
  3855. * Defines angle representation
  3856. */
  3857. export class Angle {
  3858. private _radians;
  3859. /**
  3860. * Creates an Angle object of "radians" radians (float).
  3861. * @param radians the angle in radians
  3862. */
  3863. constructor(radians: number);
  3864. /**
  3865. * Get value in degrees
  3866. * @returns the Angle value in degrees (float)
  3867. */
  3868. degrees(): number;
  3869. /**
  3870. * Get value in radians
  3871. * @returns the Angle value in radians (float)
  3872. */
  3873. radians(): number;
  3874. /**
  3875. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3876. * @param a defines first vector
  3877. * @param b defines second vector
  3878. * @returns a new Angle
  3879. */
  3880. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3881. /**
  3882. * Gets a new Angle object from the given float in radians
  3883. * @param radians defines the angle value in radians
  3884. * @returns a new Angle
  3885. */
  3886. static FromRadians(radians: number): Angle;
  3887. /**
  3888. * Gets a new Angle object from the given float in degrees
  3889. * @param degrees defines the angle value in degrees
  3890. * @returns a new Angle
  3891. */
  3892. static FromDegrees(degrees: number): Angle;
  3893. }
  3894. /**
  3895. * This represents an arc in a 2d space.
  3896. */
  3897. export class Arc2 {
  3898. /** Defines the start point of the arc */
  3899. startPoint: Vector2;
  3900. /** Defines the mid point of the arc */
  3901. midPoint: Vector2;
  3902. /** Defines the end point of the arc */
  3903. endPoint: Vector2;
  3904. /**
  3905. * Defines the center point of the arc.
  3906. */
  3907. centerPoint: Vector2;
  3908. /**
  3909. * Defines the radius of the arc.
  3910. */
  3911. radius: number;
  3912. /**
  3913. * Defines the angle of the arc (from mid point to end point).
  3914. */
  3915. angle: Angle;
  3916. /**
  3917. * Defines the start angle of the arc (from start point to middle point).
  3918. */
  3919. startAngle: Angle;
  3920. /**
  3921. * Defines the orientation of the arc (clock wise/counter clock wise).
  3922. */
  3923. orientation: Orientation;
  3924. /**
  3925. * Creates an Arc object from the three given points : start, middle and end.
  3926. * @param startPoint Defines the start point of the arc
  3927. * @param midPoint Defines the midlle point of the arc
  3928. * @param endPoint Defines the end point of the arc
  3929. */
  3930. constructor(
  3931. /** Defines the start point of the arc */
  3932. startPoint: Vector2,
  3933. /** Defines the mid point of the arc */
  3934. midPoint: Vector2,
  3935. /** Defines the end point of the arc */
  3936. endPoint: Vector2);
  3937. }
  3938. /**
  3939. * Represents a 2D path made up of multiple 2D points
  3940. */
  3941. export class Path2 {
  3942. private _points;
  3943. private _length;
  3944. /**
  3945. * If the path start and end point are the same
  3946. */
  3947. closed: boolean;
  3948. /**
  3949. * Creates a Path2 object from the starting 2D coordinates x and y.
  3950. * @param x the starting points x value
  3951. * @param y the starting points y value
  3952. */
  3953. constructor(x: number, y: number);
  3954. /**
  3955. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3956. * @param x the added points x value
  3957. * @param y the added points y value
  3958. * @returns the updated Path2.
  3959. */
  3960. addLineTo(x: number, y: number): Path2;
  3961. /**
  3962. * 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.
  3963. * @param midX middle point x value
  3964. * @param midY middle point y value
  3965. * @param endX end point x value
  3966. * @param endY end point y value
  3967. * @param numberOfSegments (default: 36)
  3968. * @returns the updated Path2.
  3969. */
  3970. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3971. /**
  3972. * Closes the Path2.
  3973. * @returns the Path2.
  3974. */
  3975. close(): Path2;
  3976. /**
  3977. * Gets the sum of the distance between each sequential point in the path
  3978. * @returns the Path2 total length (float).
  3979. */
  3980. length(): number;
  3981. /**
  3982. * Gets the points which construct the path
  3983. * @returns the Path2 internal array of points.
  3984. */
  3985. getPoints(): Vector2[];
  3986. /**
  3987. * Retreives the point at the distance aways from the starting point
  3988. * @param normalizedLengthPosition the length along the path to retreive the point from
  3989. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3990. */
  3991. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3992. /**
  3993. * Creates a new path starting from an x and y position
  3994. * @param x starting x value
  3995. * @param y starting y value
  3996. * @returns a new Path2 starting at the coordinates (x, y).
  3997. */
  3998. static StartingAt(x: number, y: number): Path2;
  3999. }
  4000. /**
  4001. * Represents a 3D path made up of multiple 3D points
  4002. */
  4003. export class Path3D {
  4004. /**
  4005. * an array of Vector3, the curve axis of the Path3D
  4006. */
  4007. path: Vector3[];
  4008. private _curve;
  4009. private _distances;
  4010. private _tangents;
  4011. private _normals;
  4012. private _binormals;
  4013. private _raw;
  4014. /**
  4015. * new Path3D(path, normal, raw)
  4016. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4017. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4018. * @param path an array of Vector3, the curve axis of the Path3D
  4019. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4020. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4021. */
  4022. constructor(
  4023. /**
  4024. * an array of Vector3, the curve axis of the Path3D
  4025. */
  4026. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4027. /**
  4028. * Returns the Path3D array of successive Vector3 designing its curve.
  4029. * @returns the Path3D array of successive Vector3 designing its curve.
  4030. */
  4031. getCurve(): Vector3[];
  4032. /**
  4033. * Returns an array populated with tangent vectors on each Path3D curve point.
  4034. * @returns an array populated with tangent vectors on each Path3D curve point.
  4035. */
  4036. getTangents(): Vector3[];
  4037. /**
  4038. * Returns an array populated with normal vectors on each Path3D curve point.
  4039. * @returns an array populated with normal vectors on each Path3D curve point.
  4040. */
  4041. getNormals(): Vector3[];
  4042. /**
  4043. * Returns an array populated with binormal vectors on each Path3D curve point.
  4044. * @returns an array populated with binormal vectors on each Path3D curve point.
  4045. */
  4046. getBinormals(): Vector3[];
  4047. /**
  4048. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4049. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4050. */
  4051. getDistances(): number[];
  4052. /**
  4053. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4054. * @param path path which all values are copied into the curves points
  4055. * @param firstNormal which should be projected onto the curve
  4056. * @returns the same object updated.
  4057. */
  4058. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4059. private _compute;
  4060. private _getFirstNonNullVector;
  4061. private _getLastNonNullVector;
  4062. private _normalVector;
  4063. }
  4064. /**
  4065. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4066. * A Curve3 is designed from a series of successive Vector3.
  4067. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4068. */
  4069. export class Curve3 {
  4070. private _points;
  4071. private _length;
  4072. /**
  4073. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4074. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4075. * @param v1 (Vector3) the control point
  4076. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4077. * @param nbPoints (integer) the wanted number of points in the curve
  4078. * @returns the created Curve3
  4079. */
  4080. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4081. /**
  4082. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4083. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4084. * @param v1 (Vector3) the first control point
  4085. * @param v2 (Vector3) the second control point
  4086. * @param v3 (Vector3) the end point of the Cubic Bezier
  4087. * @param nbPoints (integer) the wanted number of points in the curve
  4088. * @returns the created Curve3
  4089. */
  4090. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4091. /**
  4092. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4093. * @param p1 (Vector3) the origin point of the Hermite Spline
  4094. * @param t1 (Vector3) the tangent vector at the origin point
  4095. * @param p2 (Vector3) the end point of the Hermite Spline
  4096. * @param t2 (Vector3) the tangent vector at the end point
  4097. * @param nbPoints (integer) the wanted number of points in the curve
  4098. * @returns the created Curve3
  4099. */
  4100. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4101. /**
  4102. * Returns a Curve3 object along a CatmullRom Spline curve :
  4103. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4104. * @param nbPoints (integer) the wanted number of points between each curve control points
  4105. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4106. * @returns the created Curve3
  4107. */
  4108. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4109. /**
  4110. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4111. * A Curve3 is designed from a series of successive Vector3.
  4112. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4113. * @param points points which make up the curve
  4114. */
  4115. constructor(points: Vector3[]);
  4116. /**
  4117. * @returns the Curve3 stored array of successive Vector3
  4118. */
  4119. getPoints(): Vector3[];
  4120. /**
  4121. * @returns the computed length (float) of the curve.
  4122. */
  4123. length(): number;
  4124. /**
  4125. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4126. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4127. * curveA and curveB keep unchanged.
  4128. * @param curve the curve to continue from this curve
  4129. * @returns the newly constructed curve
  4130. */
  4131. continue(curve: DeepImmutable<Curve3>): Curve3;
  4132. private _computeLength;
  4133. }
  4134. /**
  4135. * Contains position and normal vectors for a vertex
  4136. */
  4137. export class PositionNormalVertex {
  4138. /** the position of the vertex (defaut: 0,0,0) */
  4139. position: Vector3;
  4140. /** the normal of the vertex (defaut: 0,1,0) */
  4141. normal: Vector3;
  4142. /**
  4143. * Creates a PositionNormalVertex
  4144. * @param position the position of the vertex (defaut: 0,0,0)
  4145. * @param normal the normal of the vertex (defaut: 0,1,0)
  4146. */
  4147. constructor(
  4148. /** the position of the vertex (defaut: 0,0,0) */
  4149. position?: Vector3,
  4150. /** the normal of the vertex (defaut: 0,1,0) */
  4151. normal?: Vector3);
  4152. /**
  4153. * Clones the PositionNormalVertex
  4154. * @returns the cloned PositionNormalVertex
  4155. */
  4156. clone(): PositionNormalVertex;
  4157. }
  4158. /**
  4159. * Contains position, normal and uv vectors for a vertex
  4160. */
  4161. export class PositionNormalTextureVertex {
  4162. /** the position of the vertex (defaut: 0,0,0) */
  4163. position: Vector3;
  4164. /** the normal of the vertex (defaut: 0,1,0) */
  4165. normal: Vector3;
  4166. /** the uv of the vertex (default: 0,0) */
  4167. uv: Vector2;
  4168. /**
  4169. * Creates a PositionNormalTextureVertex
  4170. * @param position the position of the vertex (defaut: 0,0,0)
  4171. * @param normal the normal of the vertex (defaut: 0,1,0)
  4172. * @param uv the uv of the vertex (default: 0,0)
  4173. */
  4174. constructor(
  4175. /** the position of the vertex (defaut: 0,0,0) */
  4176. position?: Vector3,
  4177. /** the normal of the vertex (defaut: 0,1,0) */
  4178. normal?: Vector3,
  4179. /** the uv of the vertex (default: 0,0) */
  4180. uv?: Vector2);
  4181. /**
  4182. * Clones the PositionNormalTextureVertex
  4183. * @returns the cloned PositionNormalTextureVertex
  4184. */
  4185. clone(): PositionNormalTextureVertex;
  4186. }
  4187. /**
  4188. * @hidden
  4189. */
  4190. export class Tmp {
  4191. static Color3: Color3[];
  4192. static Color4: Color4[];
  4193. static Vector2: Vector2[];
  4194. static Vector3: Vector3[];
  4195. static Vector4: Vector4[];
  4196. static Quaternion: Quaternion[];
  4197. static Matrix: Matrix[];
  4198. }
  4199. }
  4200. declare module BABYLON {
  4201. /**
  4202. * Class used to enable access to offline support
  4203. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4204. */
  4205. export interface IOfflineProvider {
  4206. /**
  4207. * Gets a boolean indicating if scene must be saved in the database
  4208. */
  4209. enableSceneOffline: boolean;
  4210. /**
  4211. * Gets a boolean indicating if textures must be saved in the database
  4212. */
  4213. enableTexturesOffline: boolean;
  4214. /**
  4215. * Open the offline support and make it available
  4216. * @param successCallback defines the callback to call on success
  4217. * @param errorCallback defines the callback to call on error
  4218. */
  4219. open(successCallback: () => void, errorCallback: () => void): void;
  4220. /**
  4221. * Loads an image from the offline support
  4222. * @param url defines the url to load from
  4223. * @param image defines the target DOM image
  4224. */
  4225. loadImage(url: string, image: HTMLImageElement): void;
  4226. /**
  4227. * Loads a file from offline support
  4228. * @param url defines the URL to load from
  4229. * @param sceneLoaded defines a callback to call on success
  4230. * @param progressCallBack defines a callback to call when progress changed
  4231. * @param errorCallback defines a callback to call on error
  4232. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4233. */
  4234. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4235. }
  4236. }
  4237. declare module BABYLON {
  4238. /**
  4239. * A class serves as a medium between the observable and its observers
  4240. */
  4241. export class EventState {
  4242. /**
  4243. * Create a new EventState
  4244. * @param mask defines the mask associated with this state
  4245. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4246. * @param target defines the original target of the state
  4247. * @param currentTarget defines the current target of the state
  4248. */
  4249. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4250. /**
  4251. * Initialize the current event state
  4252. * @param mask defines the mask associated with this state
  4253. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4254. * @param target defines the original target of the state
  4255. * @param currentTarget defines the current target of the state
  4256. * @returns the current event state
  4257. */
  4258. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4259. /**
  4260. * An Observer can set this property to true to prevent subsequent observers of being notified
  4261. */
  4262. skipNextObservers: boolean;
  4263. /**
  4264. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4265. */
  4266. mask: number;
  4267. /**
  4268. * The object that originally notified the event
  4269. */
  4270. target?: any;
  4271. /**
  4272. * The current object in the bubbling phase
  4273. */
  4274. currentTarget?: any;
  4275. /**
  4276. * This will be populated with the return value of the last function that was executed.
  4277. * If it is the first function in the callback chain it will be the event data.
  4278. */
  4279. lastReturnValue?: any;
  4280. }
  4281. /**
  4282. * Represent an Observer registered to a given Observable object.
  4283. */
  4284. export class Observer<T> {
  4285. /**
  4286. * Defines the callback to call when the observer is notified
  4287. */
  4288. callback: (eventData: T, eventState: EventState) => void;
  4289. /**
  4290. * Defines the mask of the observer (used to filter notifications)
  4291. */
  4292. mask: number;
  4293. /**
  4294. * Defines the current scope used to restore the JS context
  4295. */
  4296. scope: any;
  4297. /** @hidden */
  4298. _willBeUnregistered: boolean;
  4299. /**
  4300. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4301. */
  4302. unregisterOnNextCall: boolean;
  4303. /**
  4304. * Creates a new observer
  4305. * @param callback defines the callback to call when the observer is notified
  4306. * @param mask defines the mask of the observer (used to filter notifications)
  4307. * @param scope defines the current scope used to restore the JS context
  4308. */
  4309. constructor(
  4310. /**
  4311. * Defines the callback to call when the observer is notified
  4312. */
  4313. callback: (eventData: T, eventState: EventState) => void,
  4314. /**
  4315. * Defines the mask of the observer (used to filter notifications)
  4316. */
  4317. mask: number,
  4318. /**
  4319. * Defines the current scope used to restore the JS context
  4320. */
  4321. scope?: any);
  4322. }
  4323. /**
  4324. * Represent a list of observers registered to multiple Observables object.
  4325. */
  4326. export class MultiObserver<T> {
  4327. private _observers;
  4328. private _observables;
  4329. /**
  4330. * Release associated resources
  4331. */
  4332. dispose(): void;
  4333. /**
  4334. * Raise a callback when one of the observable will notify
  4335. * @param observables defines a list of observables to watch
  4336. * @param callback defines the callback to call on notification
  4337. * @param mask defines the mask used to filter notifications
  4338. * @param scope defines the current scope used to restore the JS context
  4339. * @returns the new MultiObserver
  4340. */
  4341. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4342. }
  4343. /**
  4344. * The Observable class is a simple implementation of the Observable pattern.
  4345. *
  4346. * 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.
  4347. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4348. * 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).
  4349. * 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.
  4350. */
  4351. export class Observable<T> {
  4352. private _observers;
  4353. private _eventState;
  4354. private _onObserverAdded;
  4355. /**
  4356. * Creates a new observable
  4357. * @param onObserverAdded defines a callback to call when a new observer is added
  4358. */
  4359. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4360. /**
  4361. * Create a new Observer with the specified callback
  4362. * @param callback the callback that will be executed for that Observer
  4363. * @param mask the mask used to filter observers
  4364. * @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.
  4365. * @param scope optional scope for the callback to be called from
  4366. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4367. * @returns the new observer created for the callback
  4368. */
  4369. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4370. /**
  4371. * Create a new Observer with the specified callback and unregisters after the next notification
  4372. * @param callback the callback that will be executed for that Observer
  4373. * @returns the new observer created for the callback
  4374. */
  4375. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4376. /**
  4377. * Remove an Observer from the Observable object
  4378. * @param observer the instance of the Observer to remove
  4379. * @returns false if it doesn't belong to this Observable
  4380. */
  4381. remove(observer: Nullable<Observer<T>>): boolean;
  4382. /**
  4383. * Remove a callback from the Observable object
  4384. * @param callback the callback to remove
  4385. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4386. * @returns false if it doesn't belong to this Observable
  4387. */
  4388. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4389. private _deferUnregister;
  4390. private _remove;
  4391. /**
  4392. * Moves the observable to the top of the observer list making it get called first when notified
  4393. * @param observer the observer to move
  4394. */
  4395. makeObserverTopPriority(observer: Observer<T>): void;
  4396. /**
  4397. * Moves the observable to the bottom of the observer list making it get called last when notified
  4398. * @param observer the observer to move
  4399. */
  4400. makeObserverBottomPriority(observer: Observer<T>): void;
  4401. /**
  4402. * Notify all Observers by calling their respective callback with the given data
  4403. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4404. * @param eventData defines the data to send to all observers
  4405. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4406. * @param target defines the original target of the state
  4407. * @param currentTarget defines the current target of the state
  4408. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4409. */
  4410. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4411. /**
  4412. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4413. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4414. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4415. * and it is crucial that all callbacks will be executed.
  4416. * The order of the callbacks is kept, callbacks are not executed parallel.
  4417. *
  4418. * @param eventData The data to be sent to each callback
  4419. * @param mask is used to filter observers defaults to -1
  4420. * @param target defines the callback target (see EventState)
  4421. * @param currentTarget defines he current object in the bubbling phase
  4422. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4423. */
  4424. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4425. /**
  4426. * Notify a specific observer
  4427. * @param observer defines the observer to notify
  4428. * @param eventData defines the data to be sent to each callback
  4429. * @param mask is used to filter observers defaults to -1
  4430. */
  4431. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4432. /**
  4433. * Gets a boolean indicating if the observable has at least one observer
  4434. * @returns true is the Observable has at least one Observer registered
  4435. */
  4436. hasObservers(): boolean;
  4437. /**
  4438. * Clear the list of observers
  4439. */
  4440. clear(): void;
  4441. /**
  4442. * Clone the current observable
  4443. * @returns a new observable
  4444. */
  4445. clone(): Observable<T>;
  4446. /**
  4447. * Does this observable handles observer registered with a given mask
  4448. * @param mask defines the mask to be tested
  4449. * @return whether or not one observer registered with the given mask is handeled
  4450. **/
  4451. hasSpecificMask(mask?: number): boolean;
  4452. }
  4453. }
  4454. declare module BABYLON {
  4455. /**
  4456. * Class used to help managing file picking and drag'n'drop
  4457. * File Storage
  4458. */
  4459. export class FilesInputStore {
  4460. /**
  4461. * List of files ready to be loaded
  4462. */
  4463. static FilesToLoad: {
  4464. [key: string]: File;
  4465. };
  4466. }
  4467. }
  4468. declare module BABYLON {
  4469. /** Defines the cross module used constants to avoid circular dependncies */
  4470. export class Constants {
  4471. /** Defines that alpha blending is disabled */
  4472. static readonly ALPHA_DISABLE: number;
  4473. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4474. static readonly ALPHA_ADD: number;
  4475. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4476. static readonly ALPHA_COMBINE: number;
  4477. /** Defines that alpha blending to DEST - SRC * DEST */
  4478. static readonly ALPHA_SUBTRACT: number;
  4479. /** Defines that alpha blending to SRC * DEST */
  4480. static readonly ALPHA_MULTIPLY: number;
  4481. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4482. static readonly ALPHA_MAXIMIZED: number;
  4483. /** Defines that alpha blending to SRC + DEST */
  4484. static readonly ALPHA_ONEONE: number;
  4485. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4486. static readonly ALPHA_PREMULTIPLIED: number;
  4487. /**
  4488. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4489. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4490. */
  4491. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4492. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4493. static readonly ALPHA_INTERPOLATE: number;
  4494. /**
  4495. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4496. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4497. */
  4498. static readonly ALPHA_SCREENMODE: number;
  4499. /** Defines that the ressource is not delayed*/
  4500. static readonly DELAYLOADSTATE_NONE: number;
  4501. /** Defines that the ressource was successfully delay loaded */
  4502. static readonly DELAYLOADSTATE_LOADED: number;
  4503. /** Defines that the ressource is currently delay loading */
  4504. static readonly DELAYLOADSTATE_LOADING: number;
  4505. /** Defines that the ressource is delayed and has not started loading */
  4506. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4507. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4508. static readonly NEVER: number;
  4509. /** 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 */
  4510. static readonly ALWAYS: number;
  4511. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4512. static readonly LESS: number;
  4513. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4514. static readonly EQUAL: number;
  4515. /** 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 */
  4516. static readonly LEQUAL: number;
  4517. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4518. static readonly GREATER: number;
  4519. /** 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 */
  4520. static readonly GEQUAL: number;
  4521. /** 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 */
  4522. static readonly NOTEQUAL: number;
  4523. /** Passed to stencilOperation to specify that stencil value must be kept */
  4524. static readonly KEEP: number;
  4525. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4526. static readonly REPLACE: number;
  4527. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4528. static readonly INCR: number;
  4529. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4530. static readonly DECR: number;
  4531. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4532. static readonly INVERT: number;
  4533. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4534. static readonly INCR_WRAP: number;
  4535. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4536. static readonly DECR_WRAP: number;
  4537. /** Texture is not repeating outside of 0..1 UVs */
  4538. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4539. /** Texture is repeating outside of 0..1 UVs */
  4540. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4541. /** Texture is repeating and mirrored */
  4542. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4543. /** ALPHA */
  4544. static readonly TEXTUREFORMAT_ALPHA: number;
  4545. /** LUMINANCE */
  4546. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4547. /** LUMINANCE_ALPHA */
  4548. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4549. /** RGB */
  4550. static readonly TEXTUREFORMAT_RGB: number;
  4551. /** RGBA */
  4552. static readonly TEXTUREFORMAT_RGBA: number;
  4553. /** RED */
  4554. static readonly TEXTUREFORMAT_RED: number;
  4555. /** RED (2nd reference) */
  4556. static readonly TEXTUREFORMAT_R: number;
  4557. /** RG */
  4558. static readonly TEXTUREFORMAT_RG: number;
  4559. /** RED_INTEGER */
  4560. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4561. /** RED_INTEGER (2nd reference) */
  4562. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4563. /** RG_INTEGER */
  4564. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4565. /** RGB_INTEGER */
  4566. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4567. /** RGBA_INTEGER */
  4568. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4569. /** UNSIGNED_BYTE */
  4570. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4571. /** UNSIGNED_BYTE (2nd reference) */
  4572. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4573. /** FLOAT */
  4574. static readonly TEXTURETYPE_FLOAT: number;
  4575. /** HALF_FLOAT */
  4576. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4577. /** BYTE */
  4578. static readonly TEXTURETYPE_BYTE: number;
  4579. /** SHORT */
  4580. static readonly TEXTURETYPE_SHORT: number;
  4581. /** UNSIGNED_SHORT */
  4582. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4583. /** INT */
  4584. static readonly TEXTURETYPE_INT: number;
  4585. /** UNSIGNED_INT */
  4586. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4587. /** UNSIGNED_SHORT_4_4_4_4 */
  4588. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4589. /** UNSIGNED_SHORT_5_5_5_1 */
  4590. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4591. /** UNSIGNED_SHORT_5_6_5 */
  4592. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4593. /** UNSIGNED_INT_2_10_10_10_REV */
  4594. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4595. /** UNSIGNED_INT_24_8 */
  4596. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4597. /** UNSIGNED_INT_10F_11F_11F_REV */
  4598. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4599. /** UNSIGNED_INT_5_9_9_9_REV */
  4600. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4601. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4602. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4603. /** nearest is mag = nearest and min = nearest and mip = linear */
  4604. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4605. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4606. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4607. /** Trilinear is mag = linear and min = linear and mip = linear */
  4608. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4609. /** nearest is mag = nearest and min = nearest and mip = linear */
  4610. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4611. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4612. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4613. /** Trilinear is mag = linear and min = linear and mip = linear */
  4614. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4615. /** mag = nearest and min = nearest and mip = nearest */
  4616. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4617. /** mag = nearest and min = linear and mip = nearest */
  4618. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4619. /** mag = nearest and min = linear and mip = linear */
  4620. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4621. /** mag = nearest and min = linear and mip = none */
  4622. static readonly TEXTURE_NEAREST_LINEAR: number;
  4623. /** mag = nearest and min = nearest and mip = none */
  4624. static readonly TEXTURE_NEAREST_NEAREST: number;
  4625. /** mag = linear and min = nearest and mip = nearest */
  4626. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4627. /** mag = linear and min = nearest and mip = linear */
  4628. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4629. /** mag = linear and min = linear and mip = none */
  4630. static readonly TEXTURE_LINEAR_LINEAR: number;
  4631. /** mag = linear and min = nearest and mip = none */
  4632. static readonly TEXTURE_LINEAR_NEAREST: number;
  4633. /** Explicit coordinates mode */
  4634. static readonly TEXTURE_EXPLICIT_MODE: number;
  4635. /** Spherical coordinates mode */
  4636. static readonly TEXTURE_SPHERICAL_MODE: number;
  4637. /** Planar coordinates mode */
  4638. static readonly TEXTURE_PLANAR_MODE: number;
  4639. /** Cubic coordinates mode */
  4640. static readonly TEXTURE_CUBIC_MODE: number;
  4641. /** Projection coordinates mode */
  4642. static readonly TEXTURE_PROJECTION_MODE: number;
  4643. /** Skybox coordinates mode */
  4644. static readonly TEXTURE_SKYBOX_MODE: number;
  4645. /** Inverse Cubic coordinates mode */
  4646. static readonly TEXTURE_INVCUBIC_MODE: number;
  4647. /** Equirectangular coordinates mode */
  4648. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4649. /** Equirectangular Fixed coordinates mode */
  4650. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4651. /** Equirectangular Fixed Mirrored coordinates mode */
  4652. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4653. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4654. static readonly SCALEMODE_FLOOR: number;
  4655. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4656. static readonly SCALEMODE_NEAREST: number;
  4657. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4658. static readonly SCALEMODE_CEILING: number;
  4659. /**
  4660. * The dirty texture flag value
  4661. */
  4662. static readonly MATERIAL_TextureDirtyFlag: number;
  4663. /**
  4664. * The dirty light flag value
  4665. */
  4666. static readonly MATERIAL_LightDirtyFlag: number;
  4667. /**
  4668. * The dirty fresnel flag value
  4669. */
  4670. static readonly MATERIAL_FresnelDirtyFlag: number;
  4671. /**
  4672. * The dirty attribute flag value
  4673. */
  4674. static readonly MATERIAL_AttributesDirtyFlag: number;
  4675. /**
  4676. * The dirty misc flag value
  4677. */
  4678. static readonly MATERIAL_MiscDirtyFlag: number;
  4679. /**
  4680. * The all dirty flag value
  4681. */
  4682. static readonly MATERIAL_AllDirtyFlag: number;
  4683. /**
  4684. * Returns the triangle fill mode
  4685. */
  4686. static readonly MATERIAL_TriangleFillMode: number;
  4687. /**
  4688. * Returns the wireframe mode
  4689. */
  4690. static readonly MATERIAL_WireFrameFillMode: number;
  4691. /**
  4692. * Returns the point fill mode
  4693. */
  4694. static readonly MATERIAL_PointFillMode: number;
  4695. /**
  4696. * Returns the point list draw mode
  4697. */
  4698. static readonly MATERIAL_PointListDrawMode: number;
  4699. /**
  4700. * Returns the line list draw mode
  4701. */
  4702. static readonly MATERIAL_LineListDrawMode: number;
  4703. /**
  4704. * Returns the line loop draw mode
  4705. */
  4706. static readonly MATERIAL_LineLoopDrawMode: number;
  4707. /**
  4708. * Returns the line strip draw mode
  4709. */
  4710. static readonly MATERIAL_LineStripDrawMode: number;
  4711. /**
  4712. * Returns the triangle strip draw mode
  4713. */
  4714. static readonly MATERIAL_TriangleStripDrawMode: number;
  4715. /**
  4716. * Returns the triangle fan draw mode
  4717. */
  4718. static readonly MATERIAL_TriangleFanDrawMode: number;
  4719. /**
  4720. * Stores the clock-wise side orientation
  4721. */
  4722. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4723. /**
  4724. * Stores the counter clock-wise side orientation
  4725. */
  4726. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4727. /**
  4728. * Nothing
  4729. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4730. */
  4731. static readonly ACTION_NothingTrigger: number;
  4732. /**
  4733. * On pick
  4734. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4735. */
  4736. static readonly ACTION_OnPickTrigger: number;
  4737. /**
  4738. * On left pick
  4739. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4740. */
  4741. static readonly ACTION_OnLeftPickTrigger: number;
  4742. /**
  4743. * On right pick
  4744. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4745. */
  4746. static readonly ACTION_OnRightPickTrigger: number;
  4747. /**
  4748. * On center pick
  4749. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4750. */
  4751. static readonly ACTION_OnCenterPickTrigger: number;
  4752. /**
  4753. * On pick down
  4754. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4755. */
  4756. static readonly ACTION_OnPickDownTrigger: number;
  4757. /**
  4758. * On double pick
  4759. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4760. */
  4761. static readonly ACTION_OnDoublePickTrigger: number;
  4762. /**
  4763. * On pick up
  4764. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4765. */
  4766. static readonly ACTION_OnPickUpTrigger: number;
  4767. /**
  4768. * On pick out.
  4769. * This trigger will only be raised if you also declared a OnPickDown
  4770. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4771. */
  4772. static readonly ACTION_OnPickOutTrigger: number;
  4773. /**
  4774. * On long press
  4775. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4776. */
  4777. static readonly ACTION_OnLongPressTrigger: number;
  4778. /**
  4779. * On pointer over
  4780. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4781. */
  4782. static readonly ACTION_OnPointerOverTrigger: number;
  4783. /**
  4784. * On pointer out
  4785. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4786. */
  4787. static readonly ACTION_OnPointerOutTrigger: number;
  4788. /**
  4789. * On every frame
  4790. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4791. */
  4792. static readonly ACTION_OnEveryFrameTrigger: number;
  4793. /**
  4794. * On intersection enter
  4795. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4796. */
  4797. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4798. /**
  4799. * On intersection exit
  4800. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4801. */
  4802. static readonly ACTION_OnIntersectionExitTrigger: number;
  4803. /**
  4804. * On key down
  4805. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4806. */
  4807. static readonly ACTION_OnKeyDownTrigger: number;
  4808. /**
  4809. * On key up
  4810. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4811. */
  4812. static readonly ACTION_OnKeyUpTrigger: number;
  4813. /**
  4814. * Billboard mode will only apply to Y axis
  4815. */
  4816. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4817. /**
  4818. * Billboard mode will apply to all axes
  4819. */
  4820. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4821. /**
  4822. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4823. */
  4824. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4825. /**
  4826. * Gets or sets base Assets URL
  4827. */
  4828. static readonly PARTICLES_BaseAssetsUrl: string;
  4829. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4830. * Test order :
  4831. * Is the bounding sphere outside the frustum ?
  4832. * If not, are the bounding box vertices outside the frustum ?
  4833. * It not, then the cullable object is in the frustum.
  4834. */
  4835. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4836. /** Culling strategy : Bounding Sphere Only.
  4837. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4838. * It's also less accurate than the standard because some not visible objects can still be selected.
  4839. * Test : is the bounding sphere outside the frustum ?
  4840. * If not, then the cullable object is in the frustum.
  4841. */
  4842. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4843. /** Culling strategy : Optimistic Inclusion.
  4844. * This in an inclusion test first, then the standard exclusion test.
  4845. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4846. * 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.
  4847. * Anyway, it's as accurate as the standard strategy.
  4848. * Test :
  4849. * Is the cullable object bounding sphere center in the frustum ?
  4850. * If not, apply the default culling strategy.
  4851. */
  4852. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4853. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4854. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4855. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4856. * 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.
  4857. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4858. * Test :
  4859. * Is the cullable object bounding sphere center in the frustum ?
  4860. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4861. */
  4862. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4863. /**
  4864. * No logging while loading
  4865. */
  4866. static readonly SCENELOADER_NO_LOGGING: number;
  4867. /**
  4868. * Minimal logging while loading
  4869. */
  4870. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4871. /**
  4872. * Summary logging while loading
  4873. */
  4874. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4875. /**
  4876. * Detailled logging while loading
  4877. */
  4878. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4879. }
  4880. }
  4881. declare module BABYLON {
  4882. /**
  4883. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4884. * Babylon.js
  4885. */
  4886. export class DomManagement {
  4887. /**
  4888. * Checks if the window object exists
  4889. * @returns true if the window object exists
  4890. */
  4891. static IsWindowObjectExist(): boolean;
  4892. /**
  4893. * Extracts text content from a DOM element hierarchy
  4894. * @param element defines the root element
  4895. * @returns a string
  4896. */
  4897. static GetDOMTextContent(element: HTMLElement): string;
  4898. }
  4899. }
  4900. declare module BABYLON {
  4901. /**
  4902. * Logger used througouht the application to allow configuration of
  4903. * the log level required for the messages.
  4904. */
  4905. export class Logger {
  4906. /**
  4907. * No log
  4908. */
  4909. static readonly NoneLogLevel: number;
  4910. /**
  4911. * Only message logs
  4912. */
  4913. static readonly MessageLogLevel: number;
  4914. /**
  4915. * Only warning logs
  4916. */
  4917. static readonly WarningLogLevel: number;
  4918. /**
  4919. * Only error logs
  4920. */
  4921. static readonly ErrorLogLevel: number;
  4922. /**
  4923. * All logs
  4924. */
  4925. static readonly AllLogLevel: number;
  4926. private static _LogCache;
  4927. /**
  4928. * Gets a value indicating the number of loading errors
  4929. * @ignorenaming
  4930. */
  4931. static errorsCount: number;
  4932. /**
  4933. * Callback called when a new log is added
  4934. */
  4935. static OnNewCacheEntry: (entry: string) => void;
  4936. private static _AddLogEntry;
  4937. private static _FormatMessage;
  4938. private static _LogDisabled;
  4939. private static _LogEnabled;
  4940. private static _WarnDisabled;
  4941. private static _WarnEnabled;
  4942. private static _ErrorDisabled;
  4943. private static _ErrorEnabled;
  4944. /**
  4945. * Log a message to the console
  4946. */
  4947. static Log: (message: string) => void;
  4948. /**
  4949. * Write a warning message to the console
  4950. */
  4951. static Warn: (message: string) => void;
  4952. /**
  4953. * Write an error message to the console
  4954. */
  4955. static Error: (message: string) => void;
  4956. /**
  4957. * Gets current log cache (list of logs)
  4958. */
  4959. static readonly LogCache: string;
  4960. /**
  4961. * Clears the log cache
  4962. */
  4963. static ClearLogCache(): void;
  4964. /**
  4965. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4966. */
  4967. static LogLevels: number;
  4968. }
  4969. }
  4970. declare module BABYLON {
  4971. /** @hidden */
  4972. export class _TypeStore {
  4973. /** @hidden */
  4974. static RegisteredTypes: {
  4975. [key: string]: Object;
  4976. };
  4977. /** @hidden */
  4978. static GetClass(fqdn: string): any;
  4979. }
  4980. }
  4981. declare module BABYLON {
  4982. /**
  4983. * Class containing a set of static utilities functions for deep copy.
  4984. */
  4985. export class DeepCopier {
  4986. /**
  4987. * Tries to copy an object by duplicating every property
  4988. * @param source defines the source object
  4989. * @param destination defines the target object
  4990. * @param doNotCopyList defines a list of properties to avoid
  4991. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4992. */
  4993. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4994. }
  4995. }
  4996. declare module BABYLON {
  4997. /**
  4998. * Class containing a set of static utilities functions for precision date
  4999. */
  5000. export class PrecisionDate {
  5001. /**
  5002. * Gets either window.performance.now() if supported or Date.now() else
  5003. */
  5004. static readonly Now: number;
  5005. }
  5006. }
  5007. declare module BABYLON {
  5008. /** @hidden */
  5009. export class _DevTools {
  5010. static WarnImport(name: string): string;
  5011. }
  5012. }
  5013. declare module BABYLON {
  5014. /**
  5015. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  5016. */
  5017. export class WebRequest {
  5018. private _xhr;
  5019. /**
  5020. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  5021. * i.e. when loading files, where the server/service expects an Authorization header
  5022. */
  5023. static CustomRequestHeaders: {
  5024. [key: string]: string;
  5025. };
  5026. /**
  5027. * Add callback functions in this array to update all the requests before they get sent to the network
  5028. */
  5029. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  5030. private _injectCustomRequestHeaders;
  5031. /**
  5032. * Gets or sets a function to be called when loading progress changes
  5033. */
  5034. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  5035. /**
  5036. * Returns client's state
  5037. */
  5038. readonly readyState: number;
  5039. /**
  5040. * Returns client's status
  5041. */
  5042. readonly status: number;
  5043. /**
  5044. * Returns client's status as a text
  5045. */
  5046. readonly statusText: string;
  5047. /**
  5048. * Returns client's response
  5049. */
  5050. readonly response: any;
  5051. /**
  5052. * Returns client's response url
  5053. */
  5054. readonly responseURL: string;
  5055. /**
  5056. * Returns client's response as text
  5057. */
  5058. readonly responseText: string;
  5059. /**
  5060. * Gets or sets the expected response type
  5061. */
  5062. responseType: XMLHttpRequestResponseType;
  5063. /** @hidden */
  5064. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5065. /** @hidden */
  5066. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5067. /**
  5068. * Cancels any network activity
  5069. */
  5070. abort(): void;
  5071. /**
  5072. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5073. * @param body defines an optional request body
  5074. */
  5075. send(body?: Document | BodyInit | null): void;
  5076. /**
  5077. * Sets the request method, request URL
  5078. * @param method defines the method to use (GET, POST, etc..)
  5079. * @param url defines the url to connect with
  5080. */
  5081. open(method: string, url: string): void;
  5082. }
  5083. }
  5084. declare module BABYLON {
  5085. /**
  5086. * Class used to evalaute queries containing `and` and `or` operators
  5087. */
  5088. export class AndOrNotEvaluator {
  5089. /**
  5090. * Evaluate a query
  5091. * @param query defines the query to evaluate
  5092. * @param evaluateCallback defines the callback used to filter result
  5093. * @returns true if the query matches
  5094. */
  5095. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5096. private static _HandleParenthesisContent;
  5097. private static _SimplifyNegation;
  5098. }
  5099. }
  5100. declare module BABYLON {
  5101. /**
  5102. * Class used to store custom tags
  5103. */
  5104. export class Tags {
  5105. /**
  5106. * Adds support for tags on the given object
  5107. * @param obj defines the object to use
  5108. */
  5109. static EnableFor(obj: any): void;
  5110. /**
  5111. * Removes tags support
  5112. * @param obj defines the object to use
  5113. */
  5114. static DisableFor(obj: any): void;
  5115. /**
  5116. * Gets a boolean indicating if the given object has tags
  5117. * @param obj defines the object to use
  5118. * @returns a boolean
  5119. */
  5120. static HasTags(obj: any): boolean;
  5121. /**
  5122. * Gets the tags available on a given object
  5123. * @param obj defines the object to use
  5124. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5125. * @returns the tags
  5126. */
  5127. static GetTags(obj: any, asString?: boolean): any;
  5128. /**
  5129. * Adds tags to an object
  5130. * @param obj defines the object to use
  5131. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5132. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5133. */
  5134. static AddTagsTo(obj: any, tagsString: string): void;
  5135. /**
  5136. * @hidden
  5137. */
  5138. static _AddTagTo(obj: any, tag: string): void;
  5139. /**
  5140. * Removes specific tags from a specific object
  5141. * @param obj defines the object to use
  5142. * @param tagsString defines the tags to remove
  5143. */
  5144. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5145. /**
  5146. * @hidden
  5147. */
  5148. static _RemoveTagFrom(obj: any, tag: string): void;
  5149. /**
  5150. * Defines if tags hosted on an object match a given query
  5151. * @param obj defines the object to use
  5152. * @param tagsQuery defines the tag query
  5153. * @returns a boolean
  5154. */
  5155. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5156. }
  5157. }
  5158. declare module BABYLON {
  5159. /**
  5160. * Manages the defines for the Material
  5161. */
  5162. export class MaterialDefines {
  5163. /** @hidden */
  5164. protected _keys: string[];
  5165. private _isDirty;
  5166. /** @hidden */
  5167. _renderId: number;
  5168. /** @hidden */
  5169. _areLightsDirty: boolean;
  5170. /** @hidden */
  5171. _areAttributesDirty: boolean;
  5172. /** @hidden */
  5173. _areTexturesDirty: boolean;
  5174. /** @hidden */
  5175. _areFresnelDirty: boolean;
  5176. /** @hidden */
  5177. _areMiscDirty: boolean;
  5178. /** @hidden */
  5179. _areImageProcessingDirty: boolean;
  5180. /** @hidden */
  5181. _normals: boolean;
  5182. /** @hidden */
  5183. _uvs: boolean;
  5184. /** @hidden */
  5185. _needNormals: boolean;
  5186. /** @hidden */
  5187. _needUVs: boolean;
  5188. [id: string]: any;
  5189. /**
  5190. * Specifies if the material needs to be re-calculated
  5191. */
  5192. readonly isDirty: boolean;
  5193. /**
  5194. * Marks the material to indicate that it has been re-calculated
  5195. */
  5196. markAsProcessed(): void;
  5197. /**
  5198. * Marks the material to indicate that it needs to be re-calculated
  5199. */
  5200. markAsUnprocessed(): void;
  5201. /**
  5202. * Marks the material to indicate all of its defines need to be re-calculated
  5203. */
  5204. markAllAsDirty(): void;
  5205. /**
  5206. * Marks the material to indicate that image processing needs to be re-calculated
  5207. */
  5208. markAsImageProcessingDirty(): void;
  5209. /**
  5210. * Marks the material to indicate the lights need to be re-calculated
  5211. */
  5212. markAsLightDirty(): void;
  5213. /**
  5214. * Marks the attribute state as changed
  5215. */
  5216. markAsAttributesDirty(): void;
  5217. /**
  5218. * Marks the texture state as changed
  5219. */
  5220. markAsTexturesDirty(): void;
  5221. /**
  5222. * Marks the fresnel state as changed
  5223. */
  5224. markAsFresnelDirty(): void;
  5225. /**
  5226. * Marks the misc state as changed
  5227. */
  5228. markAsMiscDirty(): void;
  5229. /**
  5230. * Rebuilds the material defines
  5231. */
  5232. rebuild(): void;
  5233. /**
  5234. * Specifies if two material defines are equal
  5235. * @param other - A material define instance to compare to
  5236. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5237. */
  5238. isEqual(other: MaterialDefines): boolean;
  5239. /**
  5240. * Clones this instance's defines to another instance
  5241. * @param other - material defines to clone values to
  5242. */
  5243. cloneTo(other: MaterialDefines): void;
  5244. /**
  5245. * Resets the material define values
  5246. */
  5247. reset(): void;
  5248. /**
  5249. * Converts the material define values to a string
  5250. * @returns - String of material define information
  5251. */
  5252. toString(): string;
  5253. }
  5254. }
  5255. declare module BABYLON {
  5256. /**
  5257. * Class used to store and describe the pipeline context associated with an effect
  5258. */
  5259. export interface IPipelineContext {
  5260. /**
  5261. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  5262. */
  5263. isAsync: boolean;
  5264. /**
  5265. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  5266. */
  5267. isReady: boolean;
  5268. /** @hidden */
  5269. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  5270. }
  5271. }
  5272. declare module BABYLON {
  5273. /**
  5274. * Class used to store gfx data (like WebGLBuffer)
  5275. */
  5276. export class DataBuffer {
  5277. /**
  5278. * Gets or sets the number of objects referencing this buffer
  5279. */
  5280. references: number;
  5281. /** Gets or sets the size of the underlying buffer */
  5282. capacity: number;
  5283. /**
  5284. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  5285. */
  5286. is32Bits: boolean;
  5287. /**
  5288. * Gets the underlying buffer
  5289. */
  5290. readonly underlyingResource: any;
  5291. }
  5292. }
  5293. declare module BABYLON {
  5294. /**
  5295. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5296. */
  5297. export class PerformanceMonitor {
  5298. private _enabled;
  5299. private _rollingFrameTime;
  5300. private _lastFrameTimeMs;
  5301. /**
  5302. * constructor
  5303. * @param frameSampleSize The number of samples required to saturate the sliding window
  5304. */
  5305. constructor(frameSampleSize?: number);
  5306. /**
  5307. * Samples current frame
  5308. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5309. */
  5310. sampleFrame(timeMs?: number): void;
  5311. /**
  5312. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5313. */
  5314. readonly averageFrameTime: number;
  5315. /**
  5316. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5317. */
  5318. readonly averageFrameTimeVariance: number;
  5319. /**
  5320. * Returns the frame time of the most recent frame
  5321. */
  5322. readonly instantaneousFrameTime: number;
  5323. /**
  5324. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5325. */
  5326. readonly averageFPS: number;
  5327. /**
  5328. * Returns the average framerate in frames per second using the most recent frame time
  5329. */
  5330. readonly instantaneousFPS: number;
  5331. /**
  5332. * Returns true if enough samples have been taken to completely fill the sliding window
  5333. */
  5334. readonly isSaturated: boolean;
  5335. /**
  5336. * Enables contributions to the sliding window sample set
  5337. */
  5338. enable(): void;
  5339. /**
  5340. * Disables contributions to the sliding window sample set
  5341. * Samples will not be interpolated over the disabled period
  5342. */
  5343. disable(): void;
  5344. /**
  5345. * Returns true if sampling is enabled
  5346. */
  5347. readonly isEnabled: boolean;
  5348. /**
  5349. * Resets performance monitor
  5350. */
  5351. reset(): void;
  5352. }
  5353. /**
  5354. * RollingAverage
  5355. *
  5356. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5357. */
  5358. export class RollingAverage {
  5359. /**
  5360. * Current average
  5361. */
  5362. average: number;
  5363. /**
  5364. * Current variance
  5365. */
  5366. variance: number;
  5367. protected _samples: Array<number>;
  5368. protected _sampleCount: number;
  5369. protected _pos: number;
  5370. protected _m2: number;
  5371. /**
  5372. * constructor
  5373. * @param length The number of samples required to saturate the sliding window
  5374. */
  5375. constructor(length: number);
  5376. /**
  5377. * Adds a sample to the sample set
  5378. * @param v The sample value
  5379. */
  5380. add(v: number): void;
  5381. /**
  5382. * Returns previously added values or null if outside of history or outside the sliding window domain
  5383. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5384. * @return Value previously recorded with add() or null if outside of range
  5385. */
  5386. history(i: number): number;
  5387. /**
  5388. * Returns true if enough samples have been taken to completely fill the sliding window
  5389. * @return true if sample-set saturated
  5390. */
  5391. isSaturated(): boolean;
  5392. /**
  5393. * Resets the rolling average (equivalent to 0 samples taken so far)
  5394. */
  5395. reset(): void;
  5396. /**
  5397. * Wraps a value around the sample range boundaries
  5398. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5399. * @return Wrapped position in sample range
  5400. */
  5401. protected _wrapPosition(i: number): number;
  5402. }
  5403. }
  5404. declare module BABYLON {
  5405. /**
  5406. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5407. * The underlying implementation relies on an associative array to ensure the best performances.
  5408. * The value can be anything including 'null' but except 'undefined'
  5409. */
  5410. export class StringDictionary<T> {
  5411. /**
  5412. * This will clear this dictionary and copy the content from the 'source' one.
  5413. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5414. * @param source the dictionary to take the content from and copy to this dictionary
  5415. */
  5416. copyFrom(source: StringDictionary<T>): void;
  5417. /**
  5418. * Get a value based from its key
  5419. * @param key the given key to get the matching value from
  5420. * @return the value if found, otherwise undefined is returned
  5421. */
  5422. get(key: string): T | undefined;
  5423. /**
  5424. * Get a value from its key or add it if it doesn't exist.
  5425. * This method will ensure you that a given key/data will be present in the dictionary.
  5426. * @param key the given key to get the matching value from
  5427. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5428. * The factory will only be invoked if there's no data for the given key.
  5429. * @return the value corresponding to the key.
  5430. */
  5431. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5432. /**
  5433. * Get a value from its key if present in the dictionary otherwise add it
  5434. * @param key the key to get the value from
  5435. * @param val if there's no such key/value pair in the dictionary add it with this value
  5436. * @return the value corresponding to the key
  5437. */
  5438. getOrAdd(key: string, val: T): T;
  5439. /**
  5440. * Check if there's a given key in the dictionary
  5441. * @param key the key to check for
  5442. * @return true if the key is present, false otherwise
  5443. */
  5444. contains(key: string): boolean;
  5445. /**
  5446. * Add a new key and its corresponding value
  5447. * @param key the key to add
  5448. * @param value the value corresponding to the key
  5449. * @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
  5450. */
  5451. add(key: string, value: T): boolean;
  5452. /**
  5453. * Update a specific value associated to a key
  5454. * @param key defines the key to use
  5455. * @param value defines the value to store
  5456. * @returns true if the value was updated (or false if the key was not found)
  5457. */
  5458. set(key: string, value: T): boolean;
  5459. /**
  5460. * Get the element of the given key and remove it from the dictionary
  5461. * @param key defines the key to search
  5462. * @returns the value associated with the key or null if not found
  5463. */
  5464. getAndRemove(key: string): Nullable<T>;
  5465. /**
  5466. * Remove a key/value from the dictionary.
  5467. * @param key the key to remove
  5468. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5469. */
  5470. remove(key: string): boolean;
  5471. /**
  5472. * Clear the whole content of the dictionary
  5473. */
  5474. clear(): void;
  5475. /**
  5476. * Gets the current count
  5477. */
  5478. readonly count: number;
  5479. /**
  5480. * Execute a callback on each key/val of the dictionary.
  5481. * Note that you can remove any element in this dictionary in the callback implementation
  5482. * @param callback the callback to execute on a given key/value pair
  5483. */
  5484. forEach(callback: (key: string, val: T) => void): void;
  5485. /**
  5486. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5487. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5488. * Note that you can remove any element in this dictionary in the callback implementation
  5489. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5490. * @returns the first item
  5491. */
  5492. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5493. private _count;
  5494. private _data;
  5495. }
  5496. }
  5497. declare module BABYLON {
  5498. /**
  5499. * Helper class that provides a small promise polyfill
  5500. */
  5501. export class PromisePolyfill {
  5502. /**
  5503. * Static function used to check if the polyfill is required
  5504. * If this is the case then the function will inject the polyfill to window.Promise
  5505. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5506. */
  5507. static Apply(force?: boolean): void;
  5508. }
  5509. }
  5510. declare module BABYLON {
  5511. /**
  5512. * Class used to store data that will be store in GPU memory
  5513. */
  5514. export class Buffer {
  5515. private _engine;
  5516. private _buffer;
  5517. /** @hidden */
  5518. _data: Nullable<DataArray>;
  5519. private _updatable;
  5520. private _instanced;
  5521. /**
  5522. * Gets the byte stride.
  5523. */
  5524. readonly byteStride: number;
  5525. /**
  5526. * Constructor
  5527. * @param engine the engine
  5528. * @param data the data to use for this buffer
  5529. * @param updatable whether the data is updatable
  5530. * @param stride the stride (optional)
  5531. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5532. * @param instanced whether the buffer is instanced (optional)
  5533. * @param useBytes set to true if the stride in in bytes (optional)
  5534. */
  5535. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5536. /**
  5537. * Create a new VertexBuffer based on the current buffer
  5538. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5539. * @param offset defines offset in the buffer (0 by default)
  5540. * @param size defines the size in floats of attributes (position is 3 for instance)
  5541. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5542. * @param instanced defines if the vertex buffer contains indexed data
  5543. * @param useBytes defines if the offset and stride are in bytes
  5544. * @returns the new vertex buffer
  5545. */
  5546. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5547. /**
  5548. * Gets a boolean indicating if the Buffer is updatable?
  5549. * @returns true if the buffer is updatable
  5550. */
  5551. isUpdatable(): boolean;
  5552. /**
  5553. * Gets current buffer's data
  5554. * @returns a DataArray or null
  5555. */
  5556. getData(): Nullable<DataArray>;
  5557. /**
  5558. * Gets underlying native buffer
  5559. * @returns underlying native buffer
  5560. */
  5561. getBuffer(): Nullable<DataBuffer>;
  5562. /**
  5563. * Gets the stride in float32 units (i.e. byte stride / 4).
  5564. * May not be an integer if the byte stride is not divisible by 4.
  5565. * DEPRECATED. Use byteStride instead.
  5566. * @returns the stride in float32 units
  5567. */
  5568. getStrideSize(): number;
  5569. /**
  5570. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5571. * @param data defines the data to store
  5572. */
  5573. create(data?: Nullable<DataArray>): void;
  5574. /** @hidden */
  5575. _rebuild(): void;
  5576. /**
  5577. * Update current buffer data
  5578. * @param data defines the data to store
  5579. */
  5580. update(data: DataArray): void;
  5581. /**
  5582. * Updates the data directly.
  5583. * @param data the new data
  5584. * @param offset the new offset
  5585. * @param vertexCount the vertex count (optional)
  5586. * @param useBytes set to true if the offset is in bytes
  5587. */
  5588. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5589. /**
  5590. * Release all resources
  5591. */
  5592. dispose(): void;
  5593. }
  5594. /**
  5595. * Specialized buffer used to store vertex data
  5596. */
  5597. export class VertexBuffer {
  5598. /** @hidden */
  5599. _buffer: Buffer;
  5600. private _kind;
  5601. private _size;
  5602. private _ownsBuffer;
  5603. private _instanced;
  5604. private _instanceDivisor;
  5605. /**
  5606. * The byte type.
  5607. */
  5608. static readonly BYTE: number;
  5609. /**
  5610. * The unsigned byte type.
  5611. */
  5612. static readonly UNSIGNED_BYTE: number;
  5613. /**
  5614. * The short type.
  5615. */
  5616. static readonly SHORT: number;
  5617. /**
  5618. * The unsigned short type.
  5619. */
  5620. static readonly UNSIGNED_SHORT: number;
  5621. /**
  5622. * The integer type.
  5623. */
  5624. static readonly INT: number;
  5625. /**
  5626. * The unsigned integer type.
  5627. */
  5628. static readonly UNSIGNED_INT: number;
  5629. /**
  5630. * The float type.
  5631. */
  5632. static readonly FLOAT: number;
  5633. /**
  5634. * Gets or sets the instance divisor when in instanced mode
  5635. */
  5636. instanceDivisor: number;
  5637. /**
  5638. * Gets the byte stride.
  5639. */
  5640. readonly byteStride: number;
  5641. /**
  5642. * Gets the byte offset.
  5643. */
  5644. readonly byteOffset: number;
  5645. /**
  5646. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5647. */
  5648. readonly normalized: boolean;
  5649. /**
  5650. * Gets the data type of each component in the array.
  5651. */
  5652. readonly type: number;
  5653. /**
  5654. * Constructor
  5655. * @param engine the engine
  5656. * @param data the data to use for this vertex buffer
  5657. * @param kind the vertex buffer kind
  5658. * @param updatable whether the data is updatable
  5659. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5660. * @param stride the stride (optional)
  5661. * @param instanced whether the buffer is instanced (optional)
  5662. * @param offset the offset of the data (optional)
  5663. * @param size the number of components (optional)
  5664. * @param type the type of the component (optional)
  5665. * @param normalized whether the data contains normalized data (optional)
  5666. * @param useBytes set to true if stride and offset are in bytes (optional)
  5667. */
  5668. 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);
  5669. /** @hidden */
  5670. _rebuild(): void;
  5671. /**
  5672. * Returns the kind of the VertexBuffer (string)
  5673. * @returns a string
  5674. */
  5675. getKind(): string;
  5676. /**
  5677. * Gets a boolean indicating if the VertexBuffer is updatable?
  5678. * @returns true if the buffer is updatable
  5679. */
  5680. isUpdatable(): boolean;
  5681. /**
  5682. * Gets current buffer's data
  5683. * @returns a DataArray or null
  5684. */
  5685. getData(): Nullable<DataArray>;
  5686. /**
  5687. * Gets underlying native buffer
  5688. * @returns underlying native buffer
  5689. */
  5690. getBuffer(): Nullable<DataBuffer>;
  5691. /**
  5692. * Gets the stride in float32 units (i.e. byte stride / 4).
  5693. * May not be an integer if the byte stride is not divisible by 4.
  5694. * DEPRECATED. Use byteStride instead.
  5695. * @returns the stride in float32 units
  5696. */
  5697. getStrideSize(): number;
  5698. /**
  5699. * Returns the offset as a multiple of the type byte length.
  5700. * DEPRECATED. Use byteOffset instead.
  5701. * @returns the offset in bytes
  5702. */
  5703. getOffset(): number;
  5704. /**
  5705. * Returns the number of components per vertex attribute (integer)
  5706. * @returns the size in float
  5707. */
  5708. getSize(): number;
  5709. /**
  5710. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5711. * @returns true if this buffer is instanced
  5712. */
  5713. getIsInstanced(): boolean;
  5714. /**
  5715. * Returns the instancing divisor, zero for non-instanced (integer).
  5716. * @returns a number
  5717. */
  5718. getInstanceDivisor(): number;
  5719. /**
  5720. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5721. * @param data defines the data to store
  5722. */
  5723. create(data?: DataArray): void;
  5724. /**
  5725. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5726. * This function will create a new buffer if the current one is not updatable
  5727. * @param data defines the data to store
  5728. */
  5729. update(data: DataArray): void;
  5730. /**
  5731. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5732. * Returns the directly updated WebGLBuffer.
  5733. * @param data the new data
  5734. * @param offset the new offset
  5735. * @param useBytes set to true if the offset is in bytes
  5736. */
  5737. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5738. /**
  5739. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5740. */
  5741. dispose(): void;
  5742. /**
  5743. * Enumerates each value of this vertex buffer as numbers.
  5744. * @param count the number of values to enumerate
  5745. * @param callback the callback function called for each value
  5746. */
  5747. forEach(count: number, callback: (value: number, index: number) => void): void;
  5748. /**
  5749. * Positions
  5750. */
  5751. static readonly PositionKind: string;
  5752. /**
  5753. * Normals
  5754. */
  5755. static readonly NormalKind: string;
  5756. /**
  5757. * Tangents
  5758. */
  5759. static readonly TangentKind: string;
  5760. /**
  5761. * Texture coordinates
  5762. */
  5763. static readonly UVKind: string;
  5764. /**
  5765. * Texture coordinates 2
  5766. */
  5767. static readonly UV2Kind: string;
  5768. /**
  5769. * Texture coordinates 3
  5770. */
  5771. static readonly UV3Kind: string;
  5772. /**
  5773. * Texture coordinates 4
  5774. */
  5775. static readonly UV4Kind: string;
  5776. /**
  5777. * Texture coordinates 5
  5778. */
  5779. static readonly UV5Kind: string;
  5780. /**
  5781. * Texture coordinates 6
  5782. */
  5783. static readonly UV6Kind: string;
  5784. /**
  5785. * Colors
  5786. */
  5787. static readonly ColorKind: string;
  5788. /**
  5789. * Matrix indices (for bones)
  5790. */
  5791. static readonly MatricesIndicesKind: string;
  5792. /**
  5793. * Matrix weights (for bones)
  5794. */
  5795. static readonly MatricesWeightsKind: string;
  5796. /**
  5797. * Additional matrix indices (for bones)
  5798. */
  5799. static readonly MatricesIndicesExtraKind: string;
  5800. /**
  5801. * Additional matrix weights (for bones)
  5802. */
  5803. static readonly MatricesWeightsExtraKind: string;
  5804. /**
  5805. * Deduces the stride given a kind.
  5806. * @param kind The kind string to deduce
  5807. * @returns The deduced stride
  5808. */
  5809. static DeduceStride(kind: string): number;
  5810. /**
  5811. * Gets the byte length of the given type.
  5812. * @param type the type
  5813. * @returns the number of bytes
  5814. */
  5815. static GetTypeByteLength(type: number): number;
  5816. /**
  5817. * Enumerates each value of the given parameters as numbers.
  5818. * @param data the data to enumerate
  5819. * @param byteOffset the byte offset of the data
  5820. * @param byteStride the byte stride of the data
  5821. * @param componentCount the number of components per element
  5822. * @param componentType the type of the component
  5823. * @param count the total number of components
  5824. * @param normalized whether the data is normalized
  5825. * @param callback the callback function called for each value
  5826. */
  5827. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5828. private static _GetFloatValue;
  5829. }
  5830. }
  5831. declare module BABYLON {
  5832. /**
  5833. * Class representing spherical harmonics coefficients to the 3rd degree
  5834. */
  5835. export class SphericalHarmonics {
  5836. /**
  5837. * Defines whether or not the harmonics have been prescaled for rendering.
  5838. */
  5839. preScaled: boolean;
  5840. /**
  5841. * The l0,0 coefficients of the spherical harmonics
  5842. */
  5843. l00: Vector3;
  5844. /**
  5845. * The l1,-1 coefficients of the spherical harmonics
  5846. */
  5847. l1_1: Vector3;
  5848. /**
  5849. * The l1,0 coefficients of the spherical harmonics
  5850. */
  5851. l10: Vector3;
  5852. /**
  5853. * The l1,1 coefficients of the spherical harmonics
  5854. */
  5855. l11: Vector3;
  5856. /**
  5857. * The l2,-2 coefficients of the spherical harmonics
  5858. */
  5859. l2_2: Vector3;
  5860. /**
  5861. * The l2,-1 coefficients of the spherical harmonics
  5862. */
  5863. l2_1: Vector3;
  5864. /**
  5865. * The l2,0 coefficients of the spherical harmonics
  5866. */
  5867. l20: Vector3;
  5868. /**
  5869. * The l2,1 coefficients of the spherical harmonics
  5870. */
  5871. l21: Vector3;
  5872. /**
  5873. * The l2,2 coefficients of the spherical harmonics
  5874. */
  5875. l22: Vector3;
  5876. /**
  5877. * Adds a light to the spherical harmonics
  5878. * @param direction the direction of the light
  5879. * @param color the color of the light
  5880. * @param deltaSolidAngle the delta solid angle of the light
  5881. */
  5882. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5883. /**
  5884. * Scales the spherical harmonics by the given amount
  5885. * @param scale the amount to scale
  5886. */
  5887. scaleInPlace(scale: number): void;
  5888. /**
  5889. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5890. *
  5891. * ```
  5892. * E_lm = A_l * L_lm
  5893. * ```
  5894. *
  5895. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5896. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5897. * the scaling factors are given in equation 9.
  5898. */
  5899. convertIncidentRadianceToIrradiance(): void;
  5900. /**
  5901. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5902. *
  5903. * ```
  5904. * L = (1/pi) * E * rho
  5905. * ```
  5906. *
  5907. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5908. */
  5909. convertIrradianceToLambertianRadiance(): void;
  5910. /**
  5911. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5912. * required operations at run time.
  5913. *
  5914. * This is simply done by scaling back the SH with Ylm constants parameter.
  5915. * The trigonometric part being applied by the shader at run time.
  5916. */
  5917. preScaleForRendering(): void;
  5918. /**
  5919. * Constructs a spherical harmonics from an array.
  5920. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5921. * @returns the spherical harmonics
  5922. */
  5923. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5924. /**
  5925. * Gets the spherical harmonics from polynomial
  5926. * @param polynomial the spherical polynomial
  5927. * @returns the spherical harmonics
  5928. */
  5929. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5930. }
  5931. /**
  5932. * Class representing spherical polynomial coefficients to the 3rd degree
  5933. */
  5934. export class SphericalPolynomial {
  5935. private _harmonics;
  5936. /**
  5937. * The spherical harmonics used to create the polynomials.
  5938. */
  5939. readonly preScaledHarmonics: SphericalHarmonics;
  5940. /**
  5941. * The x coefficients of the spherical polynomial
  5942. */
  5943. x: Vector3;
  5944. /**
  5945. * The y coefficients of the spherical polynomial
  5946. */
  5947. y: Vector3;
  5948. /**
  5949. * The z coefficients of the spherical polynomial
  5950. */
  5951. z: Vector3;
  5952. /**
  5953. * The xx coefficients of the spherical polynomial
  5954. */
  5955. xx: Vector3;
  5956. /**
  5957. * The yy coefficients of the spherical polynomial
  5958. */
  5959. yy: Vector3;
  5960. /**
  5961. * The zz coefficients of the spherical polynomial
  5962. */
  5963. zz: Vector3;
  5964. /**
  5965. * The xy coefficients of the spherical polynomial
  5966. */
  5967. xy: Vector3;
  5968. /**
  5969. * The yz coefficients of the spherical polynomial
  5970. */
  5971. yz: Vector3;
  5972. /**
  5973. * The zx coefficients of the spherical polynomial
  5974. */
  5975. zx: Vector3;
  5976. /**
  5977. * Adds an ambient color to the spherical polynomial
  5978. * @param color the color to add
  5979. */
  5980. addAmbient(color: Color3): void;
  5981. /**
  5982. * Scales the spherical polynomial by the given amount
  5983. * @param scale the amount to scale
  5984. */
  5985. scaleInPlace(scale: number): void;
  5986. /**
  5987. * Gets the spherical polynomial from harmonics
  5988. * @param harmonics the spherical harmonics
  5989. * @returns the spherical polynomial
  5990. */
  5991. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5992. /**
  5993. * Constructs a spherical polynomial from an array.
  5994. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5995. * @returns the spherical polynomial
  5996. */
  5997. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5998. }
  5999. }
  6000. declare module BABYLON {
  6001. /**
  6002. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  6003. */
  6004. export interface CubeMapInfo {
  6005. /**
  6006. * The pixel array for the front face.
  6007. * This is stored in format, left to right, up to down format.
  6008. */
  6009. front: Nullable<ArrayBufferView>;
  6010. /**
  6011. * The pixel array for the back face.
  6012. * This is stored in format, left to right, up to down format.
  6013. */
  6014. back: Nullable<ArrayBufferView>;
  6015. /**
  6016. * The pixel array for the left face.
  6017. * This is stored in format, left to right, up to down format.
  6018. */
  6019. left: Nullable<ArrayBufferView>;
  6020. /**
  6021. * The pixel array for the right face.
  6022. * This is stored in format, left to right, up to down format.
  6023. */
  6024. right: Nullable<ArrayBufferView>;
  6025. /**
  6026. * The pixel array for the up face.
  6027. * This is stored in format, left to right, up to down format.
  6028. */
  6029. up: Nullable<ArrayBufferView>;
  6030. /**
  6031. * The pixel array for the down face.
  6032. * This is stored in format, left to right, up to down format.
  6033. */
  6034. down: Nullable<ArrayBufferView>;
  6035. /**
  6036. * The size of the cubemap stored.
  6037. *
  6038. * Each faces will be size * size pixels.
  6039. */
  6040. size: number;
  6041. /**
  6042. * The format of the texture.
  6043. *
  6044. * RGBA, RGB.
  6045. */
  6046. format: number;
  6047. /**
  6048. * The type of the texture data.
  6049. *
  6050. * UNSIGNED_INT, FLOAT.
  6051. */
  6052. type: number;
  6053. /**
  6054. * Specifies whether the texture is in gamma space.
  6055. */
  6056. gammaSpace: boolean;
  6057. }
  6058. /**
  6059. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  6060. */
  6061. export class PanoramaToCubeMapTools {
  6062. private static FACE_FRONT;
  6063. private static FACE_BACK;
  6064. private static FACE_RIGHT;
  6065. private static FACE_LEFT;
  6066. private static FACE_DOWN;
  6067. private static FACE_UP;
  6068. /**
  6069. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  6070. *
  6071. * @param float32Array The source data.
  6072. * @param inputWidth The width of the input panorama.
  6073. * @param inputHeight The height of the input panorama.
  6074. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  6075. * @return The cubemap data
  6076. */
  6077. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  6078. private static CreateCubemapTexture;
  6079. private static CalcProjectionSpherical;
  6080. }
  6081. }
  6082. declare module BABYLON {
  6083. /**
  6084. * Helper class dealing with the extraction of spherical polynomial dataArray
  6085. * from a cube map.
  6086. */
  6087. export class CubeMapToSphericalPolynomialTools {
  6088. private static FileFaces;
  6089. /**
  6090. * Converts a texture to the according Spherical Polynomial data.
  6091. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6092. *
  6093. * @param texture The texture to extract the information from.
  6094. * @return The Spherical Polynomial data.
  6095. */
  6096. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6097. /**
  6098. * Converts a cubemap to the according Spherical Polynomial data.
  6099. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6100. *
  6101. * @param cubeInfo The Cube map to extract the information from.
  6102. * @return The Spherical Polynomial data.
  6103. */
  6104. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6105. }
  6106. }
  6107. declare module BABYLON {
  6108. /**
  6109. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6110. * during the life time of the application.
  6111. */
  6112. export class EngineStore {
  6113. /** Gets the list of created engines */
  6114. static Instances: Engine[];
  6115. /** @hidden */
  6116. static _LastCreatedScene: Nullable<Scene>;
  6117. /**
  6118. * Gets the latest created engine
  6119. */
  6120. static readonly LastCreatedEngine: Nullable<Engine>;
  6121. /**
  6122. * Gets the latest created scene
  6123. */
  6124. static readonly LastCreatedScene: Nullable<Scene>;
  6125. }
  6126. }
  6127. declare module BABYLON {
  6128. /**
  6129. * Define options used to create a render target texture
  6130. */
  6131. export class RenderTargetCreationOptions {
  6132. /**
  6133. * Specifies is mipmaps must be generated
  6134. */
  6135. generateMipMaps?: boolean;
  6136. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6137. generateDepthBuffer?: boolean;
  6138. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6139. generateStencilBuffer?: boolean;
  6140. /** Defines texture type (int by default) */
  6141. type?: number;
  6142. /** Defines sampling mode (trilinear by default) */
  6143. samplingMode?: number;
  6144. /** Defines format (RGBA by default) */
  6145. format?: number;
  6146. }
  6147. }
  6148. declare module BABYLON {
  6149. /**
  6150. * @hidden
  6151. **/
  6152. export class _AlphaState {
  6153. private _isAlphaBlendDirty;
  6154. private _isBlendFunctionParametersDirty;
  6155. private _isBlendEquationParametersDirty;
  6156. private _isBlendConstantsDirty;
  6157. private _alphaBlend;
  6158. private _blendFunctionParameters;
  6159. private _blendEquationParameters;
  6160. private _blendConstants;
  6161. /**
  6162. * Initializes the state.
  6163. */
  6164. constructor();
  6165. readonly isDirty: boolean;
  6166. alphaBlend: boolean;
  6167. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6168. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6169. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6170. reset(): void;
  6171. apply(gl: WebGLRenderingContext): void;
  6172. }
  6173. }
  6174. declare module BABYLON {
  6175. /**
  6176. * @hidden
  6177. **/
  6178. export class _DepthCullingState {
  6179. private _isDepthTestDirty;
  6180. private _isDepthMaskDirty;
  6181. private _isDepthFuncDirty;
  6182. private _isCullFaceDirty;
  6183. private _isCullDirty;
  6184. private _isZOffsetDirty;
  6185. private _isFrontFaceDirty;
  6186. private _depthTest;
  6187. private _depthMask;
  6188. private _depthFunc;
  6189. private _cull;
  6190. private _cullFace;
  6191. private _zOffset;
  6192. private _frontFace;
  6193. /**
  6194. * Initializes the state.
  6195. */
  6196. constructor();
  6197. readonly isDirty: boolean;
  6198. zOffset: number;
  6199. cullFace: Nullable<number>;
  6200. cull: Nullable<boolean>;
  6201. depthFunc: Nullable<number>;
  6202. depthMask: boolean;
  6203. depthTest: boolean;
  6204. frontFace: Nullable<number>;
  6205. reset(): void;
  6206. apply(gl: WebGLRenderingContext): void;
  6207. }
  6208. }
  6209. declare module BABYLON {
  6210. /**
  6211. * @hidden
  6212. **/
  6213. export class _StencilState {
  6214. /** 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 */
  6215. static readonly ALWAYS: number;
  6216. /** Passed to stencilOperation to specify that stencil value must be kept */
  6217. static readonly KEEP: number;
  6218. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6219. static readonly REPLACE: number;
  6220. private _isStencilTestDirty;
  6221. private _isStencilMaskDirty;
  6222. private _isStencilFuncDirty;
  6223. private _isStencilOpDirty;
  6224. private _stencilTest;
  6225. private _stencilMask;
  6226. private _stencilFunc;
  6227. private _stencilFuncRef;
  6228. private _stencilFuncMask;
  6229. private _stencilOpStencilFail;
  6230. private _stencilOpDepthFail;
  6231. private _stencilOpStencilDepthPass;
  6232. readonly isDirty: boolean;
  6233. stencilFunc: number;
  6234. stencilFuncRef: number;
  6235. stencilFuncMask: number;
  6236. stencilOpStencilFail: number;
  6237. stencilOpDepthFail: number;
  6238. stencilOpStencilDepthPass: number;
  6239. stencilMask: number;
  6240. stencilTest: boolean;
  6241. constructor();
  6242. reset(): void;
  6243. apply(gl: WebGLRenderingContext): void;
  6244. }
  6245. }
  6246. declare module BABYLON {
  6247. /**
  6248. * @hidden
  6249. **/
  6250. export class _TimeToken {
  6251. _startTimeQuery: Nullable<WebGLQuery>;
  6252. _endTimeQuery: Nullable<WebGLQuery>;
  6253. _timeElapsedQuery: Nullable<WebGLQuery>;
  6254. _timeElapsedQueryEnded: boolean;
  6255. }
  6256. }
  6257. declare module BABYLON {
  6258. /**
  6259. * Class used to store data associated with WebGL texture data for the engine
  6260. * This class should not be used directly
  6261. */
  6262. export class InternalTexture {
  6263. /** hidden */
  6264. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6265. /**
  6266. * The source of the texture data is unknown
  6267. */
  6268. static DATASOURCE_UNKNOWN: number;
  6269. /**
  6270. * Texture data comes from an URL
  6271. */
  6272. static DATASOURCE_URL: number;
  6273. /**
  6274. * Texture data is only used for temporary storage
  6275. */
  6276. static DATASOURCE_TEMP: number;
  6277. /**
  6278. * Texture data comes from raw data (ArrayBuffer)
  6279. */
  6280. static DATASOURCE_RAW: number;
  6281. /**
  6282. * Texture content is dynamic (video or dynamic texture)
  6283. */
  6284. static DATASOURCE_DYNAMIC: number;
  6285. /**
  6286. * Texture content is generated by rendering to it
  6287. */
  6288. static DATASOURCE_RENDERTARGET: number;
  6289. /**
  6290. * Texture content is part of a multi render target process
  6291. */
  6292. static DATASOURCE_MULTIRENDERTARGET: number;
  6293. /**
  6294. * Texture data comes from a cube data file
  6295. */
  6296. static DATASOURCE_CUBE: number;
  6297. /**
  6298. * Texture data comes from a raw cube data
  6299. */
  6300. static DATASOURCE_CUBERAW: number;
  6301. /**
  6302. * Texture data come from a prefiltered cube data file
  6303. */
  6304. static DATASOURCE_CUBEPREFILTERED: number;
  6305. /**
  6306. * Texture content is raw 3D data
  6307. */
  6308. static DATASOURCE_RAW3D: number;
  6309. /**
  6310. * Texture content is a depth texture
  6311. */
  6312. static DATASOURCE_DEPTHTEXTURE: number;
  6313. /**
  6314. * Texture data comes from a raw cube data encoded with RGBD
  6315. */
  6316. static DATASOURCE_CUBERAW_RGBD: number;
  6317. /**
  6318. * Defines if the texture is ready
  6319. */
  6320. isReady: boolean;
  6321. /**
  6322. * Defines if the texture is a cube texture
  6323. */
  6324. isCube: boolean;
  6325. /**
  6326. * Defines if the texture contains 3D data
  6327. */
  6328. is3D: boolean;
  6329. /**
  6330. * Defines if the texture contains multiview data
  6331. */
  6332. isMultiview: boolean;
  6333. /**
  6334. * Gets the URL used to load this texture
  6335. */
  6336. url: string;
  6337. /**
  6338. * Gets the sampling mode of the texture
  6339. */
  6340. samplingMode: number;
  6341. /**
  6342. * Gets a boolean indicating if the texture needs mipmaps generation
  6343. */
  6344. generateMipMaps: boolean;
  6345. /**
  6346. * Gets the number of samples used by the texture (WebGL2+ only)
  6347. */
  6348. samples: number;
  6349. /**
  6350. * Gets the type of the texture (int, float...)
  6351. */
  6352. type: number;
  6353. /**
  6354. * Gets the format of the texture (RGB, RGBA...)
  6355. */
  6356. format: number;
  6357. /**
  6358. * Observable called when the texture is loaded
  6359. */
  6360. onLoadedObservable: Observable<InternalTexture>;
  6361. /**
  6362. * Gets the width of the texture
  6363. */
  6364. width: number;
  6365. /**
  6366. * Gets the height of the texture
  6367. */
  6368. height: number;
  6369. /**
  6370. * Gets the depth of the texture
  6371. */
  6372. depth: number;
  6373. /**
  6374. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6375. */
  6376. baseWidth: number;
  6377. /**
  6378. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6379. */
  6380. baseHeight: number;
  6381. /**
  6382. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6383. */
  6384. baseDepth: number;
  6385. /**
  6386. * Gets a boolean indicating if the texture is inverted on Y axis
  6387. */
  6388. invertY: boolean;
  6389. /** @hidden */
  6390. _invertVScale: boolean;
  6391. /** @hidden */
  6392. _associatedChannel: number;
  6393. /** @hidden */
  6394. _dataSource: number;
  6395. /** @hidden */
  6396. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6397. /** @hidden */
  6398. _bufferView: Nullable<ArrayBufferView>;
  6399. /** @hidden */
  6400. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6401. /** @hidden */
  6402. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6403. /** @hidden */
  6404. _size: number;
  6405. /** @hidden */
  6406. _extension: string;
  6407. /** @hidden */
  6408. _files: Nullable<string[]>;
  6409. /** @hidden */
  6410. _workingCanvas: Nullable<HTMLCanvasElement>;
  6411. /** @hidden */
  6412. _workingContext: Nullable<CanvasRenderingContext2D>;
  6413. /** @hidden */
  6414. _framebuffer: Nullable<WebGLFramebuffer>;
  6415. /** @hidden */
  6416. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6417. /** @hidden */
  6418. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6419. /** @hidden */
  6420. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6421. /** @hidden */
  6422. _attachments: Nullable<number[]>;
  6423. /** @hidden */
  6424. _cachedCoordinatesMode: Nullable<number>;
  6425. /** @hidden */
  6426. _cachedWrapU: Nullable<number>;
  6427. /** @hidden */
  6428. _cachedWrapV: Nullable<number>;
  6429. /** @hidden */
  6430. _cachedWrapR: Nullable<number>;
  6431. /** @hidden */
  6432. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6433. /** @hidden */
  6434. _isDisabled: boolean;
  6435. /** @hidden */
  6436. _compression: Nullable<string>;
  6437. /** @hidden */
  6438. _generateStencilBuffer: boolean;
  6439. /** @hidden */
  6440. _generateDepthBuffer: boolean;
  6441. /** @hidden */
  6442. _comparisonFunction: number;
  6443. /** @hidden */
  6444. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6445. /** @hidden */
  6446. _lodGenerationScale: number;
  6447. /** @hidden */
  6448. _lodGenerationOffset: number;
  6449. /** @hidden */
  6450. _colorTextureArray: Nullable<WebGLTexture>;
  6451. /** @hidden */
  6452. _depthStencilTextureArray: Nullable<WebGLTexture>;
  6453. /** @hidden */
  6454. _lodTextureHigh: Nullable<BaseTexture>;
  6455. /** @hidden */
  6456. _lodTextureMid: Nullable<BaseTexture>;
  6457. /** @hidden */
  6458. _lodTextureLow: Nullable<BaseTexture>;
  6459. /** @hidden */
  6460. _isRGBD: boolean;
  6461. /** @hidden */
  6462. _webGLTexture: Nullable<WebGLTexture>;
  6463. /** @hidden */
  6464. _references: number;
  6465. private _engine;
  6466. /**
  6467. * Gets the Engine the texture belongs to.
  6468. * @returns The babylon engine
  6469. */
  6470. getEngine(): Engine;
  6471. /**
  6472. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6473. */
  6474. readonly dataSource: number;
  6475. /**
  6476. * Creates a new InternalTexture
  6477. * @param engine defines the engine to use
  6478. * @param dataSource defines the type of data that will be used
  6479. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6480. */
  6481. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6482. /**
  6483. * Increments the number of references (ie. the number of Texture that point to it)
  6484. */
  6485. incrementReferences(): void;
  6486. /**
  6487. * Change the size of the texture (not the size of the content)
  6488. * @param width defines the new width
  6489. * @param height defines the new height
  6490. * @param depth defines the new depth (1 by default)
  6491. */
  6492. updateSize(width: int, height: int, depth?: int): void;
  6493. /** @hidden */
  6494. _rebuild(): void;
  6495. /** @hidden */
  6496. _swapAndDie(target: InternalTexture): void;
  6497. /**
  6498. * Dispose the current allocated resources
  6499. */
  6500. dispose(): void;
  6501. }
  6502. }
  6503. declare module BABYLON {
  6504. /**
  6505. * This represents the main contract an easing function should follow.
  6506. * Easing functions are used throughout the animation system.
  6507. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6508. */
  6509. export interface IEasingFunction {
  6510. /**
  6511. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6512. * of the easing function.
  6513. * The link below provides some of the most common examples of easing functions.
  6514. * @see https://easings.net/
  6515. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6516. * @returns the corresponding value on the curve defined by the easing function
  6517. */
  6518. ease(gradient: number): number;
  6519. }
  6520. /**
  6521. * Base class used for every default easing function.
  6522. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6523. */
  6524. export class EasingFunction implements IEasingFunction {
  6525. /**
  6526. * Interpolation follows the mathematical formula associated with the easing function.
  6527. */
  6528. static readonly EASINGMODE_EASEIN: number;
  6529. /**
  6530. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6531. */
  6532. static readonly EASINGMODE_EASEOUT: number;
  6533. /**
  6534. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6535. */
  6536. static readonly EASINGMODE_EASEINOUT: number;
  6537. private _easingMode;
  6538. /**
  6539. * Sets the easing mode of the current function.
  6540. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6541. */
  6542. setEasingMode(easingMode: number): void;
  6543. /**
  6544. * Gets the current easing mode.
  6545. * @returns the easing mode
  6546. */
  6547. getEasingMode(): number;
  6548. /**
  6549. * @hidden
  6550. */
  6551. easeInCore(gradient: number): number;
  6552. /**
  6553. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6554. * of the easing function.
  6555. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6556. * @returns the corresponding value on the curve defined by the easing function
  6557. */
  6558. ease(gradient: number): number;
  6559. }
  6560. /**
  6561. * Easing function with a circle shape (see link below).
  6562. * @see https://easings.net/#easeInCirc
  6563. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6564. */
  6565. export class CircleEase extends EasingFunction implements IEasingFunction {
  6566. /** @hidden */
  6567. easeInCore(gradient: number): number;
  6568. }
  6569. /**
  6570. * Easing function with a ease back shape (see link below).
  6571. * @see https://easings.net/#easeInBack
  6572. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6573. */
  6574. export class BackEase extends EasingFunction implements IEasingFunction {
  6575. /** Defines the amplitude of the function */
  6576. amplitude: number;
  6577. /**
  6578. * Instantiates a back ease easing
  6579. * @see https://easings.net/#easeInBack
  6580. * @param amplitude Defines the amplitude of the function
  6581. */
  6582. constructor(
  6583. /** Defines the amplitude of the function */
  6584. amplitude?: number);
  6585. /** @hidden */
  6586. easeInCore(gradient: number): number;
  6587. }
  6588. /**
  6589. * Easing function with a bouncing shape (see link below).
  6590. * @see https://easings.net/#easeInBounce
  6591. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6592. */
  6593. export class BounceEase extends EasingFunction implements IEasingFunction {
  6594. /** Defines the number of bounces */
  6595. bounces: number;
  6596. /** Defines the amplitude of the bounce */
  6597. bounciness: number;
  6598. /**
  6599. * Instantiates a bounce easing
  6600. * @see https://easings.net/#easeInBounce
  6601. * @param bounces Defines the number of bounces
  6602. * @param bounciness Defines the amplitude of the bounce
  6603. */
  6604. constructor(
  6605. /** Defines the number of bounces */
  6606. bounces?: number,
  6607. /** Defines the amplitude of the bounce */
  6608. bounciness?: number);
  6609. /** @hidden */
  6610. easeInCore(gradient: number): number;
  6611. }
  6612. /**
  6613. * Easing function with a power of 3 shape (see link below).
  6614. * @see https://easings.net/#easeInCubic
  6615. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6616. */
  6617. export class CubicEase extends EasingFunction implements IEasingFunction {
  6618. /** @hidden */
  6619. easeInCore(gradient: number): number;
  6620. }
  6621. /**
  6622. * Easing function with an elastic shape (see link below).
  6623. * @see https://easings.net/#easeInElastic
  6624. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6625. */
  6626. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6627. /** Defines the number of oscillations*/
  6628. oscillations: number;
  6629. /** Defines the amplitude of the oscillations*/
  6630. springiness: number;
  6631. /**
  6632. * Instantiates an elastic easing function
  6633. * @see https://easings.net/#easeInElastic
  6634. * @param oscillations Defines the number of oscillations
  6635. * @param springiness Defines the amplitude of the oscillations
  6636. */
  6637. constructor(
  6638. /** Defines the number of oscillations*/
  6639. oscillations?: number,
  6640. /** Defines the amplitude of the oscillations*/
  6641. springiness?: number);
  6642. /** @hidden */
  6643. easeInCore(gradient: number): number;
  6644. }
  6645. /**
  6646. * Easing function with an exponential shape (see link below).
  6647. * @see https://easings.net/#easeInExpo
  6648. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6649. */
  6650. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6651. /** Defines the exponent of the function */
  6652. exponent: number;
  6653. /**
  6654. * Instantiates an exponential easing function
  6655. * @see https://easings.net/#easeInExpo
  6656. * @param exponent Defines the exponent of the function
  6657. */
  6658. constructor(
  6659. /** Defines the exponent of the function */
  6660. exponent?: number);
  6661. /** @hidden */
  6662. easeInCore(gradient: number): number;
  6663. }
  6664. /**
  6665. * Easing function with a power shape (see link below).
  6666. * @see https://easings.net/#easeInQuad
  6667. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6668. */
  6669. export class PowerEase extends EasingFunction implements IEasingFunction {
  6670. /** Defines the power of the function */
  6671. power: number;
  6672. /**
  6673. * Instantiates an power base easing function
  6674. * @see https://easings.net/#easeInQuad
  6675. * @param power Defines the power of the function
  6676. */
  6677. constructor(
  6678. /** Defines the power of the function */
  6679. power?: number);
  6680. /** @hidden */
  6681. easeInCore(gradient: number): number;
  6682. }
  6683. /**
  6684. * Easing function with a power of 2 shape (see link below).
  6685. * @see https://easings.net/#easeInQuad
  6686. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6687. */
  6688. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6689. /** @hidden */
  6690. easeInCore(gradient: number): number;
  6691. }
  6692. /**
  6693. * Easing function with a power of 4 shape (see link below).
  6694. * @see https://easings.net/#easeInQuart
  6695. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6696. */
  6697. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6698. /** @hidden */
  6699. easeInCore(gradient: number): number;
  6700. }
  6701. /**
  6702. * Easing function with a power of 5 shape (see link below).
  6703. * @see https://easings.net/#easeInQuint
  6704. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6705. */
  6706. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6707. /** @hidden */
  6708. easeInCore(gradient: number): number;
  6709. }
  6710. /**
  6711. * Easing function with a sin shape (see link below).
  6712. * @see https://easings.net/#easeInSine
  6713. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6714. */
  6715. export class SineEase extends EasingFunction implements IEasingFunction {
  6716. /** @hidden */
  6717. easeInCore(gradient: number): number;
  6718. }
  6719. /**
  6720. * Easing function with a bezier shape (see link below).
  6721. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6722. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6723. */
  6724. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6725. /** Defines the x component of the start tangent in the bezier curve */
  6726. x1: number;
  6727. /** Defines the y component of the start tangent in the bezier curve */
  6728. y1: number;
  6729. /** Defines the x component of the end tangent in the bezier curve */
  6730. x2: number;
  6731. /** Defines the y component of the end tangent in the bezier curve */
  6732. y2: number;
  6733. /**
  6734. * Instantiates a bezier function
  6735. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6736. * @param x1 Defines the x component of the start tangent in the bezier curve
  6737. * @param y1 Defines the y component of the start tangent in the bezier curve
  6738. * @param x2 Defines the x component of the end tangent in the bezier curve
  6739. * @param y2 Defines the y component of the end tangent in the bezier curve
  6740. */
  6741. constructor(
  6742. /** Defines the x component of the start tangent in the bezier curve */
  6743. x1?: number,
  6744. /** Defines the y component of the start tangent in the bezier curve */
  6745. y1?: number,
  6746. /** Defines the x component of the end tangent in the bezier curve */
  6747. x2?: number,
  6748. /** Defines the y component of the end tangent in the bezier curve */
  6749. y2?: number);
  6750. /** @hidden */
  6751. easeInCore(gradient: number): number;
  6752. }
  6753. }
  6754. declare module BABYLON {
  6755. /**
  6756. * Defines an interface which represents an animation key frame
  6757. */
  6758. export interface IAnimationKey {
  6759. /**
  6760. * Frame of the key frame
  6761. */
  6762. frame: number;
  6763. /**
  6764. * Value at the specifies key frame
  6765. */
  6766. value: any;
  6767. /**
  6768. * The input tangent for the cubic hermite spline
  6769. */
  6770. inTangent?: any;
  6771. /**
  6772. * The output tangent for the cubic hermite spline
  6773. */
  6774. outTangent?: any;
  6775. /**
  6776. * The animation interpolation type
  6777. */
  6778. interpolation?: AnimationKeyInterpolation;
  6779. }
  6780. /**
  6781. * Enum for the animation key frame interpolation type
  6782. */
  6783. export enum AnimationKeyInterpolation {
  6784. /**
  6785. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6786. */
  6787. STEP = 1
  6788. }
  6789. }
  6790. declare module BABYLON {
  6791. /**
  6792. * Represents the range of an animation
  6793. */
  6794. export class AnimationRange {
  6795. /**The name of the animation range**/
  6796. name: string;
  6797. /**The starting frame of the animation */
  6798. from: number;
  6799. /**The ending frame of the animation*/
  6800. to: number;
  6801. /**
  6802. * Initializes the range of an animation
  6803. * @param name The name of the animation range
  6804. * @param from The starting frame of the animation
  6805. * @param to The ending frame of the animation
  6806. */
  6807. constructor(
  6808. /**The name of the animation range**/
  6809. name: string,
  6810. /**The starting frame of the animation */
  6811. from: number,
  6812. /**The ending frame of the animation*/
  6813. to: number);
  6814. /**
  6815. * Makes a copy of the animation range
  6816. * @returns A copy of the animation range
  6817. */
  6818. clone(): AnimationRange;
  6819. }
  6820. }
  6821. declare module BABYLON {
  6822. /**
  6823. * Composed of a frame, and an action function
  6824. */
  6825. export class AnimationEvent {
  6826. /** The frame for which the event is triggered **/
  6827. frame: number;
  6828. /** The event to perform when triggered **/
  6829. action: (currentFrame: number) => void;
  6830. /** Specifies if the event should be triggered only once**/
  6831. onlyOnce?: boolean | undefined;
  6832. /**
  6833. * Specifies if the animation event is done
  6834. */
  6835. isDone: boolean;
  6836. /**
  6837. * Initializes the animation event
  6838. * @param frame The frame for which the event is triggered
  6839. * @param action The event to perform when triggered
  6840. * @param onlyOnce Specifies if the event should be triggered only once
  6841. */
  6842. constructor(
  6843. /** The frame for which the event is triggered **/
  6844. frame: number,
  6845. /** The event to perform when triggered **/
  6846. action: (currentFrame: number) => void,
  6847. /** Specifies if the event should be triggered only once**/
  6848. onlyOnce?: boolean | undefined);
  6849. /** @hidden */
  6850. _clone(): AnimationEvent;
  6851. }
  6852. }
  6853. declare module BABYLON {
  6854. /**
  6855. * Interface used to define a behavior
  6856. */
  6857. export interface Behavior<T> {
  6858. /** gets or sets behavior's name */
  6859. name: string;
  6860. /**
  6861. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6862. */
  6863. init(): void;
  6864. /**
  6865. * Called when the behavior is attached to a target
  6866. * @param target defines the target where the behavior is attached to
  6867. */
  6868. attach(target: T): void;
  6869. /**
  6870. * Called when the behavior is detached from its target
  6871. */
  6872. detach(): void;
  6873. }
  6874. /**
  6875. * Interface implemented by classes supporting behaviors
  6876. */
  6877. export interface IBehaviorAware<T> {
  6878. /**
  6879. * Attach a behavior
  6880. * @param behavior defines the behavior to attach
  6881. * @returns the current host
  6882. */
  6883. addBehavior(behavior: Behavior<T>): T;
  6884. /**
  6885. * Remove a behavior from the current object
  6886. * @param behavior defines the behavior to detach
  6887. * @returns the current host
  6888. */
  6889. removeBehavior(behavior: Behavior<T>): T;
  6890. /**
  6891. * Gets a behavior using its name to search
  6892. * @param name defines the name to search
  6893. * @returns the behavior or null if not found
  6894. */
  6895. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6896. }
  6897. }
  6898. declare module BABYLON {
  6899. /**
  6900. * @hidden
  6901. */
  6902. export class IntersectionInfo {
  6903. bu: Nullable<number>;
  6904. bv: Nullable<number>;
  6905. distance: number;
  6906. faceId: number;
  6907. subMeshId: number;
  6908. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6909. }
  6910. }
  6911. declare module BABYLON {
  6912. /**
  6913. * Class used to store bounding sphere information
  6914. */
  6915. export class BoundingSphere {
  6916. /**
  6917. * Gets the center of the bounding sphere in local space
  6918. */
  6919. readonly center: Vector3;
  6920. /**
  6921. * Radius of the bounding sphere in local space
  6922. */
  6923. radius: number;
  6924. /**
  6925. * Gets the center of the bounding sphere in world space
  6926. */
  6927. readonly centerWorld: Vector3;
  6928. /**
  6929. * Radius of the bounding sphere in world space
  6930. */
  6931. radiusWorld: number;
  6932. /**
  6933. * Gets the minimum vector in local space
  6934. */
  6935. readonly minimum: Vector3;
  6936. /**
  6937. * Gets the maximum vector in local space
  6938. */
  6939. readonly maximum: Vector3;
  6940. private _worldMatrix;
  6941. private static readonly TmpVector3;
  6942. /**
  6943. * Creates a new bounding sphere
  6944. * @param min defines the minimum vector (in local space)
  6945. * @param max defines the maximum vector (in local space)
  6946. * @param worldMatrix defines the new world matrix
  6947. */
  6948. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6949. /**
  6950. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6951. * @param min defines the new minimum vector (in local space)
  6952. * @param max defines the new maximum vector (in local space)
  6953. * @param worldMatrix defines the new world matrix
  6954. */
  6955. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6956. /**
  6957. * Scale the current bounding sphere by applying a scale factor
  6958. * @param factor defines the scale factor to apply
  6959. * @returns the current bounding box
  6960. */
  6961. scale(factor: number): BoundingSphere;
  6962. /**
  6963. * Gets the world matrix of the bounding box
  6964. * @returns a matrix
  6965. */
  6966. getWorldMatrix(): DeepImmutable<Matrix>;
  6967. /** @hidden */
  6968. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6969. /**
  6970. * Tests if the bounding sphere is intersecting the frustum planes
  6971. * @param frustumPlanes defines the frustum planes to test
  6972. * @returns true if there is an intersection
  6973. */
  6974. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6975. /**
  6976. * Tests if the bounding sphere center is in between the frustum planes.
  6977. * Used for optimistic fast inclusion.
  6978. * @param frustumPlanes defines the frustum planes to test
  6979. * @returns true if the sphere center is in between the frustum planes
  6980. */
  6981. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6982. /**
  6983. * Tests if a point is inside the bounding sphere
  6984. * @param point defines the point to test
  6985. * @returns true if the point is inside the bounding sphere
  6986. */
  6987. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6988. /**
  6989. * Checks if two sphere intersct
  6990. * @param sphere0 sphere 0
  6991. * @param sphere1 sphere 1
  6992. * @returns true if the speres intersect
  6993. */
  6994. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6995. }
  6996. }
  6997. declare module BABYLON {
  6998. /**
  6999. * Class used to store bounding box information
  7000. */
  7001. export class BoundingBox implements ICullable {
  7002. /**
  7003. * Gets the 8 vectors representing the bounding box in local space
  7004. */
  7005. readonly vectors: Vector3[];
  7006. /**
  7007. * Gets the center of the bounding box in local space
  7008. */
  7009. readonly center: Vector3;
  7010. /**
  7011. * Gets the center of the bounding box in world space
  7012. */
  7013. readonly centerWorld: Vector3;
  7014. /**
  7015. * Gets the extend size in local space
  7016. */
  7017. readonly extendSize: Vector3;
  7018. /**
  7019. * Gets the extend size in world space
  7020. */
  7021. readonly extendSizeWorld: Vector3;
  7022. /**
  7023. * Gets the OBB (object bounding box) directions
  7024. */
  7025. readonly directions: Vector3[];
  7026. /**
  7027. * Gets the 8 vectors representing the bounding box in world space
  7028. */
  7029. readonly vectorsWorld: Vector3[];
  7030. /**
  7031. * Gets the minimum vector in world space
  7032. */
  7033. readonly minimumWorld: Vector3;
  7034. /**
  7035. * Gets the maximum vector in world space
  7036. */
  7037. readonly maximumWorld: Vector3;
  7038. /**
  7039. * Gets the minimum vector in local space
  7040. */
  7041. readonly minimum: Vector3;
  7042. /**
  7043. * Gets the maximum vector in local space
  7044. */
  7045. readonly maximum: Vector3;
  7046. private _worldMatrix;
  7047. private static readonly TmpVector3;
  7048. /**
  7049. * @hidden
  7050. */
  7051. _tag: number;
  7052. /**
  7053. * Creates a new bounding box
  7054. * @param min defines the minimum vector (in local space)
  7055. * @param max defines the maximum vector (in local space)
  7056. * @param worldMatrix defines the new world matrix
  7057. */
  7058. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7059. /**
  7060. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7061. * @param min defines the new minimum vector (in local space)
  7062. * @param max defines the new maximum vector (in local space)
  7063. * @param worldMatrix defines the new world matrix
  7064. */
  7065. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7066. /**
  7067. * Scale the current bounding box by applying a scale factor
  7068. * @param factor defines the scale factor to apply
  7069. * @returns the current bounding box
  7070. */
  7071. scale(factor: number): BoundingBox;
  7072. /**
  7073. * Gets the world matrix of the bounding box
  7074. * @returns a matrix
  7075. */
  7076. getWorldMatrix(): DeepImmutable<Matrix>;
  7077. /** @hidden */
  7078. _update(world: DeepImmutable<Matrix>): void;
  7079. /**
  7080. * Tests if the bounding box is intersecting the frustum planes
  7081. * @param frustumPlanes defines the frustum planes to test
  7082. * @returns true if there is an intersection
  7083. */
  7084. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7085. /**
  7086. * Tests if the bounding box is entirely inside the frustum planes
  7087. * @param frustumPlanes defines the frustum planes to test
  7088. * @returns true if there is an inclusion
  7089. */
  7090. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7091. /**
  7092. * Tests if a point is inside the bounding box
  7093. * @param point defines the point to test
  7094. * @returns true if the point is inside the bounding box
  7095. */
  7096. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7097. /**
  7098. * Tests if the bounding box intersects with a bounding sphere
  7099. * @param sphere defines the sphere to test
  7100. * @returns true if there is an intersection
  7101. */
  7102. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7103. /**
  7104. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7105. * @param min defines the min vector to use
  7106. * @param max defines the max vector to use
  7107. * @returns true if there is an intersection
  7108. */
  7109. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7110. /**
  7111. * Tests if two bounding boxes are intersections
  7112. * @param box0 defines the first box to test
  7113. * @param box1 defines the second box to test
  7114. * @returns true if there is an intersection
  7115. */
  7116. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7117. /**
  7118. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7119. * @param minPoint defines the minimum vector of the bounding box
  7120. * @param maxPoint defines the maximum vector of the bounding box
  7121. * @param sphereCenter defines the sphere center
  7122. * @param sphereRadius defines the sphere radius
  7123. * @returns true if there is an intersection
  7124. */
  7125. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7126. /**
  7127. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7128. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7129. * @param frustumPlanes defines the frustum planes to test
  7130. * @return true if there is an inclusion
  7131. */
  7132. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7133. /**
  7134. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7135. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7136. * @param frustumPlanes defines the frustum planes to test
  7137. * @return true if there is an intersection
  7138. */
  7139. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7140. }
  7141. }
  7142. declare module BABYLON {
  7143. /** @hidden */
  7144. export class Collider {
  7145. /** Define if a collision was found */
  7146. collisionFound: boolean;
  7147. /**
  7148. * Define last intersection point in local space
  7149. */
  7150. intersectionPoint: Vector3;
  7151. /**
  7152. * Define last collided mesh
  7153. */
  7154. collidedMesh: Nullable<AbstractMesh>;
  7155. private _collisionPoint;
  7156. private _planeIntersectionPoint;
  7157. private _tempVector;
  7158. private _tempVector2;
  7159. private _tempVector3;
  7160. private _tempVector4;
  7161. private _edge;
  7162. private _baseToVertex;
  7163. private _destinationPoint;
  7164. private _slidePlaneNormal;
  7165. private _displacementVector;
  7166. /** @hidden */
  7167. _radius: Vector3;
  7168. /** @hidden */
  7169. _retry: number;
  7170. private _velocity;
  7171. private _basePoint;
  7172. private _epsilon;
  7173. /** @hidden */
  7174. _velocityWorldLength: number;
  7175. /** @hidden */
  7176. _basePointWorld: Vector3;
  7177. private _velocityWorld;
  7178. private _normalizedVelocity;
  7179. /** @hidden */
  7180. _initialVelocity: Vector3;
  7181. /** @hidden */
  7182. _initialPosition: Vector3;
  7183. private _nearestDistance;
  7184. private _collisionMask;
  7185. collisionMask: number;
  7186. /**
  7187. * Gets the plane normal used to compute the sliding response (in local space)
  7188. */
  7189. readonly slidePlaneNormal: Vector3;
  7190. /** @hidden */
  7191. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7192. /** @hidden */
  7193. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7194. /** @hidden */
  7195. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7196. /** @hidden */
  7197. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7198. /** @hidden */
  7199. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7200. /** @hidden */
  7201. _getResponse(pos: Vector3, vel: Vector3): void;
  7202. }
  7203. }
  7204. declare module BABYLON {
  7205. /**
  7206. * Interface for cullable objects
  7207. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7208. */
  7209. export interface ICullable {
  7210. /**
  7211. * Checks if the object or part of the object is in the frustum
  7212. * @param frustumPlanes Camera near/planes
  7213. * @returns true if the object is in frustum otherwise false
  7214. */
  7215. isInFrustum(frustumPlanes: Plane[]): boolean;
  7216. /**
  7217. * Checks if a cullable object (mesh...) is in the camera frustum
  7218. * Unlike isInFrustum this cheks the full bounding box
  7219. * @param frustumPlanes Camera near/planes
  7220. * @returns true if the object is in frustum otherwise false
  7221. */
  7222. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7223. }
  7224. /**
  7225. * Info for a bounding data of a mesh
  7226. */
  7227. export class BoundingInfo implements ICullable {
  7228. /**
  7229. * Bounding box for the mesh
  7230. */
  7231. readonly boundingBox: BoundingBox;
  7232. /**
  7233. * Bounding sphere for the mesh
  7234. */
  7235. readonly boundingSphere: BoundingSphere;
  7236. private _isLocked;
  7237. private static readonly TmpVector3;
  7238. /**
  7239. * Constructs bounding info
  7240. * @param minimum min vector of the bounding box/sphere
  7241. * @param maximum max vector of the bounding box/sphere
  7242. * @param worldMatrix defines the new world matrix
  7243. */
  7244. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7245. /**
  7246. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7247. * @param min defines the new minimum vector (in local space)
  7248. * @param max defines the new maximum vector (in local space)
  7249. * @param worldMatrix defines the new world matrix
  7250. */
  7251. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7252. /**
  7253. * min vector of the bounding box/sphere
  7254. */
  7255. readonly minimum: Vector3;
  7256. /**
  7257. * max vector of the bounding box/sphere
  7258. */
  7259. readonly maximum: Vector3;
  7260. /**
  7261. * If the info is locked and won't be updated to avoid perf overhead
  7262. */
  7263. isLocked: boolean;
  7264. /**
  7265. * Updates the bounding sphere and box
  7266. * @param world world matrix to be used to update
  7267. */
  7268. update(world: DeepImmutable<Matrix>): void;
  7269. /**
  7270. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7271. * @param center New center of the bounding info
  7272. * @param extend New extend of the bounding info
  7273. * @returns the current bounding info
  7274. */
  7275. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7276. /**
  7277. * Scale the current bounding info by applying a scale factor
  7278. * @param factor defines the scale factor to apply
  7279. * @returns the current bounding info
  7280. */
  7281. scale(factor: number): BoundingInfo;
  7282. /**
  7283. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7284. * @param frustumPlanes defines the frustum to test
  7285. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7286. * @returns true if the bounding info is in the frustum planes
  7287. */
  7288. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7289. /**
  7290. * Gets the world distance between the min and max points of the bounding box
  7291. */
  7292. readonly diagonalLength: number;
  7293. /**
  7294. * Checks if a cullable object (mesh...) is in the camera frustum
  7295. * Unlike isInFrustum this cheks the full bounding box
  7296. * @param frustumPlanes Camera near/planes
  7297. * @returns true if the object is in frustum otherwise false
  7298. */
  7299. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7300. /** @hidden */
  7301. _checkCollision(collider: Collider): boolean;
  7302. /**
  7303. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7304. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7305. * @param point the point to check intersection with
  7306. * @returns if the point intersects
  7307. */
  7308. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7309. /**
  7310. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7311. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7312. * @param boundingInfo the bounding info to check intersection with
  7313. * @param precise if the intersection should be done using OBB
  7314. * @returns if the bounding info intersects
  7315. */
  7316. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7317. }
  7318. }
  7319. declare module BABYLON {
  7320. /**
  7321. * Defines an array and its length.
  7322. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7323. */
  7324. export interface ISmartArrayLike<T> {
  7325. /**
  7326. * The data of the array.
  7327. */
  7328. data: Array<T>;
  7329. /**
  7330. * The active length of the array.
  7331. */
  7332. length: number;
  7333. }
  7334. /**
  7335. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7336. */
  7337. export class SmartArray<T> implements ISmartArrayLike<T> {
  7338. /**
  7339. * The full set of data from the array.
  7340. */
  7341. data: Array<T>;
  7342. /**
  7343. * The active length of the array.
  7344. */
  7345. length: number;
  7346. protected _id: number;
  7347. /**
  7348. * Instantiates a Smart Array.
  7349. * @param capacity defines the default capacity of the array.
  7350. */
  7351. constructor(capacity: number);
  7352. /**
  7353. * Pushes a value at the end of the active data.
  7354. * @param value defines the object to push in the array.
  7355. */
  7356. push(value: T): void;
  7357. /**
  7358. * Iterates over the active data and apply the lambda to them.
  7359. * @param func defines the action to apply on each value.
  7360. */
  7361. forEach(func: (content: T) => void): void;
  7362. /**
  7363. * Sorts the full sets of data.
  7364. * @param compareFn defines the comparison function to apply.
  7365. */
  7366. sort(compareFn: (a: T, b: T) => number): void;
  7367. /**
  7368. * Resets the active data to an empty array.
  7369. */
  7370. reset(): void;
  7371. /**
  7372. * Releases all the data from the array as well as the array.
  7373. */
  7374. dispose(): void;
  7375. /**
  7376. * Concats the active data with a given array.
  7377. * @param array defines the data to concatenate with.
  7378. */
  7379. concat(array: any): void;
  7380. /**
  7381. * Returns the position of a value in the active data.
  7382. * @param value defines the value to find the index for
  7383. * @returns the index if found in the active data otherwise -1
  7384. */
  7385. indexOf(value: T): number;
  7386. /**
  7387. * Returns whether an element is part of the active data.
  7388. * @param value defines the value to look for
  7389. * @returns true if found in the active data otherwise false
  7390. */
  7391. contains(value: T): boolean;
  7392. private static _GlobalId;
  7393. }
  7394. /**
  7395. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7396. * The data in this array can only be present once
  7397. */
  7398. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7399. private _duplicateId;
  7400. /**
  7401. * Pushes a value at the end of the active data.
  7402. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7403. * @param value defines the object to push in the array.
  7404. */
  7405. push(value: T): void;
  7406. /**
  7407. * Pushes a value at the end of the active data.
  7408. * If the data is already present, it won t be added again
  7409. * @param value defines the object to push in the array.
  7410. * @returns true if added false if it was already present
  7411. */
  7412. pushNoDuplicate(value: T): boolean;
  7413. /**
  7414. * Resets the active data to an empty array.
  7415. */
  7416. reset(): void;
  7417. /**
  7418. * Concats the active data with a given array.
  7419. * This ensures no dupplicate will be present in the result.
  7420. * @param array defines the data to concatenate with.
  7421. */
  7422. concatWithNoDuplicate(array: any): void;
  7423. }
  7424. }
  7425. declare module BABYLON {
  7426. /**
  7427. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7428. * separate meshes. This can be use to improve performances.
  7429. * @see http://doc.babylonjs.com/how_to/multi_materials
  7430. */
  7431. export class MultiMaterial extends Material {
  7432. private _subMaterials;
  7433. /**
  7434. * Gets or Sets the list of Materials used within the multi material.
  7435. * They need to be ordered according to the submeshes order in the associated mesh
  7436. */
  7437. subMaterials: Nullable<Material>[];
  7438. /**
  7439. * Function used to align with Node.getChildren()
  7440. * @returns the list of Materials used within the multi material
  7441. */
  7442. getChildren(): Nullable<Material>[];
  7443. /**
  7444. * Instantiates a new Multi Material
  7445. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7446. * separate meshes. This can be use to improve performances.
  7447. * @see http://doc.babylonjs.com/how_to/multi_materials
  7448. * @param name Define the name in the scene
  7449. * @param scene Define the scene the material belongs to
  7450. */
  7451. constructor(name: string, scene: Scene);
  7452. private _hookArray;
  7453. /**
  7454. * Get one of the submaterial by its index in the submaterials array
  7455. * @param index The index to look the sub material at
  7456. * @returns The Material if the index has been defined
  7457. */
  7458. getSubMaterial(index: number): Nullable<Material>;
  7459. /**
  7460. * Get the list of active textures for the whole sub materials list.
  7461. * @returns All the textures that will be used during the rendering
  7462. */
  7463. getActiveTextures(): BaseTexture[];
  7464. /**
  7465. * Gets the current class name of the material e.g. "MultiMaterial"
  7466. * Mainly use in serialization.
  7467. * @returns the class name
  7468. */
  7469. getClassName(): string;
  7470. /**
  7471. * Checks if the material is ready to render the requested sub mesh
  7472. * @param mesh Define the mesh the submesh belongs to
  7473. * @param subMesh Define the sub mesh to look readyness for
  7474. * @param useInstances Define whether or not the material is used with instances
  7475. * @returns true if ready, otherwise false
  7476. */
  7477. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7478. /**
  7479. * Clones the current material and its related sub materials
  7480. * @param name Define the name of the newly cloned material
  7481. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7482. * @returns the cloned material
  7483. */
  7484. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7485. /**
  7486. * Serializes the materials into a JSON representation.
  7487. * @returns the JSON representation
  7488. */
  7489. serialize(): any;
  7490. /**
  7491. * Dispose the material and release its associated resources
  7492. * @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)
  7493. * @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)
  7494. * @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)
  7495. */
  7496. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7497. /**
  7498. * Creates a MultiMaterial from parsed MultiMaterial data.
  7499. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7500. * @param scene defines the hosting scene
  7501. * @returns a new MultiMaterial
  7502. */
  7503. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7504. }
  7505. }
  7506. declare module BABYLON {
  7507. /**
  7508. * Class used to represent data loading progression
  7509. */
  7510. export class SceneLoaderFlags {
  7511. private static _ForceFullSceneLoadingForIncremental;
  7512. private static _ShowLoadingScreen;
  7513. private static _CleanBoneMatrixWeights;
  7514. private static _loggingLevel;
  7515. /**
  7516. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7517. */
  7518. static ForceFullSceneLoadingForIncremental: boolean;
  7519. /**
  7520. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7521. */
  7522. static ShowLoadingScreen: boolean;
  7523. /**
  7524. * Defines the current logging level (while loading the scene)
  7525. * @ignorenaming
  7526. */
  7527. static loggingLevel: number;
  7528. /**
  7529. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7530. */
  7531. static CleanBoneMatrixWeights: boolean;
  7532. }
  7533. }
  7534. declare module BABYLON {
  7535. /**
  7536. * 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.
  7537. * @see https://doc.babylonjs.com/how_to/transformnode
  7538. */
  7539. export class TransformNode extends Node {
  7540. /**
  7541. * Object will not rotate to face the camera
  7542. */
  7543. static BILLBOARDMODE_NONE: number;
  7544. /**
  7545. * Object will rotate to face the camera but only on the x axis
  7546. */
  7547. static BILLBOARDMODE_X: number;
  7548. /**
  7549. * Object will rotate to face the camera but only on the y axis
  7550. */
  7551. static BILLBOARDMODE_Y: number;
  7552. /**
  7553. * Object will rotate to face the camera but only on the z axis
  7554. */
  7555. static BILLBOARDMODE_Z: number;
  7556. /**
  7557. * Object will rotate to face the camera
  7558. */
  7559. static BILLBOARDMODE_ALL: number;
  7560. private _forward;
  7561. private _forwardInverted;
  7562. private _up;
  7563. private _right;
  7564. private _rightInverted;
  7565. private _position;
  7566. private _rotation;
  7567. private _rotationQuaternion;
  7568. protected _scaling: Vector3;
  7569. protected _isDirty: boolean;
  7570. private _transformToBoneReferal;
  7571. private _billboardMode;
  7572. /**
  7573. * Gets or sets the billboard mode. Default is 0.
  7574. *
  7575. * | Value | Type | Description |
  7576. * | --- | --- | --- |
  7577. * | 0 | BILLBOARDMODE_NONE | |
  7578. * | 1 | BILLBOARDMODE_X | |
  7579. * | 2 | BILLBOARDMODE_Y | |
  7580. * | 4 | BILLBOARDMODE_Z | |
  7581. * | 7 | BILLBOARDMODE_ALL | |
  7582. *
  7583. */
  7584. billboardMode: number;
  7585. private _preserveParentRotationForBillboard;
  7586. /**
  7587. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  7588. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  7589. */
  7590. preserveParentRotationForBillboard: boolean;
  7591. /**
  7592. * 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
  7593. */
  7594. scalingDeterminant: number;
  7595. private _infiniteDistance;
  7596. /**
  7597. * Gets or sets the distance of the object to max, often used by skybox
  7598. */
  7599. infiniteDistance: boolean;
  7600. /**
  7601. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7602. * By default the system will update normals to compensate
  7603. */
  7604. ignoreNonUniformScaling: boolean;
  7605. /**
  7606. * 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
  7607. */
  7608. reIntegrateRotationIntoRotationQuaternion: boolean;
  7609. /** @hidden */
  7610. _poseMatrix: Nullable<Matrix>;
  7611. /** @hidden */
  7612. _localMatrix: Matrix;
  7613. private _usePivotMatrix;
  7614. private _absolutePosition;
  7615. private _pivotMatrix;
  7616. private _pivotMatrixInverse;
  7617. protected _postMultiplyPivotMatrix: boolean;
  7618. protected _isWorldMatrixFrozen: boolean;
  7619. /** @hidden */
  7620. _indexInSceneTransformNodesArray: number;
  7621. /**
  7622. * An event triggered after the world matrix is updated
  7623. */
  7624. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7625. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7626. /**
  7627. * Gets a string identifying the name of the class
  7628. * @returns "TransformNode" string
  7629. */
  7630. getClassName(): string;
  7631. /**
  7632. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7633. */
  7634. position: Vector3;
  7635. /**
  7636. * 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)).
  7637. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7638. */
  7639. rotation: Vector3;
  7640. /**
  7641. * 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)).
  7642. */
  7643. scaling: Vector3;
  7644. /**
  7645. * 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).
  7646. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7647. */
  7648. rotationQuaternion: Nullable<Quaternion>;
  7649. /**
  7650. * The forward direction of that transform in world space.
  7651. */
  7652. readonly forward: Vector3;
  7653. /**
  7654. * The up direction of that transform in world space.
  7655. */
  7656. readonly up: Vector3;
  7657. /**
  7658. * The right direction of that transform in world space.
  7659. */
  7660. readonly right: Vector3;
  7661. /**
  7662. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7663. * @param matrix the matrix to copy the pose from
  7664. * @returns this TransformNode.
  7665. */
  7666. updatePoseMatrix(matrix: Matrix): TransformNode;
  7667. /**
  7668. * Returns the mesh Pose matrix.
  7669. * @returns the pose matrix
  7670. */
  7671. getPoseMatrix(): Matrix;
  7672. /** @hidden */
  7673. _isSynchronized(): boolean;
  7674. /** @hidden */
  7675. _initCache(): void;
  7676. /**
  7677. * Flag the transform node as dirty (Forcing it to update everything)
  7678. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7679. * @returns this transform node
  7680. */
  7681. markAsDirty(property: string): TransformNode;
  7682. /**
  7683. * Returns the current mesh absolute position.
  7684. * Returns a Vector3.
  7685. */
  7686. readonly absolutePosition: Vector3;
  7687. /**
  7688. * Sets a new matrix to apply before all other transformation
  7689. * @param matrix defines the transform matrix
  7690. * @returns the current TransformNode
  7691. */
  7692. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7693. /**
  7694. * Sets a new pivot matrix to the current node
  7695. * @param matrix defines the new pivot matrix to use
  7696. * @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
  7697. * @returns the current TransformNode
  7698. */
  7699. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7700. /**
  7701. * Returns the mesh pivot matrix.
  7702. * Default : Identity.
  7703. * @returns the matrix
  7704. */
  7705. getPivotMatrix(): Matrix;
  7706. /**
  7707. * Prevents the World matrix to be computed any longer.
  7708. * @returns the TransformNode.
  7709. */
  7710. freezeWorldMatrix(): TransformNode;
  7711. /**
  7712. * Allows back the World matrix computation.
  7713. * @returns the TransformNode.
  7714. */
  7715. unfreezeWorldMatrix(): this;
  7716. /**
  7717. * True if the World matrix has been frozen.
  7718. */
  7719. readonly isWorldMatrixFrozen: boolean;
  7720. /**
  7721. * Retuns the mesh absolute position in the World.
  7722. * @returns a Vector3.
  7723. */
  7724. getAbsolutePosition(): Vector3;
  7725. /**
  7726. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7727. * @param absolutePosition the absolute position to set
  7728. * @returns the TransformNode.
  7729. */
  7730. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7731. /**
  7732. * Sets the mesh position in its local space.
  7733. * @param vector3 the position to set in localspace
  7734. * @returns the TransformNode.
  7735. */
  7736. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7737. /**
  7738. * Returns the mesh position in the local space from the current World matrix values.
  7739. * @returns a new Vector3.
  7740. */
  7741. getPositionExpressedInLocalSpace(): Vector3;
  7742. /**
  7743. * Translates the mesh along the passed Vector3 in its local space.
  7744. * @param vector3 the distance to translate in localspace
  7745. * @returns the TransformNode.
  7746. */
  7747. locallyTranslate(vector3: Vector3): TransformNode;
  7748. private static _lookAtVectorCache;
  7749. /**
  7750. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7751. * @param targetPoint the position (must be in same space as current mesh) to look at
  7752. * @param yawCor optional yaw (y-axis) correction in radians
  7753. * @param pitchCor optional pitch (x-axis) correction in radians
  7754. * @param rollCor optional roll (z-axis) correction in radians
  7755. * @param space the choosen space of the target
  7756. * @returns the TransformNode.
  7757. */
  7758. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7759. /**
  7760. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7761. * This Vector3 is expressed in the World space.
  7762. * @param localAxis axis to rotate
  7763. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7764. */
  7765. getDirection(localAxis: Vector3): Vector3;
  7766. /**
  7767. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7768. * localAxis is expressed in the mesh local space.
  7769. * result is computed in the Wordl space from the mesh World matrix.
  7770. * @param localAxis axis to rotate
  7771. * @param result the resulting transformnode
  7772. * @returns this TransformNode.
  7773. */
  7774. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7775. /**
  7776. * Sets this transform node rotation to the given local axis.
  7777. * @param localAxis the axis in local space
  7778. * @param yawCor optional yaw (y-axis) correction in radians
  7779. * @param pitchCor optional pitch (x-axis) correction in radians
  7780. * @param rollCor optional roll (z-axis) correction in radians
  7781. * @returns this TransformNode
  7782. */
  7783. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7784. /**
  7785. * Sets a new pivot point to the current node
  7786. * @param point defines the new pivot point to use
  7787. * @param space defines if the point is in world or local space (local by default)
  7788. * @returns the current TransformNode
  7789. */
  7790. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7791. /**
  7792. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7793. * @returns the pivot point
  7794. */
  7795. getPivotPoint(): Vector3;
  7796. /**
  7797. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7798. * @param result the vector3 to store the result
  7799. * @returns this TransformNode.
  7800. */
  7801. getPivotPointToRef(result: Vector3): TransformNode;
  7802. /**
  7803. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7804. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7805. */
  7806. getAbsolutePivotPoint(): Vector3;
  7807. /**
  7808. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7809. * @param result vector3 to store the result
  7810. * @returns this TransformNode.
  7811. */
  7812. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7813. /**
  7814. * Defines the passed node as the parent of the current node.
  7815. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7816. * @see https://doc.babylonjs.com/how_to/parenting
  7817. * @param node the node ot set as the parent
  7818. * @returns this TransformNode.
  7819. */
  7820. setParent(node: Nullable<Node>): TransformNode;
  7821. private _nonUniformScaling;
  7822. /**
  7823. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7824. */
  7825. readonly nonUniformScaling: boolean;
  7826. /** @hidden */
  7827. _updateNonUniformScalingState(value: boolean): boolean;
  7828. /**
  7829. * Attach the current TransformNode to another TransformNode associated with a bone
  7830. * @param bone Bone affecting the TransformNode
  7831. * @param affectedTransformNode TransformNode associated with the bone
  7832. * @returns this object
  7833. */
  7834. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7835. /**
  7836. * Detach the transform node if its associated with a bone
  7837. * @returns this object
  7838. */
  7839. detachFromBone(): TransformNode;
  7840. private static _rotationAxisCache;
  7841. /**
  7842. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7843. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7844. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7845. * The passed axis is also normalized.
  7846. * @param axis the axis to rotate around
  7847. * @param amount the amount to rotate in radians
  7848. * @param space Space to rotate in (Default: local)
  7849. * @returns the TransformNode.
  7850. */
  7851. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7852. /**
  7853. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7854. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7855. * The passed axis is also normalized. .
  7856. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7857. * @param point the point to rotate around
  7858. * @param axis the axis to rotate around
  7859. * @param amount the amount to rotate in radians
  7860. * @returns the TransformNode
  7861. */
  7862. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7863. /**
  7864. * Translates the mesh along the axis vector for the passed distance in the given space.
  7865. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7866. * @param axis the axis to translate in
  7867. * @param distance the distance to translate
  7868. * @param space Space to rotate in (Default: local)
  7869. * @returns the TransformNode.
  7870. */
  7871. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7872. /**
  7873. * Adds a rotation step to the mesh current rotation.
  7874. * x, y, z are Euler angles expressed in radians.
  7875. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7876. * This means this rotation is made in the mesh local space only.
  7877. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7878. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7879. * ```javascript
  7880. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7881. * ```
  7882. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7883. * 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.
  7884. * @param x Rotation to add
  7885. * @param y Rotation to add
  7886. * @param z Rotation to add
  7887. * @returns the TransformNode.
  7888. */
  7889. addRotation(x: number, y: number, z: number): TransformNode;
  7890. /**
  7891. * @hidden
  7892. */
  7893. protected _getEffectiveParent(): Nullable<Node>;
  7894. /**
  7895. * Computes the world matrix of the node
  7896. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7897. * @returns the world matrix
  7898. */
  7899. computeWorldMatrix(force?: boolean): Matrix;
  7900. protected _afterComputeWorldMatrix(): void;
  7901. /**
  7902. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7903. * @param func callback function to add
  7904. *
  7905. * @returns the TransformNode.
  7906. */
  7907. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7908. /**
  7909. * Removes a registered callback function.
  7910. * @param func callback function to remove
  7911. * @returns the TransformNode.
  7912. */
  7913. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7914. /**
  7915. * Gets the position of the current mesh in camera space
  7916. * @param camera defines the camera to use
  7917. * @returns a position
  7918. */
  7919. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7920. /**
  7921. * Returns the distance from the mesh to the active camera
  7922. * @param camera defines the camera to use
  7923. * @returns the distance
  7924. */
  7925. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7926. /**
  7927. * Clone the current transform node
  7928. * @param name Name of the new clone
  7929. * @param newParent New parent for the clone
  7930. * @param doNotCloneChildren Do not clone children hierarchy
  7931. * @returns the new transform node
  7932. */
  7933. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7934. /**
  7935. * Serializes the objects information.
  7936. * @param currentSerializationObject defines the object to serialize in
  7937. * @returns the serialized object
  7938. */
  7939. serialize(currentSerializationObject?: any): any;
  7940. /**
  7941. * Returns a new TransformNode object parsed from the source provided.
  7942. * @param parsedTransformNode is the source.
  7943. * @param scene the scne the object belongs to
  7944. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7945. * @returns a new TransformNode object parsed from the source provided.
  7946. */
  7947. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7948. /**
  7949. * Get all child-transformNodes of this node
  7950. * @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
  7951. * @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
  7952. * @returns an array of TransformNode
  7953. */
  7954. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7955. /**
  7956. * Releases resources associated with this transform node.
  7957. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7958. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7959. */
  7960. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7961. }
  7962. }
  7963. declare module BABYLON {
  7964. /**
  7965. * Class used to override all child animations of a given target
  7966. */
  7967. export class AnimationPropertiesOverride {
  7968. /**
  7969. * Gets or sets a value indicating if animation blending must be used
  7970. */
  7971. enableBlending: boolean;
  7972. /**
  7973. * Gets or sets the blending speed to use when enableBlending is true
  7974. */
  7975. blendingSpeed: number;
  7976. /**
  7977. * Gets or sets the default loop mode to use
  7978. */
  7979. loopMode: number;
  7980. }
  7981. }
  7982. declare module BABYLON {
  7983. /**
  7984. * Class used to store bone information
  7985. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  7986. */
  7987. export class Bone extends Node {
  7988. /**
  7989. * defines the bone name
  7990. */
  7991. name: string;
  7992. private static _tmpVecs;
  7993. private static _tmpQuat;
  7994. private static _tmpMats;
  7995. /**
  7996. * Gets the list of child bones
  7997. */
  7998. children: Bone[];
  7999. /** Gets the animations associated with this bone */
  8000. animations: Animation[];
  8001. /**
  8002. * Gets or sets bone length
  8003. */
  8004. length: number;
  8005. /**
  8006. * @hidden Internal only
  8007. * Set this value to map this bone to a different index in the transform matrices
  8008. * Set this value to -1 to exclude the bone from the transform matrices
  8009. */
  8010. _index: Nullable<number>;
  8011. private _skeleton;
  8012. private _localMatrix;
  8013. private _restPose;
  8014. private _baseMatrix;
  8015. private _absoluteTransform;
  8016. private _invertedAbsoluteTransform;
  8017. private _parent;
  8018. private _scalingDeterminant;
  8019. private _worldTransform;
  8020. private _localScaling;
  8021. private _localRotation;
  8022. private _localPosition;
  8023. private _needToDecompose;
  8024. private _needToCompose;
  8025. /** @hidden */
  8026. _linkedTransformNode: Nullable<TransformNode>;
  8027. /** @hidden */
  8028. _waitingTransformNodeId: Nullable<string>;
  8029. /** @hidden */
  8030. /** @hidden */
  8031. _matrix: Matrix;
  8032. /**
  8033. * Create a new bone
  8034. * @param name defines the bone name
  8035. * @param skeleton defines the parent skeleton
  8036. * @param parentBone defines the parent (can be null if the bone is the root)
  8037. * @param localMatrix defines the local matrix
  8038. * @param restPose defines the rest pose matrix
  8039. * @param baseMatrix defines the base matrix
  8040. * @param index defines index of the bone in the hiearchy
  8041. */
  8042. constructor(
  8043. /**
  8044. * defines the bone name
  8045. */
  8046. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  8047. /**
  8048. * Gets the current object class name.
  8049. * @return the class name
  8050. */
  8051. getClassName(): string;
  8052. /**
  8053. * Gets the parent skeleton
  8054. * @returns a skeleton
  8055. */
  8056. getSkeleton(): Skeleton;
  8057. /**
  8058. * Gets parent bone
  8059. * @returns a bone or null if the bone is the root of the bone hierarchy
  8060. */
  8061. getParent(): Nullable<Bone>;
  8062. /**
  8063. * Returns an array containing the root bones
  8064. * @returns an array containing the root bones
  8065. */
  8066. getChildren(): Array<Bone>;
  8067. /**
  8068. * Sets the parent bone
  8069. * @param parent defines the parent (can be null if the bone is the root)
  8070. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8071. */
  8072. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  8073. /**
  8074. * Gets the local matrix
  8075. * @returns a matrix
  8076. */
  8077. getLocalMatrix(): Matrix;
  8078. /**
  8079. * Gets the base matrix (initial matrix which remains unchanged)
  8080. * @returns a matrix
  8081. */
  8082. getBaseMatrix(): Matrix;
  8083. /**
  8084. * Gets the rest pose matrix
  8085. * @returns a matrix
  8086. */
  8087. getRestPose(): Matrix;
  8088. /**
  8089. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  8090. */
  8091. getWorldMatrix(): Matrix;
  8092. /**
  8093. * Sets the local matrix to rest pose matrix
  8094. */
  8095. returnToRest(): void;
  8096. /**
  8097. * Gets the inverse of the absolute transform matrix.
  8098. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  8099. * @returns a matrix
  8100. */
  8101. getInvertedAbsoluteTransform(): Matrix;
  8102. /**
  8103. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  8104. * @returns a matrix
  8105. */
  8106. getAbsoluteTransform(): Matrix;
  8107. /**
  8108. * Links with the given transform node.
  8109. * The local matrix of this bone is copied from the transform node every frame.
  8110. * @param transformNode defines the transform node to link to
  8111. */
  8112. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8113. /** Gets or sets current position (in local space) */
  8114. position: Vector3;
  8115. /** Gets or sets current rotation (in local space) */
  8116. rotation: Vector3;
  8117. /** Gets or sets current rotation quaternion (in local space) */
  8118. rotationQuaternion: Quaternion;
  8119. /** Gets or sets current scaling (in local space) */
  8120. scaling: Vector3;
  8121. /**
  8122. * Gets the animation properties override
  8123. */
  8124. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8125. private _decompose;
  8126. private _compose;
  8127. /**
  8128. * Update the base and local matrices
  8129. * @param matrix defines the new base or local matrix
  8130. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8131. * @param updateLocalMatrix defines if the local matrix should be updated
  8132. */
  8133. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8134. /** @hidden */
  8135. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8136. /**
  8137. * Flag the bone as dirty (Forcing it to update everything)
  8138. */
  8139. markAsDirty(): void;
  8140. private _markAsDirtyAndCompose;
  8141. private _markAsDirtyAndDecompose;
  8142. /**
  8143. * Translate the bone in local or world space
  8144. * @param vec The amount to translate the bone
  8145. * @param space The space that the translation is in
  8146. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8147. */
  8148. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8149. /**
  8150. * Set the postion of the bone in local or world space
  8151. * @param position The position to set the bone
  8152. * @param space The space that the position is in
  8153. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8154. */
  8155. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8156. /**
  8157. * Set the absolute position of the bone (world space)
  8158. * @param position The position to set the bone
  8159. * @param mesh The mesh that this bone is attached to
  8160. */
  8161. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8162. /**
  8163. * Scale the bone on the x, y and z axes (in local space)
  8164. * @param x The amount to scale the bone on the x axis
  8165. * @param y The amount to scale the bone on the y axis
  8166. * @param z The amount to scale the bone on the z axis
  8167. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8168. */
  8169. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8170. /**
  8171. * Set the bone scaling in local space
  8172. * @param scale defines the scaling vector
  8173. */
  8174. setScale(scale: Vector3): void;
  8175. /**
  8176. * Gets the current scaling in local space
  8177. * @returns the current scaling vector
  8178. */
  8179. getScale(): Vector3;
  8180. /**
  8181. * Gets the current scaling in local space and stores it in a target vector
  8182. * @param result defines the target vector
  8183. */
  8184. getScaleToRef(result: Vector3): void;
  8185. /**
  8186. * Set the yaw, pitch, and roll of the bone in local or world space
  8187. * @param yaw The rotation of the bone on the y axis
  8188. * @param pitch The rotation of the bone on the x axis
  8189. * @param roll The rotation of the bone on the z axis
  8190. * @param space The space that the axes of rotation are in
  8191. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8192. */
  8193. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8194. /**
  8195. * Add a rotation to the bone on an axis in local or world space
  8196. * @param axis The axis to rotate the bone on
  8197. * @param amount The amount to rotate the bone
  8198. * @param space The space that the axis is in
  8199. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8200. */
  8201. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8202. /**
  8203. * Set the rotation of the bone to a particular axis angle in local or world space
  8204. * @param axis The axis to rotate the bone on
  8205. * @param angle The angle that the bone should be rotated to
  8206. * @param space The space that the axis is in
  8207. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8208. */
  8209. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8210. /**
  8211. * Set the euler rotation of the bone in local of world space
  8212. * @param rotation The euler rotation that the bone should be set to
  8213. * @param space The space that the rotation is in
  8214. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8215. */
  8216. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8217. /**
  8218. * Set the quaternion rotation of the bone in local of world space
  8219. * @param quat The quaternion rotation that the bone should be set to
  8220. * @param space The space that the rotation is in
  8221. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8222. */
  8223. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8224. /**
  8225. * Set the rotation matrix of the bone in local of world space
  8226. * @param rotMat The rotation matrix that the bone should be set to
  8227. * @param space The space that the rotation is in
  8228. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8229. */
  8230. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8231. private _rotateWithMatrix;
  8232. private _getNegativeRotationToRef;
  8233. /**
  8234. * Get the position of the bone in local or world space
  8235. * @param space The space that the returned position is in
  8236. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8237. * @returns The position of the bone
  8238. */
  8239. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8240. /**
  8241. * Copy the position of the bone to a vector3 in local or world space
  8242. * @param space The space that the returned position is in
  8243. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8244. * @param result The vector3 to copy the position to
  8245. */
  8246. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8247. /**
  8248. * Get the absolute position of the bone (world space)
  8249. * @param mesh The mesh that this bone is attached to
  8250. * @returns The absolute position of the bone
  8251. */
  8252. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8253. /**
  8254. * Copy the absolute position of the bone (world space) to the result param
  8255. * @param mesh The mesh that this bone is attached to
  8256. * @param result The vector3 to copy the absolute position to
  8257. */
  8258. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8259. /**
  8260. * Compute the absolute transforms of this bone and its children
  8261. */
  8262. computeAbsoluteTransforms(): void;
  8263. /**
  8264. * Get the world direction from an axis that is in the local space of the bone
  8265. * @param localAxis The local direction that is used to compute the world direction
  8266. * @param mesh The mesh that this bone is attached to
  8267. * @returns The world direction
  8268. */
  8269. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8270. /**
  8271. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8272. * @param localAxis The local direction that is used to compute the world direction
  8273. * @param mesh The mesh that this bone is attached to
  8274. * @param result The vector3 that the world direction will be copied to
  8275. */
  8276. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8277. /**
  8278. * Get the euler rotation of the bone in local or world space
  8279. * @param space The space that the rotation should be in
  8280. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8281. * @returns The euler rotation
  8282. */
  8283. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8284. /**
  8285. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8286. * @param space The space that the rotation should be in
  8287. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8288. * @param result The vector3 that the rotation should be copied to
  8289. */
  8290. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8291. /**
  8292. * Get the quaternion rotation of the bone in either local or world space
  8293. * @param space The space that the rotation should be in
  8294. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8295. * @returns The quaternion rotation
  8296. */
  8297. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8298. /**
  8299. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8300. * @param space The space that the rotation should be in
  8301. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8302. * @param result The quaternion that the rotation should be copied to
  8303. */
  8304. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8305. /**
  8306. * Get the rotation matrix of the bone in local or world space
  8307. * @param space The space that the rotation should be in
  8308. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8309. * @returns The rotation matrix
  8310. */
  8311. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8312. /**
  8313. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8314. * @param space The space that the rotation should be in
  8315. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8316. * @param result The quaternion that the rotation should be copied to
  8317. */
  8318. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8319. /**
  8320. * Get the world position of a point that is in the local space of the bone
  8321. * @param position The local position
  8322. * @param mesh The mesh that this bone is attached to
  8323. * @returns The world position
  8324. */
  8325. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8326. /**
  8327. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8328. * @param position The local position
  8329. * @param mesh The mesh that this bone is attached to
  8330. * @param result The vector3 that the world position should be copied to
  8331. */
  8332. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8333. /**
  8334. * Get the local position of a point that is in world space
  8335. * @param position The world position
  8336. * @param mesh The mesh that this bone is attached to
  8337. * @returns The local position
  8338. */
  8339. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8340. /**
  8341. * Get the local position of a point that is in world space and copy it to the result param
  8342. * @param position The world position
  8343. * @param mesh The mesh that this bone is attached to
  8344. * @param result The vector3 that the local position should be copied to
  8345. */
  8346. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8347. }
  8348. }
  8349. declare module BABYLON {
  8350. /**
  8351. * Enum that determines the text-wrapping mode to use.
  8352. */
  8353. export enum InspectableType {
  8354. /**
  8355. * Checkbox for booleans
  8356. */
  8357. Checkbox = 0,
  8358. /**
  8359. * Sliders for numbers
  8360. */
  8361. Slider = 1,
  8362. /**
  8363. * Vector3
  8364. */
  8365. Vector3 = 2,
  8366. /**
  8367. * Quaternions
  8368. */
  8369. Quaternion = 3,
  8370. /**
  8371. * Color3
  8372. */
  8373. Color3 = 4
  8374. }
  8375. /**
  8376. * Interface used to define custom inspectable properties.
  8377. * This interface is used by the inspector to display custom property grids
  8378. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8379. */
  8380. export interface IInspectable {
  8381. /**
  8382. * Gets the label to display
  8383. */
  8384. label: string;
  8385. /**
  8386. * Gets the name of the property to edit
  8387. */
  8388. propertyName: string;
  8389. /**
  8390. * Gets the type of the editor to use
  8391. */
  8392. type: InspectableType;
  8393. /**
  8394. * Gets the minimum value of the property when using in "slider" mode
  8395. */
  8396. min?: number;
  8397. /**
  8398. * Gets the maximum value of the property when using in "slider" mode
  8399. */
  8400. max?: number;
  8401. /**
  8402. * Gets the setp to use when using in "slider" mode
  8403. */
  8404. step?: number;
  8405. }
  8406. }
  8407. declare module BABYLON {
  8408. /**
  8409. * This represents the required contract to create a new type of texture loader.
  8410. */
  8411. export interface IInternalTextureLoader {
  8412. /**
  8413. * Defines wether the loader supports cascade loading the different faces.
  8414. */
  8415. supportCascades: boolean;
  8416. /**
  8417. * This returns if the loader support the current file information.
  8418. * @param extension defines the file extension of the file being loaded
  8419. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8420. * @param fallback defines the fallback internal texture if any
  8421. * @param isBase64 defines whether the texture is encoded as a base64
  8422. * @param isBuffer defines whether the texture data are stored as a buffer
  8423. * @returns true if the loader can load the specified file
  8424. */
  8425. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  8426. /**
  8427. * Transform the url before loading if required.
  8428. * @param rootUrl the url of the texture
  8429. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8430. * @returns the transformed texture
  8431. */
  8432. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  8433. /**
  8434. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  8435. * @param rootUrl the url of the texture
  8436. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8437. * @returns the fallback texture
  8438. */
  8439. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  8440. /**
  8441. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  8442. * @param data contains the texture data
  8443. * @param texture defines the BabylonJS internal texture
  8444. * @param createPolynomials will be true if polynomials have been requested
  8445. * @param onLoad defines the callback to trigger once the texture is ready
  8446. * @param onError defines the callback to trigger in case of error
  8447. */
  8448. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  8449. /**
  8450. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  8451. * @param data contains the texture data
  8452. * @param texture defines the BabylonJS internal texture
  8453. * @param callback defines the method to call once ready to upload
  8454. */
  8455. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  8456. }
  8457. }
  8458. declare module BABYLON {
  8459. interface Engine {
  8460. /**
  8461. * Creates a depth stencil cube texture.
  8462. * This is only available in WebGL 2.
  8463. * @param size The size of face edge in the cube texture.
  8464. * @param options The options defining the cube texture.
  8465. * @returns The cube texture
  8466. */
  8467. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  8468. /**
  8469. * Creates a cube texture
  8470. * @param rootUrl defines the url where the files to load is located
  8471. * @param scene defines the current scene
  8472. * @param files defines the list of files to load (1 per face)
  8473. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8474. * @param onLoad defines an optional callback raised when the texture is loaded
  8475. * @param onError defines an optional callback raised if there is an issue to load the texture
  8476. * @param format defines the format of the data
  8477. * @param forcedExtension defines the extension to use to pick the right loader
  8478. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8479. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8480. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8481. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  8482. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  8483. * @returns the cube texture as an InternalTexture
  8484. */
  8485. 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;
  8486. /**
  8487. * Creates a cube texture
  8488. * @param rootUrl defines the url where the files to load is located
  8489. * @param scene defines the current scene
  8490. * @param files defines the list of files to load (1 per face)
  8491. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8492. * @param onLoad defines an optional callback raised when the texture is loaded
  8493. * @param onError defines an optional callback raised if there is an issue to load the texture
  8494. * @param format defines the format of the data
  8495. * @param forcedExtension defines the extension to use to pick the right loader
  8496. * @returns the cube texture as an InternalTexture
  8497. */
  8498. 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;
  8499. /**
  8500. * Creates a cube texture
  8501. * @param rootUrl defines the url where the files to load is located
  8502. * @param scene defines the current scene
  8503. * @param files defines the list of files to load (1 per face)
  8504. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8505. * @param onLoad defines an optional callback raised when the texture is loaded
  8506. * @param onError defines an optional callback raised if there is an issue to load the texture
  8507. * @param format defines the format of the data
  8508. * @param forcedExtension defines the extension to use to pick the right loader
  8509. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8510. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8511. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8512. * @returns the cube texture as an InternalTexture
  8513. */
  8514. 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;
  8515. /** @hidden */
  8516. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8517. /** @hidden */
  8518. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8519. /** @hidden */
  8520. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8521. /** @hidden */
  8522. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8523. }
  8524. }
  8525. declare module BABYLON {
  8526. /**
  8527. * Class for creating a cube texture
  8528. */
  8529. export class CubeTexture extends BaseTexture {
  8530. private _delayedOnLoad;
  8531. /**
  8532. * The url of the texture
  8533. */
  8534. url: string;
  8535. /**
  8536. * Gets or sets the center of the bounding box associated with the cube texture.
  8537. * It must define where the camera used to render the texture was set
  8538. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8539. */
  8540. boundingBoxPosition: Vector3;
  8541. private _boundingBoxSize;
  8542. /**
  8543. * Gets or sets the size of the bounding box associated with the cube texture
  8544. * When defined, the cubemap will switch to local mode
  8545. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8546. * @example https://www.babylonjs-playground.com/#RNASML
  8547. */
  8548. /**
  8549. * Returns the bounding box size
  8550. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8551. */
  8552. boundingBoxSize: Vector3;
  8553. protected _rotationY: number;
  8554. /**
  8555. * Sets texture matrix rotation angle around Y axis in radians.
  8556. */
  8557. /**
  8558. * Gets texture matrix rotation angle around Y axis radians.
  8559. */
  8560. rotationY: number;
  8561. /**
  8562. * Are mip maps generated for this texture or not.
  8563. */
  8564. readonly noMipmap: boolean;
  8565. private _noMipmap;
  8566. private _files;
  8567. private _extensions;
  8568. private _textureMatrix;
  8569. private _format;
  8570. private _createPolynomials;
  8571. /** @hidden */
  8572. _prefiltered: boolean;
  8573. /**
  8574. * Creates a cube texture from an array of image urls
  8575. * @param files defines an array of image urls
  8576. * @param scene defines the hosting scene
  8577. * @param noMipmap specifies if mip maps are not used
  8578. * @returns a cube texture
  8579. */
  8580. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8581. /**
  8582. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8583. * @param url defines the url of the prefiltered texture
  8584. * @param scene defines the scene the texture is attached to
  8585. * @param forcedExtension defines the extension of the file if different from the url
  8586. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8587. * @return the prefiltered texture
  8588. */
  8589. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8590. /**
  8591. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8592. * as prefiltered data.
  8593. * @param rootUrl defines the url of the texture or the root name of the six images
  8594. * @param scene defines the scene the texture is attached to
  8595. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8596. * @param noMipmap defines if mipmaps should be created or not
  8597. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8598. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8599. * @param onError defines a callback triggered in case of error during load
  8600. * @param format defines the internal format to use for the texture once loaded
  8601. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8602. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8603. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8604. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8605. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8606. * @return the cube texture
  8607. */
  8608. 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);
  8609. /**
  8610. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  8611. */
  8612. readonly isPrefiltered: boolean;
  8613. /**
  8614. * Get the current class name of the texture useful for serialization or dynamic coding.
  8615. * @returns "CubeTexture"
  8616. */
  8617. getClassName(): string;
  8618. /**
  8619. * Update the url (and optional buffer) of this texture if url was null during construction.
  8620. * @param url the url of the texture
  8621. * @param forcedExtension defines the extension to use
  8622. * @param onLoad callback called when the texture is loaded (defaults to null)
  8623. */
  8624. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8625. /**
  8626. * Delays loading of the cube texture
  8627. * @param forcedExtension defines the extension to use
  8628. */
  8629. delayLoad(forcedExtension?: string): void;
  8630. /**
  8631. * Returns the reflection texture matrix
  8632. * @returns the reflection texture matrix
  8633. */
  8634. getReflectionTextureMatrix(): Matrix;
  8635. /**
  8636. * Sets the reflection texture matrix
  8637. * @param value Reflection texture matrix
  8638. */
  8639. setReflectionTextureMatrix(value: Matrix): void;
  8640. /**
  8641. * Parses text to create a cube texture
  8642. * @param parsedTexture define the serialized text to read from
  8643. * @param scene defines the hosting scene
  8644. * @param rootUrl defines the root url of the cube texture
  8645. * @returns a cube texture
  8646. */
  8647. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8648. /**
  8649. * Makes a clone, or deep copy, of the cube texture
  8650. * @returns a new cube texture
  8651. */
  8652. clone(): CubeTexture;
  8653. }
  8654. }
  8655. declare module BABYLON {
  8656. /** @hidden */
  8657. export var postprocessVertexShader: {
  8658. name: string;
  8659. shader: string;
  8660. };
  8661. }
  8662. declare module BABYLON {
  8663. /**
  8664. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8665. * This is the base of the follow, arc rotate cameras and Free camera
  8666. * @see http://doc.babylonjs.com/features/cameras
  8667. */
  8668. export class TargetCamera extends Camera {
  8669. private static _RigCamTransformMatrix;
  8670. private static _TargetTransformMatrix;
  8671. private static _TargetFocalPoint;
  8672. /**
  8673. * Define the current direction the camera is moving to
  8674. */
  8675. cameraDirection: Vector3;
  8676. /**
  8677. * Define the current rotation the camera is rotating to
  8678. */
  8679. cameraRotation: Vector2;
  8680. /**
  8681. * When set, the up vector of the camera will be updated by the rotation of the camera
  8682. */
  8683. updateUpVectorFromRotation: boolean;
  8684. private _tmpQuaternion;
  8685. /**
  8686. * Define the current rotation of the camera
  8687. */
  8688. rotation: Vector3;
  8689. /**
  8690. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8691. */
  8692. rotationQuaternion: Quaternion;
  8693. /**
  8694. * Define the current speed of the camera
  8695. */
  8696. speed: number;
  8697. /**
  8698. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8699. * around all axis.
  8700. */
  8701. noRotationConstraint: boolean;
  8702. /**
  8703. * Define the current target of the camera as an object or a position.
  8704. */
  8705. lockedTarget: any;
  8706. /** @hidden */
  8707. _currentTarget: Vector3;
  8708. /** @hidden */
  8709. _initialFocalDistance: number;
  8710. /** @hidden */
  8711. _viewMatrix: Matrix;
  8712. /** @hidden */
  8713. _camMatrix: Matrix;
  8714. /** @hidden */
  8715. _cameraTransformMatrix: Matrix;
  8716. /** @hidden */
  8717. _cameraRotationMatrix: Matrix;
  8718. /** @hidden */
  8719. _referencePoint: Vector3;
  8720. /** @hidden */
  8721. _transformedReferencePoint: Vector3;
  8722. protected _globalCurrentTarget: Vector3;
  8723. protected _globalCurrentUpVector: Vector3;
  8724. /** @hidden */
  8725. _reset: () => void;
  8726. private _defaultUp;
  8727. /**
  8728. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8729. * This is the base of the follow, arc rotate cameras and Free camera
  8730. * @see http://doc.babylonjs.com/features/cameras
  8731. * @param name Defines the name of the camera in the scene
  8732. * @param position Defines the start position of the camera in the scene
  8733. * @param scene Defines the scene the camera belongs to
  8734. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8735. */
  8736. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8737. /**
  8738. * Gets the position in front of the camera at a given distance.
  8739. * @param distance The distance from the camera we want the position to be
  8740. * @returns the position
  8741. */
  8742. getFrontPosition(distance: number): Vector3;
  8743. /** @hidden */
  8744. _getLockedTargetPosition(): Nullable<Vector3>;
  8745. private _storedPosition;
  8746. private _storedRotation;
  8747. private _storedRotationQuaternion;
  8748. /**
  8749. * Store current camera state of the camera (fov, position, rotation, etc..)
  8750. * @returns the camera
  8751. */
  8752. storeState(): Camera;
  8753. /**
  8754. * Restored camera state. You must call storeState() first
  8755. * @returns whether it was successful or not
  8756. * @hidden
  8757. */
  8758. _restoreStateValues(): boolean;
  8759. /** @hidden */
  8760. _initCache(): void;
  8761. /** @hidden */
  8762. _updateCache(ignoreParentClass?: boolean): void;
  8763. /** @hidden */
  8764. _isSynchronizedViewMatrix(): boolean;
  8765. /** @hidden */
  8766. _computeLocalCameraSpeed(): number;
  8767. /**
  8768. * Defines the target the camera should look at.
  8769. * This will automatically adapt alpha beta and radius to fit within the new target.
  8770. * @param target Defines the new target as a Vector or a mesh
  8771. */
  8772. setTarget(target: Vector3): void;
  8773. /**
  8774. * Return the current target position of the camera. This value is expressed in local space.
  8775. * @returns the target position
  8776. */
  8777. getTarget(): Vector3;
  8778. /** @hidden */
  8779. _decideIfNeedsToMove(): boolean;
  8780. /** @hidden */
  8781. _updatePosition(): void;
  8782. /** @hidden */
  8783. _checkInputs(): void;
  8784. protected _updateCameraRotationMatrix(): void;
  8785. /**
  8786. * 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)
  8787. * @returns the current camera
  8788. */
  8789. private _rotateUpVectorWithCameraRotationMatrix;
  8790. private _cachedRotationZ;
  8791. private _cachedQuaternionRotationZ;
  8792. /** @hidden */
  8793. _getViewMatrix(): Matrix;
  8794. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8795. /**
  8796. * @hidden
  8797. */
  8798. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8799. /**
  8800. * @hidden
  8801. */
  8802. _updateRigCameras(): void;
  8803. private _getRigCamPositionAndTarget;
  8804. /**
  8805. * Gets the current object class name.
  8806. * @return the class name
  8807. */
  8808. getClassName(): string;
  8809. }
  8810. }
  8811. declare module BABYLON {
  8812. /**
  8813. * @ignore
  8814. * This is a list of all the different input types that are available in the application.
  8815. * Fo instance: ArcRotateCameraGamepadInput...
  8816. */
  8817. export var CameraInputTypes: {};
  8818. /**
  8819. * This is the contract to implement in order to create a new input class.
  8820. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8821. */
  8822. export interface ICameraInput<TCamera extends Camera> {
  8823. /**
  8824. * Defines the camera the input is attached to.
  8825. */
  8826. camera: Nullable<TCamera>;
  8827. /**
  8828. * Gets the class name of the current intput.
  8829. * @returns the class name
  8830. */
  8831. getClassName(): string;
  8832. /**
  8833. * Get the friendly name associated with the input class.
  8834. * @returns the input friendly name
  8835. */
  8836. getSimpleName(): string;
  8837. /**
  8838. * Attach the input controls to a specific dom element to get the input from.
  8839. * @param element Defines the element the controls should be listened from
  8840. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8841. */
  8842. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8843. /**
  8844. * Detach the current controls from the specified dom element.
  8845. * @param element Defines the element to stop listening the inputs from
  8846. */
  8847. detachControl(element: Nullable<HTMLElement>): void;
  8848. /**
  8849. * Update the current camera state depending on the inputs that have been used this frame.
  8850. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8851. */
  8852. checkInputs?: () => void;
  8853. }
  8854. /**
  8855. * Represents a map of input types to input instance or input index to input instance.
  8856. */
  8857. export interface CameraInputsMap<TCamera extends Camera> {
  8858. /**
  8859. * Accessor to the input by input type.
  8860. */
  8861. [name: string]: ICameraInput<TCamera>;
  8862. /**
  8863. * Accessor to the input by input index.
  8864. */
  8865. [idx: number]: ICameraInput<TCamera>;
  8866. }
  8867. /**
  8868. * This represents the input manager used within a camera.
  8869. * It helps dealing with all the different kind of input attached to a camera.
  8870. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8871. */
  8872. export class CameraInputsManager<TCamera extends Camera> {
  8873. /**
  8874. * Defines the list of inputs attahed to the camera.
  8875. */
  8876. attached: CameraInputsMap<TCamera>;
  8877. /**
  8878. * Defines the dom element the camera is collecting inputs from.
  8879. * This is null if the controls have not been attached.
  8880. */
  8881. attachedElement: Nullable<HTMLElement>;
  8882. /**
  8883. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8884. */
  8885. noPreventDefault: boolean;
  8886. /**
  8887. * Defined the camera the input manager belongs to.
  8888. */
  8889. camera: TCamera;
  8890. /**
  8891. * Update the current camera state depending on the inputs that have been used this frame.
  8892. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8893. */
  8894. checkInputs: () => void;
  8895. /**
  8896. * Instantiate a new Camera Input Manager.
  8897. * @param camera Defines the camera the input manager blongs to
  8898. */
  8899. constructor(camera: TCamera);
  8900. /**
  8901. * Add an input method to a camera
  8902. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8903. * @param input camera input method
  8904. */
  8905. add(input: ICameraInput<TCamera>): void;
  8906. /**
  8907. * Remove a specific input method from a camera
  8908. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8909. * @param inputToRemove camera input method
  8910. */
  8911. remove(inputToRemove: ICameraInput<TCamera>): void;
  8912. /**
  8913. * Remove a specific input type from a camera
  8914. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8915. * @param inputType the type of the input to remove
  8916. */
  8917. removeByType(inputType: string): void;
  8918. private _addCheckInputs;
  8919. /**
  8920. * Attach the input controls to the currently attached dom element to listen the events from.
  8921. * @param input Defines the input to attach
  8922. */
  8923. attachInput(input: ICameraInput<TCamera>): void;
  8924. /**
  8925. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8926. * @param element Defines the dom element to collect the events from
  8927. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8928. */
  8929. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8930. /**
  8931. * Detach the current manager inputs controls from a specific dom element.
  8932. * @param element Defines the dom element to collect the events from
  8933. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8934. */
  8935. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8936. /**
  8937. * Rebuild the dynamic inputCheck function from the current list of
  8938. * defined inputs in the manager.
  8939. */
  8940. rebuildInputCheck(): void;
  8941. /**
  8942. * Remove all attached input methods from a camera
  8943. */
  8944. clear(): void;
  8945. /**
  8946. * Serialize the current input manager attached to a camera.
  8947. * This ensures than once parsed,
  8948. * the input associated to the camera will be identical to the current ones
  8949. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8950. */
  8951. serialize(serializedCamera: any): void;
  8952. /**
  8953. * Parses an input manager serialized JSON to restore the previous list of inputs
  8954. * and states associated to a camera.
  8955. * @param parsedCamera Defines the JSON to parse
  8956. */
  8957. parse(parsedCamera: any): void;
  8958. }
  8959. }
  8960. declare module BABYLON {
  8961. /**
  8962. * Gather the list of keyboard event types as constants.
  8963. */
  8964. export class KeyboardEventTypes {
  8965. /**
  8966. * The keydown event is fired when a key becomes active (pressed).
  8967. */
  8968. static readonly KEYDOWN: number;
  8969. /**
  8970. * The keyup event is fired when a key has been released.
  8971. */
  8972. static readonly KEYUP: number;
  8973. }
  8974. /**
  8975. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8976. */
  8977. export class KeyboardInfo {
  8978. /**
  8979. * Defines the type of event (KeyboardEventTypes)
  8980. */
  8981. type: number;
  8982. /**
  8983. * Defines the related dom event
  8984. */
  8985. event: KeyboardEvent;
  8986. /**
  8987. * Instantiates a new keyboard info.
  8988. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8989. * @param type Defines the type of event (KeyboardEventTypes)
  8990. * @param event Defines the related dom event
  8991. */
  8992. constructor(
  8993. /**
  8994. * Defines the type of event (KeyboardEventTypes)
  8995. */
  8996. type: number,
  8997. /**
  8998. * Defines the related dom event
  8999. */
  9000. event: KeyboardEvent);
  9001. }
  9002. /**
  9003. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9004. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9005. */
  9006. export class KeyboardInfoPre extends KeyboardInfo {
  9007. /**
  9008. * Defines the type of event (KeyboardEventTypes)
  9009. */
  9010. type: number;
  9011. /**
  9012. * Defines the related dom event
  9013. */
  9014. event: KeyboardEvent;
  9015. /**
  9016. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  9017. */
  9018. skipOnPointerObservable: boolean;
  9019. /**
  9020. * Instantiates a new keyboard pre info.
  9021. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9022. * @param type Defines the type of event (KeyboardEventTypes)
  9023. * @param event Defines the related dom event
  9024. */
  9025. constructor(
  9026. /**
  9027. * Defines the type of event (KeyboardEventTypes)
  9028. */
  9029. type: number,
  9030. /**
  9031. * Defines the related dom event
  9032. */
  9033. event: KeyboardEvent);
  9034. }
  9035. }
  9036. declare module BABYLON {
  9037. /**
  9038. * Manage the keyboard inputs to control the movement of a free camera.
  9039. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  9040. */
  9041. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  9042. /**
  9043. * Defines the camera the input is attached to.
  9044. */
  9045. camera: FreeCamera;
  9046. /**
  9047. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  9048. */
  9049. keysUp: number[];
  9050. /**
  9051. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  9052. */
  9053. keysDown: number[];
  9054. /**
  9055. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  9056. */
  9057. keysLeft: number[];
  9058. /**
  9059. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  9060. */
  9061. keysRight: number[];
  9062. private _keys;
  9063. private _onCanvasBlurObserver;
  9064. private _onKeyboardObserver;
  9065. private _engine;
  9066. private _scene;
  9067. /**
  9068. * Attach the input controls to a specific dom element to get the input from.
  9069. * @param element Defines the element the controls should be listened from
  9070. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9071. */
  9072. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  9073. /**
  9074. * Detach the current controls from the specified dom element.
  9075. * @param element Defines the element to stop listening the inputs from
  9076. */
  9077. detachControl(element: Nullable<HTMLElement>): void;
  9078. /**
  9079. * Update the current camera state depending on the inputs that have been used this frame.
  9080. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9081. */
  9082. checkInputs(): void;
  9083. /**
  9084. * Gets the class name of the current intput.
  9085. * @returns the class name
  9086. */
  9087. getClassName(): string;
  9088. /** @hidden */
  9089. _onLostFocus(): void;
  9090. /**
  9091. * Get the friendly name associated with the input class.
  9092. * @returns the input friendly name
  9093. */
  9094. getSimpleName(): string;
  9095. }
  9096. }
  9097. declare module BABYLON {
  9098. /**
  9099. * Interface describing all the common properties and methods a shadow light needs to implement.
  9100. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9101. * as well as binding the different shadow properties to the effects.
  9102. */
  9103. export interface IShadowLight extends Light {
  9104. /**
  9105. * The light id in the scene (used in scene.findLighById for instance)
  9106. */
  9107. id: string;
  9108. /**
  9109. * The position the shdow will be casted from.
  9110. */
  9111. position: Vector3;
  9112. /**
  9113. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9114. */
  9115. direction: Vector3;
  9116. /**
  9117. * The transformed position. Position of the light in world space taking parenting in account.
  9118. */
  9119. transformedPosition: Vector3;
  9120. /**
  9121. * The transformed direction. Direction of the light in world space taking parenting in account.
  9122. */
  9123. transformedDirection: Vector3;
  9124. /**
  9125. * The friendly name of the light in the scene.
  9126. */
  9127. name: string;
  9128. /**
  9129. * Defines the shadow projection clipping minimum z value.
  9130. */
  9131. shadowMinZ: number;
  9132. /**
  9133. * Defines the shadow projection clipping maximum z value.
  9134. */
  9135. shadowMaxZ: number;
  9136. /**
  9137. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9138. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9139. */
  9140. computeTransformedInformation(): boolean;
  9141. /**
  9142. * Gets the scene the light belongs to.
  9143. * @returns The scene
  9144. */
  9145. getScene(): Scene;
  9146. /**
  9147. * Callback defining a custom Projection Matrix Builder.
  9148. * This can be used to override the default projection matrix computation.
  9149. */
  9150. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9151. /**
  9152. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9153. * @param matrix The materix to updated with the projection information
  9154. * @param viewMatrix The transform matrix of the light
  9155. * @param renderList The list of mesh to render in the map
  9156. * @returns The current light
  9157. */
  9158. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9159. /**
  9160. * Gets the current depth scale used in ESM.
  9161. * @returns The scale
  9162. */
  9163. getDepthScale(): number;
  9164. /**
  9165. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9166. * @returns true if a cube texture needs to be use
  9167. */
  9168. needCube(): boolean;
  9169. /**
  9170. * Detects if the projection matrix requires to be recomputed this frame.
  9171. * @returns true if it requires to be recomputed otherwise, false.
  9172. */
  9173. needProjectionMatrixCompute(): boolean;
  9174. /**
  9175. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9176. */
  9177. forceProjectionMatrixCompute(): void;
  9178. /**
  9179. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9180. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9181. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9182. */
  9183. getShadowDirection(faceIndex?: number): Vector3;
  9184. /**
  9185. * Gets the minZ used for shadow according to both the scene and the light.
  9186. * @param activeCamera The camera we are returning the min for
  9187. * @returns the depth min z
  9188. */
  9189. getDepthMinZ(activeCamera: Camera): number;
  9190. /**
  9191. * Gets the maxZ used for shadow according to both the scene and the light.
  9192. * @param activeCamera The camera we are returning the max for
  9193. * @returns the depth max z
  9194. */
  9195. getDepthMaxZ(activeCamera: Camera): number;
  9196. }
  9197. /**
  9198. * Base implementation IShadowLight
  9199. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9200. */
  9201. export abstract class ShadowLight extends Light implements IShadowLight {
  9202. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9203. protected _position: Vector3;
  9204. protected _setPosition(value: Vector3): void;
  9205. /**
  9206. * Sets the position the shadow will be casted from. Also use as the light position for both
  9207. * point and spot lights.
  9208. */
  9209. /**
  9210. * Sets the position the shadow will be casted from. Also use as the light position for both
  9211. * point and spot lights.
  9212. */
  9213. position: Vector3;
  9214. protected _direction: Vector3;
  9215. protected _setDirection(value: Vector3): void;
  9216. /**
  9217. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9218. * Also use as the light direction on spot and directional lights.
  9219. */
  9220. /**
  9221. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9222. * Also use as the light direction on spot and directional lights.
  9223. */
  9224. direction: Vector3;
  9225. private _shadowMinZ;
  9226. /**
  9227. * Gets the shadow projection clipping minimum z value.
  9228. */
  9229. /**
  9230. * Sets the shadow projection clipping minimum z value.
  9231. */
  9232. shadowMinZ: number;
  9233. private _shadowMaxZ;
  9234. /**
  9235. * Sets the shadow projection clipping maximum z value.
  9236. */
  9237. /**
  9238. * Gets the shadow projection clipping maximum z value.
  9239. */
  9240. shadowMaxZ: number;
  9241. /**
  9242. * Callback defining a custom Projection Matrix Builder.
  9243. * This can be used to override the default projection matrix computation.
  9244. */
  9245. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9246. /**
  9247. * The transformed position. Position of the light in world space taking parenting in account.
  9248. */
  9249. transformedPosition: Vector3;
  9250. /**
  9251. * The transformed direction. Direction of the light in world space taking parenting in account.
  9252. */
  9253. transformedDirection: Vector3;
  9254. private _needProjectionMatrixCompute;
  9255. /**
  9256. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9257. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9258. */
  9259. computeTransformedInformation(): boolean;
  9260. /**
  9261. * Return the depth scale used for the shadow map.
  9262. * @returns the depth scale.
  9263. */
  9264. getDepthScale(): number;
  9265. /**
  9266. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9267. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9268. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9269. */
  9270. getShadowDirection(faceIndex?: number): Vector3;
  9271. /**
  9272. * Returns the ShadowLight absolute position in the World.
  9273. * @returns the position vector in world space
  9274. */
  9275. getAbsolutePosition(): Vector3;
  9276. /**
  9277. * Sets the ShadowLight direction toward the passed target.
  9278. * @param target The point to target in local space
  9279. * @returns the updated ShadowLight direction
  9280. */
  9281. setDirectionToTarget(target: Vector3): Vector3;
  9282. /**
  9283. * Returns the light rotation in euler definition.
  9284. * @returns the x y z rotation in local space.
  9285. */
  9286. getRotation(): Vector3;
  9287. /**
  9288. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9289. * @returns true if a cube texture needs to be use
  9290. */
  9291. needCube(): boolean;
  9292. /**
  9293. * Detects if the projection matrix requires to be recomputed this frame.
  9294. * @returns true if it requires to be recomputed otherwise, false.
  9295. */
  9296. needProjectionMatrixCompute(): boolean;
  9297. /**
  9298. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9299. */
  9300. forceProjectionMatrixCompute(): void;
  9301. /** @hidden */
  9302. _initCache(): void;
  9303. /** @hidden */
  9304. _isSynchronized(): boolean;
  9305. /**
  9306. * Computes the world matrix of the node
  9307. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9308. * @returns the world matrix
  9309. */
  9310. computeWorldMatrix(force?: boolean): Matrix;
  9311. /**
  9312. * Gets the minZ used for shadow according to both the scene and the light.
  9313. * @param activeCamera The camera we are returning the min for
  9314. * @returns the depth min z
  9315. */
  9316. getDepthMinZ(activeCamera: Camera): number;
  9317. /**
  9318. * Gets the maxZ used for shadow according to both the scene and the light.
  9319. * @param activeCamera The camera we are returning the max for
  9320. * @returns the depth max z
  9321. */
  9322. getDepthMaxZ(activeCamera: Camera): number;
  9323. /**
  9324. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9325. * @param matrix The materix to updated with the projection information
  9326. * @param viewMatrix The transform matrix of the light
  9327. * @param renderList The list of mesh to render in the map
  9328. * @returns The current light
  9329. */
  9330. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9331. }
  9332. }
  9333. declare module BABYLON {
  9334. /**
  9335. * "Static Class" containing the most commonly used helper while dealing with material for
  9336. * rendering purpose.
  9337. *
  9338. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9339. *
  9340. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9341. */
  9342. export class MaterialHelper {
  9343. /**
  9344. * Bind the current view position to an effect.
  9345. * @param effect The effect to be bound
  9346. * @param scene The scene the eyes position is used from
  9347. */
  9348. static BindEyePosition(effect: Effect, scene: Scene): void;
  9349. /**
  9350. * Helps preparing the defines values about the UVs in used in the effect.
  9351. * UVs are shared as much as we can accross channels in the shaders.
  9352. * @param texture The texture we are preparing the UVs for
  9353. * @param defines The defines to update
  9354. * @param key The channel key "diffuse", "specular"... used in the shader
  9355. */
  9356. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9357. /**
  9358. * Binds a texture matrix value to its corrsponding uniform
  9359. * @param texture The texture to bind the matrix for
  9360. * @param uniformBuffer The uniform buffer receivin the data
  9361. * @param key The channel key "diffuse", "specular"... used in the shader
  9362. */
  9363. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9364. /**
  9365. * Gets the current status of the fog (should it be enabled?)
  9366. * @param mesh defines the mesh to evaluate for fog support
  9367. * @param scene defines the hosting scene
  9368. * @returns true if fog must be enabled
  9369. */
  9370. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9371. /**
  9372. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9373. * @param mesh defines the current mesh
  9374. * @param scene defines the current scene
  9375. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9376. * @param pointsCloud defines if point cloud rendering has to be turned on
  9377. * @param fogEnabled defines if fog has to be turned on
  9378. * @param alphaTest defines if alpha testing has to be turned on
  9379. * @param defines defines the current list of defines
  9380. */
  9381. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9382. /**
  9383. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9384. * @param scene defines the current scene
  9385. * @param engine defines the current engine
  9386. * @param defines specifies the list of active defines
  9387. * @param useInstances defines if instances have to be turned on
  9388. * @param useClipPlane defines if clip plane have to be turned on
  9389. */
  9390. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9391. /**
  9392. * Prepares the defines for bones
  9393. * @param mesh The mesh containing the geometry data we will draw
  9394. * @param defines The defines to update
  9395. */
  9396. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9397. /**
  9398. * Prepares the defines for morph targets
  9399. * @param mesh The mesh containing the geometry data we will draw
  9400. * @param defines The defines to update
  9401. */
  9402. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9403. /**
  9404. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9405. * @param mesh The mesh containing the geometry data we will draw
  9406. * @param defines The defines to update
  9407. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9408. * @param useBones Precise whether bones should be used or not (override mesh info)
  9409. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9410. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9411. * @returns false if defines are considered not dirty and have not been checked
  9412. */
  9413. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9414. /**
  9415. * Prepares the defines related to multiview
  9416. * @param scene The scene we are intending to draw
  9417. * @param defines The defines to update
  9418. */
  9419. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9420. /**
  9421. * Prepares the defines related to the light information passed in parameter
  9422. * @param scene The scene we are intending to draw
  9423. * @param mesh The mesh the effect is compiling for
  9424. * @param defines The defines to update
  9425. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9426. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9427. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9428. * @returns true if normals will be required for the rest of the effect
  9429. */
  9430. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9431. /**
  9432. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9433. * that won t be acctive due to defines being turned off.
  9434. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9435. * @param samplersList The samplers list
  9436. * @param defines The defines helping in the list generation
  9437. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9438. */
  9439. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9440. /**
  9441. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9442. * @param defines The defines to update while falling back
  9443. * @param fallbacks The authorized effect fallbacks
  9444. * @param maxSimultaneousLights The maximum number of lights allowed
  9445. * @param rank the current rank of the Effect
  9446. * @returns The newly affected rank
  9447. */
  9448. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9449. /**
  9450. * Prepares the list of attributes required for morph targets according to the effect defines.
  9451. * @param attribs The current list of supported attribs
  9452. * @param mesh The mesh to prepare the morph targets attributes for
  9453. * @param defines The current Defines of the effect
  9454. */
  9455. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9456. /**
  9457. * Prepares the list of attributes required for bones according to the effect defines.
  9458. * @param attribs The current list of supported attribs
  9459. * @param mesh The mesh to prepare the bones attributes for
  9460. * @param defines The current Defines of the effect
  9461. * @param fallbacks The current efffect fallback strategy
  9462. */
  9463. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9464. /**
  9465. * Check and prepare the list of attributes required for instances according to the effect defines.
  9466. * @param attribs The current list of supported attribs
  9467. * @param defines The current MaterialDefines of the effect
  9468. */
  9469. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9470. /**
  9471. * Add the list of attributes required for instances to the attribs array.
  9472. * @param attribs The current list of supported attribs
  9473. */
  9474. static PushAttributesForInstances(attribs: string[]): void;
  9475. /**
  9476. * Binds the light shadow information to the effect for the given mesh.
  9477. * @param light The light containing the generator
  9478. * @param scene The scene the lights belongs to
  9479. * @param mesh The mesh we are binding the information to render
  9480. * @param lightIndex The light index in the effect used to render the mesh
  9481. * @param effect The effect we are binding the data to
  9482. */
  9483. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9484. /**
  9485. * Binds the light information to the effect.
  9486. * @param light The light containing the generator
  9487. * @param effect The effect we are binding the data to
  9488. * @param lightIndex The light index in the effect used to render
  9489. */
  9490. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9491. /**
  9492. * Binds the lights information from the scene to the effect for the given mesh.
  9493. * @param scene The scene the lights belongs to
  9494. * @param mesh The mesh we are binding the information to render
  9495. * @param effect The effect we are binding the data to
  9496. * @param defines The generated defines for the effect
  9497. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9498. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9499. */
  9500. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9501. private static _tempFogColor;
  9502. /**
  9503. * Binds the fog information from the scene to the effect for the given mesh.
  9504. * @param scene The scene the lights belongs to
  9505. * @param mesh The mesh we are binding the information to render
  9506. * @param effect The effect we are binding the data to
  9507. * @param linearSpace Defines if the fog effect is applied in linear space
  9508. */
  9509. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9510. /**
  9511. * Binds the bones information from the mesh to the effect.
  9512. * @param mesh The mesh we are binding the information to render
  9513. * @param effect The effect we are binding the data to
  9514. */
  9515. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9516. /**
  9517. * Binds the morph targets information from the mesh to the effect.
  9518. * @param abstractMesh The mesh we are binding the information to render
  9519. * @param effect The effect we are binding the data to
  9520. */
  9521. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9522. /**
  9523. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9524. * @param defines The generated defines used in the effect
  9525. * @param effect The effect we are binding the data to
  9526. * @param scene The scene we are willing to render with logarithmic scale for
  9527. */
  9528. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9529. /**
  9530. * Binds the clip plane information from the scene to the effect.
  9531. * @param scene The scene the clip plane information are extracted from
  9532. * @param effect The effect we are binding the data to
  9533. */
  9534. static BindClipPlane(effect: Effect, scene: Scene): void;
  9535. }
  9536. }
  9537. declare module BABYLON {
  9538. /** @hidden */
  9539. export var kernelBlurVaryingDeclaration: {
  9540. name: string;
  9541. shader: string;
  9542. };
  9543. }
  9544. declare module BABYLON {
  9545. /** @hidden */
  9546. export var kernelBlurFragment: {
  9547. name: string;
  9548. shader: string;
  9549. };
  9550. }
  9551. declare module BABYLON {
  9552. /** @hidden */
  9553. export var kernelBlurFragment2: {
  9554. name: string;
  9555. shader: string;
  9556. };
  9557. }
  9558. declare module BABYLON {
  9559. /** @hidden */
  9560. export var kernelBlurPixelShader: {
  9561. name: string;
  9562. shader: string;
  9563. };
  9564. }
  9565. declare module BABYLON {
  9566. /** @hidden */
  9567. export var kernelBlurVertex: {
  9568. name: string;
  9569. shader: string;
  9570. };
  9571. }
  9572. declare module BABYLON {
  9573. /** @hidden */
  9574. export var kernelBlurVertexShader: {
  9575. name: string;
  9576. shader: string;
  9577. };
  9578. }
  9579. declare module BABYLON {
  9580. /**
  9581. * The Blur Post Process which blurs an image based on a kernel and direction.
  9582. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9583. */
  9584. export class BlurPostProcess extends PostProcess {
  9585. /** The direction in which to blur the image. */
  9586. direction: Vector2;
  9587. private blockCompilation;
  9588. protected _kernel: number;
  9589. protected _idealKernel: number;
  9590. protected _packedFloat: boolean;
  9591. private _staticDefines;
  9592. /**
  9593. * Sets the length in pixels of the blur sample region
  9594. */
  9595. /**
  9596. * Gets the length in pixels of the blur sample region
  9597. */
  9598. kernel: number;
  9599. /**
  9600. * Sets wether or not the blur needs to unpack/repack floats
  9601. */
  9602. /**
  9603. * Gets wether or not the blur is unpacking/repacking floats
  9604. */
  9605. packedFloat: boolean;
  9606. /**
  9607. * Creates a new instance BlurPostProcess
  9608. * @param name The name of the effect.
  9609. * @param direction The direction in which to blur the image.
  9610. * @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.
  9611. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9612. * @param camera The camera to apply the render pass to.
  9613. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9614. * @param engine The engine which the post process will be applied. (default: current engine)
  9615. * @param reusable If the post process can be reused on the same frame. (default: false)
  9616. * @param textureType Type of textures used when performing the post process. (default: 0)
  9617. * @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)
  9618. */
  9619. constructor(name: string,
  9620. /** The direction in which to blur the image. */
  9621. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9622. /**
  9623. * Updates the effect with the current post process compile time values and recompiles the shader.
  9624. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9625. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9626. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9627. * @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
  9628. * @param onCompiled Called when the shader has been compiled.
  9629. * @param onError Called if there is an error when compiling a shader.
  9630. */
  9631. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9632. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9633. /**
  9634. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9635. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9636. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9637. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9638. * The gaps between physical kernels are compensated for in the weighting of the samples
  9639. * @param idealKernel Ideal blur kernel.
  9640. * @return Nearest best kernel.
  9641. */
  9642. protected _nearestBestKernel(idealKernel: number): number;
  9643. /**
  9644. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9645. * @param x The point on the Gaussian distribution to sample.
  9646. * @return the value of the Gaussian function at x.
  9647. */
  9648. protected _gaussianWeight(x: number): number;
  9649. /**
  9650. * Generates a string that can be used as a floating point number in GLSL.
  9651. * @param x Value to print.
  9652. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9653. * @return GLSL float string.
  9654. */
  9655. protected _glslFloat(x: number, decimalFigures?: number): string;
  9656. }
  9657. }
  9658. declare module BABYLON {
  9659. /** @hidden */
  9660. export var shadowMapPixelShader: {
  9661. name: string;
  9662. shader: string;
  9663. };
  9664. }
  9665. declare module BABYLON {
  9666. /** @hidden */
  9667. export var bonesDeclaration: {
  9668. name: string;
  9669. shader: string;
  9670. };
  9671. }
  9672. declare module BABYLON {
  9673. /** @hidden */
  9674. export var morphTargetsVertexGlobalDeclaration: {
  9675. name: string;
  9676. shader: string;
  9677. };
  9678. }
  9679. declare module BABYLON {
  9680. /** @hidden */
  9681. export var morphTargetsVertexDeclaration: {
  9682. name: string;
  9683. shader: string;
  9684. };
  9685. }
  9686. declare module BABYLON {
  9687. /** @hidden */
  9688. export var instancesDeclaration: {
  9689. name: string;
  9690. shader: string;
  9691. };
  9692. }
  9693. declare module BABYLON {
  9694. /** @hidden */
  9695. export var helperFunctions: {
  9696. name: string;
  9697. shader: string;
  9698. };
  9699. }
  9700. declare module BABYLON {
  9701. /** @hidden */
  9702. export var morphTargetsVertex: {
  9703. name: string;
  9704. shader: string;
  9705. };
  9706. }
  9707. declare module BABYLON {
  9708. /** @hidden */
  9709. export var instancesVertex: {
  9710. name: string;
  9711. shader: string;
  9712. };
  9713. }
  9714. declare module BABYLON {
  9715. /** @hidden */
  9716. export var bonesVertex: {
  9717. name: string;
  9718. shader: string;
  9719. };
  9720. }
  9721. declare module BABYLON {
  9722. /** @hidden */
  9723. export var shadowMapVertexShader: {
  9724. name: string;
  9725. shader: string;
  9726. };
  9727. }
  9728. declare module BABYLON {
  9729. /** @hidden */
  9730. export var depthBoxBlurPixelShader: {
  9731. name: string;
  9732. shader: string;
  9733. };
  9734. }
  9735. declare module BABYLON {
  9736. /**
  9737. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9738. */
  9739. export interface ICustomShaderOptions {
  9740. /**
  9741. * Gets or sets the custom shader name to use
  9742. */
  9743. shaderName: string;
  9744. /**
  9745. * The list of attribute names used in the shader
  9746. */
  9747. attributes?: string[];
  9748. /**
  9749. * The list of unifrom names used in the shader
  9750. */
  9751. uniforms?: string[];
  9752. /**
  9753. * The list of sampler names used in the shader
  9754. */
  9755. samplers?: string[];
  9756. /**
  9757. * The list of defines used in the shader
  9758. */
  9759. defines?: string[];
  9760. }
  9761. /**
  9762. * Interface to implement to create a shadow generator compatible with BJS.
  9763. */
  9764. export interface IShadowGenerator {
  9765. /**
  9766. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9767. * @returns The render target texture if present otherwise, null
  9768. */
  9769. getShadowMap(): Nullable<RenderTargetTexture>;
  9770. /**
  9771. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9772. * @returns The render target texture if the shadow map is present otherwise, null
  9773. */
  9774. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9775. /**
  9776. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9777. * @param subMesh The submesh we want to render in the shadow map
  9778. * @param useInstances Defines wether will draw in the map using instances
  9779. * @returns true if ready otherwise, false
  9780. */
  9781. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9782. /**
  9783. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9784. * @param defines Defines of the material we want to update
  9785. * @param lightIndex Index of the light in the enabled light list of the material
  9786. */
  9787. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9788. /**
  9789. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9790. * defined in the generator but impacting the effect).
  9791. * It implies the unifroms available on the materials are the standard BJS ones.
  9792. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9793. * @param effect The effect we are binfing the information for
  9794. */
  9795. bindShadowLight(lightIndex: string, effect: Effect): void;
  9796. /**
  9797. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9798. * (eq to shadow prjection matrix * light transform matrix)
  9799. * @returns The transform matrix used to create the shadow map
  9800. */
  9801. getTransformMatrix(): Matrix;
  9802. /**
  9803. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9804. * Cube and 2D textures for instance.
  9805. */
  9806. recreateShadowMap(): void;
  9807. /**
  9808. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9809. * @param onCompiled Callback triggered at the and of the effects compilation
  9810. * @param options Sets of optional options forcing the compilation with different modes
  9811. */
  9812. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9813. useInstances: boolean;
  9814. }>): void;
  9815. /**
  9816. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9817. * @param options Sets of optional options forcing the compilation with different modes
  9818. * @returns A promise that resolves when the compilation completes
  9819. */
  9820. forceCompilationAsync(options?: Partial<{
  9821. useInstances: boolean;
  9822. }>): Promise<void>;
  9823. /**
  9824. * Serializes the shadow generator setup to a json object.
  9825. * @returns The serialized JSON object
  9826. */
  9827. serialize(): any;
  9828. /**
  9829. * Disposes the Shadow map and related Textures and effects.
  9830. */
  9831. dispose(): void;
  9832. }
  9833. /**
  9834. * Default implementation IShadowGenerator.
  9835. * This is the main object responsible of generating shadows in the framework.
  9836. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9837. */
  9838. export class ShadowGenerator implements IShadowGenerator {
  9839. /**
  9840. * Shadow generator mode None: no filtering applied.
  9841. */
  9842. static readonly FILTER_NONE: number;
  9843. /**
  9844. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9845. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9846. */
  9847. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9848. /**
  9849. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9850. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9851. */
  9852. static readonly FILTER_POISSONSAMPLING: number;
  9853. /**
  9854. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9855. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9856. */
  9857. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9858. /**
  9859. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9860. * edge artifacts on steep falloff.
  9861. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9862. */
  9863. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9864. /**
  9865. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9866. * edge artifacts on steep falloff.
  9867. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9868. */
  9869. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9870. /**
  9871. * Shadow generator mode PCF: Percentage Closer Filtering
  9872. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9873. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9874. */
  9875. static readonly FILTER_PCF: number;
  9876. /**
  9877. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9878. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9879. * Contact Hardening
  9880. */
  9881. static readonly FILTER_PCSS: number;
  9882. /**
  9883. * Reserved for PCF and PCSS
  9884. * Highest Quality.
  9885. *
  9886. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9887. *
  9888. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9889. */
  9890. static readonly QUALITY_HIGH: number;
  9891. /**
  9892. * Reserved for PCF and PCSS
  9893. * Good tradeoff for quality/perf cross devices
  9894. *
  9895. * Execute PCF on a 3*3 kernel.
  9896. *
  9897. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9898. */
  9899. static readonly QUALITY_MEDIUM: number;
  9900. /**
  9901. * Reserved for PCF and PCSS
  9902. * The lowest quality but the fastest.
  9903. *
  9904. * Execute PCF on a 1*1 kernel.
  9905. *
  9906. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9907. */
  9908. static readonly QUALITY_LOW: number;
  9909. /** Gets or sets the custom shader name to use */
  9910. customShaderOptions: ICustomShaderOptions;
  9911. /**
  9912. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9913. */
  9914. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9915. /**
  9916. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9917. */
  9918. onAfterShadowMapRenderObservable: Observable<Effect>;
  9919. /**
  9920. * Observable triggered before a mesh is rendered in the shadow map.
  9921. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9922. */
  9923. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9924. /**
  9925. * Observable triggered after a mesh is rendered in the shadow map.
  9926. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9927. */
  9928. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9929. private _bias;
  9930. /**
  9931. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9932. */
  9933. /**
  9934. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9935. */
  9936. bias: number;
  9937. private _normalBias;
  9938. /**
  9939. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9940. */
  9941. /**
  9942. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9943. */
  9944. normalBias: number;
  9945. private _blurBoxOffset;
  9946. /**
  9947. * Gets the blur box offset: offset applied during the blur pass.
  9948. * Only useful if useKernelBlur = false
  9949. */
  9950. /**
  9951. * Sets the blur box offset: offset applied during the blur pass.
  9952. * Only useful if useKernelBlur = false
  9953. */
  9954. blurBoxOffset: number;
  9955. private _blurScale;
  9956. /**
  9957. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9958. * 2 means half of the size.
  9959. */
  9960. /**
  9961. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9962. * 2 means half of the size.
  9963. */
  9964. blurScale: number;
  9965. private _blurKernel;
  9966. /**
  9967. * Gets the blur kernel: kernel size of the blur pass.
  9968. * Only useful if useKernelBlur = true
  9969. */
  9970. /**
  9971. * Sets the blur kernel: kernel size of the blur pass.
  9972. * Only useful if useKernelBlur = true
  9973. */
  9974. blurKernel: number;
  9975. private _useKernelBlur;
  9976. /**
  9977. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9978. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9979. */
  9980. /**
  9981. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9982. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9983. */
  9984. useKernelBlur: boolean;
  9985. private _depthScale;
  9986. /**
  9987. * Gets the depth scale used in ESM mode.
  9988. */
  9989. /**
  9990. * Sets the depth scale used in ESM mode.
  9991. * This can override the scale stored on the light.
  9992. */
  9993. depthScale: number;
  9994. private _filter;
  9995. /**
  9996. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9997. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9998. */
  9999. /**
  10000. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  10001. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  10002. */
  10003. filter: number;
  10004. /**
  10005. * Gets if the current filter is set to Poisson Sampling.
  10006. */
  10007. /**
  10008. * Sets the current filter to Poisson Sampling.
  10009. */
  10010. usePoissonSampling: boolean;
  10011. /**
  10012. * Gets if the current filter is set to ESM.
  10013. */
  10014. /**
  10015. * Sets the current filter is to ESM.
  10016. */
  10017. useExponentialShadowMap: boolean;
  10018. /**
  10019. * Gets if the current filter is set to filtered ESM.
  10020. */
  10021. /**
  10022. * Gets if the current filter is set to filtered ESM.
  10023. */
  10024. useBlurExponentialShadowMap: boolean;
  10025. /**
  10026. * Gets if the current filter is set to "close ESM" (using the inverse of the
  10027. * exponential to prevent steep falloff artifacts).
  10028. */
  10029. /**
  10030. * Sets the current filter to "close ESM" (using the inverse of the
  10031. * exponential to prevent steep falloff artifacts).
  10032. */
  10033. useCloseExponentialShadowMap: boolean;
  10034. /**
  10035. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  10036. * exponential to prevent steep falloff artifacts).
  10037. */
  10038. /**
  10039. * Sets the current filter to filtered "close ESM" (using the inverse of the
  10040. * exponential to prevent steep falloff artifacts).
  10041. */
  10042. useBlurCloseExponentialShadowMap: boolean;
  10043. /**
  10044. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  10045. */
  10046. /**
  10047. * Sets the current filter to "PCF" (percentage closer filtering).
  10048. */
  10049. usePercentageCloserFiltering: boolean;
  10050. private _filteringQuality;
  10051. /**
  10052. * Gets the PCF or PCSS Quality.
  10053. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  10054. */
  10055. /**
  10056. * Sets the PCF or PCSS Quality.
  10057. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  10058. */
  10059. filteringQuality: number;
  10060. /**
  10061. * Gets if the current filter is set to "PCSS" (contact hardening).
  10062. */
  10063. /**
  10064. * Sets the current filter to "PCSS" (contact hardening).
  10065. */
  10066. useContactHardeningShadow: boolean;
  10067. private _contactHardeningLightSizeUVRatio;
  10068. /**
  10069. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  10070. * Using a ratio helps keeping shape stability independently of the map size.
  10071. *
  10072. * It does not account for the light projection as it was having too much
  10073. * instability during the light setup or during light position changes.
  10074. *
  10075. * Only valid if useContactHardeningShadow is true.
  10076. */
  10077. /**
  10078. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  10079. * Using a ratio helps keeping shape stability independently of the map size.
  10080. *
  10081. * It does not account for the light projection as it was having too much
  10082. * instability during the light setup or during light position changes.
  10083. *
  10084. * Only valid if useContactHardeningShadow is true.
  10085. */
  10086. contactHardeningLightSizeUVRatio: number;
  10087. private _darkness;
  10088. /** Gets or sets the actual darkness of a shadow */
  10089. darkness: number;
  10090. /**
  10091. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  10092. * 0 means strongest and 1 would means no shadow.
  10093. * @returns the darkness.
  10094. */
  10095. getDarkness(): number;
  10096. /**
  10097. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  10098. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  10099. * @returns the shadow generator allowing fluent coding.
  10100. */
  10101. setDarkness(darkness: number): ShadowGenerator;
  10102. private _transparencyShadow;
  10103. /** Gets or sets the ability to have transparent shadow */
  10104. transparencyShadow: boolean;
  10105. /**
  10106. * Sets the ability to have transparent shadow (boolean).
  10107. * @param transparent True if transparent else False
  10108. * @returns the shadow generator allowing fluent coding
  10109. */
  10110. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  10111. private _shadowMap;
  10112. private _shadowMap2;
  10113. /**
  10114. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  10115. * @returns The render target texture if present otherwise, null
  10116. */
  10117. getShadowMap(): Nullable<RenderTargetTexture>;
  10118. /**
  10119. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  10120. * @returns The render target texture if the shadow map is present otherwise, null
  10121. */
  10122. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  10123. /**
  10124. * Gets the class name of that object
  10125. * @returns "ShadowGenerator"
  10126. */
  10127. getClassName(): string;
  10128. /**
  10129. * Helper function to add a mesh and its descendants to the list of shadow casters.
  10130. * @param mesh Mesh to add
  10131. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  10132. * @returns the Shadow Generator itself
  10133. */
  10134. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10135. /**
  10136. * Helper function to remove a mesh and its descendants from the list of shadow casters
  10137. * @param mesh Mesh to remove
  10138. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  10139. * @returns the Shadow Generator itself
  10140. */
  10141. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10142. /**
  10143. * Controls the extent to which the shadows fade out at the edge of the frustum
  10144. * Used only by directionals and spots
  10145. */
  10146. frustumEdgeFalloff: number;
  10147. private _light;
  10148. /**
  10149. * Returns the associated light object.
  10150. * @returns the light generating the shadow
  10151. */
  10152. getLight(): IShadowLight;
  10153. /**
  10154. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  10155. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  10156. * It might on the other hand introduce peter panning.
  10157. */
  10158. forceBackFacesOnly: boolean;
  10159. private _scene;
  10160. private _lightDirection;
  10161. private _effect;
  10162. private _viewMatrix;
  10163. private _projectionMatrix;
  10164. private _transformMatrix;
  10165. private _cachedPosition;
  10166. private _cachedDirection;
  10167. private _cachedDefines;
  10168. private _currentRenderID;
  10169. private _boxBlurPostprocess;
  10170. private _kernelBlurXPostprocess;
  10171. private _kernelBlurYPostprocess;
  10172. private _blurPostProcesses;
  10173. private _mapSize;
  10174. private _currentFaceIndex;
  10175. private _currentFaceIndexCache;
  10176. private _textureType;
  10177. private _defaultTextureMatrix;
  10178. /** @hidden */
  10179. static _SceneComponentInitialization: (scene: Scene) => void;
  10180. /**
  10181. * Creates a ShadowGenerator object.
  10182. * A ShadowGenerator is the required tool to use the shadows.
  10183. * Each light casting shadows needs to use its own ShadowGenerator.
  10184. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  10185. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  10186. * @param light The light object generating the shadows.
  10187. * @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.
  10188. */
  10189. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  10190. private _initializeGenerator;
  10191. private _initializeShadowMap;
  10192. private _initializeBlurRTTAndPostProcesses;
  10193. private _renderForShadowMap;
  10194. private _renderSubMeshForShadowMap;
  10195. private _applyFilterValues;
  10196. /**
  10197. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10198. * @param onCompiled Callback triggered at the and of the effects compilation
  10199. * @param options Sets of optional options forcing the compilation with different modes
  10200. */
  10201. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10202. useInstances: boolean;
  10203. }>): void;
  10204. /**
  10205. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10206. * @param options Sets of optional options forcing the compilation with different modes
  10207. * @returns A promise that resolves when the compilation completes
  10208. */
  10209. forceCompilationAsync(options?: Partial<{
  10210. useInstances: boolean;
  10211. }>): Promise<void>;
  10212. /**
  10213. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10214. * @param subMesh The submesh we want to render in the shadow map
  10215. * @param useInstances Defines wether will draw in the map using instances
  10216. * @returns true if ready otherwise, false
  10217. */
  10218. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10219. /**
  10220. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10221. * @param defines Defines of the material we want to update
  10222. * @param lightIndex Index of the light in the enabled light list of the material
  10223. */
  10224. prepareDefines(defines: any, lightIndex: number): void;
  10225. /**
  10226. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10227. * defined in the generator but impacting the effect).
  10228. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10229. * @param effect The effect we are binfing the information for
  10230. */
  10231. bindShadowLight(lightIndex: string, effect: Effect): void;
  10232. /**
  10233. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10234. * (eq to shadow prjection matrix * light transform matrix)
  10235. * @returns The transform matrix used to create the shadow map
  10236. */
  10237. getTransformMatrix(): Matrix;
  10238. /**
  10239. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10240. * Cube and 2D textures for instance.
  10241. */
  10242. recreateShadowMap(): void;
  10243. private _disposeBlurPostProcesses;
  10244. private _disposeRTTandPostProcesses;
  10245. /**
  10246. * Disposes the ShadowGenerator.
  10247. * Returns nothing.
  10248. */
  10249. dispose(): void;
  10250. /**
  10251. * Serializes the shadow generator setup to a json object.
  10252. * @returns The serialized JSON object
  10253. */
  10254. serialize(): any;
  10255. /**
  10256. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10257. * @param parsedShadowGenerator The JSON object to parse
  10258. * @param scene The scene to create the shadow map for
  10259. * @returns The parsed shadow generator
  10260. */
  10261. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10262. }
  10263. }
  10264. declare module BABYLON {
  10265. /**
  10266. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10267. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10268. * 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.
  10269. */
  10270. export abstract class Light extends Node {
  10271. /**
  10272. * Falloff Default: light is falling off following the material specification:
  10273. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10274. */
  10275. static readonly FALLOFF_DEFAULT: number;
  10276. /**
  10277. * Falloff Physical: light is falling off following the inverse squared distance law.
  10278. */
  10279. static readonly FALLOFF_PHYSICAL: number;
  10280. /**
  10281. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10282. * to enhance interoperability with other engines.
  10283. */
  10284. static readonly FALLOFF_GLTF: number;
  10285. /**
  10286. * Falloff Standard: light is falling off like in the standard material
  10287. * to enhance interoperability with other materials.
  10288. */
  10289. static readonly FALLOFF_STANDARD: number;
  10290. /**
  10291. * If every light affecting the material is in this lightmapMode,
  10292. * material.lightmapTexture adds or multiplies
  10293. * (depends on material.useLightmapAsShadowmap)
  10294. * after every other light calculations.
  10295. */
  10296. static readonly LIGHTMAP_DEFAULT: number;
  10297. /**
  10298. * material.lightmapTexture as only diffuse lighting from this light
  10299. * adds only specular lighting from this light
  10300. * adds dynamic shadows
  10301. */
  10302. static readonly LIGHTMAP_SPECULAR: number;
  10303. /**
  10304. * material.lightmapTexture as only lighting
  10305. * no light calculation from this light
  10306. * only adds dynamic shadows from this light
  10307. */
  10308. static readonly LIGHTMAP_SHADOWSONLY: number;
  10309. /**
  10310. * Each light type uses the default quantity according to its type:
  10311. * point/spot lights use luminous intensity
  10312. * directional lights use illuminance
  10313. */
  10314. static readonly INTENSITYMODE_AUTOMATIC: number;
  10315. /**
  10316. * lumen (lm)
  10317. */
  10318. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10319. /**
  10320. * candela (lm/sr)
  10321. */
  10322. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10323. /**
  10324. * lux (lm/m^2)
  10325. */
  10326. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10327. /**
  10328. * nit (cd/m^2)
  10329. */
  10330. static readonly INTENSITYMODE_LUMINANCE: number;
  10331. /**
  10332. * Light type const id of the point light.
  10333. */
  10334. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10335. /**
  10336. * Light type const id of the directional light.
  10337. */
  10338. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10339. /**
  10340. * Light type const id of the spot light.
  10341. */
  10342. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10343. /**
  10344. * Light type const id of the hemispheric light.
  10345. */
  10346. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10347. /**
  10348. * Diffuse gives the basic color to an object.
  10349. */
  10350. diffuse: Color3;
  10351. /**
  10352. * Specular produces a highlight color on an object.
  10353. * Note: This is note affecting PBR materials.
  10354. */
  10355. specular: Color3;
  10356. /**
  10357. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10358. * falling off base on range or angle.
  10359. * This can be set to any values in Light.FALLOFF_x.
  10360. *
  10361. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10362. * other types of materials.
  10363. */
  10364. falloffType: number;
  10365. /**
  10366. * Strength of the light.
  10367. * Note: By default it is define in the framework own unit.
  10368. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10369. */
  10370. intensity: number;
  10371. private _range;
  10372. protected _inverseSquaredRange: number;
  10373. /**
  10374. * Defines how far from the source the light is impacting in scene units.
  10375. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10376. */
  10377. /**
  10378. * Defines how far from the source the light is impacting in scene units.
  10379. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10380. */
  10381. range: number;
  10382. /**
  10383. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10384. * of light.
  10385. */
  10386. private _photometricScale;
  10387. private _intensityMode;
  10388. /**
  10389. * Gets the photometric scale used to interpret the intensity.
  10390. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10391. */
  10392. /**
  10393. * Sets the photometric scale used to interpret the intensity.
  10394. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10395. */
  10396. intensityMode: number;
  10397. private _radius;
  10398. /**
  10399. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10400. */
  10401. /**
  10402. * sets the light radius used by PBR Materials to simulate soft area lights.
  10403. */
  10404. radius: number;
  10405. private _renderPriority;
  10406. /**
  10407. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10408. * exceeding the number allowed of the materials.
  10409. */
  10410. renderPriority: number;
  10411. private _shadowEnabled;
  10412. /**
  10413. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10414. * the current shadow generator.
  10415. */
  10416. /**
  10417. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10418. * the current shadow generator.
  10419. */
  10420. shadowEnabled: boolean;
  10421. private _includedOnlyMeshes;
  10422. /**
  10423. * Gets the only meshes impacted by this light.
  10424. */
  10425. /**
  10426. * Sets the only meshes impacted by this light.
  10427. */
  10428. includedOnlyMeshes: AbstractMesh[];
  10429. private _excludedMeshes;
  10430. /**
  10431. * Gets the meshes not impacted by this light.
  10432. */
  10433. /**
  10434. * Sets the meshes not impacted by this light.
  10435. */
  10436. excludedMeshes: AbstractMesh[];
  10437. private _excludeWithLayerMask;
  10438. /**
  10439. * Gets the layer id use to find what meshes are not impacted by the light.
  10440. * Inactive if 0
  10441. */
  10442. /**
  10443. * Sets the layer id use to find what meshes are not impacted by the light.
  10444. * Inactive if 0
  10445. */
  10446. excludeWithLayerMask: number;
  10447. private _includeOnlyWithLayerMask;
  10448. /**
  10449. * Gets the layer id use to find what meshes are impacted by the light.
  10450. * Inactive if 0
  10451. */
  10452. /**
  10453. * Sets the layer id use to find what meshes are impacted by the light.
  10454. * Inactive if 0
  10455. */
  10456. includeOnlyWithLayerMask: number;
  10457. private _lightmapMode;
  10458. /**
  10459. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10460. */
  10461. /**
  10462. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10463. */
  10464. lightmapMode: number;
  10465. /**
  10466. * Shadow generator associted to the light.
  10467. * @hidden Internal use only.
  10468. */
  10469. _shadowGenerator: Nullable<IShadowGenerator>;
  10470. /**
  10471. * @hidden Internal use only.
  10472. */
  10473. _excludedMeshesIds: string[];
  10474. /**
  10475. * @hidden Internal use only.
  10476. */
  10477. _includedOnlyMeshesIds: string[];
  10478. /**
  10479. * The current light unifom buffer.
  10480. * @hidden Internal use only.
  10481. */
  10482. _uniformBuffer: UniformBuffer;
  10483. /**
  10484. * Creates a Light object in the scene.
  10485. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10486. * @param name The firendly name of the light
  10487. * @param scene The scene the light belongs too
  10488. */
  10489. constructor(name: string, scene: Scene);
  10490. protected abstract _buildUniformLayout(): void;
  10491. /**
  10492. * Sets the passed Effect "effect" with the Light information.
  10493. * @param effect The effect to update
  10494. * @param lightIndex The index of the light in the effect to update
  10495. * @returns The light
  10496. */
  10497. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10498. /**
  10499. * Returns the string "Light".
  10500. * @returns the class name
  10501. */
  10502. getClassName(): string;
  10503. /** @hidden */
  10504. readonly _isLight: boolean;
  10505. /**
  10506. * Converts the light information to a readable string for debug purpose.
  10507. * @param fullDetails Supports for multiple levels of logging within scene loading
  10508. * @returns the human readable light info
  10509. */
  10510. toString(fullDetails?: boolean): string;
  10511. /** @hidden */
  10512. protected _syncParentEnabledState(): void;
  10513. /**
  10514. * Set the enabled state of this node.
  10515. * @param value - the new enabled state
  10516. */
  10517. setEnabled(value: boolean): void;
  10518. /**
  10519. * Returns the Light associated shadow generator if any.
  10520. * @return the associated shadow generator.
  10521. */
  10522. getShadowGenerator(): Nullable<IShadowGenerator>;
  10523. /**
  10524. * Returns a Vector3, the absolute light position in the World.
  10525. * @returns the world space position of the light
  10526. */
  10527. getAbsolutePosition(): Vector3;
  10528. /**
  10529. * Specifies if the light will affect the passed mesh.
  10530. * @param mesh The mesh to test against the light
  10531. * @return true the mesh is affected otherwise, false.
  10532. */
  10533. canAffectMesh(mesh: AbstractMesh): boolean;
  10534. /**
  10535. * Sort function to order lights for rendering.
  10536. * @param a First Light object to compare to second.
  10537. * @param b Second Light object to compare first.
  10538. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10539. */
  10540. static CompareLightsPriority(a: Light, b: Light): number;
  10541. /**
  10542. * Releases resources associated with this node.
  10543. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10544. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10545. */
  10546. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10547. /**
  10548. * Returns the light type ID (integer).
  10549. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10550. */
  10551. getTypeID(): number;
  10552. /**
  10553. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10554. * @returns the scaled intensity in intensity mode unit
  10555. */
  10556. getScaledIntensity(): number;
  10557. /**
  10558. * Returns a new Light object, named "name", from the current one.
  10559. * @param name The name of the cloned light
  10560. * @returns the new created light
  10561. */
  10562. clone(name: string): Nullable<Light>;
  10563. /**
  10564. * Serializes the current light into a Serialization object.
  10565. * @returns the serialized object.
  10566. */
  10567. serialize(): any;
  10568. /**
  10569. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10570. * This new light is named "name" and added to the passed scene.
  10571. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10572. * @param name The friendly name of the light
  10573. * @param scene The scene the new light will belong to
  10574. * @returns the constructor function
  10575. */
  10576. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10577. /**
  10578. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10579. * @param parsedLight The JSON representation of the light
  10580. * @param scene The scene to create the parsed light in
  10581. * @returns the created light after parsing
  10582. */
  10583. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10584. private _hookArrayForExcluded;
  10585. private _hookArrayForIncludedOnly;
  10586. private _resyncMeshes;
  10587. /**
  10588. * Forces the meshes to update their light related information in their rendering used effects
  10589. * @hidden Internal Use Only
  10590. */
  10591. _markMeshesAsLightDirty(): void;
  10592. /**
  10593. * Recomputes the cached photometric scale if needed.
  10594. */
  10595. private _computePhotometricScale;
  10596. /**
  10597. * Returns the Photometric Scale according to the light type and intensity mode.
  10598. */
  10599. private _getPhotometricScale;
  10600. /**
  10601. * Reorder the light in the scene according to their defined priority.
  10602. * @hidden Internal Use Only
  10603. */
  10604. _reorderLightsInScene(): void;
  10605. /**
  10606. * Prepares the list of defines specific to the light type.
  10607. * @param defines the list of defines
  10608. * @param lightIndex defines the index of the light for the effect
  10609. */
  10610. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10611. }
  10612. }
  10613. declare module BABYLON {
  10614. /**
  10615. * Interface used to define Action
  10616. */
  10617. export interface IAction {
  10618. /**
  10619. * Trigger for the action
  10620. */
  10621. trigger: number;
  10622. /** Options of the trigger */
  10623. triggerOptions: any;
  10624. /**
  10625. * Gets the trigger parameters
  10626. * @returns the trigger parameters
  10627. */
  10628. getTriggerParameter(): any;
  10629. /**
  10630. * Internal only - executes current action event
  10631. * @hidden
  10632. */
  10633. _executeCurrent(evt?: ActionEvent): void;
  10634. /**
  10635. * Serialize placeholder for child classes
  10636. * @param parent of child
  10637. * @returns the serialized object
  10638. */
  10639. serialize(parent: any): any;
  10640. /**
  10641. * Internal only
  10642. * @hidden
  10643. */
  10644. _prepare(): void;
  10645. /**
  10646. * Internal only - manager for action
  10647. * @hidden
  10648. */
  10649. _actionManager: AbstractActionManager;
  10650. /**
  10651. * Adds action to chain of actions, may be a DoNothingAction
  10652. * @param action defines the next action to execute
  10653. * @returns The action passed in
  10654. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10655. */
  10656. then(action: IAction): IAction;
  10657. }
  10658. /**
  10659. * The action to be carried out following a trigger
  10660. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10661. */
  10662. export class Action implements IAction {
  10663. /** the trigger, with or without parameters, for the action */
  10664. triggerOptions: any;
  10665. /**
  10666. * Trigger for the action
  10667. */
  10668. trigger: number;
  10669. /**
  10670. * Internal only - manager for action
  10671. * @hidden
  10672. */
  10673. _actionManager: ActionManager;
  10674. private _nextActiveAction;
  10675. private _child;
  10676. private _condition?;
  10677. private _triggerParameter;
  10678. /**
  10679. * An event triggered prior to action being executed.
  10680. */
  10681. onBeforeExecuteObservable: Observable<Action>;
  10682. /**
  10683. * Creates a new Action
  10684. * @param triggerOptions the trigger, with or without parameters, for the action
  10685. * @param condition an optional determinant of action
  10686. */
  10687. constructor(
  10688. /** the trigger, with or without parameters, for the action */
  10689. triggerOptions: any, condition?: Condition);
  10690. /**
  10691. * Internal only
  10692. * @hidden
  10693. */
  10694. _prepare(): void;
  10695. /**
  10696. * Gets the trigger parameters
  10697. * @returns the trigger parameters
  10698. */
  10699. getTriggerParameter(): any;
  10700. /**
  10701. * Internal only - executes current action event
  10702. * @hidden
  10703. */
  10704. _executeCurrent(evt?: ActionEvent): void;
  10705. /**
  10706. * Execute placeholder for child classes
  10707. * @param evt optional action event
  10708. */
  10709. execute(evt?: ActionEvent): void;
  10710. /**
  10711. * Skips to next active action
  10712. */
  10713. skipToNextActiveAction(): void;
  10714. /**
  10715. * Adds action to chain of actions, may be a DoNothingAction
  10716. * @param action defines the next action to execute
  10717. * @returns The action passed in
  10718. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10719. */
  10720. then(action: Action): Action;
  10721. /**
  10722. * Internal only
  10723. * @hidden
  10724. */
  10725. _getProperty(propertyPath: string): string;
  10726. /**
  10727. * Internal only
  10728. * @hidden
  10729. */
  10730. _getEffectiveTarget(target: any, propertyPath: string): any;
  10731. /**
  10732. * Serialize placeholder for child classes
  10733. * @param parent of child
  10734. * @returns the serialized object
  10735. */
  10736. serialize(parent: any): any;
  10737. /**
  10738. * Internal only called by serialize
  10739. * @hidden
  10740. */
  10741. protected _serialize(serializedAction: any, parent?: any): any;
  10742. /**
  10743. * Internal only
  10744. * @hidden
  10745. */
  10746. static _SerializeValueAsString: (value: any) => string;
  10747. /**
  10748. * Internal only
  10749. * @hidden
  10750. */
  10751. static _GetTargetProperty: (target: Scene | Node) => {
  10752. name: string;
  10753. targetType: string;
  10754. value: string;
  10755. };
  10756. }
  10757. }
  10758. declare module BABYLON {
  10759. /**
  10760. * A Condition applied to an Action
  10761. */
  10762. export class Condition {
  10763. /**
  10764. * Internal only - manager for action
  10765. * @hidden
  10766. */
  10767. _actionManager: ActionManager;
  10768. /**
  10769. * Internal only
  10770. * @hidden
  10771. */
  10772. _evaluationId: number;
  10773. /**
  10774. * Internal only
  10775. * @hidden
  10776. */
  10777. _currentResult: boolean;
  10778. /**
  10779. * Creates a new Condition
  10780. * @param actionManager the manager of the action the condition is applied to
  10781. */
  10782. constructor(actionManager: ActionManager);
  10783. /**
  10784. * Check if the current condition is valid
  10785. * @returns a boolean
  10786. */
  10787. isValid(): boolean;
  10788. /**
  10789. * Internal only
  10790. * @hidden
  10791. */
  10792. _getProperty(propertyPath: string): string;
  10793. /**
  10794. * Internal only
  10795. * @hidden
  10796. */
  10797. _getEffectiveTarget(target: any, propertyPath: string): any;
  10798. /**
  10799. * Serialize placeholder for child classes
  10800. * @returns the serialized object
  10801. */
  10802. serialize(): any;
  10803. /**
  10804. * Internal only
  10805. * @hidden
  10806. */
  10807. protected _serialize(serializedCondition: any): any;
  10808. }
  10809. /**
  10810. * Defines specific conditional operators as extensions of Condition
  10811. */
  10812. export class ValueCondition extends Condition {
  10813. /** path to specify the property of the target the conditional operator uses */
  10814. propertyPath: string;
  10815. /** the value compared by the conditional operator against the current value of the property */
  10816. value: any;
  10817. /** the conditional operator, default ValueCondition.IsEqual */
  10818. operator: number;
  10819. /**
  10820. * Internal only
  10821. * @hidden
  10822. */
  10823. private static _IsEqual;
  10824. /**
  10825. * Internal only
  10826. * @hidden
  10827. */
  10828. private static _IsDifferent;
  10829. /**
  10830. * Internal only
  10831. * @hidden
  10832. */
  10833. private static _IsGreater;
  10834. /**
  10835. * Internal only
  10836. * @hidden
  10837. */
  10838. private static _IsLesser;
  10839. /**
  10840. * returns the number for IsEqual
  10841. */
  10842. static readonly IsEqual: number;
  10843. /**
  10844. * Returns the number for IsDifferent
  10845. */
  10846. static readonly IsDifferent: number;
  10847. /**
  10848. * Returns the number for IsGreater
  10849. */
  10850. static readonly IsGreater: number;
  10851. /**
  10852. * Returns the number for IsLesser
  10853. */
  10854. static readonly IsLesser: number;
  10855. /**
  10856. * Internal only The action manager for the condition
  10857. * @hidden
  10858. */
  10859. _actionManager: ActionManager;
  10860. /**
  10861. * Internal only
  10862. * @hidden
  10863. */
  10864. private _target;
  10865. /**
  10866. * Internal only
  10867. * @hidden
  10868. */
  10869. private _effectiveTarget;
  10870. /**
  10871. * Internal only
  10872. * @hidden
  10873. */
  10874. private _property;
  10875. /**
  10876. * Creates a new ValueCondition
  10877. * @param actionManager manager for the action the condition applies to
  10878. * @param target for the action
  10879. * @param propertyPath path to specify the property of the target the conditional operator uses
  10880. * @param value the value compared by the conditional operator against the current value of the property
  10881. * @param operator the conditional operator, default ValueCondition.IsEqual
  10882. */
  10883. constructor(actionManager: ActionManager, target: any,
  10884. /** path to specify the property of the target the conditional operator uses */
  10885. propertyPath: string,
  10886. /** the value compared by the conditional operator against the current value of the property */
  10887. value: any,
  10888. /** the conditional operator, default ValueCondition.IsEqual */
  10889. operator?: number);
  10890. /**
  10891. * Compares the given value with the property value for the specified conditional operator
  10892. * @returns the result of the comparison
  10893. */
  10894. isValid(): boolean;
  10895. /**
  10896. * Serialize the ValueCondition into a JSON compatible object
  10897. * @returns serialization object
  10898. */
  10899. serialize(): any;
  10900. /**
  10901. * Gets the name of the conditional operator for the ValueCondition
  10902. * @param operator the conditional operator
  10903. * @returns the name
  10904. */
  10905. static GetOperatorName(operator: number): string;
  10906. }
  10907. /**
  10908. * Defines a predicate condition as an extension of Condition
  10909. */
  10910. export class PredicateCondition extends Condition {
  10911. /** defines the predicate function used to validate the condition */
  10912. predicate: () => boolean;
  10913. /**
  10914. * Internal only - manager for action
  10915. * @hidden
  10916. */
  10917. _actionManager: ActionManager;
  10918. /**
  10919. * Creates a new PredicateCondition
  10920. * @param actionManager manager for the action the condition applies to
  10921. * @param predicate defines the predicate function used to validate the condition
  10922. */
  10923. constructor(actionManager: ActionManager,
  10924. /** defines the predicate function used to validate the condition */
  10925. predicate: () => boolean);
  10926. /**
  10927. * @returns the validity of the predicate condition
  10928. */
  10929. isValid(): boolean;
  10930. }
  10931. /**
  10932. * Defines a state condition as an extension of Condition
  10933. */
  10934. export class StateCondition extends Condition {
  10935. /** Value to compare with target state */
  10936. value: string;
  10937. /**
  10938. * Internal only - manager for action
  10939. * @hidden
  10940. */
  10941. _actionManager: ActionManager;
  10942. /**
  10943. * Internal only
  10944. * @hidden
  10945. */
  10946. private _target;
  10947. /**
  10948. * Creates a new StateCondition
  10949. * @param actionManager manager for the action the condition applies to
  10950. * @param target of the condition
  10951. * @param value to compare with target state
  10952. */
  10953. constructor(actionManager: ActionManager, target: any,
  10954. /** Value to compare with target state */
  10955. value: string);
  10956. /**
  10957. * Gets a boolean indicating if the current condition is met
  10958. * @returns the validity of the state
  10959. */
  10960. isValid(): boolean;
  10961. /**
  10962. * Serialize the StateCondition into a JSON compatible object
  10963. * @returns serialization object
  10964. */
  10965. serialize(): any;
  10966. }
  10967. }
  10968. declare module BABYLON {
  10969. /**
  10970. * This defines an action responsible to toggle a boolean once triggered.
  10971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10972. */
  10973. export class SwitchBooleanAction extends Action {
  10974. /**
  10975. * The path to the boolean property in the target object
  10976. */
  10977. propertyPath: string;
  10978. private _target;
  10979. private _effectiveTarget;
  10980. private _property;
  10981. /**
  10982. * Instantiate the action
  10983. * @param triggerOptions defines the trigger options
  10984. * @param target defines the object containing the boolean
  10985. * @param propertyPath defines the path to the boolean property in the target object
  10986. * @param condition defines the trigger related conditions
  10987. */
  10988. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10989. /** @hidden */
  10990. _prepare(): void;
  10991. /**
  10992. * Execute the action toggle the boolean value.
  10993. */
  10994. execute(): void;
  10995. /**
  10996. * Serializes the actions and its related information.
  10997. * @param parent defines the object to serialize in
  10998. * @returns the serialized object
  10999. */
  11000. serialize(parent: any): any;
  11001. }
  11002. /**
  11003. * This defines an action responsible to set a the state field of the target
  11004. * to a desired value once triggered.
  11005. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11006. */
  11007. export class SetStateAction extends Action {
  11008. /**
  11009. * The value to store in the state field.
  11010. */
  11011. value: string;
  11012. private _target;
  11013. /**
  11014. * Instantiate the action
  11015. * @param triggerOptions defines the trigger options
  11016. * @param target defines the object containing the state property
  11017. * @param value defines the value to store in the state field
  11018. * @param condition defines the trigger related conditions
  11019. */
  11020. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  11021. /**
  11022. * Execute the action and store the value on the target state property.
  11023. */
  11024. execute(): void;
  11025. /**
  11026. * Serializes the actions and its related information.
  11027. * @param parent defines the object to serialize in
  11028. * @returns the serialized object
  11029. */
  11030. serialize(parent: any): any;
  11031. }
  11032. /**
  11033. * This defines an action responsible to set a property of the target
  11034. * to a desired value once triggered.
  11035. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11036. */
  11037. export class SetValueAction extends Action {
  11038. /**
  11039. * The path of the property to set in the target.
  11040. */
  11041. propertyPath: string;
  11042. /**
  11043. * The value to set in the property
  11044. */
  11045. value: any;
  11046. private _target;
  11047. private _effectiveTarget;
  11048. private _property;
  11049. /**
  11050. * Instantiate the action
  11051. * @param triggerOptions defines the trigger options
  11052. * @param target defines the object containing the property
  11053. * @param propertyPath defines the path of the property to set in the target
  11054. * @param value defines the value to set in the property
  11055. * @param condition defines the trigger related conditions
  11056. */
  11057. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  11058. /** @hidden */
  11059. _prepare(): void;
  11060. /**
  11061. * Execute the action and set the targetted property to the desired value.
  11062. */
  11063. execute(): void;
  11064. /**
  11065. * Serializes the actions and its related information.
  11066. * @param parent defines the object to serialize in
  11067. * @returns the serialized object
  11068. */
  11069. serialize(parent: any): any;
  11070. }
  11071. /**
  11072. * This defines an action responsible to increment the target value
  11073. * to a desired value once triggered.
  11074. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11075. */
  11076. export class IncrementValueAction extends Action {
  11077. /**
  11078. * The path of the property to increment in the target.
  11079. */
  11080. propertyPath: string;
  11081. /**
  11082. * The value we should increment the property by.
  11083. */
  11084. value: any;
  11085. private _target;
  11086. private _effectiveTarget;
  11087. private _property;
  11088. /**
  11089. * Instantiate the action
  11090. * @param triggerOptions defines the trigger options
  11091. * @param target defines the object containing the property
  11092. * @param propertyPath defines the path of the property to increment in the target
  11093. * @param value defines the value value we should increment the property by
  11094. * @param condition defines the trigger related conditions
  11095. */
  11096. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  11097. /** @hidden */
  11098. _prepare(): void;
  11099. /**
  11100. * Execute the action and increment the target of the value amount.
  11101. */
  11102. execute(): void;
  11103. /**
  11104. * Serializes the actions and its related information.
  11105. * @param parent defines the object to serialize in
  11106. * @returns the serialized object
  11107. */
  11108. serialize(parent: any): any;
  11109. }
  11110. /**
  11111. * This defines an action responsible to start an animation once triggered.
  11112. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11113. */
  11114. export class PlayAnimationAction extends Action {
  11115. /**
  11116. * Where the animation should start (animation frame)
  11117. */
  11118. from: number;
  11119. /**
  11120. * Where the animation should stop (animation frame)
  11121. */
  11122. to: number;
  11123. /**
  11124. * Define if the animation should loop or stop after the first play.
  11125. */
  11126. loop?: boolean;
  11127. private _target;
  11128. /**
  11129. * Instantiate the action
  11130. * @param triggerOptions defines the trigger options
  11131. * @param target defines the target animation or animation name
  11132. * @param from defines from where the animation should start (animation frame)
  11133. * @param end defines where the animation should stop (animation frame)
  11134. * @param loop defines if the animation should loop or stop after the first play
  11135. * @param condition defines the trigger related conditions
  11136. */
  11137. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  11138. /** @hidden */
  11139. _prepare(): void;
  11140. /**
  11141. * Execute the action and play the animation.
  11142. */
  11143. execute(): void;
  11144. /**
  11145. * Serializes the actions and its related information.
  11146. * @param parent defines the object to serialize in
  11147. * @returns the serialized object
  11148. */
  11149. serialize(parent: any): any;
  11150. }
  11151. /**
  11152. * This defines an action responsible to stop an animation once triggered.
  11153. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11154. */
  11155. export class StopAnimationAction extends Action {
  11156. private _target;
  11157. /**
  11158. * Instantiate the action
  11159. * @param triggerOptions defines the trigger options
  11160. * @param target defines the target animation or animation name
  11161. * @param condition defines the trigger related conditions
  11162. */
  11163. constructor(triggerOptions: any, target: any, condition?: Condition);
  11164. /** @hidden */
  11165. _prepare(): void;
  11166. /**
  11167. * Execute the action and stop the animation.
  11168. */
  11169. execute(): void;
  11170. /**
  11171. * Serializes the actions and its related information.
  11172. * @param parent defines the object to serialize in
  11173. * @returns the serialized object
  11174. */
  11175. serialize(parent: any): any;
  11176. }
  11177. /**
  11178. * This defines an action responsible that does nothing once triggered.
  11179. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11180. */
  11181. export class DoNothingAction extends Action {
  11182. /**
  11183. * Instantiate the action
  11184. * @param triggerOptions defines the trigger options
  11185. * @param condition defines the trigger related conditions
  11186. */
  11187. constructor(triggerOptions?: any, condition?: Condition);
  11188. /**
  11189. * Execute the action and do nothing.
  11190. */
  11191. execute(): void;
  11192. /**
  11193. * Serializes the actions and its related information.
  11194. * @param parent defines the object to serialize in
  11195. * @returns the serialized object
  11196. */
  11197. serialize(parent: any): any;
  11198. }
  11199. /**
  11200. * This defines an action responsible to trigger several actions once triggered.
  11201. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11202. */
  11203. export class CombineAction extends Action {
  11204. /**
  11205. * The list of aggregated animations to run.
  11206. */
  11207. children: Action[];
  11208. /**
  11209. * Instantiate the action
  11210. * @param triggerOptions defines the trigger options
  11211. * @param children defines the list of aggregated animations to run
  11212. * @param condition defines the trigger related conditions
  11213. */
  11214. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  11215. /** @hidden */
  11216. _prepare(): void;
  11217. /**
  11218. * Execute the action and executes all the aggregated actions.
  11219. */
  11220. execute(evt: ActionEvent): void;
  11221. /**
  11222. * Serializes the actions and its related information.
  11223. * @param parent defines the object to serialize in
  11224. * @returns the serialized object
  11225. */
  11226. serialize(parent: any): any;
  11227. }
  11228. /**
  11229. * This defines an action responsible to run code (external event) once triggered.
  11230. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11231. */
  11232. export class ExecuteCodeAction extends Action {
  11233. /**
  11234. * The callback function to run.
  11235. */
  11236. func: (evt: ActionEvent) => void;
  11237. /**
  11238. * Instantiate the action
  11239. * @param triggerOptions defines the trigger options
  11240. * @param func defines the callback function to run
  11241. * @param condition defines the trigger related conditions
  11242. */
  11243. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11244. /**
  11245. * Execute the action and run the attached code.
  11246. */
  11247. execute(evt: ActionEvent): void;
  11248. }
  11249. /**
  11250. * This defines an action responsible to set the parent property of the target once triggered.
  11251. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11252. */
  11253. export class SetParentAction extends Action {
  11254. private _parent;
  11255. private _target;
  11256. /**
  11257. * Instantiate the action
  11258. * @param triggerOptions defines the trigger options
  11259. * @param target defines the target containing the parent property
  11260. * @param parent defines from where the animation should start (animation frame)
  11261. * @param condition defines the trigger related conditions
  11262. */
  11263. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11264. /** @hidden */
  11265. _prepare(): void;
  11266. /**
  11267. * Execute the action and set the parent property.
  11268. */
  11269. execute(): void;
  11270. /**
  11271. * Serializes the actions and its related information.
  11272. * @param parent defines the object to serialize in
  11273. * @returns the serialized object
  11274. */
  11275. serialize(parent: any): any;
  11276. }
  11277. }
  11278. declare module BABYLON {
  11279. /**
  11280. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11281. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11282. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11283. */
  11284. export class ActionManager extends AbstractActionManager {
  11285. /**
  11286. * Nothing
  11287. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11288. */
  11289. static readonly NothingTrigger: number;
  11290. /**
  11291. * On pick
  11292. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11293. */
  11294. static readonly OnPickTrigger: number;
  11295. /**
  11296. * On left pick
  11297. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11298. */
  11299. static readonly OnLeftPickTrigger: number;
  11300. /**
  11301. * On right pick
  11302. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11303. */
  11304. static readonly OnRightPickTrigger: number;
  11305. /**
  11306. * On center pick
  11307. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11308. */
  11309. static readonly OnCenterPickTrigger: number;
  11310. /**
  11311. * On pick down
  11312. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11313. */
  11314. static readonly OnPickDownTrigger: number;
  11315. /**
  11316. * On double pick
  11317. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11318. */
  11319. static readonly OnDoublePickTrigger: number;
  11320. /**
  11321. * On pick up
  11322. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11323. */
  11324. static readonly OnPickUpTrigger: number;
  11325. /**
  11326. * On pick out.
  11327. * This trigger will only be raised if you also declared a OnPickDown
  11328. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11329. */
  11330. static readonly OnPickOutTrigger: number;
  11331. /**
  11332. * On long press
  11333. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11334. */
  11335. static readonly OnLongPressTrigger: number;
  11336. /**
  11337. * On pointer over
  11338. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11339. */
  11340. static readonly OnPointerOverTrigger: number;
  11341. /**
  11342. * On pointer out
  11343. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11344. */
  11345. static readonly OnPointerOutTrigger: number;
  11346. /**
  11347. * On every frame
  11348. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11349. */
  11350. static readonly OnEveryFrameTrigger: number;
  11351. /**
  11352. * On intersection enter
  11353. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11354. */
  11355. static readonly OnIntersectionEnterTrigger: number;
  11356. /**
  11357. * On intersection exit
  11358. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11359. */
  11360. static readonly OnIntersectionExitTrigger: number;
  11361. /**
  11362. * On key down
  11363. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11364. */
  11365. static readonly OnKeyDownTrigger: number;
  11366. /**
  11367. * On key up
  11368. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11369. */
  11370. static readonly OnKeyUpTrigger: number;
  11371. private _scene;
  11372. /**
  11373. * Creates a new action manager
  11374. * @param scene defines the hosting scene
  11375. */
  11376. constructor(scene: Scene);
  11377. /**
  11378. * Releases all associated resources
  11379. */
  11380. dispose(): void;
  11381. /**
  11382. * Gets hosting scene
  11383. * @returns the hosting scene
  11384. */
  11385. getScene(): Scene;
  11386. /**
  11387. * Does this action manager handles actions of any of the given triggers
  11388. * @param triggers defines the triggers to be tested
  11389. * @return a boolean indicating whether one (or more) of the triggers is handled
  11390. */
  11391. hasSpecificTriggers(triggers: number[]): boolean;
  11392. /**
  11393. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11394. * speed.
  11395. * @param triggerA defines the trigger to be tested
  11396. * @param triggerB defines the trigger to be tested
  11397. * @return a boolean indicating whether one (or more) of the triggers is handled
  11398. */
  11399. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11400. /**
  11401. * Does this action manager handles actions of a given trigger
  11402. * @param trigger defines the trigger to be tested
  11403. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11404. * @return whether the trigger is handled
  11405. */
  11406. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11407. /**
  11408. * Does this action manager has pointer triggers
  11409. */
  11410. readonly hasPointerTriggers: boolean;
  11411. /**
  11412. * Does this action manager has pick triggers
  11413. */
  11414. readonly hasPickTriggers: boolean;
  11415. /**
  11416. * Registers an action to this action manager
  11417. * @param action defines the action to be registered
  11418. * @return the action amended (prepared) after registration
  11419. */
  11420. registerAction(action: IAction): Nullable<IAction>;
  11421. /**
  11422. * Unregisters an action to this action manager
  11423. * @param action defines the action to be unregistered
  11424. * @return a boolean indicating whether the action has been unregistered
  11425. */
  11426. unregisterAction(action: IAction): Boolean;
  11427. /**
  11428. * Process a specific trigger
  11429. * @param trigger defines the trigger to process
  11430. * @param evt defines the event details to be processed
  11431. */
  11432. processTrigger(trigger: number, evt?: IActionEvent): void;
  11433. /** @hidden */
  11434. _getEffectiveTarget(target: any, propertyPath: string): any;
  11435. /** @hidden */
  11436. _getProperty(propertyPath: string): string;
  11437. /**
  11438. * Serialize this manager to a JSON object
  11439. * @param name defines the property name to store this manager
  11440. * @returns a JSON representation of this manager
  11441. */
  11442. serialize(name: string): any;
  11443. /**
  11444. * Creates a new ActionManager from a JSON data
  11445. * @param parsedActions defines the JSON data to read from
  11446. * @param object defines the hosting mesh
  11447. * @param scene defines the hosting scene
  11448. */
  11449. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11450. /**
  11451. * Get a trigger name by index
  11452. * @param trigger defines the trigger index
  11453. * @returns a trigger name
  11454. */
  11455. static GetTriggerName(trigger: number): string;
  11456. }
  11457. }
  11458. declare module BABYLON {
  11459. /**
  11460. * Class representing a ray with position and direction
  11461. */
  11462. export class Ray {
  11463. /** origin point */
  11464. origin: Vector3;
  11465. /** direction */
  11466. direction: Vector3;
  11467. /** length of the ray */
  11468. length: number;
  11469. private static readonly TmpVector3;
  11470. private _tmpRay;
  11471. /**
  11472. * Creates a new ray
  11473. * @param origin origin point
  11474. * @param direction direction
  11475. * @param length length of the ray
  11476. */
  11477. constructor(
  11478. /** origin point */
  11479. origin: Vector3,
  11480. /** direction */
  11481. direction: Vector3,
  11482. /** length of the ray */
  11483. length?: number);
  11484. /**
  11485. * Checks if the ray intersects a box
  11486. * @param minimum bound of the box
  11487. * @param maximum bound of the box
  11488. * @param intersectionTreshold extra extend to be added to the box in all direction
  11489. * @returns if the box was hit
  11490. */
  11491. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11492. /**
  11493. * Checks if the ray intersects a box
  11494. * @param box the bounding box to check
  11495. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11496. * @returns if the box was hit
  11497. */
  11498. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11499. /**
  11500. * If the ray hits a sphere
  11501. * @param sphere the bounding sphere to check
  11502. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11503. * @returns true if it hits the sphere
  11504. */
  11505. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11506. /**
  11507. * If the ray hits a triange
  11508. * @param vertex0 triangle vertex
  11509. * @param vertex1 triangle vertex
  11510. * @param vertex2 triangle vertex
  11511. * @returns intersection information if hit
  11512. */
  11513. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11514. /**
  11515. * Checks if ray intersects a plane
  11516. * @param plane the plane to check
  11517. * @returns the distance away it was hit
  11518. */
  11519. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11520. /**
  11521. * Checks if ray intersects a mesh
  11522. * @param mesh the mesh to check
  11523. * @param fastCheck if only the bounding box should checked
  11524. * @returns picking info of the intersecton
  11525. */
  11526. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11527. /**
  11528. * Checks if ray intersects a mesh
  11529. * @param meshes the meshes to check
  11530. * @param fastCheck if only the bounding box should checked
  11531. * @param results array to store result in
  11532. * @returns Array of picking infos
  11533. */
  11534. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11535. private _comparePickingInfo;
  11536. private static smallnum;
  11537. private static rayl;
  11538. /**
  11539. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11540. * @param sega the first point of the segment to test the intersection against
  11541. * @param segb the second point of the segment to test the intersection against
  11542. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11543. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11544. */
  11545. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11546. /**
  11547. * Update the ray from viewport position
  11548. * @param x position
  11549. * @param y y position
  11550. * @param viewportWidth viewport width
  11551. * @param viewportHeight viewport height
  11552. * @param world world matrix
  11553. * @param view view matrix
  11554. * @param projection projection matrix
  11555. * @returns this ray updated
  11556. */
  11557. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11558. /**
  11559. * Creates a ray with origin and direction of 0,0,0
  11560. * @returns the new ray
  11561. */
  11562. static Zero(): Ray;
  11563. /**
  11564. * Creates a new ray from screen space and viewport
  11565. * @param x position
  11566. * @param y y position
  11567. * @param viewportWidth viewport width
  11568. * @param viewportHeight viewport height
  11569. * @param world world matrix
  11570. * @param view view matrix
  11571. * @param projection projection matrix
  11572. * @returns new ray
  11573. */
  11574. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11575. /**
  11576. * 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
  11577. * transformed to the given world matrix.
  11578. * @param origin The origin point
  11579. * @param end The end point
  11580. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11581. * @returns the new ray
  11582. */
  11583. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11584. /**
  11585. * Transforms a ray by a matrix
  11586. * @param ray ray to transform
  11587. * @param matrix matrix to apply
  11588. * @returns the resulting new ray
  11589. */
  11590. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11591. /**
  11592. * Transforms a ray by a matrix
  11593. * @param ray ray to transform
  11594. * @param matrix matrix to apply
  11595. * @param result ray to store result in
  11596. */
  11597. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11598. /**
  11599. * Unproject a ray from screen space to object space
  11600. * @param sourceX defines the screen space x coordinate to use
  11601. * @param sourceY defines the screen space y coordinate to use
  11602. * @param viewportWidth defines the current width of the viewport
  11603. * @param viewportHeight defines the current height of the viewport
  11604. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11605. * @param view defines the view matrix to use
  11606. * @param projection defines the projection matrix to use
  11607. */
  11608. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11609. }
  11610. /**
  11611. * Type used to define predicate used to select faces when a mesh intersection is detected
  11612. */
  11613. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11614. interface Scene {
  11615. /** @hidden */
  11616. _tempPickingRay: Nullable<Ray>;
  11617. /** @hidden */
  11618. _cachedRayForTransform: Ray;
  11619. /** @hidden */
  11620. _pickWithRayInverseMatrix: Matrix;
  11621. /** @hidden */
  11622. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11623. /** @hidden */
  11624. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11625. }
  11626. }
  11627. declare module BABYLON {
  11628. /**
  11629. * Groups all the scene component constants in one place to ease maintenance.
  11630. * @hidden
  11631. */
  11632. export class SceneComponentConstants {
  11633. static readonly NAME_EFFECTLAYER: string;
  11634. static readonly NAME_LAYER: string;
  11635. static readonly NAME_LENSFLARESYSTEM: string;
  11636. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11637. static readonly NAME_PARTICLESYSTEM: string;
  11638. static readonly NAME_GAMEPAD: string;
  11639. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11640. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11641. static readonly NAME_DEPTHRENDERER: string;
  11642. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11643. static readonly NAME_SPRITE: string;
  11644. static readonly NAME_OUTLINERENDERER: string;
  11645. static readonly NAME_PROCEDURALTEXTURE: string;
  11646. static readonly NAME_SHADOWGENERATOR: string;
  11647. static readonly NAME_OCTREE: string;
  11648. static readonly NAME_PHYSICSENGINE: string;
  11649. static readonly NAME_AUDIO: string;
  11650. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11651. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11652. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11653. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11654. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11655. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11656. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11657. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11658. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11659. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11660. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11661. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11662. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11663. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11664. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11665. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11666. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11667. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11668. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11669. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11670. static readonly STEP_AFTERRENDER_AUDIO: number;
  11671. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11672. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11673. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11674. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11675. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11676. static readonly STEP_POINTERMOVE_SPRITE: number;
  11677. static readonly STEP_POINTERDOWN_SPRITE: number;
  11678. static readonly STEP_POINTERUP_SPRITE: number;
  11679. }
  11680. /**
  11681. * This represents a scene component.
  11682. *
  11683. * This is used to decouple the dependency the scene is having on the different workloads like
  11684. * layers, post processes...
  11685. */
  11686. export interface ISceneComponent {
  11687. /**
  11688. * The name of the component. Each component must have a unique name.
  11689. */
  11690. name: string;
  11691. /**
  11692. * The scene the component belongs to.
  11693. */
  11694. scene: Scene;
  11695. /**
  11696. * Register the component to one instance of a scene.
  11697. */
  11698. register(): void;
  11699. /**
  11700. * Rebuilds the elements related to this component in case of
  11701. * context lost for instance.
  11702. */
  11703. rebuild(): void;
  11704. /**
  11705. * Disposes the component and the associated ressources.
  11706. */
  11707. dispose(): void;
  11708. }
  11709. /**
  11710. * This represents a SERIALIZABLE scene component.
  11711. *
  11712. * This extends Scene Component to add Serialization methods on top.
  11713. */
  11714. export interface ISceneSerializableComponent extends ISceneComponent {
  11715. /**
  11716. * Adds all the elements from the container to the scene
  11717. * @param container the container holding the elements
  11718. */
  11719. addFromContainer(container: AbstractScene): void;
  11720. /**
  11721. * Removes all the elements in the container from the scene
  11722. * @param container contains the elements to remove
  11723. * @param dispose if the removed element should be disposed (default: false)
  11724. */
  11725. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11726. /**
  11727. * Serializes the component data to the specified json object
  11728. * @param serializationObject The object to serialize to
  11729. */
  11730. serialize(serializationObject: any): void;
  11731. }
  11732. /**
  11733. * Strong typing of a Mesh related stage step action
  11734. */
  11735. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11736. /**
  11737. * Strong typing of a Evaluate Sub Mesh related stage step action
  11738. */
  11739. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11740. /**
  11741. * Strong typing of a Active Mesh related stage step action
  11742. */
  11743. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11744. /**
  11745. * Strong typing of a Camera related stage step action
  11746. */
  11747. export type CameraStageAction = (camera: Camera) => void;
  11748. /**
  11749. * Strong typing of a Camera Frame buffer related stage step action
  11750. */
  11751. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11752. /**
  11753. * Strong typing of a Render Target related stage step action
  11754. */
  11755. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11756. /**
  11757. * Strong typing of a RenderingGroup related stage step action
  11758. */
  11759. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11760. /**
  11761. * Strong typing of a Mesh Render related stage step action
  11762. */
  11763. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11764. /**
  11765. * Strong typing of a simple stage step action
  11766. */
  11767. export type SimpleStageAction = () => void;
  11768. /**
  11769. * Strong typing of a render target action.
  11770. */
  11771. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11772. /**
  11773. * Strong typing of a pointer move action.
  11774. */
  11775. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11776. /**
  11777. * Strong typing of a pointer up/down action.
  11778. */
  11779. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11780. /**
  11781. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11782. * @hidden
  11783. */
  11784. export class Stage<T extends Function> extends Array<{
  11785. index: number;
  11786. component: ISceneComponent;
  11787. action: T;
  11788. }> {
  11789. /**
  11790. * Hide ctor from the rest of the world.
  11791. * @param items The items to add.
  11792. */
  11793. private constructor();
  11794. /**
  11795. * Creates a new Stage.
  11796. * @returns A new instance of a Stage
  11797. */
  11798. static Create<T extends Function>(): Stage<T>;
  11799. /**
  11800. * Registers a step in an ordered way in the targeted stage.
  11801. * @param index Defines the position to register the step in
  11802. * @param component Defines the component attached to the step
  11803. * @param action Defines the action to launch during the step
  11804. */
  11805. registerStep(index: number, component: ISceneComponent, action: T): void;
  11806. /**
  11807. * Clears all the steps from the stage.
  11808. */
  11809. clear(): void;
  11810. }
  11811. }
  11812. declare module BABYLON {
  11813. interface Scene {
  11814. /** @hidden */
  11815. _pointerOverSprite: Nullable<Sprite>;
  11816. /** @hidden */
  11817. _pickedDownSprite: Nullable<Sprite>;
  11818. /** @hidden */
  11819. _tempSpritePickingRay: Nullable<Ray>;
  11820. /**
  11821. * All of the sprite managers added to this scene
  11822. * @see http://doc.babylonjs.com/babylon101/sprites
  11823. */
  11824. spriteManagers: Array<ISpriteManager>;
  11825. /**
  11826. * An event triggered when sprites rendering is about to start
  11827. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11828. */
  11829. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11830. /**
  11831. * An event triggered when sprites rendering is done
  11832. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11833. */
  11834. onAfterSpritesRenderingObservable: Observable<Scene>;
  11835. /** @hidden */
  11836. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11837. /** Launch a ray to try to pick a sprite in the scene
  11838. * @param x position on screen
  11839. * @param y position on screen
  11840. * @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
  11841. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11842. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11843. * @returns a PickingInfo
  11844. */
  11845. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11846. /** Use the given ray to pick a sprite in the scene
  11847. * @param ray The ray (in world space) to use to pick meshes
  11848. * @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
  11849. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11850. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11851. * @returns a PickingInfo
  11852. */
  11853. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11854. /**
  11855. * Force the sprite under the pointer
  11856. * @param sprite defines the sprite to use
  11857. */
  11858. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11859. /**
  11860. * Gets the sprite under the pointer
  11861. * @returns a Sprite or null if no sprite is under the pointer
  11862. */
  11863. getPointerOverSprite(): Nullable<Sprite>;
  11864. }
  11865. /**
  11866. * Defines the sprite scene component responsible to manage sprites
  11867. * in a given scene.
  11868. */
  11869. export class SpriteSceneComponent implements ISceneComponent {
  11870. /**
  11871. * The component name helpfull to identify the component in the list of scene components.
  11872. */
  11873. readonly name: string;
  11874. /**
  11875. * The scene the component belongs to.
  11876. */
  11877. scene: Scene;
  11878. /** @hidden */
  11879. private _spritePredicate;
  11880. /**
  11881. * Creates a new instance of the component for the given scene
  11882. * @param scene Defines the scene to register the component in
  11883. */
  11884. constructor(scene: Scene);
  11885. /**
  11886. * Registers the component in a given scene
  11887. */
  11888. register(): void;
  11889. /**
  11890. * Rebuilds the elements related to this component in case of
  11891. * context lost for instance.
  11892. */
  11893. rebuild(): void;
  11894. /**
  11895. * Disposes the component and the associated ressources.
  11896. */
  11897. dispose(): void;
  11898. private _pickSpriteButKeepRay;
  11899. private _pointerMove;
  11900. private _pointerDown;
  11901. private _pointerUp;
  11902. }
  11903. }
  11904. declare module BABYLON {
  11905. /** @hidden */
  11906. export var fogFragmentDeclaration: {
  11907. name: string;
  11908. shader: string;
  11909. };
  11910. }
  11911. declare module BABYLON {
  11912. /** @hidden */
  11913. export var fogFragment: {
  11914. name: string;
  11915. shader: string;
  11916. };
  11917. }
  11918. declare module BABYLON {
  11919. /** @hidden */
  11920. export var spritesPixelShader: {
  11921. name: string;
  11922. shader: string;
  11923. };
  11924. }
  11925. declare module BABYLON {
  11926. /** @hidden */
  11927. export var fogVertexDeclaration: {
  11928. name: string;
  11929. shader: string;
  11930. };
  11931. }
  11932. declare module BABYLON {
  11933. /** @hidden */
  11934. export var spritesVertexShader: {
  11935. name: string;
  11936. shader: string;
  11937. };
  11938. }
  11939. declare module BABYLON {
  11940. /**
  11941. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11942. */
  11943. export interface ISpriteManager extends IDisposable {
  11944. /**
  11945. * Restricts the camera to viewing objects with the same layerMask.
  11946. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11947. */
  11948. layerMask: number;
  11949. /**
  11950. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11951. */
  11952. isPickable: boolean;
  11953. /**
  11954. * Specifies the rendering group id for this mesh (0 by default)
  11955. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11956. */
  11957. renderingGroupId: number;
  11958. /**
  11959. * Defines the list of sprites managed by the manager.
  11960. */
  11961. sprites: Array<Sprite>;
  11962. /**
  11963. * Tests the intersection of a sprite with a specific ray.
  11964. * @param ray The ray we are sending to test the collision
  11965. * @param camera The camera space we are sending rays in
  11966. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11967. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11968. * @returns picking info or null.
  11969. */
  11970. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11971. /**
  11972. * Renders the list of sprites on screen.
  11973. */
  11974. render(): void;
  11975. }
  11976. /**
  11977. * Class used to manage multiple sprites on the same spritesheet
  11978. * @see http://doc.babylonjs.com/babylon101/sprites
  11979. */
  11980. export class SpriteManager implements ISpriteManager {
  11981. /** defines the manager's name */
  11982. name: string;
  11983. /** Gets the list of sprites */
  11984. sprites: Sprite[];
  11985. /** Gets or sets the rendering group id (0 by default) */
  11986. renderingGroupId: number;
  11987. /** Gets or sets camera layer mask */
  11988. layerMask: number;
  11989. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11990. fogEnabled: boolean;
  11991. /** Gets or sets a boolean indicating if the sprites are pickable */
  11992. isPickable: boolean;
  11993. /** Defines the default width of a cell in the spritesheet */
  11994. cellWidth: number;
  11995. /** Defines the default height of a cell in the spritesheet */
  11996. cellHeight: number;
  11997. /**
  11998. * An event triggered when the manager is disposed.
  11999. */
  12000. onDisposeObservable: Observable<SpriteManager>;
  12001. private _onDisposeObserver;
  12002. /**
  12003. * Callback called when the manager is disposed
  12004. */
  12005. onDispose: () => void;
  12006. private _capacity;
  12007. private _spriteTexture;
  12008. private _epsilon;
  12009. private _scene;
  12010. private _vertexData;
  12011. private _buffer;
  12012. private _vertexBuffers;
  12013. private _indexBuffer;
  12014. private _effectBase;
  12015. private _effectFog;
  12016. /**
  12017. * Gets or sets the spritesheet texture
  12018. */
  12019. texture: Texture;
  12020. /**
  12021. * Creates a new sprite manager
  12022. * @param name defines the manager's name
  12023. * @param imgUrl defines the sprite sheet url
  12024. * @param capacity defines the maximum allowed number of sprites
  12025. * @param cellSize defines the size of a sprite cell
  12026. * @param scene defines the hosting scene
  12027. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  12028. * @param samplingMode defines the smapling mode to use with spritesheet
  12029. */
  12030. constructor(
  12031. /** defines the manager's name */
  12032. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  12033. private _appendSpriteVertex;
  12034. /**
  12035. * Intersects the sprites with a ray
  12036. * @param ray defines the ray to intersect with
  12037. * @param camera defines the current active camera
  12038. * @param predicate defines a predicate used to select candidate sprites
  12039. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  12040. * @returns null if no hit or a PickingInfo
  12041. */
  12042. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  12043. /**
  12044. * Render all child sprites
  12045. */
  12046. render(): void;
  12047. /**
  12048. * Release associated resources
  12049. */
  12050. dispose(): void;
  12051. }
  12052. }
  12053. declare module BABYLON {
  12054. /**
  12055. * Class used to represent a sprite
  12056. * @see http://doc.babylonjs.com/babylon101/sprites
  12057. */
  12058. export class Sprite {
  12059. /** defines the name */
  12060. name: string;
  12061. /** Gets or sets the current world position */
  12062. position: Vector3;
  12063. /** Gets or sets the main color */
  12064. color: Color4;
  12065. /** Gets or sets the width */
  12066. width: number;
  12067. /** Gets or sets the height */
  12068. height: number;
  12069. /** Gets or sets rotation angle */
  12070. angle: number;
  12071. /** Gets or sets the cell index in the sprite sheet */
  12072. cellIndex: number;
  12073. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  12074. invertU: number;
  12075. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  12076. invertV: number;
  12077. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  12078. disposeWhenFinishedAnimating: boolean;
  12079. /** Gets the list of attached animations */
  12080. animations: Animation[];
  12081. /** Gets or sets a boolean indicating if the sprite can be picked */
  12082. isPickable: boolean;
  12083. /**
  12084. * Gets or sets the associated action manager
  12085. */
  12086. actionManager: Nullable<ActionManager>;
  12087. private _animationStarted;
  12088. private _loopAnimation;
  12089. private _fromIndex;
  12090. private _toIndex;
  12091. private _delay;
  12092. private _direction;
  12093. private _manager;
  12094. private _time;
  12095. private _onAnimationEnd;
  12096. /**
  12097. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  12098. */
  12099. isVisible: boolean;
  12100. /**
  12101. * Gets or sets the sprite size
  12102. */
  12103. size: number;
  12104. /**
  12105. * Creates a new Sprite
  12106. * @param name defines the name
  12107. * @param manager defines the manager
  12108. */
  12109. constructor(
  12110. /** defines the name */
  12111. name: string, manager: ISpriteManager);
  12112. /**
  12113. * Starts an animation
  12114. * @param from defines the initial key
  12115. * @param to defines the end key
  12116. * @param loop defines if the animation must loop
  12117. * @param delay defines the start delay (in ms)
  12118. * @param onAnimationEnd defines a callback to call when animation ends
  12119. */
  12120. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  12121. /** Stops current animation (if any) */
  12122. stopAnimation(): void;
  12123. /** @hidden */
  12124. _animate(deltaTime: number): void;
  12125. /** Release associated resources */
  12126. dispose(): void;
  12127. }
  12128. }
  12129. declare module BABYLON {
  12130. /**
  12131. * Information about the result of picking within a scene
  12132. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  12133. */
  12134. export class PickingInfo {
  12135. /** @hidden */
  12136. _pickingUnavailable: boolean;
  12137. /**
  12138. * If the pick collided with an object
  12139. */
  12140. hit: boolean;
  12141. /**
  12142. * Distance away where the pick collided
  12143. */
  12144. distance: number;
  12145. /**
  12146. * The location of pick collision
  12147. */
  12148. pickedPoint: Nullable<Vector3>;
  12149. /**
  12150. * The mesh corresponding the the pick collision
  12151. */
  12152. pickedMesh: Nullable<AbstractMesh>;
  12153. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  12154. bu: number;
  12155. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  12156. bv: number;
  12157. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12158. faceId: number;
  12159. /** Id of the the submesh that was picked */
  12160. subMeshId: number;
  12161. /** If a sprite was picked, this will be the sprite the pick collided with */
  12162. pickedSprite: Nullable<Sprite>;
  12163. /**
  12164. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12165. */
  12166. originMesh: Nullable<AbstractMesh>;
  12167. /**
  12168. * The ray that was used to perform the picking.
  12169. */
  12170. ray: Nullable<Ray>;
  12171. /**
  12172. * Gets the normal correspodning to the face the pick collided with
  12173. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12174. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12175. * @returns The normal correspodning to the face the pick collided with
  12176. */
  12177. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12178. /**
  12179. * Gets the texture coordinates of where the pick occured
  12180. * @returns the vector containing the coordnates of the texture
  12181. */
  12182. getTextureCoordinates(): Nullable<Vector2>;
  12183. }
  12184. }
  12185. declare module BABYLON {
  12186. /**
  12187. * Gather the list of pointer event types as constants.
  12188. */
  12189. export class PointerEventTypes {
  12190. /**
  12191. * 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.
  12192. */
  12193. static readonly POINTERDOWN: number;
  12194. /**
  12195. * The pointerup event is fired when a pointer is no longer active.
  12196. */
  12197. static readonly POINTERUP: number;
  12198. /**
  12199. * The pointermove event is fired when a pointer changes coordinates.
  12200. */
  12201. static readonly POINTERMOVE: number;
  12202. /**
  12203. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12204. */
  12205. static readonly POINTERWHEEL: number;
  12206. /**
  12207. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12208. */
  12209. static readonly POINTERPICK: number;
  12210. /**
  12211. * The pointertap event is fired when a the object has been touched and released without drag.
  12212. */
  12213. static readonly POINTERTAP: number;
  12214. /**
  12215. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12216. */
  12217. static readonly POINTERDOUBLETAP: number;
  12218. }
  12219. /**
  12220. * Base class of pointer info types.
  12221. */
  12222. export class PointerInfoBase {
  12223. /**
  12224. * Defines the type of event (PointerEventTypes)
  12225. */
  12226. type: number;
  12227. /**
  12228. * Defines the related dom event
  12229. */
  12230. event: PointerEvent | MouseWheelEvent;
  12231. /**
  12232. * Instantiates the base class of pointers info.
  12233. * @param type Defines the type of event (PointerEventTypes)
  12234. * @param event Defines the related dom event
  12235. */
  12236. constructor(
  12237. /**
  12238. * Defines the type of event (PointerEventTypes)
  12239. */
  12240. type: number,
  12241. /**
  12242. * Defines the related dom event
  12243. */
  12244. event: PointerEvent | MouseWheelEvent);
  12245. }
  12246. /**
  12247. * This class is used to store pointer related info for the onPrePointerObservable event.
  12248. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12249. */
  12250. export class PointerInfoPre extends PointerInfoBase {
  12251. /**
  12252. * Ray from a pointer if availible (eg. 6dof controller)
  12253. */
  12254. ray: Nullable<Ray>;
  12255. /**
  12256. * Defines the local position of the pointer on the canvas.
  12257. */
  12258. localPosition: Vector2;
  12259. /**
  12260. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12261. */
  12262. skipOnPointerObservable: boolean;
  12263. /**
  12264. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12265. * @param type Defines the type of event (PointerEventTypes)
  12266. * @param event Defines the related dom event
  12267. * @param localX Defines the local x coordinates of the pointer when the event occured
  12268. * @param localY Defines the local y coordinates of the pointer when the event occured
  12269. */
  12270. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12271. }
  12272. /**
  12273. * This type contains all the data related to a pointer event in Babylon.js.
  12274. * 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.
  12275. */
  12276. export class PointerInfo extends PointerInfoBase {
  12277. /**
  12278. * Defines the picking info associated to the info (if any)\
  12279. */
  12280. pickInfo: Nullable<PickingInfo>;
  12281. /**
  12282. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12283. * @param type Defines the type of event (PointerEventTypes)
  12284. * @param event Defines the related dom event
  12285. * @param pickInfo Defines the picking info associated to the info (if any)\
  12286. */
  12287. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12288. /**
  12289. * Defines the picking info associated to the info (if any)\
  12290. */
  12291. pickInfo: Nullable<PickingInfo>);
  12292. }
  12293. /**
  12294. * Data relating to a touch event on the screen.
  12295. */
  12296. export interface PointerTouch {
  12297. /**
  12298. * X coordinate of touch.
  12299. */
  12300. x: number;
  12301. /**
  12302. * Y coordinate of touch.
  12303. */
  12304. y: number;
  12305. /**
  12306. * Id of touch. Unique for each finger.
  12307. */
  12308. pointerId: number;
  12309. /**
  12310. * Event type passed from DOM.
  12311. */
  12312. type: any;
  12313. }
  12314. }
  12315. declare module BABYLON {
  12316. /**
  12317. * Manage the mouse inputs to control the movement of a free camera.
  12318. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12319. */
  12320. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12321. /**
  12322. * Define if touch is enabled in the mouse input
  12323. */
  12324. touchEnabled: boolean;
  12325. /**
  12326. * Defines the camera the input is attached to.
  12327. */
  12328. camera: FreeCamera;
  12329. /**
  12330. * Defines the buttons associated with the input to handle camera move.
  12331. */
  12332. buttons: number[];
  12333. /**
  12334. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12335. */
  12336. angularSensibility: number;
  12337. private _pointerInput;
  12338. private _onMouseMove;
  12339. private _observer;
  12340. private previousPosition;
  12341. /**
  12342. * Observable for when a pointer move event occurs containing the move offset
  12343. */
  12344. onPointerMovedObservable: Observable<{
  12345. offsetX: number;
  12346. offsetY: number;
  12347. }>;
  12348. /**
  12349. * @hidden
  12350. * If the camera should be rotated automatically based on pointer movement
  12351. */
  12352. _allowCameraRotation: boolean;
  12353. /**
  12354. * Manage the mouse inputs to control the movement of a free camera.
  12355. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12356. * @param touchEnabled Defines if touch is enabled or not
  12357. */
  12358. constructor(
  12359. /**
  12360. * Define if touch is enabled in the mouse input
  12361. */
  12362. touchEnabled?: boolean);
  12363. /**
  12364. * Attach the input controls to a specific dom element to get the input from.
  12365. * @param element Defines the element the controls should be listened from
  12366. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12367. */
  12368. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12369. /**
  12370. * Called on JS contextmenu event.
  12371. * Override this method to provide functionality.
  12372. */
  12373. protected onContextMenu(evt: PointerEvent): void;
  12374. /**
  12375. * Detach the current controls from the specified dom element.
  12376. * @param element Defines the element to stop listening the inputs from
  12377. */
  12378. detachControl(element: Nullable<HTMLElement>): void;
  12379. /**
  12380. * Gets the class name of the current intput.
  12381. * @returns the class name
  12382. */
  12383. getClassName(): string;
  12384. /**
  12385. * Get the friendly name associated with the input class.
  12386. * @returns the input friendly name
  12387. */
  12388. getSimpleName(): string;
  12389. }
  12390. }
  12391. declare module BABYLON {
  12392. /**
  12393. * Manage the touch inputs to control the movement of a free camera.
  12394. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12395. */
  12396. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12397. /**
  12398. * Defines the camera the input is attached to.
  12399. */
  12400. camera: FreeCamera;
  12401. /**
  12402. * Defines the touch sensibility for rotation.
  12403. * The higher the faster.
  12404. */
  12405. touchAngularSensibility: number;
  12406. /**
  12407. * Defines the touch sensibility for move.
  12408. * The higher the faster.
  12409. */
  12410. touchMoveSensibility: number;
  12411. private _offsetX;
  12412. private _offsetY;
  12413. private _pointerPressed;
  12414. private _pointerInput;
  12415. private _observer;
  12416. private _onLostFocus;
  12417. /**
  12418. * Attach the input controls to a specific dom element to get the input from.
  12419. * @param element Defines the element the controls should be listened from
  12420. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12421. */
  12422. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12423. /**
  12424. * Detach the current controls from the specified dom element.
  12425. * @param element Defines the element to stop listening the inputs from
  12426. */
  12427. detachControl(element: Nullable<HTMLElement>): void;
  12428. /**
  12429. * Update the current camera state depending on the inputs that have been used this frame.
  12430. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12431. */
  12432. checkInputs(): void;
  12433. /**
  12434. * Gets the class name of the current intput.
  12435. * @returns the class name
  12436. */
  12437. getClassName(): string;
  12438. /**
  12439. * Get the friendly name associated with the input class.
  12440. * @returns the input friendly name
  12441. */
  12442. getSimpleName(): string;
  12443. }
  12444. }
  12445. declare module BABYLON {
  12446. /**
  12447. * Default Inputs manager for the FreeCamera.
  12448. * It groups all the default supported inputs for ease of use.
  12449. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12450. */
  12451. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12452. /**
  12453. * @hidden
  12454. */
  12455. _mouseInput: Nullable<FreeCameraMouseInput>;
  12456. /**
  12457. * Instantiates a new FreeCameraInputsManager.
  12458. * @param camera Defines the camera the inputs belong to
  12459. */
  12460. constructor(camera: FreeCamera);
  12461. /**
  12462. * Add keyboard input support to the input manager.
  12463. * @returns the current input manager
  12464. */
  12465. addKeyboard(): FreeCameraInputsManager;
  12466. /**
  12467. * Add mouse input support to the input manager.
  12468. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12469. * @returns the current input manager
  12470. */
  12471. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12472. /**
  12473. * Removes the mouse input support from the manager
  12474. * @returns the current input manager
  12475. */
  12476. removeMouse(): FreeCameraInputsManager;
  12477. /**
  12478. * Add touch input support to the input manager.
  12479. * @returns the current input manager
  12480. */
  12481. addTouch(): FreeCameraInputsManager;
  12482. /**
  12483. * Remove all attached input methods from a camera
  12484. */
  12485. clear(): void;
  12486. }
  12487. }
  12488. declare module BABYLON {
  12489. /**
  12490. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12491. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12492. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12493. */
  12494. export class FreeCamera extends TargetCamera {
  12495. /**
  12496. * Define the collision ellipsoid of the camera.
  12497. * This is helpful to simulate a camera body like the player body around the camera
  12498. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12499. */
  12500. ellipsoid: Vector3;
  12501. /**
  12502. * Define an offset for the position of the ellipsoid around the camera.
  12503. * This can be helpful to determine the center of the body near the gravity center of the body
  12504. * instead of its head.
  12505. */
  12506. ellipsoidOffset: Vector3;
  12507. /**
  12508. * Enable or disable collisions of the camera with the rest of the scene objects.
  12509. */
  12510. checkCollisions: boolean;
  12511. /**
  12512. * Enable or disable gravity on the camera.
  12513. */
  12514. applyGravity: boolean;
  12515. /**
  12516. * Define the input manager associated to the camera.
  12517. */
  12518. inputs: FreeCameraInputsManager;
  12519. /**
  12520. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12521. * Higher values reduce sensitivity.
  12522. */
  12523. /**
  12524. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12525. * Higher values reduce sensitivity.
  12526. */
  12527. angularSensibility: number;
  12528. /**
  12529. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12530. */
  12531. keysUp: number[];
  12532. /**
  12533. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12534. */
  12535. keysDown: number[];
  12536. /**
  12537. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12538. */
  12539. keysLeft: number[];
  12540. /**
  12541. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12542. */
  12543. keysRight: number[];
  12544. /**
  12545. * Event raised when the camera collide with a mesh in the scene.
  12546. */
  12547. onCollide: (collidedMesh: AbstractMesh) => void;
  12548. private _collider;
  12549. private _needMoveForGravity;
  12550. private _oldPosition;
  12551. private _diffPosition;
  12552. private _newPosition;
  12553. /** @hidden */
  12554. _localDirection: Vector3;
  12555. /** @hidden */
  12556. _transformedDirection: Vector3;
  12557. /**
  12558. * Instantiates a Free Camera.
  12559. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12560. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12561. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12562. * @param name Define the name of the camera in the scene
  12563. * @param position Define the start position of the camera in the scene
  12564. * @param scene Define the scene the camera belongs to
  12565. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12566. */
  12567. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12568. /**
  12569. * Attached controls to the current camera.
  12570. * @param element Defines the element the controls should be listened from
  12571. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12572. */
  12573. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12574. /**
  12575. * Detach the current controls from the camera.
  12576. * The camera will stop reacting to inputs.
  12577. * @param element Defines the element to stop listening the inputs from
  12578. */
  12579. detachControl(element: HTMLElement): void;
  12580. private _collisionMask;
  12581. /**
  12582. * Define a collision mask to limit the list of object the camera can collide with
  12583. */
  12584. collisionMask: number;
  12585. /** @hidden */
  12586. _collideWithWorld(displacement: Vector3): void;
  12587. private _onCollisionPositionChange;
  12588. /** @hidden */
  12589. _checkInputs(): void;
  12590. /** @hidden */
  12591. _decideIfNeedsToMove(): boolean;
  12592. /** @hidden */
  12593. _updatePosition(): void;
  12594. /**
  12595. * Destroy the camera and release the current resources hold by it.
  12596. */
  12597. dispose(): void;
  12598. /**
  12599. * Gets the current object class name.
  12600. * @return the class name
  12601. */
  12602. getClassName(): string;
  12603. }
  12604. }
  12605. declare module BABYLON {
  12606. /**
  12607. * Represents a gamepad control stick position
  12608. */
  12609. export class StickValues {
  12610. /**
  12611. * The x component of the control stick
  12612. */
  12613. x: number;
  12614. /**
  12615. * The y component of the control stick
  12616. */
  12617. y: number;
  12618. /**
  12619. * Initializes the gamepad x and y control stick values
  12620. * @param x The x component of the gamepad control stick value
  12621. * @param y The y component of the gamepad control stick value
  12622. */
  12623. constructor(
  12624. /**
  12625. * The x component of the control stick
  12626. */
  12627. x: number,
  12628. /**
  12629. * The y component of the control stick
  12630. */
  12631. y: number);
  12632. }
  12633. /**
  12634. * An interface which manages callbacks for gamepad button changes
  12635. */
  12636. export interface GamepadButtonChanges {
  12637. /**
  12638. * Called when a gamepad has been changed
  12639. */
  12640. changed: boolean;
  12641. /**
  12642. * Called when a gamepad press event has been triggered
  12643. */
  12644. pressChanged: boolean;
  12645. /**
  12646. * Called when a touch event has been triggered
  12647. */
  12648. touchChanged: boolean;
  12649. /**
  12650. * Called when a value has changed
  12651. */
  12652. valueChanged: boolean;
  12653. }
  12654. /**
  12655. * Represents a gamepad
  12656. */
  12657. export class Gamepad {
  12658. /**
  12659. * The id of the gamepad
  12660. */
  12661. id: string;
  12662. /**
  12663. * The index of the gamepad
  12664. */
  12665. index: number;
  12666. /**
  12667. * The browser gamepad
  12668. */
  12669. browserGamepad: any;
  12670. /**
  12671. * Specifies what type of gamepad this represents
  12672. */
  12673. type: number;
  12674. private _leftStick;
  12675. private _rightStick;
  12676. /** @hidden */
  12677. _isConnected: boolean;
  12678. private _leftStickAxisX;
  12679. private _leftStickAxisY;
  12680. private _rightStickAxisX;
  12681. private _rightStickAxisY;
  12682. /**
  12683. * Triggered when the left control stick has been changed
  12684. */
  12685. private _onleftstickchanged;
  12686. /**
  12687. * Triggered when the right control stick has been changed
  12688. */
  12689. private _onrightstickchanged;
  12690. /**
  12691. * Represents a gamepad controller
  12692. */
  12693. static GAMEPAD: number;
  12694. /**
  12695. * Represents a generic controller
  12696. */
  12697. static GENERIC: number;
  12698. /**
  12699. * Represents an XBox controller
  12700. */
  12701. static XBOX: number;
  12702. /**
  12703. * Represents a pose-enabled controller
  12704. */
  12705. static POSE_ENABLED: number;
  12706. /**
  12707. * Specifies whether the left control stick should be Y-inverted
  12708. */
  12709. protected _invertLeftStickY: boolean;
  12710. /**
  12711. * Specifies if the gamepad has been connected
  12712. */
  12713. readonly isConnected: boolean;
  12714. /**
  12715. * Initializes the gamepad
  12716. * @param id The id of the gamepad
  12717. * @param index The index of the gamepad
  12718. * @param browserGamepad The browser gamepad
  12719. * @param leftStickX The x component of the left joystick
  12720. * @param leftStickY The y component of the left joystick
  12721. * @param rightStickX The x component of the right joystick
  12722. * @param rightStickY The y component of the right joystick
  12723. */
  12724. constructor(
  12725. /**
  12726. * The id of the gamepad
  12727. */
  12728. id: string,
  12729. /**
  12730. * The index of the gamepad
  12731. */
  12732. index: number,
  12733. /**
  12734. * The browser gamepad
  12735. */
  12736. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12737. /**
  12738. * Callback triggered when the left joystick has changed
  12739. * @param callback
  12740. */
  12741. onleftstickchanged(callback: (values: StickValues) => void): void;
  12742. /**
  12743. * Callback triggered when the right joystick has changed
  12744. * @param callback
  12745. */
  12746. onrightstickchanged(callback: (values: StickValues) => void): void;
  12747. /**
  12748. * Gets the left joystick
  12749. */
  12750. /**
  12751. * Sets the left joystick values
  12752. */
  12753. leftStick: StickValues;
  12754. /**
  12755. * Gets the right joystick
  12756. */
  12757. /**
  12758. * Sets the right joystick value
  12759. */
  12760. rightStick: StickValues;
  12761. /**
  12762. * Updates the gamepad joystick positions
  12763. */
  12764. update(): void;
  12765. /**
  12766. * Disposes the gamepad
  12767. */
  12768. dispose(): void;
  12769. }
  12770. /**
  12771. * Represents a generic gamepad
  12772. */
  12773. export class GenericPad extends Gamepad {
  12774. private _buttons;
  12775. private _onbuttondown;
  12776. private _onbuttonup;
  12777. /**
  12778. * Observable triggered when a button has been pressed
  12779. */
  12780. onButtonDownObservable: Observable<number>;
  12781. /**
  12782. * Observable triggered when a button has been released
  12783. */
  12784. onButtonUpObservable: Observable<number>;
  12785. /**
  12786. * Callback triggered when a button has been pressed
  12787. * @param callback Called when a button has been pressed
  12788. */
  12789. onbuttondown(callback: (buttonPressed: number) => void): void;
  12790. /**
  12791. * Callback triggered when a button has been released
  12792. * @param callback Called when a button has been released
  12793. */
  12794. onbuttonup(callback: (buttonReleased: number) => void): void;
  12795. /**
  12796. * Initializes the generic gamepad
  12797. * @param id The id of the generic gamepad
  12798. * @param index The index of the generic gamepad
  12799. * @param browserGamepad The browser gamepad
  12800. */
  12801. constructor(id: string, index: number, browserGamepad: any);
  12802. private _setButtonValue;
  12803. /**
  12804. * Updates the generic gamepad
  12805. */
  12806. update(): void;
  12807. /**
  12808. * Disposes the generic gamepad
  12809. */
  12810. dispose(): void;
  12811. }
  12812. }
  12813. declare module BABYLON {
  12814. /**
  12815. * Defines the types of pose enabled controllers that are supported
  12816. */
  12817. export enum PoseEnabledControllerType {
  12818. /**
  12819. * HTC Vive
  12820. */
  12821. VIVE = 0,
  12822. /**
  12823. * Oculus Rift
  12824. */
  12825. OCULUS = 1,
  12826. /**
  12827. * Windows mixed reality
  12828. */
  12829. WINDOWS = 2,
  12830. /**
  12831. * Samsung gear VR
  12832. */
  12833. GEAR_VR = 3,
  12834. /**
  12835. * Google Daydream
  12836. */
  12837. DAYDREAM = 4,
  12838. /**
  12839. * Generic
  12840. */
  12841. GENERIC = 5
  12842. }
  12843. /**
  12844. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12845. */
  12846. export interface MutableGamepadButton {
  12847. /**
  12848. * Value of the button/trigger
  12849. */
  12850. value: number;
  12851. /**
  12852. * If the button/trigger is currently touched
  12853. */
  12854. touched: boolean;
  12855. /**
  12856. * If the button/trigger is currently pressed
  12857. */
  12858. pressed: boolean;
  12859. }
  12860. /**
  12861. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12862. * @hidden
  12863. */
  12864. export interface ExtendedGamepadButton extends GamepadButton {
  12865. /**
  12866. * If the button/trigger is currently pressed
  12867. */
  12868. readonly pressed: boolean;
  12869. /**
  12870. * If the button/trigger is currently touched
  12871. */
  12872. readonly touched: boolean;
  12873. /**
  12874. * Value of the button/trigger
  12875. */
  12876. readonly value: number;
  12877. }
  12878. /** @hidden */
  12879. export interface _GamePadFactory {
  12880. /**
  12881. * Returns wether or not the current gamepad can be created for this type of controller.
  12882. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12883. * @returns true if it can be created, otherwise false
  12884. */
  12885. canCreate(gamepadInfo: any): boolean;
  12886. /**
  12887. * Creates a new instance of the Gamepad.
  12888. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12889. * @returns the new gamepad instance
  12890. */
  12891. create(gamepadInfo: any): Gamepad;
  12892. }
  12893. /**
  12894. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12895. */
  12896. export class PoseEnabledControllerHelper {
  12897. /** @hidden */
  12898. static _ControllerFactories: _GamePadFactory[];
  12899. /** @hidden */
  12900. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12901. /**
  12902. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12903. * @param vrGamepad the gamepad to initialized
  12904. * @returns a vr controller of the type the gamepad identified as
  12905. */
  12906. static InitiateController(vrGamepad: any): Gamepad;
  12907. }
  12908. /**
  12909. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12910. */
  12911. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12912. private _deviceRoomPosition;
  12913. private _deviceRoomRotationQuaternion;
  12914. /**
  12915. * The device position in babylon space
  12916. */
  12917. devicePosition: Vector3;
  12918. /**
  12919. * The device rotation in babylon space
  12920. */
  12921. deviceRotationQuaternion: Quaternion;
  12922. /**
  12923. * The scale factor of the device in babylon space
  12924. */
  12925. deviceScaleFactor: number;
  12926. /**
  12927. * (Likely devicePosition should be used instead) The device position in its room space
  12928. */
  12929. position: Vector3;
  12930. /**
  12931. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12932. */
  12933. rotationQuaternion: Quaternion;
  12934. /**
  12935. * The type of controller (Eg. Windows mixed reality)
  12936. */
  12937. controllerType: PoseEnabledControllerType;
  12938. protected _calculatedPosition: Vector3;
  12939. private _calculatedRotation;
  12940. /**
  12941. * The raw pose from the device
  12942. */
  12943. rawPose: DevicePose;
  12944. private _trackPosition;
  12945. private _maxRotationDistFromHeadset;
  12946. private _draggedRoomRotation;
  12947. /**
  12948. * @hidden
  12949. */
  12950. _disableTrackPosition(fixedPosition: Vector3): void;
  12951. /**
  12952. * Internal, the mesh attached to the controller
  12953. * @hidden
  12954. */
  12955. _mesh: Nullable<AbstractMesh>;
  12956. private _poseControlledCamera;
  12957. private _leftHandSystemQuaternion;
  12958. /**
  12959. * Internal, matrix used to convert room space to babylon space
  12960. * @hidden
  12961. */
  12962. _deviceToWorld: Matrix;
  12963. /**
  12964. * Node to be used when casting a ray from the controller
  12965. * @hidden
  12966. */
  12967. _pointingPoseNode: Nullable<TransformNode>;
  12968. /**
  12969. * Name of the child mesh that can be used to cast a ray from the controller
  12970. */
  12971. static readonly POINTING_POSE: string;
  12972. /**
  12973. * Creates a new PoseEnabledController from a gamepad
  12974. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12975. */
  12976. constructor(browserGamepad: any);
  12977. private _workingMatrix;
  12978. /**
  12979. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12980. */
  12981. update(): void;
  12982. /**
  12983. * Updates only the pose device and mesh without doing any button event checking
  12984. */
  12985. protected _updatePoseAndMesh(): void;
  12986. /**
  12987. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  12988. * @param poseData raw pose fromthe device
  12989. */
  12990. updateFromDevice(poseData: DevicePose): void;
  12991. /**
  12992. * @hidden
  12993. */
  12994. _meshAttachedObservable: Observable<AbstractMesh>;
  12995. /**
  12996. * Attaches a mesh to the controller
  12997. * @param mesh the mesh to be attached
  12998. */
  12999. attachToMesh(mesh: AbstractMesh): void;
  13000. /**
  13001. * Attaches the controllers mesh to a camera
  13002. * @param camera the camera the mesh should be attached to
  13003. */
  13004. attachToPoseControlledCamera(camera: TargetCamera): void;
  13005. /**
  13006. * Disposes of the controller
  13007. */
  13008. dispose(): void;
  13009. /**
  13010. * The mesh that is attached to the controller
  13011. */
  13012. readonly mesh: Nullable<AbstractMesh>;
  13013. /**
  13014. * Gets the ray of the controller in the direction the controller is pointing
  13015. * @param length the length the resulting ray should be
  13016. * @returns a ray in the direction the controller is pointing
  13017. */
  13018. getForwardRay(length?: number): Ray;
  13019. }
  13020. }
  13021. declare module BABYLON {
  13022. /**
  13023. * Defines the WebVRController object that represents controllers tracked in 3D space
  13024. */
  13025. export abstract class WebVRController extends PoseEnabledController {
  13026. /**
  13027. * Internal, the default controller model for the controller
  13028. */
  13029. protected _defaultModel: AbstractMesh;
  13030. /**
  13031. * Fired when the trigger state has changed
  13032. */
  13033. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  13034. /**
  13035. * Fired when the main button state has changed
  13036. */
  13037. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13038. /**
  13039. * Fired when the secondary button state has changed
  13040. */
  13041. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13042. /**
  13043. * Fired when the pad state has changed
  13044. */
  13045. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  13046. /**
  13047. * Fired when controllers stick values have changed
  13048. */
  13049. onPadValuesChangedObservable: Observable<StickValues>;
  13050. /**
  13051. * Array of button availible on the controller
  13052. */
  13053. protected _buttons: Array<MutableGamepadButton>;
  13054. private _onButtonStateChange;
  13055. /**
  13056. * Fired when a controller button's state has changed
  13057. * @param callback the callback containing the button that was modified
  13058. */
  13059. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  13060. /**
  13061. * X and Y axis corrisponding to the controllers joystick
  13062. */
  13063. pad: StickValues;
  13064. /**
  13065. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  13066. */
  13067. hand: string;
  13068. /**
  13069. * The default controller model for the controller
  13070. */
  13071. readonly defaultModel: AbstractMesh;
  13072. /**
  13073. * Creates a new WebVRController from a gamepad
  13074. * @param vrGamepad the gamepad that the WebVRController should be created from
  13075. */
  13076. constructor(vrGamepad: any);
  13077. /**
  13078. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  13079. */
  13080. update(): void;
  13081. /**
  13082. * Function to be called when a button is modified
  13083. */
  13084. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  13085. /**
  13086. * Loads a mesh and attaches it to the controller
  13087. * @param scene the scene the mesh should be added to
  13088. * @param meshLoaded callback for when the mesh has been loaded
  13089. */
  13090. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  13091. private _setButtonValue;
  13092. private _changes;
  13093. private _checkChanges;
  13094. /**
  13095. * Disposes of th webVRCOntroller
  13096. */
  13097. dispose(): void;
  13098. }
  13099. }
  13100. declare module BABYLON {
  13101. /**
  13102. * The HemisphericLight simulates the ambient environment light,
  13103. * so the passed direction is the light reflection direction, not the incoming direction.
  13104. */
  13105. export class HemisphericLight extends Light {
  13106. /**
  13107. * The groundColor is the light in the opposite direction to the one specified during creation.
  13108. * 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.
  13109. */
  13110. groundColor: Color3;
  13111. /**
  13112. * The light reflection direction, not the incoming direction.
  13113. */
  13114. direction: Vector3;
  13115. /**
  13116. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  13117. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  13118. * The HemisphericLight can't cast shadows.
  13119. * Documentation : https://doc.babylonjs.com/babylon101/lights
  13120. * @param name The friendly name of the light
  13121. * @param direction The direction of the light reflection
  13122. * @param scene The scene the light belongs to
  13123. */
  13124. constructor(name: string, direction: Vector3, scene: Scene);
  13125. protected _buildUniformLayout(): void;
  13126. /**
  13127. * Returns the string "HemisphericLight".
  13128. * @return The class name
  13129. */
  13130. getClassName(): string;
  13131. /**
  13132. * Sets the HemisphericLight direction towards the passed target (Vector3).
  13133. * Returns the updated direction.
  13134. * @param target The target the direction should point to
  13135. * @return The computed direction
  13136. */
  13137. setDirectionToTarget(target: Vector3): Vector3;
  13138. /**
  13139. * Returns the shadow generator associated to the light.
  13140. * @returns Always null for hemispheric lights because it does not support shadows.
  13141. */
  13142. getShadowGenerator(): Nullable<IShadowGenerator>;
  13143. /**
  13144. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  13145. * @param effect The effect to update
  13146. * @param lightIndex The index of the light in the effect to update
  13147. * @returns The hemispheric light
  13148. */
  13149. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  13150. /**
  13151. * Computes the world matrix of the node
  13152. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13153. * @param useWasUpdatedFlag defines a reserved property
  13154. * @returns the world matrix
  13155. */
  13156. computeWorldMatrix(): Matrix;
  13157. /**
  13158. * Returns the integer 3.
  13159. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  13160. */
  13161. getTypeID(): number;
  13162. /**
  13163. * Prepares the list of defines specific to the light type.
  13164. * @param defines the list of defines
  13165. * @param lightIndex defines the index of the light for the effect
  13166. */
  13167. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  13168. }
  13169. }
  13170. declare module BABYLON {
  13171. /** @hidden */
  13172. export var vrMultiviewToSingleviewPixelShader: {
  13173. name: string;
  13174. shader: string;
  13175. };
  13176. }
  13177. declare module BABYLON {
  13178. /**
  13179. * Renders to multiple views with a single draw call
  13180. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  13181. */
  13182. export class MultiviewRenderTarget extends RenderTargetTexture {
  13183. /**
  13184. * Creates a multiview render target
  13185. * @param scene scene used with the render target
  13186. * @param size the size of the render target (used for each view)
  13187. */
  13188. constructor(scene: Scene, size?: number | {
  13189. width: number;
  13190. height: number;
  13191. } | {
  13192. ratio: number;
  13193. });
  13194. /**
  13195. * @hidden
  13196. * @param faceIndex the face index, if its a cube texture
  13197. */
  13198. _bindFrameBuffer(faceIndex?: number): void;
  13199. /**
  13200. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  13201. * @returns the view count
  13202. */
  13203. getViewCount(): number;
  13204. }
  13205. }
  13206. declare module BABYLON {
  13207. interface Engine {
  13208. /**
  13209. * Creates a new multiview render target
  13210. * @param width defines the width of the texture
  13211. * @param height defines the height of the texture
  13212. * @returns the created multiview texture
  13213. */
  13214. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  13215. /**
  13216. * Binds a multiview framebuffer to be drawn to
  13217. * @param multiviewTexture texture to bind
  13218. */
  13219. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  13220. }
  13221. interface Camera {
  13222. /**
  13223. * @hidden
  13224. * 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)
  13225. */
  13226. _useMultiviewToSingleView: boolean;
  13227. /**
  13228. * @hidden
  13229. * 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)
  13230. */
  13231. _multiviewTexture: Nullable<RenderTargetTexture>;
  13232. /**
  13233. * @hidden
  13234. * ensures the multiview texture of the camera exists and has the specified width/height
  13235. * @param width height to set on the multiview texture
  13236. * @param height width to set on the multiview texture
  13237. */
  13238. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  13239. }
  13240. interface Scene {
  13241. /** @hidden */
  13242. _transformMatrixR: Matrix;
  13243. /** @hidden */
  13244. _multiviewSceneUbo: Nullable<UniformBuffer>;
  13245. /** @hidden */
  13246. _createMultiviewUbo(): void;
  13247. /** @hidden */
  13248. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  13249. /** @hidden */
  13250. _renderMultiviewToSingleView(camera: Camera): void;
  13251. }
  13252. }
  13253. declare module BABYLON {
  13254. /**
  13255. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  13256. * This will not be used for webXR as it supports displaying texture arrays directly
  13257. */
  13258. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  13259. /**
  13260. * Initializes a VRMultiviewToSingleview
  13261. * @param name name of the post process
  13262. * @param camera camera to be applied to
  13263. * @param scaleFactor scaling factor to the size of the output texture
  13264. */
  13265. constructor(name: string, camera: Camera, scaleFactor: number);
  13266. }
  13267. }
  13268. declare module BABYLON {
  13269. /**
  13270. * Defines the interface used by display changed events
  13271. */
  13272. interface IDisplayChangedEventArgs {
  13273. /** Gets the vrDisplay object (if any) */
  13274. vrDisplay: Nullable<any>;
  13275. /** Gets a boolean indicating if webVR is supported */
  13276. vrSupported: boolean;
  13277. }
  13278. interface Engine {
  13279. /** @hidden */
  13280. _vrDisplay: any;
  13281. /** @hidden */
  13282. _vrSupported: boolean;
  13283. /** @hidden */
  13284. _oldSize: Size;
  13285. /** @hidden */
  13286. _oldHardwareScaleFactor: number;
  13287. /** @hidden */
  13288. _vrExclusivePointerMode: boolean;
  13289. /** @hidden */
  13290. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  13291. /** @hidden */
  13292. _onVRDisplayPointerRestricted: () => void;
  13293. /** @hidden */
  13294. _onVRDisplayPointerUnrestricted: () => void;
  13295. /** @hidden */
  13296. _onVrDisplayConnect: Nullable<(display: any) => void>;
  13297. /** @hidden */
  13298. _onVrDisplayDisconnect: Nullable<() => void>;
  13299. /** @hidden */
  13300. _onVrDisplayPresentChange: Nullable<() => void>;
  13301. /**
  13302. * Observable signaled when VR display mode changes
  13303. */
  13304. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  13305. /**
  13306. * Observable signaled when VR request present is complete
  13307. */
  13308. onVRRequestPresentComplete: Observable<boolean>;
  13309. /**
  13310. * Observable signaled when VR request present starts
  13311. */
  13312. onVRRequestPresentStart: Observable<Engine>;
  13313. /**
  13314. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  13315. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  13316. */
  13317. isInVRExclusivePointerMode: boolean;
  13318. /**
  13319. * Gets a boolean indicating if a webVR device was detected
  13320. * @returns true if a webVR device was detected
  13321. */
  13322. isVRDevicePresent(): boolean;
  13323. /**
  13324. * Gets the current webVR device
  13325. * @returns the current webVR device (or null)
  13326. */
  13327. getVRDevice(): any;
  13328. /**
  13329. * Initializes a webVR display and starts listening to display change events
  13330. * The onVRDisplayChangedObservable will be notified upon these changes
  13331. * @returns A promise containing a VRDisplay and if vr is supported
  13332. */
  13333. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  13334. /** @hidden */
  13335. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  13336. /**
  13337. * Call this function to switch to webVR mode
  13338. * Will do nothing if webVR is not supported or if there is no webVR device
  13339. * @see http://doc.babylonjs.com/how_to/webvr_camera
  13340. */
  13341. enableVR(): void;
  13342. /** @hidden */
  13343. _onVRFullScreenTriggered(): void;
  13344. }
  13345. }
  13346. declare module BABYLON {
  13347. /**
  13348. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  13349. * IMPORTANT!! The data is right-hand data.
  13350. * @export
  13351. * @interface DevicePose
  13352. */
  13353. export interface DevicePose {
  13354. /**
  13355. * The position of the device, values in array are [x,y,z].
  13356. */
  13357. readonly position: Nullable<Float32Array>;
  13358. /**
  13359. * The linearVelocity of the device, values in array are [x,y,z].
  13360. */
  13361. readonly linearVelocity: Nullable<Float32Array>;
  13362. /**
  13363. * The linearAcceleration of the device, values in array are [x,y,z].
  13364. */
  13365. readonly linearAcceleration: Nullable<Float32Array>;
  13366. /**
  13367. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13368. */
  13369. readonly orientation: Nullable<Float32Array>;
  13370. /**
  13371. * The angularVelocity of the device, values in array are [x,y,z].
  13372. */
  13373. readonly angularVelocity: Nullable<Float32Array>;
  13374. /**
  13375. * The angularAcceleration of the device, values in array are [x,y,z].
  13376. */
  13377. readonly angularAcceleration: Nullable<Float32Array>;
  13378. }
  13379. /**
  13380. * Interface representing a pose controlled object in Babylon.
  13381. * A pose controlled object has both regular pose values as well as pose values
  13382. * from an external device such as a VR head mounted display
  13383. */
  13384. export interface PoseControlled {
  13385. /**
  13386. * The position of the object in babylon space.
  13387. */
  13388. position: Vector3;
  13389. /**
  13390. * The rotation quaternion of the object in babylon space.
  13391. */
  13392. rotationQuaternion: Quaternion;
  13393. /**
  13394. * The position of the device in babylon space.
  13395. */
  13396. devicePosition?: Vector3;
  13397. /**
  13398. * The rotation quaternion of the device in babylon space.
  13399. */
  13400. deviceRotationQuaternion: Quaternion;
  13401. /**
  13402. * The raw pose coming from the device.
  13403. */
  13404. rawPose: Nullable<DevicePose>;
  13405. /**
  13406. * The scale of the device to be used when translating from device space to babylon space.
  13407. */
  13408. deviceScaleFactor: number;
  13409. /**
  13410. * Updates the poseControlled values based on the input device pose.
  13411. * @param poseData the pose data to update the object with
  13412. */
  13413. updateFromDevice(poseData: DevicePose): void;
  13414. }
  13415. /**
  13416. * Set of options to customize the webVRCamera
  13417. */
  13418. export interface WebVROptions {
  13419. /**
  13420. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13421. */
  13422. trackPosition?: boolean;
  13423. /**
  13424. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13425. */
  13426. positionScale?: number;
  13427. /**
  13428. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13429. */
  13430. displayName?: string;
  13431. /**
  13432. * Should the native controller meshes be initialized. (default: true)
  13433. */
  13434. controllerMeshes?: boolean;
  13435. /**
  13436. * Creating a default HemiLight only on controllers. (default: true)
  13437. */
  13438. defaultLightingOnControllers?: boolean;
  13439. /**
  13440. * If you don't want to use the default VR button of the helper. (default: false)
  13441. */
  13442. useCustomVRButton?: boolean;
  13443. /**
  13444. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13445. */
  13446. customVRButton?: HTMLButtonElement;
  13447. /**
  13448. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13449. */
  13450. rayLength?: number;
  13451. /**
  13452. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13453. */
  13454. defaultHeight?: number;
  13455. /**
  13456. * If multiview should be used if availible (default: false)
  13457. */
  13458. useMultiview?: boolean;
  13459. }
  13460. /**
  13461. * This represents a WebVR camera.
  13462. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13463. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13464. */
  13465. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13466. private webVROptions;
  13467. /**
  13468. * @hidden
  13469. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13470. */
  13471. _vrDevice: any;
  13472. /**
  13473. * The rawPose of the vrDevice.
  13474. */
  13475. rawPose: Nullable<DevicePose>;
  13476. private _onVREnabled;
  13477. private _specsVersion;
  13478. private _attached;
  13479. private _frameData;
  13480. protected _descendants: Array<Node>;
  13481. private _deviceRoomPosition;
  13482. /** @hidden */
  13483. _deviceRoomRotationQuaternion: Quaternion;
  13484. private _standingMatrix;
  13485. /**
  13486. * Represents device position in babylon space.
  13487. */
  13488. devicePosition: Vector3;
  13489. /**
  13490. * Represents device rotation in babylon space.
  13491. */
  13492. deviceRotationQuaternion: Quaternion;
  13493. /**
  13494. * The scale of the device to be used when translating from device space to babylon space.
  13495. */
  13496. deviceScaleFactor: number;
  13497. private _deviceToWorld;
  13498. private _worldToDevice;
  13499. /**
  13500. * References to the webVR controllers for the vrDevice.
  13501. */
  13502. controllers: Array<WebVRController>;
  13503. /**
  13504. * Emits an event when a controller is attached.
  13505. */
  13506. onControllersAttachedObservable: Observable<WebVRController[]>;
  13507. /**
  13508. * Emits an event when a controller's mesh has been loaded;
  13509. */
  13510. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13511. /**
  13512. * Emits an event when the HMD's pose has been updated.
  13513. */
  13514. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13515. private _poseSet;
  13516. /**
  13517. * If the rig cameras be used as parent instead of this camera.
  13518. */
  13519. rigParenting: boolean;
  13520. private _lightOnControllers;
  13521. private _defaultHeight?;
  13522. /**
  13523. * Instantiates a WebVRFreeCamera.
  13524. * @param name The name of the WebVRFreeCamera
  13525. * @param position The starting anchor position for the camera
  13526. * @param scene The scene the camera belongs to
  13527. * @param webVROptions a set of customizable options for the webVRCamera
  13528. */
  13529. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13530. /**
  13531. * Gets the device distance from the ground in meters.
  13532. * @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.
  13533. */
  13534. deviceDistanceToRoomGround(): number;
  13535. /**
  13536. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13537. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13538. */
  13539. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13540. /**
  13541. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13542. * @returns A promise with a boolean set to if the standing matrix is supported.
  13543. */
  13544. useStandingMatrixAsync(): Promise<boolean>;
  13545. /**
  13546. * Disposes the camera
  13547. */
  13548. dispose(): void;
  13549. /**
  13550. * Gets a vrController by name.
  13551. * @param name The name of the controller to retreive
  13552. * @returns the controller matching the name specified or null if not found
  13553. */
  13554. getControllerByName(name: string): Nullable<WebVRController>;
  13555. private _leftController;
  13556. /**
  13557. * The controller corrisponding to the users left hand.
  13558. */
  13559. readonly leftController: Nullable<WebVRController>;
  13560. private _rightController;
  13561. /**
  13562. * The controller corrisponding to the users right hand.
  13563. */
  13564. readonly rightController: Nullable<WebVRController>;
  13565. /**
  13566. * Casts a ray forward from the vrCamera's gaze.
  13567. * @param length Length of the ray (default: 100)
  13568. * @returns the ray corrisponding to the gaze
  13569. */
  13570. getForwardRay(length?: number): Ray;
  13571. /**
  13572. * @hidden
  13573. * Updates the camera based on device's frame data
  13574. */
  13575. _checkInputs(): void;
  13576. /**
  13577. * Updates the poseControlled values based on the input device pose.
  13578. * @param poseData Pose coming from the device
  13579. */
  13580. updateFromDevice(poseData: DevicePose): void;
  13581. private _htmlElementAttached;
  13582. private _detachIfAttached;
  13583. /**
  13584. * WebVR's attach control will start broadcasting frames to the device.
  13585. * Note that in certain browsers (chrome for example) this function must be called
  13586. * within a user-interaction callback. Example:
  13587. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13588. *
  13589. * @param element html element to attach the vrDevice to
  13590. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13591. */
  13592. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13593. /**
  13594. * Detaches the camera from the html element and disables VR
  13595. *
  13596. * @param element html element to detach from
  13597. */
  13598. detachControl(element: HTMLElement): void;
  13599. /**
  13600. * @returns the name of this class
  13601. */
  13602. getClassName(): string;
  13603. /**
  13604. * Calls resetPose on the vrDisplay
  13605. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13606. */
  13607. resetToCurrentRotation(): void;
  13608. /**
  13609. * @hidden
  13610. * Updates the rig cameras (left and right eye)
  13611. */
  13612. _updateRigCameras(): void;
  13613. private _workingVector;
  13614. private _oneVector;
  13615. private _workingMatrix;
  13616. private updateCacheCalled;
  13617. private _correctPositionIfNotTrackPosition;
  13618. /**
  13619. * @hidden
  13620. * Updates the cached values of the camera
  13621. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13622. */
  13623. _updateCache(ignoreParentClass?: boolean): void;
  13624. /**
  13625. * @hidden
  13626. * Get current device position in babylon world
  13627. */
  13628. _computeDevicePosition(): void;
  13629. /**
  13630. * Updates the current device position and rotation in the babylon world
  13631. */
  13632. update(): void;
  13633. /**
  13634. * @hidden
  13635. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13636. * @returns an identity matrix
  13637. */
  13638. _getViewMatrix(): Matrix;
  13639. private _tmpMatrix;
  13640. /**
  13641. * This function is called by the two RIG cameras.
  13642. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13643. * @hidden
  13644. */
  13645. _getWebVRViewMatrix(): Matrix;
  13646. /** @hidden */
  13647. _getWebVRProjectionMatrix(): Matrix;
  13648. private _onGamepadConnectedObserver;
  13649. private _onGamepadDisconnectedObserver;
  13650. private _updateCacheWhenTrackingDisabledObserver;
  13651. /**
  13652. * Initializes the controllers and their meshes
  13653. */
  13654. initControllers(): void;
  13655. }
  13656. }
  13657. declare module BABYLON {
  13658. /**
  13659. * Size options for a post process
  13660. */
  13661. export type PostProcessOptions = {
  13662. width: number;
  13663. height: number;
  13664. };
  13665. /**
  13666. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13667. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13668. */
  13669. export class PostProcess {
  13670. /** Name of the PostProcess. */
  13671. name: string;
  13672. /**
  13673. * Gets or sets the unique id of the post process
  13674. */
  13675. uniqueId: number;
  13676. /**
  13677. * Width of the texture to apply the post process on
  13678. */
  13679. width: number;
  13680. /**
  13681. * Height of the texture to apply the post process on
  13682. */
  13683. height: number;
  13684. /**
  13685. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13686. * @hidden
  13687. */
  13688. _outputTexture: Nullable<InternalTexture>;
  13689. /**
  13690. * Sampling mode used by the shader
  13691. * See https://doc.babylonjs.com/classes/3.1/texture
  13692. */
  13693. renderTargetSamplingMode: number;
  13694. /**
  13695. * Clear color to use when screen clearing
  13696. */
  13697. clearColor: Color4;
  13698. /**
  13699. * If the buffer needs to be cleared before applying the post process. (default: true)
  13700. * Should be set to false if shader will overwrite all previous pixels.
  13701. */
  13702. autoClear: boolean;
  13703. /**
  13704. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13705. */
  13706. alphaMode: number;
  13707. /**
  13708. * Sets the setAlphaBlendConstants of the babylon engine
  13709. */
  13710. alphaConstants: Color4;
  13711. /**
  13712. * Animations to be used for the post processing
  13713. */
  13714. animations: Animation[];
  13715. /**
  13716. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13717. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13718. */
  13719. enablePixelPerfectMode: boolean;
  13720. /**
  13721. * Force the postprocess to be applied without taking in account viewport
  13722. */
  13723. forceFullscreenViewport: boolean;
  13724. /**
  13725. * List of inspectable custom properties (used by the Inspector)
  13726. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13727. */
  13728. inspectableCustomProperties: IInspectable[];
  13729. /**
  13730. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13731. *
  13732. * | Value | Type | Description |
  13733. * | ----- | ----------------------------------- | ----------- |
  13734. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13735. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13736. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13737. *
  13738. */
  13739. scaleMode: number;
  13740. /**
  13741. * Force textures to be a power of two (default: false)
  13742. */
  13743. alwaysForcePOT: boolean;
  13744. private _samples;
  13745. /**
  13746. * Number of sample textures (default: 1)
  13747. */
  13748. samples: number;
  13749. /**
  13750. * Modify the scale of the post process to be the same as the viewport (default: false)
  13751. */
  13752. adaptScaleToCurrentViewport: boolean;
  13753. private _camera;
  13754. private _scene;
  13755. private _engine;
  13756. private _options;
  13757. private _reusable;
  13758. private _textureType;
  13759. /**
  13760. * Smart array of input and output textures for the post process.
  13761. * @hidden
  13762. */
  13763. _textures: SmartArray<InternalTexture>;
  13764. /**
  13765. * The index in _textures that corresponds to the output texture.
  13766. * @hidden
  13767. */
  13768. _currentRenderTextureInd: number;
  13769. private _effect;
  13770. private _samplers;
  13771. private _fragmentUrl;
  13772. private _vertexUrl;
  13773. private _parameters;
  13774. private _scaleRatio;
  13775. protected _indexParameters: any;
  13776. private _shareOutputWithPostProcess;
  13777. private _texelSize;
  13778. private _forcedOutputTexture;
  13779. /**
  13780. * Returns the fragment url or shader name used in the post process.
  13781. * @returns the fragment url or name in the shader store.
  13782. */
  13783. getEffectName(): string;
  13784. /**
  13785. * An event triggered when the postprocess is activated.
  13786. */
  13787. onActivateObservable: Observable<Camera>;
  13788. private _onActivateObserver;
  13789. /**
  13790. * A function that is added to the onActivateObservable
  13791. */
  13792. onActivate: Nullable<(camera: Camera) => void>;
  13793. /**
  13794. * An event triggered when the postprocess changes its size.
  13795. */
  13796. onSizeChangedObservable: Observable<PostProcess>;
  13797. private _onSizeChangedObserver;
  13798. /**
  13799. * A function that is added to the onSizeChangedObservable
  13800. */
  13801. onSizeChanged: (postProcess: PostProcess) => void;
  13802. /**
  13803. * An event triggered when the postprocess applies its effect.
  13804. */
  13805. onApplyObservable: Observable<Effect>;
  13806. private _onApplyObserver;
  13807. /**
  13808. * A function that is added to the onApplyObservable
  13809. */
  13810. onApply: (effect: Effect) => void;
  13811. /**
  13812. * An event triggered before rendering the postprocess
  13813. */
  13814. onBeforeRenderObservable: Observable<Effect>;
  13815. private _onBeforeRenderObserver;
  13816. /**
  13817. * A function that is added to the onBeforeRenderObservable
  13818. */
  13819. onBeforeRender: (effect: Effect) => void;
  13820. /**
  13821. * An event triggered after rendering the postprocess
  13822. */
  13823. onAfterRenderObservable: Observable<Effect>;
  13824. private _onAfterRenderObserver;
  13825. /**
  13826. * A function that is added to the onAfterRenderObservable
  13827. */
  13828. onAfterRender: (efect: Effect) => void;
  13829. /**
  13830. * 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
  13831. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13832. */
  13833. inputTexture: InternalTexture;
  13834. /**
  13835. * Gets the camera which post process is applied to.
  13836. * @returns The camera the post process is applied to.
  13837. */
  13838. getCamera(): Camera;
  13839. /**
  13840. * Gets the texel size of the postprocess.
  13841. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13842. */
  13843. readonly texelSize: Vector2;
  13844. /**
  13845. * Creates a new instance PostProcess
  13846. * @param name The name of the PostProcess.
  13847. * @param fragmentUrl The url of the fragment shader to be used.
  13848. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13849. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13850. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13851. * @param camera The camera to apply the render pass to.
  13852. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13853. * @param engine The engine which the post process will be applied. (default: current engine)
  13854. * @param reusable If the post process can be reused on the same frame. (default: false)
  13855. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13856. * @param textureType Type of textures used when performing the post process. (default: 0)
  13857. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13858. * @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
  13859. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13860. */
  13861. constructor(
  13862. /** Name of the PostProcess. */
  13863. 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);
  13864. /**
  13865. * Gets a string idenfifying the name of the class
  13866. * @returns "PostProcess" string
  13867. */
  13868. getClassName(): string;
  13869. /**
  13870. * Gets the engine which this post process belongs to.
  13871. * @returns The engine the post process was enabled with.
  13872. */
  13873. getEngine(): Engine;
  13874. /**
  13875. * The effect that is created when initializing the post process.
  13876. * @returns The created effect corrisponding the the postprocess.
  13877. */
  13878. getEffect(): Effect;
  13879. /**
  13880. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13881. * @param postProcess The post process to share the output with.
  13882. * @returns This post process.
  13883. */
  13884. shareOutputWith(postProcess: PostProcess): PostProcess;
  13885. /**
  13886. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13887. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13888. */
  13889. useOwnOutput(): void;
  13890. /**
  13891. * Updates the effect with the current post process compile time values and recompiles the shader.
  13892. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13893. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13894. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13895. * @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
  13896. * @param onCompiled Called when the shader has been compiled.
  13897. * @param onError Called if there is an error when compiling a shader.
  13898. */
  13899. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13900. /**
  13901. * The post process is reusable if it can be used multiple times within one frame.
  13902. * @returns If the post process is reusable
  13903. */
  13904. isReusable(): boolean;
  13905. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13906. markTextureDirty(): void;
  13907. /**
  13908. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13909. * 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.
  13910. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13911. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13912. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13913. * @returns The target texture that was bound to be written to.
  13914. */
  13915. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13916. /**
  13917. * If the post process is supported.
  13918. */
  13919. readonly isSupported: boolean;
  13920. /**
  13921. * The aspect ratio of the output texture.
  13922. */
  13923. readonly aspectRatio: number;
  13924. /**
  13925. * Get a value indicating if the post-process is ready to be used
  13926. * @returns true if the post-process is ready (shader is compiled)
  13927. */
  13928. isReady(): boolean;
  13929. /**
  13930. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13931. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13932. */
  13933. apply(): Nullable<Effect>;
  13934. private _disposeTextures;
  13935. /**
  13936. * Disposes the post process.
  13937. * @param camera The camera to dispose the post process on.
  13938. */
  13939. dispose(camera?: Camera): void;
  13940. }
  13941. }
  13942. declare module BABYLON {
  13943. /**
  13944. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13945. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13946. */
  13947. export class PostProcessManager {
  13948. private _scene;
  13949. private _indexBuffer;
  13950. private _vertexBuffers;
  13951. /**
  13952. * Creates a new instance PostProcess
  13953. * @param scene The scene that the post process is associated with.
  13954. */
  13955. constructor(scene: Scene);
  13956. private _prepareBuffers;
  13957. private _buildIndexBuffer;
  13958. /**
  13959. * Rebuilds the vertex buffers of the manager.
  13960. * @hidden
  13961. */
  13962. _rebuild(): void;
  13963. /**
  13964. * Prepares a frame to be run through a post process.
  13965. * @param sourceTexture The input texture to the post procesess. (default: null)
  13966. * @param postProcesses An array of post processes to be run. (default: null)
  13967. * @returns True if the post processes were able to be run.
  13968. * @hidden
  13969. */
  13970. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13971. /**
  13972. * Manually render a set of post processes to a texture.
  13973. * @param postProcesses An array of post processes to be run.
  13974. * @param targetTexture The target texture to render to.
  13975. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13976. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13977. * @param lodLevel defines which lod of the texture to render to
  13978. */
  13979. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13980. /**
  13981. * Finalize the result of the output of the postprocesses.
  13982. * @param doNotPresent If true the result will not be displayed to the screen.
  13983. * @param targetTexture The target texture to render to.
  13984. * @param faceIndex The index of the face to bind the target texture to.
  13985. * @param postProcesses The array of post processes to render.
  13986. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13987. * @hidden
  13988. */
  13989. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13990. /**
  13991. * Disposes of the post process manager.
  13992. */
  13993. dispose(): void;
  13994. }
  13995. }
  13996. declare module BABYLON {
  13997. interface AbstractScene {
  13998. /**
  13999. * The list of procedural textures added to the scene
  14000. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14001. */
  14002. proceduralTextures: Array<ProceduralTexture>;
  14003. }
  14004. /**
  14005. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14006. * in a given scene.
  14007. */
  14008. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14009. /**
  14010. * The component name helpfull to identify the component in the list of scene components.
  14011. */
  14012. readonly name: string;
  14013. /**
  14014. * The scene the component belongs to.
  14015. */
  14016. scene: Scene;
  14017. /**
  14018. * Creates a new instance of the component for the given scene
  14019. * @param scene Defines the scene to register the component in
  14020. */
  14021. constructor(scene: Scene);
  14022. /**
  14023. * Registers the component in a given scene
  14024. */
  14025. register(): void;
  14026. /**
  14027. * Rebuilds the elements related to this component in case of
  14028. * context lost for instance.
  14029. */
  14030. rebuild(): void;
  14031. /**
  14032. * Disposes the component and the associated ressources.
  14033. */
  14034. dispose(): void;
  14035. private _beforeClear;
  14036. }
  14037. }
  14038. declare module BABYLON {
  14039. interface Engine {
  14040. /**
  14041. * Creates a new render target cube texture
  14042. * @param size defines the size of the texture
  14043. * @param options defines the options used to create the texture
  14044. * @returns a new render target cube texture stored in an InternalTexture
  14045. */
  14046. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  14047. }
  14048. }
  14049. declare module BABYLON {
  14050. /** @hidden */
  14051. export var proceduralVertexShader: {
  14052. name: string;
  14053. shader: string;
  14054. };
  14055. }
  14056. declare module BABYLON {
  14057. /**
  14058. * 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.
  14059. * This is the base class of any Procedural texture and contains most of the shareable code.
  14060. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14061. */
  14062. export class ProceduralTexture extends Texture {
  14063. isCube: boolean;
  14064. /**
  14065. * Define if the texture is enabled or not (disabled texture will not render)
  14066. */
  14067. isEnabled: boolean;
  14068. /**
  14069. * Define if the texture must be cleared before rendering (default is true)
  14070. */
  14071. autoClear: boolean;
  14072. /**
  14073. * Callback called when the texture is generated
  14074. */
  14075. onGenerated: () => void;
  14076. /**
  14077. * Event raised when the texture is generated
  14078. */
  14079. onGeneratedObservable: Observable<ProceduralTexture>;
  14080. /** @hidden */
  14081. _generateMipMaps: boolean;
  14082. /** @hidden **/
  14083. _effect: Effect;
  14084. /** @hidden */
  14085. _textures: {
  14086. [key: string]: Texture;
  14087. };
  14088. private _size;
  14089. private _currentRefreshId;
  14090. private _refreshRate;
  14091. private _vertexBuffers;
  14092. private _indexBuffer;
  14093. private _uniforms;
  14094. private _samplers;
  14095. private _fragment;
  14096. private _floats;
  14097. private _ints;
  14098. private _floatsArrays;
  14099. private _colors3;
  14100. private _colors4;
  14101. private _vectors2;
  14102. private _vectors3;
  14103. private _matrices;
  14104. private _fallbackTexture;
  14105. private _fallbackTextureUsed;
  14106. private _engine;
  14107. private _cachedDefines;
  14108. private _contentUpdateId;
  14109. private _contentData;
  14110. /**
  14111. * Instantiates a new procedural texture.
  14112. * 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.
  14113. * This is the base class of any Procedural texture and contains most of the shareable code.
  14114. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14115. * @param name Define the name of the texture
  14116. * @param size Define the size of the texture to create
  14117. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14118. * @param scene Define the scene the texture belongs to
  14119. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14120. * @param generateMipMaps Define if the texture should creates mip maps or not
  14121. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14122. */
  14123. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  14124. /**
  14125. * The effect that is created when initializing the post process.
  14126. * @returns The created effect corrisponding the the postprocess.
  14127. */
  14128. getEffect(): Effect;
  14129. /**
  14130. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14131. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14132. */
  14133. getContent(): Nullable<ArrayBufferView>;
  14134. private _createIndexBuffer;
  14135. /** @hidden */
  14136. _rebuild(): void;
  14137. /**
  14138. * Resets the texture in order to recreate its associated resources.
  14139. * This can be called in case of context loss
  14140. */
  14141. reset(): void;
  14142. protected _getDefines(): string;
  14143. /**
  14144. * Is the texture ready to be used ? (rendered at least once)
  14145. * @returns true if ready, otherwise, false.
  14146. */
  14147. isReady(): boolean;
  14148. /**
  14149. * Resets the refresh counter of the texture and start bak from scratch.
  14150. * Could be useful to regenerate the texture if it is setup to render only once.
  14151. */
  14152. resetRefreshCounter(): void;
  14153. /**
  14154. * Set the fragment shader to use in order to render the texture.
  14155. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14156. */
  14157. setFragment(fragment: any): void;
  14158. /**
  14159. * Define the refresh rate of the texture or the rendering frequency.
  14160. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14161. */
  14162. refreshRate: number;
  14163. /** @hidden */
  14164. _shouldRender(): boolean;
  14165. /**
  14166. * Get the size the texture is rendering at.
  14167. * @returns the size (texture is always squared)
  14168. */
  14169. getRenderSize(): number;
  14170. /**
  14171. * Resize the texture to new value.
  14172. * @param size Define the new size the texture should have
  14173. * @param generateMipMaps Define whether the new texture should create mip maps
  14174. */
  14175. resize(size: number, generateMipMaps: boolean): void;
  14176. private _checkUniform;
  14177. /**
  14178. * Set a texture in the shader program used to render.
  14179. * @param name Define the name of the uniform samplers as defined in the shader
  14180. * @param texture Define the texture to bind to this sampler
  14181. * @return the texture itself allowing "fluent" like uniform updates
  14182. */
  14183. setTexture(name: string, texture: Texture): ProceduralTexture;
  14184. /**
  14185. * Set a float in the shader.
  14186. * @param name Define the name of the uniform as defined in the shader
  14187. * @param value Define the value to give to the uniform
  14188. * @return the texture itself allowing "fluent" like uniform updates
  14189. */
  14190. setFloat(name: string, value: number): ProceduralTexture;
  14191. /**
  14192. * Set a int in the shader.
  14193. * @param name Define the name of the uniform as defined in the shader
  14194. * @param value Define the value to give to the uniform
  14195. * @return the texture itself allowing "fluent" like uniform updates
  14196. */
  14197. setInt(name: string, value: number): ProceduralTexture;
  14198. /**
  14199. * Set an array of floats in the shader.
  14200. * @param name Define the name of the uniform as defined in the shader
  14201. * @param value Define the value to give to the uniform
  14202. * @return the texture itself allowing "fluent" like uniform updates
  14203. */
  14204. setFloats(name: string, value: number[]): ProceduralTexture;
  14205. /**
  14206. * Set a vec3 in the shader from a Color3.
  14207. * @param name Define the name of the uniform as defined in the shader
  14208. * @param value Define the value to give to the uniform
  14209. * @return the texture itself allowing "fluent" like uniform updates
  14210. */
  14211. setColor3(name: string, value: Color3): ProceduralTexture;
  14212. /**
  14213. * Set a vec4 in the shader from a Color4.
  14214. * @param name Define the name of the uniform as defined in the shader
  14215. * @param value Define the value to give to the uniform
  14216. * @return the texture itself allowing "fluent" like uniform updates
  14217. */
  14218. setColor4(name: string, value: Color4): ProceduralTexture;
  14219. /**
  14220. * Set a vec2 in the shader from a Vector2.
  14221. * @param name Define the name of the uniform as defined in the shader
  14222. * @param value Define the value to give to the uniform
  14223. * @return the texture itself allowing "fluent" like uniform updates
  14224. */
  14225. setVector2(name: string, value: Vector2): ProceduralTexture;
  14226. /**
  14227. * Set a vec3 in the shader from a Vector3.
  14228. * @param name Define the name of the uniform as defined in the shader
  14229. * @param value Define the value to give to the uniform
  14230. * @return the texture itself allowing "fluent" like uniform updates
  14231. */
  14232. setVector3(name: string, value: Vector3): ProceduralTexture;
  14233. /**
  14234. * Set a mat4 in the shader from a MAtrix.
  14235. * @param name Define the name of the uniform as defined in the shader
  14236. * @param value Define the value to give to the uniform
  14237. * @return the texture itself allowing "fluent" like uniform updates
  14238. */
  14239. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14240. /**
  14241. * Render the texture to its associated render target.
  14242. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14243. */
  14244. render(useCameraPostProcess?: boolean): void;
  14245. /**
  14246. * Clone the texture.
  14247. * @returns the cloned texture
  14248. */
  14249. clone(): ProceduralTexture;
  14250. /**
  14251. * Dispose the texture and release its asoociated resources.
  14252. */
  14253. dispose(): void;
  14254. }
  14255. }
  14256. declare module BABYLON {
  14257. /**
  14258. * This represents the base class for particle system in Babylon.
  14259. * 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.
  14260. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14261. * @example https://doc.babylonjs.com/babylon101/particles
  14262. */
  14263. export class BaseParticleSystem {
  14264. /**
  14265. * Source color is added to the destination color without alpha affecting the result
  14266. */
  14267. static BLENDMODE_ONEONE: number;
  14268. /**
  14269. * Blend current color and particle color using particle’s alpha
  14270. */
  14271. static BLENDMODE_STANDARD: number;
  14272. /**
  14273. * Add current color and particle color multiplied by particle’s alpha
  14274. */
  14275. static BLENDMODE_ADD: number;
  14276. /**
  14277. * Multiply current color with particle color
  14278. */
  14279. static BLENDMODE_MULTIPLY: number;
  14280. /**
  14281. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14282. */
  14283. static BLENDMODE_MULTIPLYADD: number;
  14284. /**
  14285. * List of animations used by the particle system.
  14286. */
  14287. animations: Animation[];
  14288. /**
  14289. * The id of the Particle system.
  14290. */
  14291. id: string;
  14292. /**
  14293. * The friendly name of the Particle system.
  14294. */
  14295. name: string;
  14296. /**
  14297. * The rendering group used by the Particle system to chose when to render.
  14298. */
  14299. renderingGroupId: number;
  14300. /**
  14301. * The emitter represents the Mesh or position we are attaching the particle system to.
  14302. */
  14303. emitter: Nullable<AbstractMesh | Vector3>;
  14304. /**
  14305. * The maximum number of particles to emit per frame
  14306. */
  14307. emitRate: number;
  14308. /**
  14309. * If you want to launch only a few particles at once, that can be done, as well.
  14310. */
  14311. manualEmitCount: number;
  14312. /**
  14313. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14314. */
  14315. updateSpeed: number;
  14316. /**
  14317. * The amount of time the particle system is running (depends of the overall update speed).
  14318. */
  14319. targetStopDuration: number;
  14320. /**
  14321. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14322. */
  14323. disposeOnStop: boolean;
  14324. /**
  14325. * Minimum power of emitting particles.
  14326. */
  14327. minEmitPower: number;
  14328. /**
  14329. * Maximum power of emitting particles.
  14330. */
  14331. maxEmitPower: number;
  14332. /**
  14333. * Minimum life time of emitting particles.
  14334. */
  14335. minLifeTime: number;
  14336. /**
  14337. * Maximum life time of emitting particles.
  14338. */
  14339. maxLifeTime: number;
  14340. /**
  14341. * Minimum Size of emitting particles.
  14342. */
  14343. minSize: number;
  14344. /**
  14345. * Maximum Size of emitting particles.
  14346. */
  14347. maxSize: number;
  14348. /**
  14349. * Minimum scale of emitting particles on X axis.
  14350. */
  14351. minScaleX: number;
  14352. /**
  14353. * Maximum scale of emitting particles on X axis.
  14354. */
  14355. maxScaleX: number;
  14356. /**
  14357. * Minimum scale of emitting particles on Y axis.
  14358. */
  14359. minScaleY: number;
  14360. /**
  14361. * Maximum scale of emitting particles on Y axis.
  14362. */
  14363. maxScaleY: number;
  14364. /**
  14365. * Gets or sets the minimal initial rotation in radians.
  14366. */
  14367. minInitialRotation: number;
  14368. /**
  14369. * Gets or sets the maximal initial rotation in radians.
  14370. */
  14371. maxInitialRotation: number;
  14372. /**
  14373. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14374. */
  14375. minAngularSpeed: number;
  14376. /**
  14377. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14378. */
  14379. maxAngularSpeed: number;
  14380. /**
  14381. * The texture used to render each particle. (this can be a spritesheet)
  14382. */
  14383. particleTexture: Nullable<Texture>;
  14384. /**
  14385. * The layer mask we are rendering the particles through.
  14386. */
  14387. layerMask: number;
  14388. /**
  14389. * This can help using your own shader to render the particle system.
  14390. * The according effect will be created
  14391. */
  14392. customShader: any;
  14393. /**
  14394. * By default particle system starts as soon as they are created. This prevents the
  14395. * automatic start to happen and let you decide when to start emitting particles.
  14396. */
  14397. preventAutoStart: boolean;
  14398. private _noiseTexture;
  14399. /**
  14400. * Gets or sets a texture used to add random noise to particle positions
  14401. */
  14402. noiseTexture: Nullable<ProceduralTexture>;
  14403. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14404. noiseStrength: Vector3;
  14405. /**
  14406. * Callback triggered when the particle animation is ending.
  14407. */
  14408. onAnimationEnd: Nullable<() => void>;
  14409. /**
  14410. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14411. */
  14412. blendMode: number;
  14413. /**
  14414. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14415. * to override the particles.
  14416. */
  14417. forceDepthWrite: boolean;
  14418. /** 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 */
  14419. preWarmCycles: number;
  14420. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14421. preWarmStepOffset: number;
  14422. /**
  14423. * 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)
  14424. */
  14425. spriteCellChangeSpeed: number;
  14426. /**
  14427. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14428. */
  14429. startSpriteCellID: number;
  14430. /**
  14431. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14432. */
  14433. endSpriteCellID: number;
  14434. /**
  14435. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14436. */
  14437. spriteCellWidth: number;
  14438. /**
  14439. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14440. */
  14441. spriteCellHeight: number;
  14442. /**
  14443. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14444. */
  14445. spriteRandomStartCell: boolean;
  14446. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14447. translationPivot: Vector2;
  14448. /** @hidden */
  14449. protected _isAnimationSheetEnabled: boolean;
  14450. /**
  14451. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14452. */
  14453. beginAnimationOnStart: boolean;
  14454. /**
  14455. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14456. */
  14457. beginAnimationFrom: number;
  14458. /**
  14459. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14460. */
  14461. beginAnimationTo: number;
  14462. /**
  14463. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14464. */
  14465. beginAnimationLoop: boolean;
  14466. /**
  14467. * Gets or sets a world offset applied to all particles
  14468. */
  14469. worldOffset: Vector3;
  14470. /**
  14471. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14472. */
  14473. isAnimationSheetEnabled: boolean;
  14474. /**
  14475. * Get hosting scene
  14476. * @returns the scene
  14477. */
  14478. getScene(): Scene;
  14479. /**
  14480. * You can use gravity if you want to give an orientation to your particles.
  14481. */
  14482. gravity: Vector3;
  14483. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14484. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14485. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14486. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14487. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14488. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14489. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14490. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14491. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14492. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14493. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14494. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14495. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14496. /**
  14497. * Defines the delay in milliseconds before starting the system (0 by default)
  14498. */
  14499. startDelay: number;
  14500. /**
  14501. * Gets the current list of drag gradients.
  14502. * You must use addDragGradient and removeDragGradient to udpate this list
  14503. * @returns the list of drag gradients
  14504. */
  14505. getDragGradients(): Nullable<Array<FactorGradient>>;
  14506. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14507. limitVelocityDamping: number;
  14508. /**
  14509. * Gets the current list of limit velocity gradients.
  14510. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14511. * @returns the list of limit velocity gradients
  14512. */
  14513. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14514. /**
  14515. * Gets the current list of color gradients.
  14516. * You must use addColorGradient and removeColorGradient to udpate this list
  14517. * @returns the list of color gradients
  14518. */
  14519. getColorGradients(): Nullable<Array<ColorGradient>>;
  14520. /**
  14521. * Gets the current list of size gradients.
  14522. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14523. * @returns the list of size gradients
  14524. */
  14525. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14526. /**
  14527. * Gets the current list of color remap gradients.
  14528. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14529. * @returns the list of color remap gradients
  14530. */
  14531. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14532. /**
  14533. * Gets the current list of alpha remap gradients.
  14534. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14535. * @returns the list of alpha remap gradients
  14536. */
  14537. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14538. /**
  14539. * Gets the current list of life time gradients.
  14540. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14541. * @returns the list of life time gradients
  14542. */
  14543. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14544. /**
  14545. * Gets the current list of angular speed gradients.
  14546. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14547. * @returns the list of angular speed gradients
  14548. */
  14549. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14550. /**
  14551. * Gets the current list of velocity gradients.
  14552. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14553. * @returns the list of velocity gradients
  14554. */
  14555. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14556. /**
  14557. * Gets the current list of start size gradients.
  14558. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14559. * @returns the list of start size gradients
  14560. */
  14561. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14562. /**
  14563. * Gets the current list of emit rate gradients.
  14564. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14565. * @returns the list of emit rate gradients
  14566. */
  14567. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14568. /**
  14569. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14570. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14571. */
  14572. direction1: Vector3;
  14573. /**
  14574. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14575. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14576. */
  14577. direction2: Vector3;
  14578. /**
  14579. * 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.
  14580. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14581. */
  14582. minEmitBox: Vector3;
  14583. /**
  14584. * 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.
  14585. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14586. */
  14587. maxEmitBox: Vector3;
  14588. /**
  14589. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14590. */
  14591. color1: Color4;
  14592. /**
  14593. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14594. */
  14595. color2: Color4;
  14596. /**
  14597. * Color the particle will have at the end of its lifetime
  14598. */
  14599. colorDead: Color4;
  14600. /**
  14601. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14602. */
  14603. textureMask: Color4;
  14604. /**
  14605. * The particle emitter type defines the emitter used by the particle system.
  14606. * It can be for example box, sphere, or cone...
  14607. */
  14608. particleEmitterType: IParticleEmitterType;
  14609. /** @hidden */
  14610. _isSubEmitter: boolean;
  14611. /**
  14612. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14613. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14614. */
  14615. billboardMode: number;
  14616. protected _isBillboardBased: boolean;
  14617. /**
  14618. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14619. */
  14620. isBillboardBased: boolean;
  14621. /**
  14622. * The scene the particle system belongs to.
  14623. */
  14624. protected _scene: Scene;
  14625. /**
  14626. * Local cache of defines for image processing.
  14627. */
  14628. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14629. /**
  14630. * Default configuration related to image processing available in the standard Material.
  14631. */
  14632. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14633. /**
  14634. * Gets the image processing configuration used either in this material.
  14635. */
  14636. /**
  14637. * Sets the Default image processing configuration used either in the this material.
  14638. *
  14639. * If sets to null, the scene one is in use.
  14640. */
  14641. imageProcessingConfiguration: ImageProcessingConfiguration;
  14642. /**
  14643. * Attaches a new image processing configuration to the Standard Material.
  14644. * @param configuration
  14645. */
  14646. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14647. /** @hidden */
  14648. protected _reset(): void;
  14649. /** @hidden */
  14650. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14651. /**
  14652. * Instantiates a particle system.
  14653. * 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.
  14654. * @param name The name of the particle system
  14655. */
  14656. constructor(name: string);
  14657. /**
  14658. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14659. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14660. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14661. * @returns the emitter
  14662. */
  14663. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14664. /**
  14665. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14666. * @param radius The radius of the hemisphere to emit from
  14667. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14668. * @returns the emitter
  14669. */
  14670. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14671. /**
  14672. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14673. * @param radius The radius of the sphere to emit from
  14674. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14675. * @returns the emitter
  14676. */
  14677. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14678. /**
  14679. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14680. * @param radius The radius of the sphere to emit from
  14681. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14682. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14683. * @returns the emitter
  14684. */
  14685. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14686. /**
  14687. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14688. * @param radius The radius of the emission cylinder
  14689. * @param height The height of the emission cylinder
  14690. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14691. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14692. * @returns the emitter
  14693. */
  14694. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14695. /**
  14696. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14697. * @param radius The radius of the cylinder to emit from
  14698. * @param height The height of the emission cylinder
  14699. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14700. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14701. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14702. * @returns the emitter
  14703. */
  14704. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14705. /**
  14706. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14707. * @param radius The radius of the cone to emit from
  14708. * @param angle The base angle of the cone
  14709. * @returns the emitter
  14710. */
  14711. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14712. /**
  14713. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14714. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14715. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14716. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14717. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14718. * @returns the emitter
  14719. */
  14720. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14721. }
  14722. }
  14723. declare module BABYLON {
  14724. /**
  14725. * Type of sub emitter
  14726. */
  14727. export enum SubEmitterType {
  14728. /**
  14729. * Attached to the particle over it's lifetime
  14730. */
  14731. ATTACHED = 0,
  14732. /**
  14733. * Created when the particle dies
  14734. */
  14735. END = 1
  14736. }
  14737. /**
  14738. * Sub emitter class used to emit particles from an existing particle
  14739. */
  14740. export class SubEmitter {
  14741. /**
  14742. * the particle system to be used by the sub emitter
  14743. */
  14744. particleSystem: ParticleSystem;
  14745. /**
  14746. * Type of the submitter (Default: END)
  14747. */
  14748. type: SubEmitterType;
  14749. /**
  14750. * 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)
  14751. * Note: This only is supported when using an emitter of type Mesh
  14752. */
  14753. inheritDirection: boolean;
  14754. /**
  14755. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14756. */
  14757. inheritedVelocityAmount: number;
  14758. /**
  14759. * Creates a sub emitter
  14760. * @param particleSystem the particle system to be used by the sub emitter
  14761. */
  14762. constructor(
  14763. /**
  14764. * the particle system to be used by the sub emitter
  14765. */
  14766. particleSystem: ParticleSystem);
  14767. /**
  14768. * Clones the sub emitter
  14769. * @returns the cloned sub emitter
  14770. */
  14771. clone(): SubEmitter;
  14772. /**
  14773. * Serialize current object to a JSON object
  14774. * @returns the serialized object
  14775. */
  14776. serialize(): any;
  14777. /** @hidden */
  14778. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14779. /**
  14780. * Creates a new SubEmitter from a serialized JSON version
  14781. * @param serializationObject defines the JSON object to read from
  14782. * @param scene defines the hosting scene
  14783. * @param rootUrl defines the rootUrl for data loading
  14784. * @returns a new SubEmitter
  14785. */
  14786. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14787. /** Release associated resources */
  14788. dispose(): void;
  14789. }
  14790. }
  14791. declare module BABYLON {
  14792. /** @hidden */
  14793. export var clipPlaneFragmentDeclaration: {
  14794. name: string;
  14795. shader: string;
  14796. };
  14797. }
  14798. declare module BABYLON {
  14799. /** @hidden */
  14800. export var imageProcessingDeclaration: {
  14801. name: string;
  14802. shader: string;
  14803. };
  14804. }
  14805. declare module BABYLON {
  14806. /** @hidden */
  14807. export var imageProcessingFunctions: {
  14808. name: string;
  14809. shader: string;
  14810. };
  14811. }
  14812. declare module BABYLON {
  14813. /** @hidden */
  14814. export var clipPlaneFragment: {
  14815. name: string;
  14816. shader: string;
  14817. };
  14818. }
  14819. declare module BABYLON {
  14820. /** @hidden */
  14821. export var particlesPixelShader: {
  14822. name: string;
  14823. shader: string;
  14824. };
  14825. }
  14826. declare module BABYLON {
  14827. /** @hidden */
  14828. export var clipPlaneVertexDeclaration: {
  14829. name: string;
  14830. shader: string;
  14831. };
  14832. }
  14833. declare module BABYLON {
  14834. /** @hidden */
  14835. export var clipPlaneVertex: {
  14836. name: string;
  14837. shader: string;
  14838. };
  14839. }
  14840. declare module BABYLON {
  14841. /** @hidden */
  14842. export var particlesVertexShader: {
  14843. name: string;
  14844. shader: string;
  14845. };
  14846. }
  14847. declare module BABYLON {
  14848. /**
  14849. * This represents a particle system in Babylon.
  14850. * 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.
  14851. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14852. * @example https://doc.babylonjs.com/babylon101/particles
  14853. */
  14854. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14855. /**
  14856. * Billboard mode will only apply to Y axis
  14857. */
  14858. static readonly BILLBOARDMODE_Y: number;
  14859. /**
  14860. * Billboard mode will apply to all axes
  14861. */
  14862. static readonly BILLBOARDMODE_ALL: number;
  14863. /**
  14864. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14865. */
  14866. static readonly BILLBOARDMODE_STRETCHED: number;
  14867. /**
  14868. * This function can be defined to provide custom update for active particles.
  14869. * This function will be called instead of regular update (age, position, color, etc.).
  14870. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  14871. */
  14872. updateFunction: (particles: Particle[]) => void;
  14873. private _emitterWorldMatrix;
  14874. /**
  14875. * This function can be defined to specify initial direction for every new particle.
  14876. * It by default use the emitterType defined function
  14877. */
  14878. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  14879. /**
  14880. * This function can be defined to specify initial position for every new particle.
  14881. * It by default use the emitterType defined function
  14882. */
  14883. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  14884. /**
  14885. * @hidden
  14886. */
  14887. _inheritedVelocityOffset: Vector3;
  14888. /**
  14889. * An event triggered when the system is disposed
  14890. */
  14891. onDisposeObservable: Observable<ParticleSystem>;
  14892. private _onDisposeObserver;
  14893. /**
  14894. * Sets a callback that will be triggered when the system is disposed
  14895. */
  14896. onDispose: () => void;
  14897. private _particles;
  14898. private _epsilon;
  14899. private _capacity;
  14900. private _stockParticles;
  14901. private _newPartsExcess;
  14902. private _vertexData;
  14903. private _vertexBuffer;
  14904. private _vertexBuffers;
  14905. private _spriteBuffer;
  14906. private _indexBuffer;
  14907. private _effect;
  14908. private _customEffect;
  14909. private _cachedDefines;
  14910. private _scaledColorStep;
  14911. private _colorDiff;
  14912. private _scaledDirection;
  14913. private _scaledGravity;
  14914. private _currentRenderId;
  14915. private _alive;
  14916. private _useInstancing;
  14917. private _started;
  14918. private _stopped;
  14919. private _actualFrame;
  14920. private _scaledUpdateSpeed;
  14921. private _vertexBufferSize;
  14922. /** @hidden */
  14923. _currentEmitRateGradient: Nullable<FactorGradient>;
  14924. /** @hidden */
  14925. _currentEmitRate1: number;
  14926. /** @hidden */
  14927. _currentEmitRate2: number;
  14928. /** @hidden */
  14929. _currentStartSizeGradient: Nullable<FactorGradient>;
  14930. /** @hidden */
  14931. _currentStartSize1: number;
  14932. /** @hidden */
  14933. _currentStartSize2: number;
  14934. private readonly _rawTextureWidth;
  14935. private _rampGradientsTexture;
  14936. private _useRampGradients;
  14937. /** Gets or sets a boolean indicating that ramp gradients must be used
  14938. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14939. */
  14940. useRampGradients: boolean;
  14941. /**
  14942. * 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.
  14943. * 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: [])
  14944. */
  14945. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  14946. private _subEmitters;
  14947. /**
  14948. * @hidden
  14949. * If the particle systems emitter should be disposed when the particle system is disposed
  14950. */
  14951. _disposeEmitterOnDispose: boolean;
  14952. /**
  14953. * The current active Sub-systems, this property is used by the root particle system only.
  14954. */
  14955. activeSubSystems: Array<ParticleSystem>;
  14956. private _rootParticleSystem;
  14957. /**
  14958. * Gets the current list of active particles
  14959. */
  14960. readonly particles: Particle[];
  14961. /**
  14962. * Returns the string "ParticleSystem"
  14963. * @returns a string containing the class name
  14964. */
  14965. getClassName(): string;
  14966. /**
  14967. * Instantiates a particle system.
  14968. * 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.
  14969. * @param name The name of the particle system
  14970. * @param capacity The max number of particles alive at the same time
  14971. * @param scene The scene the particle system belongs to
  14972. * @param customEffect a custom effect used to change the way particles are rendered by default
  14973. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  14974. * @param epsilon Offset used to render the particles
  14975. */
  14976. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  14977. private _addFactorGradient;
  14978. private _removeFactorGradient;
  14979. /**
  14980. * Adds a new life time gradient
  14981. * @param gradient defines the gradient to use (between 0 and 1)
  14982. * @param factor defines the life time factor to affect to the specified gradient
  14983. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14984. * @returns the current particle system
  14985. */
  14986. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14987. /**
  14988. * Remove a specific life time gradient
  14989. * @param gradient defines the gradient to remove
  14990. * @returns the current particle system
  14991. */
  14992. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14993. /**
  14994. * Adds a new size gradient
  14995. * @param gradient defines the gradient to use (between 0 and 1)
  14996. * @param factor defines the size factor to affect to the specified gradient
  14997. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14998. * @returns the current particle system
  14999. */
  15000. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15001. /**
  15002. * Remove a specific size gradient
  15003. * @param gradient defines the gradient to remove
  15004. * @returns the current particle system
  15005. */
  15006. removeSizeGradient(gradient: number): IParticleSystem;
  15007. /**
  15008. * Adds a new color remap gradient
  15009. * @param gradient defines the gradient to use (between 0 and 1)
  15010. * @param min defines the color remap minimal range
  15011. * @param max defines the color remap maximal range
  15012. * @returns the current particle system
  15013. */
  15014. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15015. /**
  15016. * Remove a specific color remap gradient
  15017. * @param gradient defines the gradient to remove
  15018. * @returns the current particle system
  15019. */
  15020. removeColorRemapGradient(gradient: number): IParticleSystem;
  15021. /**
  15022. * Adds a new alpha remap gradient
  15023. * @param gradient defines the gradient to use (between 0 and 1)
  15024. * @param min defines the alpha remap minimal range
  15025. * @param max defines the alpha remap maximal range
  15026. * @returns the current particle system
  15027. */
  15028. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15029. /**
  15030. * Remove a specific alpha remap gradient
  15031. * @param gradient defines the gradient to remove
  15032. * @returns the current particle system
  15033. */
  15034. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15035. /**
  15036. * Adds a new angular speed gradient
  15037. * @param gradient defines the gradient to use (between 0 and 1)
  15038. * @param factor defines the angular speed to affect to the specified gradient
  15039. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15040. * @returns the current particle system
  15041. */
  15042. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15043. /**
  15044. * Remove a specific angular speed gradient
  15045. * @param gradient defines the gradient to remove
  15046. * @returns the current particle system
  15047. */
  15048. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15049. /**
  15050. * Adds a new velocity gradient
  15051. * @param gradient defines the gradient to use (between 0 and 1)
  15052. * @param factor defines the velocity to affect to the specified gradient
  15053. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15054. * @returns the current particle system
  15055. */
  15056. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15057. /**
  15058. * Remove a specific velocity gradient
  15059. * @param gradient defines the gradient to remove
  15060. * @returns the current particle system
  15061. */
  15062. removeVelocityGradient(gradient: number): IParticleSystem;
  15063. /**
  15064. * Adds a new limit velocity gradient
  15065. * @param gradient defines the gradient to use (between 0 and 1)
  15066. * @param factor defines the limit velocity value to affect to the specified gradient
  15067. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15068. * @returns the current particle system
  15069. */
  15070. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15071. /**
  15072. * Remove a specific limit velocity gradient
  15073. * @param gradient defines the gradient to remove
  15074. * @returns the current particle system
  15075. */
  15076. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15077. /**
  15078. * Adds a new drag gradient
  15079. * @param gradient defines the gradient to use (between 0 and 1)
  15080. * @param factor defines the drag value to affect to the specified gradient
  15081. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15082. * @returns the current particle system
  15083. */
  15084. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15085. /**
  15086. * Remove a specific drag gradient
  15087. * @param gradient defines the gradient to remove
  15088. * @returns the current particle system
  15089. */
  15090. removeDragGradient(gradient: number): IParticleSystem;
  15091. /**
  15092. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15093. * @param gradient defines the gradient to use (between 0 and 1)
  15094. * @param factor defines the emit rate value to affect to the specified gradient
  15095. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15096. * @returns the current particle system
  15097. */
  15098. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15099. /**
  15100. * Remove a specific emit rate gradient
  15101. * @param gradient defines the gradient to remove
  15102. * @returns the current particle system
  15103. */
  15104. removeEmitRateGradient(gradient: number): IParticleSystem;
  15105. /**
  15106. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15107. * @param gradient defines the gradient to use (between 0 and 1)
  15108. * @param factor defines the start size value to affect to the specified gradient
  15109. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15110. * @returns the current particle system
  15111. */
  15112. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15113. /**
  15114. * Remove a specific start size gradient
  15115. * @param gradient defines the gradient to remove
  15116. * @returns the current particle system
  15117. */
  15118. removeStartSizeGradient(gradient: number): IParticleSystem;
  15119. private _createRampGradientTexture;
  15120. /**
  15121. * Gets the current list of ramp gradients.
  15122. * You must use addRampGradient and removeRampGradient to udpate this list
  15123. * @returns the list of ramp gradients
  15124. */
  15125. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15126. /**
  15127. * Adds a new ramp gradient used to remap particle colors
  15128. * @param gradient defines the gradient to use (between 0 and 1)
  15129. * @param color defines the color to affect to the specified gradient
  15130. * @returns the current particle system
  15131. */
  15132. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15133. /**
  15134. * Remove a specific ramp gradient
  15135. * @param gradient defines the gradient to remove
  15136. * @returns the current particle system
  15137. */
  15138. removeRampGradient(gradient: number): ParticleSystem;
  15139. /**
  15140. * Adds a new color gradient
  15141. * @param gradient defines the gradient to use (between 0 and 1)
  15142. * @param color1 defines the color to affect to the specified gradient
  15143. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15144. * @returns this particle system
  15145. */
  15146. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15147. /**
  15148. * Remove a specific color gradient
  15149. * @param gradient defines the gradient to remove
  15150. * @returns this particle system
  15151. */
  15152. removeColorGradient(gradient: number): IParticleSystem;
  15153. private _fetchR;
  15154. protected _reset(): void;
  15155. private _resetEffect;
  15156. private _createVertexBuffers;
  15157. private _createIndexBuffer;
  15158. /**
  15159. * Gets the maximum number of particles active at the same time.
  15160. * @returns The max number of active particles.
  15161. */
  15162. getCapacity(): number;
  15163. /**
  15164. * Gets whether there are still active particles in the system.
  15165. * @returns True if it is alive, otherwise false.
  15166. */
  15167. isAlive(): boolean;
  15168. /**
  15169. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15170. * @returns True if it has been started, otherwise false.
  15171. */
  15172. isStarted(): boolean;
  15173. private _prepareSubEmitterInternalArray;
  15174. /**
  15175. * Starts the particle system and begins to emit
  15176. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15177. */
  15178. start(delay?: number): void;
  15179. /**
  15180. * Stops the particle system.
  15181. * @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.
  15182. */
  15183. stop(stopSubEmitters?: boolean): void;
  15184. /**
  15185. * Remove all active particles
  15186. */
  15187. reset(): void;
  15188. /**
  15189. * @hidden (for internal use only)
  15190. */
  15191. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15192. /**
  15193. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15194. * Its lifetime will start back at 0.
  15195. */
  15196. recycleParticle: (particle: Particle) => void;
  15197. private _stopSubEmitters;
  15198. private _createParticle;
  15199. private _removeFromRoot;
  15200. private _emitFromParticle;
  15201. private _update;
  15202. /** @hidden */
  15203. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15204. /** @hidden */
  15205. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15206. /** @hidden */
  15207. private _getEffect;
  15208. /**
  15209. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15210. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15211. */
  15212. animate(preWarmOnly?: boolean): void;
  15213. private _appendParticleVertices;
  15214. /**
  15215. * Rebuilds the particle system.
  15216. */
  15217. rebuild(): void;
  15218. /**
  15219. * Is this system ready to be used/rendered
  15220. * @return true if the system is ready
  15221. */
  15222. isReady(): boolean;
  15223. private _render;
  15224. /**
  15225. * Renders the particle system in its current state.
  15226. * @returns the current number of particles
  15227. */
  15228. render(): number;
  15229. /**
  15230. * Disposes the particle system and free the associated resources
  15231. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15232. */
  15233. dispose(disposeTexture?: boolean): void;
  15234. /**
  15235. * Clones the particle system.
  15236. * @param name The name of the cloned object
  15237. * @param newEmitter The new emitter to use
  15238. * @returns the cloned particle system
  15239. */
  15240. clone(name: string, newEmitter: any): ParticleSystem;
  15241. /**
  15242. * Serializes the particle system to a JSON object.
  15243. * @returns the JSON object
  15244. */
  15245. serialize(): any;
  15246. /** @hidden */
  15247. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15248. /** @hidden */
  15249. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15250. /**
  15251. * Parses a JSON object to create a particle system.
  15252. * @param parsedParticleSystem The JSON object to parse
  15253. * @param scene The scene to create the particle system in
  15254. * @param rootUrl The root url to use to load external dependencies like texture
  15255. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15256. * @returns the Parsed particle system
  15257. */
  15258. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15259. }
  15260. }
  15261. declare module BABYLON {
  15262. /**
  15263. * A particle represents one of the element emitted by a particle system.
  15264. * This is mainly define by its coordinates, direction, velocity and age.
  15265. */
  15266. export class Particle {
  15267. /**
  15268. * The particle system the particle belongs to.
  15269. */
  15270. particleSystem: ParticleSystem;
  15271. private static _Count;
  15272. /**
  15273. * Unique ID of the particle
  15274. */
  15275. id: number;
  15276. /**
  15277. * The world position of the particle in the scene.
  15278. */
  15279. position: Vector3;
  15280. /**
  15281. * The world direction of the particle in the scene.
  15282. */
  15283. direction: Vector3;
  15284. /**
  15285. * The color of the particle.
  15286. */
  15287. color: Color4;
  15288. /**
  15289. * The color change of the particle per step.
  15290. */
  15291. colorStep: Color4;
  15292. /**
  15293. * Defines how long will the life of the particle be.
  15294. */
  15295. lifeTime: number;
  15296. /**
  15297. * The current age of the particle.
  15298. */
  15299. age: number;
  15300. /**
  15301. * The current size of the particle.
  15302. */
  15303. size: number;
  15304. /**
  15305. * The current scale of the particle.
  15306. */
  15307. scale: Vector2;
  15308. /**
  15309. * The current angle of the particle.
  15310. */
  15311. angle: number;
  15312. /**
  15313. * Defines how fast is the angle changing.
  15314. */
  15315. angularSpeed: number;
  15316. /**
  15317. * Defines the cell index used by the particle to be rendered from a sprite.
  15318. */
  15319. cellIndex: number;
  15320. /**
  15321. * The information required to support color remapping
  15322. */
  15323. remapData: Vector4;
  15324. /** @hidden */
  15325. _randomCellOffset?: number;
  15326. /** @hidden */
  15327. _initialDirection: Nullable<Vector3>;
  15328. /** @hidden */
  15329. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15330. /** @hidden */
  15331. _initialStartSpriteCellID: number;
  15332. /** @hidden */
  15333. _initialEndSpriteCellID: number;
  15334. /** @hidden */
  15335. _currentColorGradient: Nullable<ColorGradient>;
  15336. /** @hidden */
  15337. _currentColor1: Color4;
  15338. /** @hidden */
  15339. _currentColor2: Color4;
  15340. /** @hidden */
  15341. _currentSizeGradient: Nullable<FactorGradient>;
  15342. /** @hidden */
  15343. _currentSize1: number;
  15344. /** @hidden */
  15345. _currentSize2: number;
  15346. /** @hidden */
  15347. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15348. /** @hidden */
  15349. _currentAngularSpeed1: number;
  15350. /** @hidden */
  15351. _currentAngularSpeed2: number;
  15352. /** @hidden */
  15353. _currentVelocityGradient: Nullable<FactorGradient>;
  15354. /** @hidden */
  15355. _currentVelocity1: number;
  15356. /** @hidden */
  15357. _currentVelocity2: number;
  15358. /** @hidden */
  15359. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15360. /** @hidden */
  15361. _currentLimitVelocity1: number;
  15362. /** @hidden */
  15363. _currentLimitVelocity2: number;
  15364. /** @hidden */
  15365. _currentDragGradient: Nullable<FactorGradient>;
  15366. /** @hidden */
  15367. _currentDrag1: number;
  15368. /** @hidden */
  15369. _currentDrag2: number;
  15370. /** @hidden */
  15371. _randomNoiseCoordinates1: Vector3;
  15372. /** @hidden */
  15373. _randomNoiseCoordinates2: Vector3;
  15374. /**
  15375. * Creates a new instance Particle
  15376. * @param particleSystem the particle system the particle belongs to
  15377. */
  15378. constructor(
  15379. /**
  15380. * The particle system the particle belongs to.
  15381. */
  15382. particleSystem: ParticleSystem);
  15383. private updateCellInfoFromSystem;
  15384. /**
  15385. * Defines how the sprite cell index is updated for the particle
  15386. */
  15387. updateCellIndex(): void;
  15388. /** @hidden */
  15389. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15390. /** @hidden */
  15391. _inheritParticleInfoToSubEmitters(): void;
  15392. /** @hidden */
  15393. _reset(): void;
  15394. /**
  15395. * Copy the properties of particle to another one.
  15396. * @param other the particle to copy the information to.
  15397. */
  15398. copyTo(other: Particle): void;
  15399. }
  15400. }
  15401. declare module BABYLON {
  15402. /**
  15403. * Particle emitter represents a volume emitting particles.
  15404. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15405. */
  15406. export interface IParticleEmitterType {
  15407. /**
  15408. * Called by the particle System when the direction is computed for the created particle.
  15409. * @param worldMatrix is the world matrix of the particle system
  15410. * @param directionToUpdate is the direction vector to update with the result
  15411. * @param particle is the particle we are computed the direction for
  15412. */
  15413. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15414. /**
  15415. * Called by the particle System when the position is computed for the created particle.
  15416. * @param worldMatrix is the world matrix of the particle system
  15417. * @param positionToUpdate is the position vector to update with the result
  15418. * @param particle is the particle we are computed the position for
  15419. */
  15420. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15421. /**
  15422. * Clones the current emitter and returns a copy of it
  15423. * @returns the new emitter
  15424. */
  15425. clone(): IParticleEmitterType;
  15426. /**
  15427. * Called by the GPUParticleSystem to setup the update shader
  15428. * @param effect defines the update shader
  15429. */
  15430. applyToShader(effect: Effect): void;
  15431. /**
  15432. * Returns a string to use to update the GPU particles update shader
  15433. * @returns the effect defines string
  15434. */
  15435. getEffectDefines(): string;
  15436. /**
  15437. * Returns a string representing the class name
  15438. * @returns a string containing the class name
  15439. */
  15440. getClassName(): string;
  15441. /**
  15442. * Serializes the particle system to a JSON object.
  15443. * @returns the JSON object
  15444. */
  15445. serialize(): any;
  15446. /**
  15447. * Parse properties from a JSON object
  15448. * @param serializationObject defines the JSON object
  15449. */
  15450. parse(serializationObject: any): void;
  15451. }
  15452. }
  15453. declare module BABYLON {
  15454. /**
  15455. * Particle emitter emitting particles from the inside of a box.
  15456. * It emits the particles randomly between 2 given directions.
  15457. */
  15458. export class BoxParticleEmitter implements IParticleEmitterType {
  15459. /**
  15460. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15461. */
  15462. direction1: Vector3;
  15463. /**
  15464. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15465. */
  15466. direction2: Vector3;
  15467. /**
  15468. * 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.
  15469. */
  15470. minEmitBox: Vector3;
  15471. /**
  15472. * 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.
  15473. */
  15474. maxEmitBox: Vector3;
  15475. /**
  15476. * Creates a new instance BoxParticleEmitter
  15477. */
  15478. constructor();
  15479. /**
  15480. * Called by the particle System when the direction is computed for the created particle.
  15481. * @param worldMatrix is the world matrix of the particle system
  15482. * @param directionToUpdate is the direction vector to update with the result
  15483. * @param particle is the particle we are computed the direction for
  15484. */
  15485. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15486. /**
  15487. * Called by the particle System when the position is computed for the created particle.
  15488. * @param worldMatrix is the world matrix of the particle system
  15489. * @param positionToUpdate is the position vector to update with the result
  15490. * @param particle is the particle we are computed the position for
  15491. */
  15492. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15493. /**
  15494. * Clones the current emitter and returns a copy of it
  15495. * @returns the new emitter
  15496. */
  15497. clone(): BoxParticleEmitter;
  15498. /**
  15499. * Called by the GPUParticleSystem to setup the update shader
  15500. * @param effect defines the update shader
  15501. */
  15502. applyToShader(effect: Effect): void;
  15503. /**
  15504. * Returns a string to use to update the GPU particles update shader
  15505. * @returns a string containng the defines string
  15506. */
  15507. getEffectDefines(): string;
  15508. /**
  15509. * Returns the string "BoxParticleEmitter"
  15510. * @returns a string containing the class name
  15511. */
  15512. getClassName(): string;
  15513. /**
  15514. * Serializes the particle system to a JSON object.
  15515. * @returns the JSON object
  15516. */
  15517. serialize(): any;
  15518. /**
  15519. * Parse properties from a JSON object
  15520. * @param serializationObject defines the JSON object
  15521. */
  15522. parse(serializationObject: any): void;
  15523. }
  15524. }
  15525. declare module BABYLON {
  15526. /**
  15527. * Particle emitter emitting particles from the inside of a cone.
  15528. * It emits the particles alongside the cone volume from the base to the particle.
  15529. * The emission direction might be randomized.
  15530. */
  15531. export class ConeParticleEmitter implements IParticleEmitterType {
  15532. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15533. directionRandomizer: number;
  15534. private _radius;
  15535. private _angle;
  15536. private _height;
  15537. /**
  15538. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15539. */
  15540. radiusRange: number;
  15541. /**
  15542. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15543. */
  15544. heightRange: number;
  15545. /**
  15546. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15547. */
  15548. emitFromSpawnPointOnly: boolean;
  15549. /**
  15550. * Gets or sets the radius of the emission cone
  15551. */
  15552. radius: number;
  15553. /**
  15554. * Gets or sets the angle of the emission cone
  15555. */
  15556. angle: number;
  15557. private _buildHeight;
  15558. /**
  15559. * Creates a new instance ConeParticleEmitter
  15560. * @param radius the radius of the emission cone (1 by default)
  15561. * @param angle the cone base angle (PI by default)
  15562. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15563. */
  15564. constructor(radius?: number, angle?: number,
  15565. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15566. directionRandomizer?: number);
  15567. /**
  15568. * Called by the particle System when the direction is computed for the created particle.
  15569. * @param worldMatrix is the world matrix of the particle system
  15570. * @param directionToUpdate is the direction vector to update with the result
  15571. * @param particle is the particle we are computed the direction for
  15572. */
  15573. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15574. /**
  15575. * Called by the particle System when the position is computed for the created particle.
  15576. * @param worldMatrix is the world matrix of the particle system
  15577. * @param positionToUpdate is the position vector to update with the result
  15578. * @param particle is the particle we are computed the position for
  15579. */
  15580. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15581. /**
  15582. * Clones the current emitter and returns a copy of it
  15583. * @returns the new emitter
  15584. */
  15585. clone(): ConeParticleEmitter;
  15586. /**
  15587. * Called by the GPUParticleSystem to setup the update shader
  15588. * @param effect defines the update shader
  15589. */
  15590. applyToShader(effect: Effect): void;
  15591. /**
  15592. * Returns a string to use to update the GPU particles update shader
  15593. * @returns a string containng the defines string
  15594. */
  15595. getEffectDefines(): string;
  15596. /**
  15597. * Returns the string "ConeParticleEmitter"
  15598. * @returns a string containing the class name
  15599. */
  15600. getClassName(): string;
  15601. /**
  15602. * Serializes the particle system to a JSON object.
  15603. * @returns the JSON object
  15604. */
  15605. serialize(): any;
  15606. /**
  15607. * Parse properties from a JSON object
  15608. * @param serializationObject defines the JSON object
  15609. */
  15610. parse(serializationObject: any): void;
  15611. }
  15612. }
  15613. declare module BABYLON {
  15614. /**
  15615. * Particle emitter emitting particles from the inside of a cylinder.
  15616. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15617. */
  15618. export class CylinderParticleEmitter implements IParticleEmitterType {
  15619. /**
  15620. * The radius of the emission cylinder.
  15621. */
  15622. radius: number;
  15623. /**
  15624. * The height of the emission cylinder.
  15625. */
  15626. height: number;
  15627. /**
  15628. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15629. */
  15630. radiusRange: number;
  15631. /**
  15632. * How much to randomize the particle direction [0-1].
  15633. */
  15634. directionRandomizer: number;
  15635. /**
  15636. * Creates a new instance CylinderParticleEmitter
  15637. * @param radius the radius of the emission cylinder (1 by default)
  15638. * @param height the height of the emission cylinder (1 by default)
  15639. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15640. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15641. */
  15642. constructor(
  15643. /**
  15644. * The radius of the emission cylinder.
  15645. */
  15646. radius?: number,
  15647. /**
  15648. * The height of the emission cylinder.
  15649. */
  15650. height?: number,
  15651. /**
  15652. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15653. */
  15654. radiusRange?: number,
  15655. /**
  15656. * How much to randomize the particle direction [0-1].
  15657. */
  15658. directionRandomizer?: number);
  15659. /**
  15660. * Called by the particle System when the direction is computed for the created particle.
  15661. * @param worldMatrix is the world matrix of the particle system
  15662. * @param directionToUpdate is the direction vector to update with the result
  15663. * @param particle is the particle we are computed the direction for
  15664. */
  15665. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15666. /**
  15667. * Called by the particle System when the position is computed for the created particle.
  15668. * @param worldMatrix is the world matrix of the particle system
  15669. * @param positionToUpdate is the position vector to update with the result
  15670. * @param particle is the particle we are computed the position for
  15671. */
  15672. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15673. /**
  15674. * Clones the current emitter and returns a copy of it
  15675. * @returns the new emitter
  15676. */
  15677. clone(): CylinderParticleEmitter;
  15678. /**
  15679. * Called by the GPUParticleSystem to setup the update shader
  15680. * @param effect defines the update shader
  15681. */
  15682. applyToShader(effect: Effect): void;
  15683. /**
  15684. * Returns a string to use to update the GPU particles update shader
  15685. * @returns a string containng the defines string
  15686. */
  15687. getEffectDefines(): string;
  15688. /**
  15689. * Returns the string "CylinderParticleEmitter"
  15690. * @returns a string containing the class name
  15691. */
  15692. getClassName(): string;
  15693. /**
  15694. * Serializes the particle system to a JSON object.
  15695. * @returns the JSON object
  15696. */
  15697. serialize(): any;
  15698. /**
  15699. * Parse properties from a JSON object
  15700. * @param serializationObject defines the JSON object
  15701. */
  15702. parse(serializationObject: any): void;
  15703. }
  15704. /**
  15705. * Particle emitter emitting particles from the inside of a cylinder.
  15706. * It emits the particles randomly between two vectors.
  15707. */
  15708. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15709. /**
  15710. * The min limit of the emission direction.
  15711. */
  15712. direction1: Vector3;
  15713. /**
  15714. * The max limit of the emission direction.
  15715. */
  15716. direction2: Vector3;
  15717. /**
  15718. * Creates a new instance CylinderDirectedParticleEmitter
  15719. * @param radius the radius of the emission cylinder (1 by default)
  15720. * @param height the height of the emission cylinder (1 by default)
  15721. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15722. * @param direction1 the min limit of the emission direction (up vector by default)
  15723. * @param direction2 the max limit of the emission direction (up vector by default)
  15724. */
  15725. constructor(radius?: number, height?: number, radiusRange?: number,
  15726. /**
  15727. * The min limit of the emission direction.
  15728. */
  15729. direction1?: Vector3,
  15730. /**
  15731. * The max limit of the emission direction.
  15732. */
  15733. direction2?: Vector3);
  15734. /**
  15735. * Called by the particle System when the direction is computed for the created particle.
  15736. * @param worldMatrix is the world matrix of the particle system
  15737. * @param directionToUpdate is the direction vector to update with the result
  15738. * @param particle is the particle we are computed the direction for
  15739. */
  15740. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15741. /**
  15742. * Clones the current emitter and returns a copy of it
  15743. * @returns the new emitter
  15744. */
  15745. clone(): CylinderDirectedParticleEmitter;
  15746. /**
  15747. * Called by the GPUParticleSystem to setup the update shader
  15748. * @param effect defines the update shader
  15749. */
  15750. applyToShader(effect: Effect): void;
  15751. /**
  15752. * Returns a string to use to update the GPU particles update shader
  15753. * @returns a string containng the defines string
  15754. */
  15755. getEffectDefines(): string;
  15756. /**
  15757. * Returns the string "CylinderDirectedParticleEmitter"
  15758. * @returns a string containing the class name
  15759. */
  15760. getClassName(): string;
  15761. /**
  15762. * Serializes the particle system to a JSON object.
  15763. * @returns the JSON object
  15764. */
  15765. serialize(): any;
  15766. /**
  15767. * Parse properties from a JSON object
  15768. * @param serializationObject defines the JSON object
  15769. */
  15770. parse(serializationObject: any): void;
  15771. }
  15772. }
  15773. declare module BABYLON {
  15774. /**
  15775. * Particle emitter emitting particles from the inside of a hemisphere.
  15776. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15777. */
  15778. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15779. /**
  15780. * The radius of the emission hemisphere.
  15781. */
  15782. radius: number;
  15783. /**
  15784. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15785. */
  15786. radiusRange: number;
  15787. /**
  15788. * How much to randomize the particle direction [0-1].
  15789. */
  15790. directionRandomizer: number;
  15791. /**
  15792. * Creates a new instance HemisphericParticleEmitter
  15793. * @param radius the radius of the emission hemisphere (1 by default)
  15794. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15795. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15796. */
  15797. constructor(
  15798. /**
  15799. * The radius of the emission hemisphere.
  15800. */
  15801. radius?: number,
  15802. /**
  15803. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15804. */
  15805. radiusRange?: number,
  15806. /**
  15807. * How much to randomize the particle direction [0-1].
  15808. */
  15809. directionRandomizer?: number);
  15810. /**
  15811. * Called by the particle System when the direction is computed for the created particle.
  15812. * @param worldMatrix is the world matrix of the particle system
  15813. * @param directionToUpdate is the direction vector to update with the result
  15814. * @param particle is the particle we are computed the direction for
  15815. */
  15816. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15817. /**
  15818. * Called by the particle System when the position is computed for the created particle.
  15819. * @param worldMatrix is the world matrix of the particle system
  15820. * @param positionToUpdate is the position vector to update with the result
  15821. * @param particle is the particle we are computed the position for
  15822. */
  15823. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15824. /**
  15825. * Clones the current emitter and returns a copy of it
  15826. * @returns the new emitter
  15827. */
  15828. clone(): HemisphericParticleEmitter;
  15829. /**
  15830. * Called by the GPUParticleSystem to setup the update shader
  15831. * @param effect defines the update shader
  15832. */
  15833. applyToShader(effect: Effect): void;
  15834. /**
  15835. * Returns a string to use to update the GPU particles update shader
  15836. * @returns a string containng the defines string
  15837. */
  15838. getEffectDefines(): string;
  15839. /**
  15840. * Returns the string "HemisphericParticleEmitter"
  15841. * @returns a string containing the class name
  15842. */
  15843. getClassName(): string;
  15844. /**
  15845. * Serializes the particle system to a JSON object.
  15846. * @returns the JSON object
  15847. */
  15848. serialize(): any;
  15849. /**
  15850. * Parse properties from a JSON object
  15851. * @param serializationObject defines the JSON object
  15852. */
  15853. parse(serializationObject: any): void;
  15854. }
  15855. }
  15856. declare module BABYLON {
  15857. /**
  15858. * Particle emitter emitting particles from a point.
  15859. * It emits the particles randomly between 2 given directions.
  15860. */
  15861. export class PointParticleEmitter implements IParticleEmitterType {
  15862. /**
  15863. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15864. */
  15865. direction1: Vector3;
  15866. /**
  15867. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15868. */
  15869. direction2: Vector3;
  15870. /**
  15871. * Creates a new instance PointParticleEmitter
  15872. */
  15873. constructor();
  15874. /**
  15875. * Called by the particle System when the direction is computed for the created particle.
  15876. * @param worldMatrix is the world matrix of the particle system
  15877. * @param directionToUpdate is the direction vector to update with the result
  15878. * @param particle is the particle we are computed the direction for
  15879. */
  15880. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15881. /**
  15882. * Called by the particle System when the position is computed for the created particle.
  15883. * @param worldMatrix is the world matrix of the particle system
  15884. * @param positionToUpdate is the position vector to update with the result
  15885. * @param particle is the particle we are computed the position for
  15886. */
  15887. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15888. /**
  15889. * Clones the current emitter and returns a copy of it
  15890. * @returns the new emitter
  15891. */
  15892. clone(): PointParticleEmitter;
  15893. /**
  15894. * Called by the GPUParticleSystem to setup the update shader
  15895. * @param effect defines the update shader
  15896. */
  15897. applyToShader(effect: Effect): void;
  15898. /**
  15899. * Returns a string to use to update the GPU particles update shader
  15900. * @returns a string containng the defines string
  15901. */
  15902. getEffectDefines(): string;
  15903. /**
  15904. * Returns the string "PointParticleEmitter"
  15905. * @returns a string containing the class name
  15906. */
  15907. getClassName(): string;
  15908. /**
  15909. * Serializes the particle system to a JSON object.
  15910. * @returns the JSON object
  15911. */
  15912. serialize(): any;
  15913. /**
  15914. * Parse properties from a JSON object
  15915. * @param serializationObject defines the JSON object
  15916. */
  15917. parse(serializationObject: any): void;
  15918. }
  15919. }
  15920. declare module BABYLON {
  15921. /**
  15922. * Particle emitter emitting particles from the inside of a sphere.
  15923. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  15924. */
  15925. export class SphereParticleEmitter implements IParticleEmitterType {
  15926. /**
  15927. * The radius of the emission sphere.
  15928. */
  15929. radius: number;
  15930. /**
  15931. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15932. */
  15933. radiusRange: number;
  15934. /**
  15935. * How much to randomize the particle direction [0-1].
  15936. */
  15937. directionRandomizer: number;
  15938. /**
  15939. * Creates a new instance SphereParticleEmitter
  15940. * @param radius the radius of the emission sphere (1 by default)
  15941. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15942. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15943. */
  15944. constructor(
  15945. /**
  15946. * The radius of the emission sphere.
  15947. */
  15948. radius?: number,
  15949. /**
  15950. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15951. */
  15952. radiusRange?: number,
  15953. /**
  15954. * How much to randomize the particle direction [0-1].
  15955. */
  15956. directionRandomizer?: number);
  15957. /**
  15958. * Called by the particle System when the direction is computed for the created particle.
  15959. * @param worldMatrix is the world matrix of the particle system
  15960. * @param directionToUpdate is the direction vector to update with the result
  15961. * @param particle is the particle we are computed the direction for
  15962. */
  15963. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15964. /**
  15965. * Called by the particle System when the position is computed for the created particle.
  15966. * @param worldMatrix is the world matrix of the particle system
  15967. * @param positionToUpdate is the position vector to update with the result
  15968. * @param particle is the particle we are computed the position for
  15969. */
  15970. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15971. /**
  15972. * Clones the current emitter and returns a copy of it
  15973. * @returns the new emitter
  15974. */
  15975. clone(): SphereParticleEmitter;
  15976. /**
  15977. * Called by the GPUParticleSystem to setup the update shader
  15978. * @param effect defines the update shader
  15979. */
  15980. applyToShader(effect: Effect): void;
  15981. /**
  15982. * Returns a string to use to update the GPU particles update shader
  15983. * @returns a string containng the defines string
  15984. */
  15985. getEffectDefines(): string;
  15986. /**
  15987. * Returns the string "SphereParticleEmitter"
  15988. * @returns a string containing the class name
  15989. */
  15990. getClassName(): string;
  15991. /**
  15992. * Serializes the particle system to a JSON object.
  15993. * @returns the JSON object
  15994. */
  15995. serialize(): any;
  15996. /**
  15997. * Parse properties from a JSON object
  15998. * @param serializationObject defines the JSON object
  15999. */
  16000. parse(serializationObject: any): void;
  16001. }
  16002. /**
  16003. * Particle emitter emitting particles from the inside of a sphere.
  16004. * It emits the particles randomly between two vectors.
  16005. */
  16006. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16007. /**
  16008. * The min limit of the emission direction.
  16009. */
  16010. direction1: Vector3;
  16011. /**
  16012. * The max limit of the emission direction.
  16013. */
  16014. direction2: Vector3;
  16015. /**
  16016. * Creates a new instance SphereDirectedParticleEmitter
  16017. * @param radius the radius of the emission sphere (1 by default)
  16018. * @param direction1 the min limit of the emission direction (up vector by default)
  16019. * @param direction2 the max limit of the emission direction (up vector by default)
  16020. */
  16021. constructor(radius?: number,
  16022. /**
  16023. * The min limit of the emission direction.
  16024. */
  16025. direction1?: Vector3,
  16026. /**
  16027. * The max limit of the emission direction.
  16028. */
  16029. direction2?: Vector3);
  16030. /**
  16031. * Called by the particle System when the direction is computed for the created particle.
  16032. * @param worldMatrix is the world matrix of the particle system
  16033. * @param directionToUpdate is the direction vector to update with the result
  16034. * @param particle is the particle we are computed the direction for
  16035. */
  16036. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16037. /**
  16038. * Clones the current emitter and returns a copy of it
  16039. * @returns the new emitter
  16040. */
  16041. clone(): SphereDirectedParticleEmitter;
  16042. /**
  16043. * Called by the GPUParticleSystem to setup the update shader
  16044. * @param effect defines the update shader
  16045. */
  16046. applyToShader(effect: Effect): void;
  16047. /**
  16048. * Returns a string to use to update the GPU particles update shader
  16049. * @returns a string containng the defines string
  16050. */
  16051. getEffectDefines(): string;
  16052. /**
  16053. * Returns the string "SphereDirectedParticleEmitter"
  16054. * @returns a string containing the class name
  16055. */
  16056. getClassName(): string;
  16057. /**
  16058. * Serializes the particle system to a JSON object.
  16059. * @returns the JSON object
  16060. */
  16061. serialize(): any;
  16062. /**
  16063. * Parse properties from a JSON object
  16064. * @param serializationObject defines the JSON object
  16065. */
  16066. parse(serializationObject: any): void;
  16067. }
  16068. }
  16069. declare module BABYLON {
  16070. /**
  16071. * Interface representing a particle system in Babylon.js.
  16072. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16073. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16074. */
  16075. export interface IParticleSystem {
  16076. /**
  16077. * List of animations used by the particle system.
  16078. */
  16079. animations: Animation[];
  16080. /**
  16081. * The id of the Particle system.
  16082. */
  16083. id: string;
  16084. /**
  16085. * The name of the Particle system.
  16086. */
  16087. name: string;
  16088. /**
  16089. * The emitter represents the Mesh or position we are attaching the particle system to.
  16090. */
  16091. emitter: Nullable<AbstractMesh | Vector3>;
  16092. /**
  16093. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16094. */
  16095. isBillboardBased: boolean;
  16096. /**
  16097. * The rendering group used by the Particle system to chose when to render.
  16098. */
  16099. renderingGroupId: number;
  16100. /**
  16101. * The layer mask we are rendering the particles through.
  16102. */
  16103. layerMask: number;
  16104. /**
  16105. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16106. */
  16107. updateSpeed: number;
  16108. /**
  16109. * The amount of time the particle system is running (depends of the overall update speed).
  16110. */
  16111. targetStopDuration: number;
  16112. /**
  16113. * The texture used to render each particle. (this can be a spritesheet)
  16114. */
  16115. particleTexture: Nullable<Texture>;
  16116. /**
  16117. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16118. */
  16119. blendMode: number;
  16120. /**
  16121. * Minimum life time of emitting particles.
  16122. */
  16123. minLifeTime: number;
  16124. /**
  16125. * Maximum life time of emitting particles.
  16126. */
  16127. maxLifeTime: number;
  16128. /**
  16129. * Minimum Size of emitting particles.
  16130. */
  16131. minSize: number;
  16132. /**
  16133. * Maximum Size of emitting particles.
  16134. */
  16135. maxSize: number;
  16136. /**
  16137. * Minimum scale of emitting particles on X axis.
  16138. */
  16139. minScaleX: number;
  16140. /**
  16141. * Maximum scale of emitting particles on X axis.
  16142. */
  16143. maxScaleX: number;
  16144. /**
  16145. * Minimum scale of emitting particles on Y axis.
  16146. */
  16147. minScaleY: number;
  16148. /**
  16149. * Maximum scale of emitting particles on Y axis.
  16150. */
  16151. maxScaleY: number;
  16152. /**
  16153. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16154. */
  16155. color1: Color4;
  16156. /**
  16157. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16158. */
  16159. color2: Color4;
  16160. /**
  16161. * Color the particle will have at the end of its lifetime.
  16162. */
  16163. colorDead: Color4;
  16164. /**
  16165. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16166. */
  16167. emitRate: number;
  16168. /**
  16169. * You can use gravity if you want to give an orientation to your particles.
  16170. */
  16171. gravity: Vector3;
  16172. /**
  16173. * Minimum power of emitting particles.
  16174. */
  16175. minEmitPower: number;
  16176. /**
  16177. * Maximum power of emitting particles.
  16178. */
  16179. maxEmitPower: number;
  16180. /**
  16181. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16182. */
  16183. minAngularSpeed: number;
  16184. /**
  16185. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16186. */
  16187. maxAngularSpeed: number;
  16188. /**
  16189. * Gets or sets the minimal initial rotation in radians.
  16190. */
  16191. minInitialRotation: number;
  16192. /**
  16193. * Gets or sets the maximal initial rotation in radians.
  16194. */
  16195. maxInitialRotation: number;
  16196. /**
  16197. * The particle emitter type defines the emitter used by the particle system.
  16198. * It can be for example box, sphere, or cone...
  16199. */
  16200. particleEmitterType: Nullable<IParticleEmitterType>;
  16201. /**
  16202. * Defines the delay in milliseconds before starting the system (0 by default)
  16203. */
  16204. startDelay: number;
  16205. /**
  16206. * 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
  16207. */
  16208. preWarmCycles: number;
  16209. /**
  16210. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16211. */
  16212. preWarmStepOffset: number;
  16213. /**
  16214. * 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)
  16215. */
  16216. spriteCellChangeSpeed: number;
  16217. /**
  16218. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16219. */
  16220. startSpriteCellID: number;
  16221. /**
  16222. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16223. */
  16224. endSpriteCellID: number;
  16225. /**
  16226. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16227. */
  16228. spriteCellWidth: number;
  16229. /**
  16230. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16231. */
  16232. spriteCellHeight: number;
  16233. /**
  16234. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16235. */
  16236. spriteRandomStartCell: boolean;
  16237. /**
  16238. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16239. */
  16240. isAnimationSheetEnabled: boolean;
  16241. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16242. translationPivot: Vector2;
  16243. /**
  16244. * Gets or sets a texture used to add random noise to particle positions
  16245. */
  16246. noiseTexture: Nullable<BaseTexture>;
  16247. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16248. noiseStrength: Vector3;
  16249. /**
  16250. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16251. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16252. */
  16253. billboardMode: number;
  16254. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16255. limitVelocityDamping: number;
  16256. /**
  16257. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16258. */
  16259. beginAnimationOnStart: boolean;
  16260. /**
  16261. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16262. */
  16263. beginAnimationFrom: number;
  16264. /**
  16265. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16266. */
  16267. beginAnimationTo: number;
  16268. /**
  16269. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16270. */
  16271. beginAnimationLoop: boolean;
  16272. /**
  16273. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16274. */
  16275. disposeOnStop: boolean;
  16276. /**
  16277. * Gets the maximum number of particles active at the same time.
  16278. * @returns The max number of active particles.
  16279. */
  16280. getCapacity(): number;
  16281. /**
  16282. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16283. * @returns True if it has been started, otherwise false.
  16284. */
  16285. isStarted(): boolean;
  16286. /**
  16287. * Animates the particle system for this frame.
  16288. */
  16289. animate(): void;
  16290. /**
  16291. * Renders the particle system in its current state.
  16292. * @returns the current number of particles
  16293. */
  16294. render(): number;
  16295. /**
  16296. * Dispose the particle system and frees its associated resources.
  16297. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16298. */
  16299. dispose(disposeTexture?: boolean): void;
  16300. /**
  16301. * Clones the particle system.
  16302. * @param name The name of the cloned object
  16303. * @param newEmitter The new emitter to use
  16304. * @returns the cloned particle system
  16305. */
  16306. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16307. /**
  16308. * Serializes the particle system to a JSON object.
  16309. * @returns the JSON object
  16310. */
  16311. serialize(): any;
  16312. /**
  16313. * Rebuild the particle system
  16314. */
  16315. rebuild(): void;
  16316. /**
  16317. * Starts the particle system and begins to emit
  16318. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16319. */
  16320. start(delay?: number): void;
  16321. /**
  16322. * Stops the particle system.
  16323. */
  16324. stop(): void;
  16325. /**
  16326. * Remove all active particles
  16327. */
  16328. reset(): void;
  16329. /**
  16330. * Is this system ready to be used/rendered
  16331. * @return true if the system is ready
  16332. */
  16333. isReady(): boolean;
  16334. /**
  16335. * Adds a new color gradient
  16336. * @param gradient defines the gradient to use (between 0 and 1)
  16337. * @param color1 defines the color to affect to the specified gradient
  16338. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16339. * @returns the current particle system
  16340. */
  16341. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16342. /**
  16343. * Remove a specific color gradient
  16344. * @param gradient defines the gradient to remove
  16345. * @returns the current particle system
  16346. */
  16347. removeColorGradient(gradient: number): IParticleSystem;
  16348. /**
  16349. * Adds a new size gradient
  16350. * @param gradient defines the gradient to use (between 0 and 1)
  16351. * @param factor defines the size factor to affect to the specified gradient
  16352. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16353. * @returns the current particle system
  16354. */
  16355. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16356. /**
  16357. * Remove a specific size gradient
  16358. * @param gradient defines the gradient to remove
  16359. * @returns the current particle system
  16360. */
  16361. removeSizeGradient(gradient: number): IParticleSystem;
  16362. /**
  16363. * Gets the current list of color gradients.
  16364. * You must use addColorGradient and removeColorGradient to udpate this list
  16365. * @returns the list of color gradients
  16366. */
  16367. getColorGradients(): Nullable<Array<ColorGradient>>;
  16368. /**
  16369. * Gets the current list of size gradients.
  16370. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16371. * @returns the list of size gradients
  16372. */
  16373. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16374. /**
  16375. * Gets the current list of angular speed gradients.
  16376. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16377. * @returns the list of angular speed gradients
  16378. */
  16379. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16380. /**
  16381. * Adds a new angular speed gradient
  16382. * @param gradient defines the gradient to use (between 0 and 1)
  16383. * @param factor defines the angular speed to affect to the specified gradient
  16384. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16385. * @returns the current particle system
  16386. */
  16387. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16388. /**
  16389. * Remove a specific angular speed gradient
  16390. * @param gradient defines the gradient to remove
  16391. * @returns the current particle system
  16392. */
  16393. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16394. /**
  16395. * Gets the current list of velocity gradients.
  16396. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16397. * @returns the list of velocity gradients
  16398. */
  16399. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16400. /**
  16401. * Adds a new velocity gradient
  16402. * @param gradient defines the gradient to use (between 0 and 1)
  16403. * @param factor defines the velocity to affect to the specified gradient
  16404. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16405. * @returns the current particle system
  16406. */
  16407. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16408. /**
  16409. * Remove a specific velocity gradient
  16410. * @param gradient defines the gradient to remove
  16411. * @returns the current particle system
  16412. */
  16413. removeVelocityGradient(gradient: number): IParticleSystem;
  16414. /**
  16415. * Gets the current list of limit velocity gradients.
  16416. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16417. * @returns the list of limit velocity gradients
  16418. */
  16419. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16420. /**
  16421. * Adds a new limit velocity gradient
  16422. * @param gradient defines the gradient to use (between 0 and 1)
  16423. * @param factor defines the limit velocity to affect to the specified gradient
  16424. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16425. * @returns the current particle system
  16426. */
  16427. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16428. /**
  16429. * Remove a specific limit velocity gradient
  16430. * @param gradient defines the gradient to remove
  16431. * @returns the current particle system
  16432. */
  16433. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16434. /**
  16435. * Adds a new drag gradient
  16436. * @param gradient defines the gradient to use (between 0 and 1)
  16437. * @param factor defines the drag to affect to the specified gradient
  16438. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16439. * @returns the current particle system
  16440. */
  16441. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16442. /**
  16443. * Remove a specific drag gradient
  16444. * @param gradient defines the gradient to remove
  16445. * @returns the current particle system
  16446. */
  16447. removeDragGradient(gradient: number): IParticleSystem;
  16448. /**
  16449. * Gets the current list of drag gradients.
  16450. * You must use addDragGradient and removeDragGradient to udpate this list
  16451. * @returns the list of drag gradients
  16452. */
  16453. getDragGradients(): Nullable<Array<FactorGradient>>;
  16454. /**
  16455. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16456. * @param gradient defines the gradient to use (between 0 and 1)
  16457. * @param factor defines the emit rate to affect to the specified gradient
  16458. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16459. * @returns the current particle system
  16460. */
  16461. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16462. /**
  16463. * Remove a specific emit rate gradient
  16464. * @param gradient defines the gradient to remove
  16465. * @returns the current particle system
  16466. */
  16467. removeEmitRateGradient(gradient: number): IParticleSystem;
  16468. /**
  16469. * Gets the current list of emit rate gradients.
  16470. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16471. * @returns the list of emit rate gradients
  16472. */
  16473. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16474. /**
  16475. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16476. * @param gradient defines the gradient to use (between 0 and 1)
  16477. * @param factor defines the start size to affect to the specified gradient
  16478. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16479. * @returns the current particle system
  16480. */
  16481. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16482. /**
  16483. * Remove a specific start size gradient
  16484. * @param gradient defines the gradient to remove
  16485. * @returns the current particle system
  16486. */
  16487. removeStartSizeGradient(gradient: number): IParticleSystem;
  16488. /**
  16489. * Gets the current list of start size gradients.
  16490. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16491. * @returns the list of start size gradients
  16492. */
  16493. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16494. /**
  16495. * Adds a new life time gradient
  16496. * @param gradient defines the gradient to use (between 0 and 1)
  16497. * @param factor defines the life time factor to affect to the specified gradient
  16498. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16499. * @returns the current particle system
  16500. */
  16501. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16502. /**
  16503. * Remove a specific life time gradient
  16504. * @param gradient defines the gradient to remove
  16505. * @returns the current particle system
  16506. */
  16507. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16508. /**
  16509. * Gets the current list of life time gradients.
  16510. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16511. * @returns the list of life time gradients
  16512. */
  16513. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16514. /**
  16515. * Gets the current list of color gradients.
  16516. * You must use addColorGradient and removeColorGradient to udpate this list
  16517. * @returns the list of color gradients
  16518. */
  16519. getColorGradients(): Nullable<Array<ColorGradient>>;
  16520. /**
  16521. * Adds a new ramp gradient used to remap particle colors
  16522. * @param gradient defines the gradient to use (between 0 and 1)
  16523. * @param color defines the color to affect to the specified gradient
  16524. * @returns the current particle system
  16525. */
  16526. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16527. /**
  16528. * Gets the current list of ramp gradients.
  16529. * You must use addRampGradient and removeRampGradient to udpate this list
  16530. * @returns the list of ramp gradients
  16531. */
  16532. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16533. /** Gets or sets a boolean indicating that ramp gradients must be used
  16534. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16535. */
  16536. useRampGradients: boolean;
  16537. /**
  16538. * Adds a new color remap gradient
  16539. * @param gradient defines the gradient to use (between 0 and 1)
  16540. * @param min defines the color remap minimal range
  16541. * @param max defines the color remap maximal range
  16542. * @returns the current particle system
  16543. */
  16544. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16545. /**
  16546. * Gets the current list of color remap gradients.
  16547. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16548. * @returns the list of color remap gradients
  16549. */
  16550. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16551. /**
  16552. * Adds a new alpha remap gradient
  16553. * @param gradient defines the gradient to use (between 0 and 1)
  16554. * @param min defines the alpha remap minimal range
  16555. * @param max defines the alpha remap maximal range
  16556. * @returns the current particle system
  16557. */
  16558. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16559. /**
  16560. * Gets the current list of alpha remap gradients.
  16561. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16562. * @returns the list of alpha remap gradients
  16563. */
  16564. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16565. /**
  16566. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16567. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16568. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16569. * @returns the emitter
  16570. */
  16571. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16572. /**
  16573. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16574. * @param radius The radius of the hemisphere to emit from
  16575. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16576. * @returns the emitter
  16577. */
  16578. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16579. /**
  16580. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16581. * @param radius The radius of the sphere to emit from
  16582. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16583. * @returns the emitter
  16584. */
  16585. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16586. /**
  16587. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16588. * @param radius The radius of the sphere to emit from
  16589. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16590. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16591. * @returns the emitter
  16592. */
  16593. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16594. /**
  16595. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16596. * @param radius The radius of the emission cylinder
  16597. * @param height The height of the emission cylinder
  16598. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16599. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16600. * @returns the emitter
  16601. */
  16602. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16603. /**
  16604. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16605. * @param radius The radius of the cylinder to emit from
  16606. * @param height The height of the emission cylinder
  16607. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16608. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16609. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16610. * @returns the emitter
  16611. */
  16612. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16613. /**
  16614. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16615. * @param radius The radius of the cone to emit from
  16616. * @param angle The base angle of the cone
  16617. * @returns the emitter
  16618. */
  16619. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16620. /**
  16621. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16622. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16623. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16624. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16625. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16626. * @returns the emitter
  16627. */
  16628. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16629. /**
  16630. * Get hosting scene
  16631. * @returns the scene
  16632. */
  16633. getScene(): Scene;
  16634. }
  16635. }
  16636. declare module BABYLON {
  16637. /**
  16638. * Creates an instance based on a source mesh.
  16639. */
  16640. export class InstancedMesh extends AbstractMesh {
  16641. private _sourceMesh;
  16642. private _currentLOD;
  16643. /** @hidden */
  16644. _indexInSourceMeshInstanceArray: number;
  16645. constructor(name: string, source: Mesh);
  16646. /**
  16647. * Returns the string "InstancedMesh".
  16648. */
  16649. getClassName(): string;
  16650. /** Gets the list of lights affecting that mesh */
  16651. readonly lightSources: Light[];
  16652. _resyncLightSources(): void;
  16653. _resyncLighSource(light: Light): void;
  16654. _removeLightSource(light: Light): void;
  16655. /**
  16656. * If the source mesh receives shadows
  16657. */
  16658. readonly receiveShadows: boolean;
  16659. /**
  16660. * The material of the source mesh
  16661. */
  16662. readonly material: Nullable<Material>;
  16663. /**
  16664. * Visibility of the source mesh
  16665. */
  16666. readonly visibility: number;
  16667. /**
  16668. * Skeleton of the source mesh
  16669. */
  16670. readonly skeleton: Nullable<Skeleton>;
  16671. /**
  16672. * Rendering ground id of the source mesh
  16673. */
  16674. renderingGroupId: number;
  16675. /**
  16676. * Returns the total number of vertices (integer).
  16677. */
  16678. getTotalVertices(): number;
  16679. /**
  16680. * Returns a positive integer : the total number of indices in this mesh geometry.
  16681. * @returns the numner of indices or zero if the mesh has no geometry.
  16682. */
  16683. getTotalIndices(): number;
  16684. /**
  16685. * The source mesh of the instance
  16686. */
  16687. readonly sourceMesh: Mesh;
  16688. /**
  16689. * Is this node ready to be used/rendered
  16690. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16691. * @return {boolean} is it ready
  16692. */
  16693. isReady(completeCheck?: boolean): boolean;
  16694. /**
  16695. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16696. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16697. * @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.
  16698. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16699. */
  16700. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16701. /**
  16702. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16703. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16704. * The `data` are either a numeric array either a Float32Array.
  16705. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16706. * 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).
  16707. * Note that a new underlying VertexBuffer object is created each call.
  16708. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16709. *
  16710. * Possible `kind` values :
  16711. * - VertexBuffer.PositionKind
  16712. * - VertexBuffer.UVKind
  16713. * - VertexBuffer.UV2Kind
  16714. * - VertexBuffer.UV3Kind
  16715. * - VertexBuffer.UV4Kind
  16716. * - VertexBuffer.UV5Kind
  16717. * - VertexBuffer.UV6Kind
  16718. * - VertexBuffer.ColorKind
  16719. * - VertexBuffer.MatricesIndicesKind
  16720. * - VertexBuffer.MatricesIndicesExtraKind
  16721. * - VertexBuffer.MatricesWeightsKind
  16722. * - VertexBuffer.MatricesWeightsExtraKind
  16723. *
  16724. * Returns the Mesh.
  16725. */
  16726. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16727. /**
  16728. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16729. * If the mesh has no geometry, it is simply returned as it is.
  16730. * The `data` are either a numeric array either a Float32Array.
  16731. * No new underlying VertexBuffer object is created.
  16732. * 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.
  16733. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16734. *
  16735. * Possible `kind` values :
  16736. * - VertexBuffer.PositionKind
  16737. * - VertexBuffer.UVKind
  16738. * - VertexBuffer.UV2Kind
  16739. * - VertexBuffer.UV3Kind
  16740. * - VertexBuffer.UV4Kind
  16741. * - VertexBuffer.UV5Kind
  16742. * - VertexBuffer.UV6Kind
  16743. * - VertexBuffer.ColorKind
  16744. * - VertexBuffer.MatricesIndicesKind
  16745. * - VertexBuffer.MatricesIndicesExtraKind
  16746. * - VertexBuffer.MatricesWeightsKind
  16747. * - VertexBuffer.MatricesWeightsExtraKind
  16748. *
  16749. * Returns the Mesh.
  16750. */
  16751. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16752. /**
  16753. * Sets the mesh indices.
  16754. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16755. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16756. * This method creates a new index buffer each call.
  16757. * Returns the Mesh.
  16758. */
  16759. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16760. /**
  16761. * Boolean : True if the mesh owns the requested kind of data.
  16762. */
  16763. isVerticesDataPresent(kind: string): boolean;
  16764. /**
  16765. * Returns an array of indices (IndicesArray).
  16766. */
  16767. getIndices(): Nullable<IndicesArray>;
  16768. readonly _positions: Nullable<Vector3[]>;
  16769. /**
  16770. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16771. * This means the mesh underlying bounding box and sphere are recomputed.
  16772. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16773. * @returns the current mesh
  16774. */
  16775. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16776. /** @hidden */
  16777. _preActivate(): InstancedMesh;
  16778. /** @hidden */
  16779. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16780. /** @hidden */
  16781. _postActivate(): void;
  16782. getWorldMatrix(): Matrix;
  16783. readonly isAnInstance: boolean;
  16784. /**
  16785. * Returns the current associated LOD AbstractMesh.
  16786. */
  16787. getLOD(camera: Camera): AbstractMesh;
  16788. /** @hidden */
  16789. _syncSubMeshes(): InstancedMesh;
  16790. /** @hidden */
  16791. _generatePointsArray(): boolean;
  16792. /**
  16793. * Creates a new InstancedMesh from the current mesh.
  16794. * - name (string) : the cloned mesh name
  16795. * - newParent (optional Node) : the optional Node to parent the clone to.
  16796. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16797. *
  16798. * Returns the clone.
  16799. */
  16800. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  16801. /**
  16802. * Disposes the InstancedMesh.
  16803. * Returns nothing.
  16804. */
  16805. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16806. }
  16807. }
  16808. declare module BABYLON {
  16809. /**
  16810. * Defines the options associated with the creation of a shader material.
  16811. */
  16812. export interface IShaderMaterialOptions {
  16813. /**
  16814. * Does the material work in alpha blend mode
  16815. */
  16816. needAlphaBlending: boolean;
  16817. /**
  16818. * Does the material work in alpha test mode
  16819. */
  16820. needAlphaTesting: boolean;
  16821. /**
  16822. * The list of attribute names used in the shader
  16823. */
  16824. attributes: string[];
  16825. /**
  16826. * The list of unifrom names used in the shader
  16827. */
  16828. uniforms: string[];
  16829. /**
  16830. * The list of UBO names used in the shader
  16831. */
  16832. uniformBuffers: string[];
  16833. /**
  16834. * The list of sampler names used in the shader
  16835. */
  16836. samplers: string[];
  16837. /**
  16838. * The list of defines used in the shader
  16839. */
  16840. defines: string[];
  16841. }
  16842. /**
  16843. * 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.
  16844. *
  16845. * This returned material effects how the mesh will look based on the code in the shaders.
  16846. *
  16847. * @see http://doc.babylonjs.com/how_to/shader_material
  16848. */
  16849. export class ShaderMaterial extends Material {
  16850. private _shaderPath;
  16851. private _options;
  16852. private _textures;
  16853. private _textureArrays;
  16854. private _floats;
  16855. private _ints;
  16856. private _floatsArrays;
  16857. private _colors3;
  16858. private _colors3Arrays;
  16859. private _colors4;
  16860. private _vectors2;
  16861. private _vectors3;
  16862. private _vectors4;
  16863. private _matrices;
  16864. private _matrices3x3;
  16865. private _matrices2x2;
  16866. private _vectors2Arrays;
  16867. private _vectors3Arrays;
  16868. private _cachedWorldViewMatrix;
  16869. private _cachedWorldViewProjectionMatrix;
  16870. private _renderId;
  16871. /**
  16872. * Instantiate a new shader material.
  16873. * 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.
  16874. * This returned material effects how the mesh will look based on the code in the shaders.
  16875. * @see http://doc.babylonjs.com/how_to/shader_material
  16876. * @param name Define the name of the material in the scene
  16877. * @param scene Define the scene the material belongs to
  16878. * @param shaderPath Defines the route to the shader code in one of three ways:
  16879. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16880. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  16881. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16882. * @param options Define the options used to create the shader
  16883. */
  16884. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16885. /**
  16886. * Gets the options used to compile the shader.
  16887. * They can be modified to trigger a new compilation
  16888. */
  16889. readonly options: IShaderMaterialOptions;
  16890. /**
  16891. * Gets the current class name of the material e.g. "ShaderMaterial"
  16892. * Mainly use in serialization.
  16893. * @returns the class name
  16894. */
  16895. getClassName(): string;
  16896. /**
  16897. * Specifies if the material will require alpha blending
  16898. * @returns a boolean specifying if alpha blending is needed
  16899. */
  16900. needAlphaBlending(): boolean;
  16901. /**
  16902. * Specifies if this material should be rendered in alpha test mode
  16903. * @returns a boolean specifying if an alpha test is needed.
  16904. */
  16905. needAlphaTesting(): boolean;
  16906. private _checkUniform;
  16907. /**
  16908. * Set a texture in the shader.
  16909. * @param name Define the name of the uniform samplers as defined in the shader
  16910. * @param texture Define the texture to bind to this sampler
  16911. * @return the material itself allowing "fluent" like uniform updates
  16912. */
  16913. setTexture(name: string, texture: Texture): ShaderMaterial;
  16914. /**
  16915. * Set a texture array in the shader.
  16916. * @param name Define the name of the uniform sampler array as defined in the shader
  16917. * @param textures Define the list of textures to bind to this sampler
  16918. * @return the material itself allowing "fluent" like uniform updates
  16919. */
  16920. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  16921. /**
  16922. * Set a float in the shader.
  16923. * @param name Define the name of the uniform as defined in the shader
  16924. * @param value Define the value to give to the uniform
  16925. * @return the material itself allowing "fluent" like uniform updates
  16926. */
  16927. setFloat(name: string, value: number): ShaderMaterial;
  16928. /**
  16929. * Set a int in the shader.
  16930. * @param name Define the name of the uniform as defined in the shader
  16931. * @param value Define the value to give to the uniform
  16932. * @return the material itself allowing "fluent" like uniform updates
  16933. */
  16934. setInt(name: string, value: number): ShaderMaterial;
  16935. /**
  16936. * Set an array of floats in the shader.
  16937. * @param name Define the name of the uniform as defined in the shader
  16938. * @param value Define the value to give to the uniform
  16939. * @return the material itself allowing "fluent" like uniform updates
  16940. */
  16941. setFloats(name: string, value: number[]): ShaderMaterial;
  16942. /**
  16943. * Set a vec3 in the shader from a Color3.
  16944. * @param name Define the name of the uniform as defined in the shader
  16945. * @param value Define the value to give to the uniform
  16946. * @return the material itself allowing "fluent" like uniform updates
  16947. */
  16948. setColor3(name: string, value: Color3): ShaderMaterial;
  16949. /**
  16950. * Set a vec3 array in the shader from a Color3 array.
  16951. * @param name Define the name of the uniform as defined in the shader
  16952. * @param value Define the value to give to the uniform
  16953. * @return the material itself allowing "fluent" like uniform updates
  16954. */
  16955. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16956. /**
  16957. * Set a vec4 in the shader from a Color4.
  16958. * @param name Define the name of the uniform as defined in the shader
  16959. * @param value Define the value to give to the uniform
  16960. * @return the material itself allowing "fluent" like uniform updates
  16961. */
  16962. setColor4(name: string, value: Color4): ShaderMaterial;
  16963. /**
  16964. * Set a vec2 in the shader from a Vector2.
  16965. * @param name Define the name of the uniform as defined in the shader
  16966. * @param value Define the value to give to the uniform
  16967. * @return the material itself allowing "fluent" like uniform updates
  16968. */
  16969. setVector2(name: string, value: Vector2): ShaderMaterial;
  16970. /**
  16971. * Set a vec3 in the shader from a Vector3.
  16972. * @param name Define the name of the uniform as defined in the shader
  16973. * @param value Define the value to give to the uniform
  16974. * @return the material itself allowing "fluent" like uniform updates
  16975. */
  16976. setVector3(name: string, value: Vector3): ShaderMaterial;
  16977. /**
  16978. * Set a vec4 in the shader from a Vector4.
  16979. * @param name Define the name of the uniform as defined in the shader
  16980. * @param value Define the value to give to the uniform
  16981. * @return the material itself allowing "fluent" like uniform updates
  16982. */
  16983. setVector4(name: string, value: Vector4): ShaderMaterial;
  16984. /**
  16985. * Set a mat4 in the shader from a Matrix.
  16986. * @param name Define the name of the uniform as defined in the shader
  16987. * @param value Define the value to give to the uniform
  16988. * @return the material itself allowing "fluent" like uniform updates
  16989. */
  16990. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16991. /**
  16992. * Set a mat3 in the shader from a Float32Array.
  16993. * @param name Define the name of the uniform as defined in the shader
  16994. * @param value Define the value to give to the uniform
  16995. * @return the material itself allowing "fluent" like uniform updates
  16996. */
  16997. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16998. /**
  16999. * Set a mat2 in the shader from a Float32Array.
  17000. * @param name Define the name of the uniform as defined in the shader
  17001. * @param value Define the value to give to the uniform
  17002. * @return the material itself allowing "fluent" like uniform updates
  17003. */
  17004. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  17005. /**
  17006. * Set a vec2 array in the shader from a number array.
  17007. * @param name Define the name of the uniform as defined in the shader
  17008. * @param value Define the value to give to the uniform
  17009. * @return the material itself allowing "fluent" like uniform updates
  17010. */
  17011. setArray2(name: string, value: number[]): ShaderMaterial;
  17012. /**
  17013. * Set a vec3 array in the shader from a number array.
  17014. * @param name Define the name of the uniform as defined in the shader
  17015. * @param value Define the value to give to the uniform
  17016. * @return the material itself allowing "fluent" like uniform updates
  17017. */
  17018. setArray3(name: string, value: number[]): ShaderMaterial;
  17019. private _checkCache;
  17020. /**
  17021. * Specifies that the submesh is ready to be used
  17022. * @param mesh defines the mesh to check
  17023. * @param subMesh defines which submesh to check
  17024. * @param useInstances specifies that instances should be used
  17025. * @returns a boolean indicating that the submesh is ready or not
  17026. */
  17027. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  17028. /**
  17029. * Checks if the material is ready to render the requested mesh
  17030. * @param mesh Define the mesh to render
  17031. * @param useInstances Define whether or not the material is used with instances
  17032. * @returns true if ready, otherwise false
  17033. */
  17034. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17035. /**
  17036. * Binds the world matrix to the material
  17037. * @param world defines the world transformation matrix
  17038. */
  17039. bindOnlyWorldMatrix(world: Matrix): void;
  17040. /**
  17041. * Binds the material to the mesh
  17042. * @param world defines the world transformation matrix
  17043. * @param mesh defines the mesh to bind the material to
  17044. */
  17045. bind(world: Matrix, mesh?: Mesh): void;
  17046. /**
  17047. * Gets the active textures from the material
  17048. * @returns an array of textures
  17049. */
  17050. getActiveTextures(): BaseTexture[];
  17051. /**
  17052. * Specifies if the material uses a texture
  17053. * @param texture defines the texture to check against the material
  17054. * @returns a boolean specifying if the material uses the texture
  17055. */
  17056. hasTexture(texture: BaseTexture): boolean;
  17057. /**
  17058. * Makes a duplicate of the material, and gives it a new name
  17059. * @param name defines the new name for the duplicated material
  17060. * @returns the cloned material
  17061. */
  17062. clone(name: string): ShaderMaterial;
  17063. /**
  17064. * Disposes the material
  17065. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17066. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17067. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17068. */
  17069. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17070. /**
  17071. * Serializes this material in a JSON representation
  17072. * @returns the serialized material object
  17073. */
  17074. serialize(): any;
  17075. /**
  17076. * Creates a shader material from parsed shader material data
  17077. * @param source defines the JSON represnetation of the material
  17078. * @param scene defines the hosting scene
  17079. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17080. * @returns a new material
  17081. */
  17082. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17083. }
  17084. }
  17085. declare module BABYLON {
  17086. /** @hidden */
  17087. export var colorPixelShader: {
  17088. name: string;
  17089. shader: string;
  17090. };
  17091. }
  17092. declare module BABYLON {
  17093. /** @hidden */
  17094. export var colorVertexShader: {
  17095. name: string;
  17096. shader: string;
  17097. };
  17098. }
  17099. declare module BABYLON {
  17100. /**
  17101. * Line mesh
  17102. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17103. */
  17104. export class LinesMesh extends Mesh {
  17105. /**
  17106. * If vertex color should be applied to the mesh
  17107. */
  17108. readonly useVertexColor?: boolean | undefined;
  17109. /**
  17110. * If vertex alpha should be applied to the mesh
  17111. */
  17112. readonly useVertexAlpha?: boolean | undefined;
  17113. /**
  17114. * Color of the line (Default: White)
  17115. */
  17116. color: Color3;
  17117. /**
  17118. * Alpha of the line (Default: 1)
  17119. */
  17120. alpha: number;
  17121. /**
  17122. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17123. * This margin is expressed in world space coordinates, so its value may vary.
  17124. * Default value is 0.1
  17125. */
  17126. intersectionThreshold: number;
  17127. private _colorShader;
  17128. private color4;
  17129. /**
  17130. * Creates a new LinesMesh
  17131. * @param name defines the name
  17132. * @param scene defines the hosting scene
  17133. * @param parent defines the parent mesh if any
  17134. * @param source defines the optional source LinesMesh used to clone data from
  17135. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17136. * When false, achieved by calling a clone(), also passing False.
  17137. * This will make creation of children, recursive.
  17138. * @param useVertexColor defines if this LinesMesh supports vertex color
  17139. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17140. */
  17141. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  17142. /**
  17143. * If vertex color should be applied to the mesh
  17144. */
  17145. useVertexColor?: boolean | undefined,
  17146. /**
  17147. * If vertex alpha should be applied to the mesh
  17148. */
  17149. useVertexAlpha?: boolean | undefined);
  17150. private _addClipPlaneDefine;
  17151. private _removeClipPlaneDefine;
  17152. isReady(): boolean;
  17153. /**
  17154. * Returns the string "LineMesh"
  17155. */
  17156. getClassName(): string;
  17157. /**
  17158. * @hidden
  17159. */
  17160. /**
  17161. * @hidden
  17162. */
  17163. material: Material;
  17164. /**
  17165. * @hidden
  17166. */
  17167. readonly checkCollisions: boolean;
  17168. /** @hidden */
  17169. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17170. /** @hidden */
  17171. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17172. /**
  17173. * Disposes of the line mesh
  17174. * @param doNotRecurse If children should be disposed
  17175. */
  17176. dispose(doNotRecurse?: boolean): void;
  17177. /**
  17178. * Returns a new LineMesh object cloned from the current one.
  17179. */
  17180. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17181. /**
  17182. * Creates a new InstancedLinesMesh object from the mesh model.
  17183. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17184. * @param name defines the name of the new instance
  17185. * @returns a new InstancedLinesMesh
  17186. */
  17187. createInstance(name: string): InstancedLinesMesh;
  17188. }
  17189. /**
  17190. * Creates an instance based on a source LinesMesh
  17191. */
  17192. export class InstancedLinesMesh extends InstancedMesh {
  17193. /**
  17194. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17195. * This margin is expressed in world space coordinates, so its value may vary.
  17196. * Initilized with the intersectionThreshold value of the source LinesMesh
  17197. */
  17198. intersectionThreshold: number;
  17199. constructor(name: string, source: LinesMesh);
  17200. /**
  17201. * Returns the string "InstancedLinesMesh".
  17202. */
  17203. getClassName(): string;
  17204. }
  17205. }
  17206. declare module BABYLON {
  17207. /** @hidden */
  17208. export var linePixelShader: {
  17209. name: string;
  17210. shader: string;
  17211. };
  17212. }
  17213. declare module BABYLON {
  17214. /** @hidden */
  17215. export var lineVertexShader: {
  17216. name: string;
  17217. shader: string;
  17218. };
  17219. }
  17220. declare module BABYLON {
  17221. interface AbstractMesh {
  17222. /**
  17223. * Gets the edgesRenderer associated with the mesh
  17224. */
  17225. edgesRenderer: Nullable<EdgesRenderer>;
  17226. }
  17227. interface LinesMesh {
  17228. /**
  17229. * Enables the edge rendering mode on the mesh.
  17230. * This mode makes the mesh edges visible
  17231. * @param epsilon defines the maximal distance between two angles to detect a face
  17232. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17233. * @returns the currentAbstractMesh
  17234. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17235. */
  17236. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17237. }
  17238. interface InstancedLinesMesh {
  17239. /**
  17240. * Enables the edge rendering mode on the mesh.
  17241. * This mode makes the mesh edges visible
  17242. * @param epsilon defines the maximal distance between two angles to detect a face
  17243. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17244. * @returns the current InstancedLinesMesh
  17245. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17246. */
  17247. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17248. }
  17249. /**
  17250. * Defines the minimum contract an Edges renderer should follow.
  17251. */
  17252. export interface IEdgesRenderer extends IDisposable {
  17253. /**
  17254. * Gets or sets a boolean indicating if the edgesRenderer is active
  17255. */
  17256. isEnabled: boolean;
  17257. /**
  17258. * Renders the edges of the attached mesh,
  17259. */
  17260. render(): void;
  17261. /**
  17262. * Checks wether or not the edges renderer is ready to render.
  17263. * @return true if ready, otherwise false.
  17264. */
  17265. isReady(): boolean;
  17266. }
  17267. /**
  17268. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17269. */
  17270. export class EdgesRenderer implements IEdgesRenderer {
  17271. /**
  17272. * Define the size of the edges with an orthographic camera
  17273. */
  17274. edgesWidthScalerForOrthographic: number;
  17275. /**
  17276. * Define the size of the edges with a perspective camera
  17277. */
  17278. edgesWidthScalerForPerspective: number;
  17279. protected _source: AbstractMesh;
  17280. protected _linesPositions: number[];
  17281. protected _linesNormals: number[];
  17282. protected _linesIndices: number[];
  17283. protected _epsilon: number;
  17284. protected _indicesCount: number;
  17285. protected _lineShader: ShaderMaterial;
  17286. protected _ib: DataBuffer;
  17287. protected _buffers: {
  17288. [key: string]: Nullable<VertexBuffer>;
  17289. };
  17290. protected _checkVerticesInsteadOfIndices: boolean;
  17291. private _meshRebuildObserver;
  17292. private _meshDisposeObserver;
  17293. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17294. isEnabled: boolean;
  17295. /**
  17296. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17297. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17298. * @param source Mesh used to create edges
  17299. * @param epsilon sum of angles in adjacency to check for edge
  17300. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17301. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17302. */
  17303. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17304. protected _prepareRessources(): void;
  17305. /** @hidden */
  17306. _rebuild(): void;
  17307. /**
  17308. * Releases the required resources for the edges renderer
  17309. */
  17310. dispose(): void;
  17311. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17312. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17313. /**
  17314. * Checks if the pair of p0 and p1 is en edge
  17315. * @param faceIndex
  17316. * @param edge
  17317. * @param faceNormals
  17318. * @param p0
  17319. * @param p1
  17320. * @private
  17321. */
  17322. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17323. /**
  17324. * push line into the position, normal and index buffer
  17325. * @protected
  17326. */
  17327. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17328. /**
  17329. * Generates lines edges from adjacencjes
  17330. * @private
  17331. */
  17332. _generateEdgesLines(): void;
  17333. /**
  17334. * Checks wether or not the edges renderer is ready to render.
  17335. * @return true if ready, otherwise false.
  17336. */
  17337. isReady(): boolean;
  17338. /**
  17339. * Renders the edges of the attached mesh,
  17340. */
  17341. render(): void;
  17342. }
  17343. /**
  17344. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17345. */
  17346. export class LineEdgesRenderer extends EdgesRenderer {
  17347. /**
  17348. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17349. * @param source LineMesh used to generate edges
  17350. * @param epsilon not important (specified angle for edge detection)
  17351. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17352. */
  17353. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17354. /**
  17355. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17356. */
  17357. _generateEdgesLines(): void;
  17358. }
  17359. }
  17360. declare module BABYLON {
  17361. /**
  17362. * This represents the object necessary to create a rendering group.
  17363. * This is exclusively used and created by the rendering manager.
  17364. * To modify the behavior, you use the available helpers in your scene or meshes.
  17365. * @hidden
  17366. */
  17367. export class RenderingGroup {
  17368. index: number;
  17369. private static _zeroVector;
  17370. private _scene;
  17371. private _opaqueSubMeshes;
  17372. private _transparentSubMeshes;
  17373. private _alphaTestSubMeshes;
  17374. private _depthOnlySubMeshes;
  17375. private _particleSystems;
  17376. private _spriteManagers;
  17377. private _opaqueSortCompareFn;
  17378. private _alphaTestSortCompareFn;
  17379. private _transparentSortCompareFn;
  17380. private _renderOpaque;
  17381. private _renderAlphaTest;
  17382. private _renderTransparent;
  17383. /** @hidden */
  17384. _edgesRenderers: SmartArray<IEdgesRenderer>;
  17385. onBeforeTransparentRendering: () => void;
  17386. /**
  17387. * Set the opaque sort comparison function.
  17388. * If null the sub meshes will be render in the order they were created
  17389. */
  17390. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17391. /**
  17392. * Set the alpha test sort comparison function.
  17393. * If null the sub meshes will be render in the order they were created
  17394. */
  17395. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17396. /**
  17397. * Set the transparent sort comparison function.
  17398. * If null the sub meshes will be render in the order they were created
  17399. */
  17400. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17401. /**
  17402. * Creates a new rendering group.
  17403. * @param index The rendering group index
  17404. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17405. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17406. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17407. */
  17408. 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>);
  17409. /**
  17410. * Render all the sub meshes contained in the group.
  17411. * @param customRenderFunction Used to override the default render behaviour of the group.
  17412. * @returns true if rendered some submeshes.
  17413. */
  17414. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17415. /**
  17416. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17417. * @param subMeshes The submeshes to render
  17418. */
  17419. private renderOpaqueSorted;
  17420. /**
  17421. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17422. * @param subMeshes The submeshes to render
  17423. */
  17424. private renderAlphaTestSorted;
  17425. /**
  17426. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17427. * @param subMeshes The submeshes to render
  17428. */
  17429. private renderTransparentSorted;
  17430. /**
  17431. * Renders the submeshes in a specified order.
  17432. * @param subMeshes The submeshes to sort before render
  17433. * @param sortCompareFn The comparison function use to sort
  17434. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17435. * @param transparent Specifies to activate blending if true
  17436. */
  17437. private static renderSorted;
  17438. /**
  17439. * Renders the submeshes in the order they were dispatched (no sort applied).
  17440. * @param subMeshes The submeshes to render
  17441. */
  17442. private static renderUnsorted;
  17443. /**
  17444. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17445. * are rendered back to front if in the same alpha index.
  17446. *
  17447. * @param a The first submesh
  17448. * @param b The second submesh
  17449. * @returns The result of the comparison
  17450. */
  17451. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17452. /**
  17453. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17454. * are rendered back to front.
  17455. *
  17456. * @param a The first submesh
  17457. * @param b The second submesh
  17458. * @returns The result of the comparison
  17459. */
  17460. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17461. /**
  17462. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17463. * are rendered front to back (prevent overdraw).
  17464. *
  17465. * @param a The first submesh
  17466. * @param b The second submesh
  17467. * @returns The result of the comparison
  17468. */
  17469. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17470. /**
  17471. * Resets the different lists of submeshes to prepare a new frame.
  17472. */
  17473. prepare(): void;
  17474. dispose(): void;
  17475. /**
  17476. * Inserts the submesh in its correct queue depending on its material.
  17477. * @param subMesh The submesh to dispatch
  17478. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17479. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17480. */
  17481. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17482. dispatchSprites(spriteManager: ISpriteManager): void;
  17483. dispatchParticles(particleSystem: IParticleSystem): void;
  17484. private _renderParticles;
  17485. private _renderSprites;
  17486. }
  17487. }
  17488. declare module BABYLON {
  17489. /**
  17490. * Interface describing the different options available in the rendering manager
  17491. * regarding Auto Clear between groups.
  17492. */
  17493. export interface IRenderingManagerAutoClearSetup {
  17494. /**
  17495. * Defines whether or not autoclear is enable.
  17496. */
  17497. autoClear: boolean;
  17498. /**
  17499. * Defines whether or not to autoclear the depth buffer.
  17500. */
  17501. depth: boolean;
  17502. /**
  17503. * Defines whether or not to autoclear the stencil buffer.
  17504. */
  17505. stencil: boolean;
  17506. }
  17507. /**
  17508. * This class is used by the onRenderingGroupObservable
  17509. */
  17510. export class RenderingGroupInfo {
  17511. /**
  17512. * The Scene that being rendered
  17513. */
  17514. scene: Scene;
  17515. /**
  17516. * The camera currently used for the rendering pass
  17517. */
  17518. camera: Nullable<Camera>;
  17519. /**
  17520. * The ID of the renderingGroup being processed
  17521. */
  17522. renderingGroupId: number;
  17523. }
  17524. /**
  17525. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17526. * It is enable to manage the different groups as well as the different necessary sort functions.
  17527. * This should not be used directly aside of the few static configurations
  17528. */
  17529. export class RenderingManager {
  17530. /**
  17531. * The max id used for rendering groups (not included)
  17532. */
  17533. static MAX_RENDERINGGROUPS: number;
  17534. /**
  17535. * The min id used for rendering groups (included)
  17536. */
  17537. static MIN_RENDERINGGROUPS: number;
  17538. /**
  17539. * Used to globally prevent autoclearing scenes.
  17540. */
  17541. static AUTOCLEAR: boolean;
  17542. /**
  17543. * @hidden
  17544. */
  17545. _useSceneAutoClearSetup: boolean;
  17546. private _scene;
  17547. private _renderingGroups;
  17548. private _depthStencilBufferAlreadyCleaned;
  17549. private _autoClearDepthStencil;
  17550. private _customOpaqueSortCompareFn;
  17551. private _customAlphaTestSortCompareFn;
  17552. private _customTransparentSortCompareFn;
  17553. private _renderingGroupInfo;
  17554. /**
  17555. * Instantiates a new rendering group for a particular scene
  17556. * @param scene Defines the scene the groups belongs to
  17557. */
  17558. constructor(scene: Scene);
  17559. private _clearDepthStencilBuffer;
  17560. /**
  17561. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17562. * @hidden
  17563. */
  17564. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17565. /**
  17566. * Resets the different information of the group to prepare a new frame
  17567. * @hidden
  17568. */
  17569. reset(): void;
  17570. /**
  17571. * Dispose and release the group and its associated resources.
  17572. * @hidden
  17573. */
  17574. dispose(): void;
  17575. /**
  17576. * Clear the info related to rendering groups preventing retention points during dispose.
  17577. */
  17578. freeRenderingGroups(): void;
  17579. private _prepareRenderingGroup;
  17580. /**
  17581. * Add a sprite manager to the rendering manager in order to render it this frame.
  17582. * @param spriteManager Define the sprite manager to render
  17583. */
  17584. dispatchSprites(spriteManager: ISpriteManager): void;
  17585. /**
  17586. * Add a particle system to the rendering manager in order to render it this frame.
  17587. * @param particleSystem Define the particle system to render
  17588. */
  17589. dispatchParticles(particleSystem: IParticleSystem): void;
  17590. /**
  17591. * Add a submesh to the manager in order to render it this frame
  17592. * @param subMesh The submesh to dispatch
  17593. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17594. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17595. */
  17596. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17597. /**
  17598. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17599. * This allowed control for front to back rendering or reversly depending of the special needs.
  17600. *
  17601. * @param renderingGroupId The rendering group id corresponding to its index
  17602. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17603. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17604. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17605. */
  17606. 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;
  17607. /**
  17608. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17609. *
  17610. * @param renderingGroupId The rendering group id corresponding to its index
  17611. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17612. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17613. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17614. */
  17615. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17616. /**
  17617. * Gets the current auto clear configuration for one rendering group of the rendering
  17618. * manager.
  17619. * @param index the rendering group index to get the information for
  17620. * @returns The auto clear setup for the requested rendering group
  17621. */
  17622. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17623. }
  17624. }
  17625. declare module BABYLON {
  17626. /**
  17627. * This Helps creating a texture that will be created from a camera in your scene.
  17628. * It is basically a dynamic texture that could be used to create special effects for instance.
  17629. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17630. */
  17631. export class RenderTargetTexture extends Texture {
  17632. isCube: boolean;
  17633. /**
  17634. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17635. */
  17636. static readonly REFRESHRATE_RENDER_ONCE: number;
  17637. /**
  17638. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17639. */
  17640. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17641. /**
  17642. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17643. * the central point of your effect and can save a lot of performances.
  17644. */
  17645. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17646. /**
  17647. * Use this predicate to dynamically define the list of mesh you want to render.
  17648. * If set, the renderList property will be overwritten.
  17649. */
  17650. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17651. private _renderList;
  17652. /**
  17653. * Use this list to define the list of mesh you want to render.
  17654. */
  17655. renderList: Nullable<Array<AbstractMesh>>;
  17656. private _hookArray;
  17657. /**
  17658. * Define if particles should be rendered in your texture.
  17659. */
  17660. renderParticles: boolean;
  17661. /**
  17662. * Define if sprites should be rendered in your texture.
  17663. */
  17664. renderSprites: boolean;
  17665. /**
  17666. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17667. */
  17668. coordinatesMode: number;
  17669. /**
  17670. * Define the camera used to render the texture.
  17671. */
  17672. activeCamera: Nullable<Camera>;
  17673. /**
  17674. * Override the render function of the texture with your own one.
  17675. */
  17676. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17677. /**
  17678. * Define if camera post processes should be use while rendering the texture.
  17679. */
  17680. useCameraPostProcesses: boolean;
  17681. /**
  17682. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17683. */
  17684. ignoreCameraViewport: boolean;
  17685. private _postProcessManager;
  17686. private _postProcesses;
  17687. private _resizeObserver;
  17688. /**
  17689. * An event triggered when the texture is unbind.
  17690. */
  17691. onBeforeBindObservable: Observable<RenderTargetTexture>;
  17692. /**
  17693. * An event triggered when the texture is unbind.
  17694. */
  17695. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  17696. private _onAfterUnbindObserver;
  17697. /**
  17698. * Set a after unbind callback in the texture.
  17699. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  17700. */
  17701. onAfterUnbind: () => void;
  17702. /**
  17703. * An event triggered before rendering the texture
  17704. */
  17705. onBeforeRenderObservable: Observable<number>;
  17706. private _onBeforeRenderObserver;
  17707. /**
  17708. * Set a before render callback in the texture.
  17709. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  17710. */
  17711. onBeforeRender: (faceIndex: number) => void;
  17712. /**
  17713. * An event triggered after rendering the texture
  17714. */
  17715. onAfterRenderObservable: Observable<number>;
  17716. private _onAfterRenderObserver;
  17717. /**
  17718. * Set a after render callback in the texture.
  17719. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  17720. */
  17721. onAfterRender: (faceIndex: number) => void;
  17722. /**
  17723. * An event triggered after the texture clear
  17724. */
  17725. onClearObservable: Observable<Engine>;
  17726. private _onClearObserver;
  17727. /**
  17728. * Set a clear callback in the texture.
  17729. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  17730. */
  17731. onClear: (Engine: Engine) => void;
  17732. /**
  17733. * Define the clear color of the Render Target if it should be different from the scene.
  17734. */
  17735. clearColor: Color4;
  17736. protected _size: number | {
  17737. width: number;
  17738. height: number;
  17739. };
  17740. protected _initialSizeParameter: number | {
  17741. width: number;
  17742. height: number;
  17743. } | {
  17744. ratio: number;
  17745. };
  17746. protected _sizeRatio: Nullable<number>;
  17747. /** @hidden */
  17748. _generateMipMaps: boolean;
  17749. protected _renderingManager: RenderingManager;
  17750. /** @hidden */
  17751. _waitingRenderList: string[];
  17752. protected _doNotChangeAspectRatio: boolean;
  17753. protected _currentRefreshId: number;
  17754. protected _refreshRate: number;
  17755. protected _textureMatrix: Matrix;
  17756. protected _samples: number;
  17757. protected _renderTargetOptions: RenderTargetCreationOptions;
  17758. /**
  17759. * Gets render target creation options that were used.
  17760. */
  17761. readonly renderTargetOptions: RenderTargetCreationOptions;
  17762. protected _engine: Engine;
  17763. protected _onRatioRescale(): void;
  17764. /**
  17765. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  17766. * It must define where the camera used to render the texture is set
  17767. */
  17768. boundingBoxPosition: Vector3;
  17769. private _boundingBoxSize;
  17770. /**
  17771. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  17772. * When defined, the cubemap will switch to local mode
  17773. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  17774. * @example https://www.babylonjs-playground.com/#RNASML
  17775. */
  17776. boundingBoxSize: Vector3;
  17777. /**
  17778. * In case the RTT has been created with a depth texture, get the associated
  17779. * depth texture.
  17780. * Otherwise, return null.
  17781. */
  17782. depthStencilTexture: Nullable<InternalTexture>;
  17783. /**
  17784. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  17785. * or used a shadow, depth texture...
  17786. * @param name The friendly name of the texture
  17787. * @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)
  17788. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  17789. * @param generateMipMaps True if mip maps need to be generated after render.
  17790. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  17791. * @param type The type of the buffer in the RTT (int, half float, float...)
  17792. * @param isCube True if a cube texture needs to be created
  17793. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  17794. * @param generateDepthBuffer True to generate a depth buffer
  17795. * @param generateStencilBuffer True to generate a stencil buffer
  17796. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  17797. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  17798. * @param delayAllocation if the texture allocation should be delayed (default: false)
  17799. */
  17800. constructor(name: string, size: number | {
  17801. width: number;
  17802. height: number;
  17803. } | {
  17804. ratio: number;
  17805. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  17806. /**
  17807. * Creates a depth stencil texture.
  17808. * This is only available in WebGL 2 or with the depth texture extension available.
  17809. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  17810. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  17811. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  17812. */
  17813. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  17814. private _processSizeParameter;
  17815. /**
  17816. * Define the number of samples to use in case of MSAA.
  17817. * It defaults to one meaning no MSAA has been enabled.
  17818. */
  17819. samples: number;
  17820. /**
  17821. * Resets the refresh counter of the texture and start bak from scratch.
  17822. * Could be useful to regenerate the texture if it is setup to render only once.
  17823. */
  17824. resetRefreshCounter(): void;
  17825. /**
  17826. * Define the refresh rate of the texture or the rendering frequency.
  17827. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17828. */
  17829. refreshRate: number;
  17830. /**
  17831. * Adds a post process to the render target rendering passes.
  17832. * @param postProcess define the post process to add
  17833. */
  17834. addPostProcess(postProcess: PostProcess): void;
  17835. /**
  17836. * Clear all the post processes attached to the render target
  17837. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  17838. */
  17839. clearPostProcesses(dispose?: boolean): void;
  17840. /**
  17841. * Remove one of the post process from the list of attached post processes to the texture
  17842. * @param postProcess define the post process to remove from the list
  17843. */
  17844. removePostProcess(postProcess: PostProcess): void;
  17845. /** @hidden */
  17846. _shouldRender(): boolean;
  17847. /**
  17848. * Gets the actual render size of the texture.
  17849. * @returns the width of the render size
  17850. */
  17851. getRenderSize(): number;
  17852. /**
  17853. * Gets the actual render width of the texture.
  17854. * @returns the width of the render size
  17855. */
  17856. getRenderWidth(): number;
  17857. /**
  17858. * Gets the actual render height of the texture.
  17859. * @returns the height of the render size
  17860. */
  17861. getRenderHeight(): number;
  17862. /**
  17863. * Get if the texture can be rescaled or not.
  17864. */
  17865. readonly canRescale: boolean;
  17866. /**
  17867. * Resize the texture using a ratio.
  17868. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  17869. */
  17870. scale(ratio: number): void;
  17871. /**
  17872. * Get the texture reflection matrix used to rotate/transform the reflection.
  17873. * @returns the reflection matrix
  17874. */
  17875. getReflectionTextureMatrix(): Matrix;
  17876. /**
  17877. * Resize the texture to a new desired size.
  17878. * Be carrefull as it will recreate all the data in the new texture.
  17879. * @param size Define the new size. It can be:
  17880. * - a number for squared texture,
  17881. * - an object containing { width: number, height: number }
  17882. * - or an object containing a ratio { ratio: number }
  17883. */
  17884. resize(size: number | {
  17885. width: number;
  17886. height: number;
  17887. } | {
  17888. ratio: number;
  17889. }): void;
  17890. /**
  17891. * Renders all the objects from the render list into the texture.
  17892. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  17893. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  17894. */
  17895. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  17896. private _bestReflectionRenderTargetDimension;
  17897. /**
  17898. * @hidden
  17899. * @param faceIndex face index to bind to if this is a cubetexture
  17900. */
  17901. _bindFrameBuffer(faceIndex?: number): void;
  17902. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  17903. private renderToTarget;
  17904. /**
  17905. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17906. * This allowed control for front to back rendering or reversly depending of the special needs.
  17907. *
  17908. * @param renderingGroupId The rendering group id corresponding to its index
  17909. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17910. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17911. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17912. */
  17913. 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;
  17914. /**
  17915. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17916. *
  17917. * @param renderingGroupId The rendering group id corresponding to its index
  17918. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17919. */
  17920. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  17921. /**
  17922. * Clones the texture.
  17923. * @returns the cloned texture
  17924. */
  17925. clone(): RenderTargetTexture;
  17926. /**
  17927. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17928. * @returns The JSON representation of the texture
  17929. */
  17930. serialize(): any;
  17931. /**
  17932. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  17933. */
  17934. disposeFramebufferObjects(): void;
  17935. /**
  17936. * Dispose the texture and release its associated resources.
  17937. */
  17938. dispose(): void;
  17939. /** @hidden */
  17940. _rebuild(): void;
  17941. /**
  17942. * Clear the info related to rendering groups preventing retention point in material dispose.
  17943. */
  17944. freeRenderingGroups(): void;
  17945. /**
  17946. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  17947. * @returns the view count
  17948. */
  17949. getViewCount(): number;
  17950. }
  17951. }
  17952. declare module BABYLON {
  17953. /**
  17954. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17955. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17956. * You can then easily use it as a reflectionTexture on a flat surface.
  17957. * In case the surface is not a plane, please consider relying on reflection probes.
  17958. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17959. */
  17960. export class MirrorTexture extends RenderTargetTexture {
  17961. private scene;
  17962. /**
  17963. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  17964. * 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.
  17965. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17966. */
  17967. mirrorPlane: Plane;
  17968. /**
  17969. * Define the blur ratio used to blur the reflection if needed.
  17970. */
  17971. blurRatio: number;
  17972. /**
  17973. * Define the adaptive blur kernel used to blur the reflection if needed.
  17974. * This will autocompute the closest best match for the `blurKernel`
  17975. */
  17976. adaptiveBlurKernel: number;
  17977. /**
  17978. * Define the blur kernel used to blur the reflection if needed.
  17979. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17980. */
  17981. blurKernel: number;
  17982. /**
  17983. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  17984. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17985. */
  17986. blurKernelX: number;
  17987. /**
  17988. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  17989. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17990. */
  17991. blurKernelY: number;
  17992. private _autoComputeBlurKernel;
  17993. protected _onRatioRescale(): void;
  17994. private _updateGammaSpace;
  17995. private _imageProcessingConfigChangeObserver;
  17996. private _transformMatrix;
  17997. private _mirrorMatrix;
  17998. private _savedViewMatrix;
  17999. private _blurX;
  18000. private _blurY;
  18001. private _adaptiveBlurKernel;
  18002. private _blurKernelX;
  18003. private _blurKernelY;
  18004. private _blurRatio;
  18005. /**
  18006. * Instantiates a Mirror Texture.
  18007. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18008. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18009. * You can then easily use it as a reflectionTexture on a flat surface.
  18010. * In case the surface is not a plane, please consider relying on reflection probes.
  18011. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18012. * @param name
  18013. * @param size
  18014. * @param scene
  18015. * @param generateMipMaps
  18016. * @param type
  18017. * @param samplingMode
  18018. * @param generateDepthBuffer
  18019. */
  18020. constructor(name: string, size: number | {
  18021. width: number;
  18022. height: number;
  18023. } | {
  18024. ratio: number;
  18025. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18026. private _preparePostProcesses;
  18027. /**
  18028. * Clone the mirror texture.
  18029. * @returns the cloned texture
  18030. */
  18031. clone(): MirrorTexture;
  18032. /**
  18033. * Serialize the texture to a JSON representation you could use in Parse later on
  18034. * @returns the serialized JSON representation
  18035. */
  18036. serialize(): any;
  18037. /**
  18038. * Dispose the texture and release its associated resources.
  18039. */
  18040. dispose(): void;
  18041. }
  18042. }
  18043. declare module BABYLON {
  18044. /**
  18045. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18046. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18047. */
  18048. export class Texture extends BaseTexture {
  18049. /** @hidden */
  18050. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  18051. /** @hidden */
  18052. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  18053. /** @hidden */
  18054. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  18055. /** nearest is mag = nearest and min = nearest and mip = linear */
  18056. static readonly NEAREST_SAMPLINGMODE: number;
  18057. /** nearest is mag = nearest and min = nearest and mip = linear */
  18058. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18059. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18060. static readonly BILINEAR_SAMPLINGMODE: number;
  18061. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18062. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18063. /** Trilinear is mag = linear and min = linear and mip = linear */
  18064. static readonly TRILINEAR_SAMPLINGMODE: number;
  18065. /** Trilinear is mag = linear and min = linear and mip = linear */
  18066. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18067. /** mag = nearest and min = nearest and mip = nearest */
  18068. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18069. /** mag = nearest and min = linear and mip = nearest */
  18070. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18071. /** mag = nearest and min = linear and mip = linear */
  18072. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18073. /** mag = nearest and min = linear and mip = none */
  18074. static readonly NEAREST_LINEAR: number;
  18075. /** mag = nearest and min = nearest and mip = none */
  18076. static readonly NEAREST_NEAREST: number;
  18077. /** mag = linear and min = nearest and mip = nearest */
  18078. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18079. /** mag = linear and min = nearest and mip = linear */
  18080. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18081. /** mag = linear and min = linear and mip = none */
  18082. static readonly LINEAR_LINEAR: number;
  18083. /** mag = linear and min = nearest and mip = none */
  18084. static readonly LINEAR_NEAREST: number;
  18085. /** Explicit coordinates mode */
  18086. static readonly EXPLICIT_MODE: number;
  18087. /** Spherical coordinates mode */
  18088. static readonly SPHERICAL_MODE: number;
  18089. /** Planar coordinates mode */
  18090. static readonly PLANAR_MODE: number;
  18091. /** Cubic coordinates mode */
  18092. static readonly CUBIC_MODE: number;
  18093. /** Projection coordinates mode */
  18094. static readonly PROJECTION_MODE: number;
  18095. /** Inverse Cubic coordinates mode */
  18096. static readonly SKYBOX_MODE: number;
  18097. /** Inverse Cubic coordinates mode */
  18098. static readonly INVCUBIC_MODE: number;
  18099. /** Equirectangular coordinates mode */
  18100. static readonly EQUIRECTANGULAR_MODE: number;
  18101. /** Equirectangular Fixed coordinates mode */
  18102. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18103. /** Equirectangular Fixed Mirrored coordinates mode */
  18104. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18105. /** Texture is not repeating outside of 0..1 UVs */
  18106. static readonly CLAMP_ADDRESSMODE: number;
  18107. /** Texture is repeating outside of 0..1 UVs */
  18108. static readonly WRAP_ADDRESSMODE: number;
  18109. /** Texture is repeating and mirrored */
  18110. static readonly MIRROR_ADDRESSMODE: number;
  18111. /**
  18112. * 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
  18113. */
  18114. static UseSerializedUrlIfAny: boolean;
  18115. /**
  18116. * Define the url of the texture.
  18117. */
  18118. url: Nullable<string>;
  18119. /**
  18120. * Define an offset on the texture to offset the u coordinates of the UVs
  18121. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18122. */
  18123. uOffset: number;
  18124. /**
  18125. * Define an offset on the texture to offset the v coordinates of the UVs
  18126. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18127. */
  18128. vOffset: number;
  18129. /**
  18130. * Define an offset on the texture to scale the u coordinates of the UVs
  18131. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18132. */
  18133. uScale: number;
  18134. /**
  18135. * Define an offset on the texture to scale the v coordinates of the UVs
  18136. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18137. */
  18138. vScale: number;
  18139. /**
  18140. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18141. * @see http://doc.babylonjs.com/how_to/more_materials
  18142. */
  18143. uAng: number;
  18144. /**
  18145. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18146. * @see http://doc.babylonjs.com/how_to/more_materials
  18147. */
  18148. vAng: number;
  18149. /**
  18150. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18151. * @see http://doc.babylonjs.com/how_to/more_materials
  18152. */
  18153. wAng: number;
  18154. /**
  18155. * Defines the center of rotation (U)
  18156. */
  18157. uRotationCenter: number;
  18158. /**
  18159. * Defines the center of rotation (V)
  18160. */
  18161. vRotationCenter: number;
  18162. /**
  18163. * Defines the center of rotation (W)
  18164. */
  18165. wRotationCenter: number;
  18166. /**
  18167. * Are mip maps generated for this texture or not.
  18168. */
  18169. readonly noMipmap: boolean;
  18170. /**
  18171. * List of inspectable custom properties (used by the Inspector)
  18172. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18173. */
  18174. inspectableCustomProperties: Nullable<IInspectable[]>;
  18175. private _noMipmap;
  18176. /** @hidden */
  18177. _invertY: boolean;
  18178. private _rowGenerationMatrix;
  18179. private _cachedTextureMatrix;
  18180. private _projectionModeMatrix;
  18181. private _t0;
  18182. private _t1;
  18183. private _t2;
  18184. private _cachedUOffset;
  18185. private _cachedVOffset;
  18186. private _cachedUScale;
  18187. private _cachedVScale;
  18188. private _cachedUAng;
  18189. private _cachedVAng;
  18190. private _cachedWAng;
  18191. private _cachedProjectionMatrixId;
  18192. private _cachedCoordinatesMode;
  18193. /** @hidden */
  18194. protected _initialSamplingMode: number;
  18195. /** @hidden */
  18196. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18197. private _deleteBuffer;
  18198. protected _format: Nullable<number>;
  18199. private _delayedOnLoad;
  18200. private _delayedOnError;
  18201. /**
  18202. * Observable triggered once the texture has been loaded.
  18203. */
  18204. onLoadObservable: Observable<Texture>;
  18205. protected _isBlocking: boolean;
  18206. /**
  18207. * Is the texture preventing material to render while loading.
  18208. * If false, a default texture will be used instead of the loading one during the preparation step.
  18209. */
  18210. isBlocking: boolean;
  18211. /**
  18212. * Get the current sampling mode associated with the texture.
  18213. */
  18214. readonly samplingMode: number;
  18215. /**
  18216. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18217. */
  18218. readonly invertY: boolean;
  18219. /**
  18220. * Instantiates a new texture.
  18221. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18222. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18223. * @param url define the url of the picture to load as a texture
  18224. * @param scene define the scene the texture will belong to
  18225. * @param noMipmap define if the texture will require mip maps or not
  18226. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18227. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18228. * @param onLoad define a callback triggered when the texture has been loaded
  18229. * @param onError define a callback triggered when an error occurred during the loading session
  18230. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18231. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18232. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18233. */
  18234. constructor(url: Nullable<string>, scene: Nullable<Scene>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  18235. /**
  18236. * Update the url (and optional buffer) of this texture if url was null during construction.
  18237. * @param url the url of the texture
  18238. * @param buffer the buffer of the texture (defaults to null)
  18239. * @param onLoad callback called when the texture is loaded (defaults to null)
  18240. */
  18241. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18242. /**
  18243. * Finish the loading sequence of a texture flagged as delayed load.
  18244. * @hidden
  18245. */
  18246. delayLoad(): void;
  18247. private _prepareRowForTextureGeneration;
  18248. /**
  18249. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18250. * @returns the transform matrix of the texture.
  18251. */
  18252. getTextureMatrix(): Matrix;
  18253. /**
  18254. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18255. * @returns The reflection texture transform
  18256. */
  18257. getReflectionTextureMatrix(): Matrix;
  18258. /**
  18259. * Clones the texture.
  18260. * @returns the cloned texture
  18261. */
  18262. clone(): Texture;
  18263. /**
  18264. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18265. * @returns The JSON representation of the texture
  18266. */
  18267. serialize(): any;
  18268. /**
  18269. * Get the current class name of the texture useful for serialization or dynamic coding.
  18270. * @returns "Texture"
  18271. */
  18272. getClassName(): string;
  18273. /**
  18274. * Dispose the texture and release its associated resources.
  18275. */
  18276. dispose(): void;
  18277. /**
  18278. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18279. * @param parsedTexture Define the JSON representation of the texture
  18280. * @param scene Define the scene the parsed texture should be instantiated in
  18281. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18282. * @returns The parsed texture if successful
  18283. */
  18284. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18285. /**
  18286. * Creates a texture from its base 64 representation.
  18287. * @param data Define the base64 payload without the data: prefix
  18288. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18289. * @param scene Define the scene the texture should belong to
  18290. * @param noMipmap Forces the texture to not create mip map information if true
  18291. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18292. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18293. * @param onLoad define a callback triggered when the texture has been loaded
  18294. * @param onError define a callback triggered when an error occurred during the loading session
  18295. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18296. * @returns the created texture
  18297. */
  18298. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18299. /**
  18300. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18301. * @param data Define the base64 payload without the data: prefix
  18302. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18303. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18304. * @param scene Define the scene the texture should belong to
  18305. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18306. * @param noMipmap Forces the texture to not create mip map information if true
  18307. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18308. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18309. * @param onLoad define a callback triggered when the texture has been loaded
  18310. * @param onError define a callback triggered when an error occurred during the loading session
  18311. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18312. * @returns the created texture
  18313. */
  18314. 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;
  18315. }
  18316. }
  18317. declare module BABYLON {
  18318. interface Engine {
  18319. /**
  18320. * Creates a raw texture
  18321. * @param data defines the data to store in the texture
  18322. * @param width defines the width of the texture
  18323. * @param height defines the height of the texture
  18324. * @param format defines the format of the data
  18325. * @param generateMipMaps defines if the engine should generate the mip levels
  18326. * @param invertY defines if data must be stored with Y axis inverted
  18327. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  18328. * @param compression defines the compression used (null by default)
  18329. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18330. * @returns the raw texture inside an InternalTexture
  18331. */
  18332. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  18333. /**
  18334. * Update a raw texture
  18335. * @param texture defines the texture to update
  18336. * @param data defines the data to store in the texture
  18337. * @param format defines the format of the data
  18338. * @param invertY defines if data must be stored with Y axis inverted
  18339. */
  18340. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  18341. /**
  18342. * Update a raw texture
  18343. * @param texture defines the texture to update
  18344. * @param data defines the data to store in the texture
  18345. * @param format defines the format of the data
  18346. * @param invertY defines if data must be stored with Y axis inverted
  18347. * @param compression defines the compression used (null by default)
  18348. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18349. */
  18350. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  18351. /**
  18352. * Creates a new raw cube texture
  18353. * @param data defines the array of data to use to create each face
  18354. * @param size defines the size of the textures
  18355. * @param format defines the format of the data
  18356. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18357. * @param generateMipMaps defines if the engine should generate the mip levels
  18358. * @param invertY defines if data must be stored with Y axis inverted
  18359. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18360. * @param compression defines the compression used (null by default)
  18361. * @returns the cube texture as an InternalTexture
  18362. */
  18363. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  18364. /**
  18365. * Update a raw cube texture
  18366. * @param texture defines the texture to udpdate
  18367. * @param data defines the data to store
  18368. * @param format defines the data format
  18369. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18370. * @param invertY defines if data must be stored with Y axis inverted
  18371. */
  18372. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  18373. /**
  18374. * Update a raw cube texture
  18375. * @param texture defines the texture to udpdate
  18376. * @param data defines the data to store
  18377. * @param format defines the data format
  18378. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18379. * @param invertY defines if data must be stored with Y axis inverted
  18380. * @param compression defines the compression used (null by default)
  18381. */
  18382. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  18383. /**
  18384. * Update a raw cube texture
  18385. * @param texture defines the texture to udpdate
  18386. * @param data defines the data to store
  18387. * @param format defines the data format
  18388. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18389. * @param invertY defines if data must be stored with Y axis inverted
  18390. * @param compression defines the compression used (null by default)
  18391. * @param level defines which level of the texture to update
  18392. */
  18393. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  18394. /**
  18395. * Creates a new raw cube texture from a specified url
  18396. * @param url defines the url where the data is located
  18397. * @param scene defines the current scene
  18398. * @param size defines the size of the textures
  18399. * @param format defines the format of the data
  18400. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18401. * @param noMipmap defines if the engine should avoid generating the mip levels
  18402. * @param callback defines a callback used to extract texture data from loaded data
  18403. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  18404. * @param onLoad defines a callback called when texture is loaded
  18405. * @param onError defines a callback called if there is an error
  18406. * @returns the cube texture as an InternalTexture
  18407. */
  18408. 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;
  18409. /**
  18410. * Creates a new raw cube texture from a specified url
  18411. * @param url defines the url where the data is located
  18412. * @param scene defines the current scene
  18413. * @param size defines the size of the textures
  18414. * @param format defines the format of the data
  18415. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18416. * @param noMipmap defines if the engine should avoid generating the mip levels
  18417. * @param callback defines a callback used to extract texture data from loaded data
  18418. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  18419. * @param onLoad defines a callback called when texture is loaded
  18420. * @param onError defines a callback called if there is an error
  18421. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18422. * @param invertY defines if data must be stored with Y axis inverted
  18423. * @returns the cube texture as an InternalTexture
  18424. */
  18425. 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;
  18426. /**
  18427. * Creates a new raw 3D texture
  18428. * @param data defines the data used to create the texture
  18429. * @param width defines the width of the texture
  18430. * @param height defines the height of the texture
  18431. * @param depth defines the depth of the texture
  18432. * @param format defines the format of the texture
  18433. * @param generateMipMaps defines if the engine must generate mip levels
  18434. * @param invertY defines if data must be stored with Y axis inverted
  18435. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18436. * @param compression defines the compressed used (can be null)
  18437. * @param textureType defines the compressed used (can be null)
  18438. * @returns a new raw 3D texture (stored in an InternalTexture)
  18439. */
  18440. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  18441. /**
  18442. * Update a raw 3D texture
  18443. * @param texture defines the texture to update
  18444. * @param data defines the data to store
  18445. * @param format defines the data format
  18446. * @param invertY defines if data must be stored with Y axis inverted
  18447. */
  18448. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  18449. /**
  18450. * Update a raw 3D texture
  18451. * @param texture defines the texture to update
  18452. * @param data defines the data to store
  18453. * @param format defines the data format
  18454. * @param invertY defines if data must be stored with Y axis inverted
  18455. * @param compression defines the used compression (can be null)
  18456. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  18457. */
  18458. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  18459. }
  18460. }
  18461. declare module BABYLON {
  18462. /**
  18463. * Raw texture can help creating a texture directly from an array of data.
  18464. * This can be super useful if you either get the data from an uncompressed source or
  18465. * if you wish to create your texture pixel by pixel.
  18466. */
  18467. export class RawTexture extends Texture {
  18468. /**
  18469. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18470. */
  18471. format: number;
  18472. private _engine;
  18473. /**
  18474. * Instantiates a new RawTexture.
  18475. * Raw texture can help creating a texture directly from an array of data.
  18476. * This can be super useful if you either get the data from an uncompressed source or
  18477. * if you wish to create your texture pixel by pixel.
  18478. * @param data define the array of data to use to create the texture
  18479. * @param width define the width of the texture
  18480. * @param height define the height of the texture
  18481. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18482. * @param scene define the scene the texture belongs to
  18483. * @param generateMipMaps define whether mip maps should be generated or not
  18484. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18485. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18486. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18487. */
  18488. constructor(data: ArrayBufferView, width: number, height: number,
  18489. /**
  18490. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18491. */
  18492. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  18493. /**
  18494. * Updates the texture underlying data.
  18495. * @param data Define the new data of the texture
  18496. */
  18497. update(data: ArrayBufferView): void;
  18498. /**
  18499. * Creates a luminance texture from some data.
  18500. * @param data Define the texture data
  18501. * @param width Define the width of the texture
  18502. * @param height Define the height of the texture
  18503. * @param scene Define the scene the texture belongs to
  18504. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18505. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18506. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18507. * @returns the luminance texture
  18508. */
  18509. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18510. /**
  18511. * Creates a luminance alpha texture from some data.
  18512. * @param data Define the texture data
  18513. * @param width Define the width of the texture
  18514. * @param height Define the height of the texture
  18515. * @param scene Define the scene the texture belongs to
  18516. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18517. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18518. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18519. * @returns the luminance alpha texture
  18520. */
  18521. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18522. /**
  18523. * Creates an alpha texture from some data.
  18524. * @param data Define the texture data
  18525. * @param width Define the width of the texture
  18526. * @param height Define the height of the texture
  18527. * @param scene Define the scene the texture belongs to
  18528. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18529. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18530. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18531. * @returns the alpha texture
  18532. */
  18533. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18534. /**
  18535. * Creates a RGB texture from some data.
  18536. * @param data Define the texture data
  18537. * @param width Define the width of the texture
  18538. * @param height Define the height of the texture
  18539. * @param scene Define the scene the texture belongs to
  18540. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18541. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18542. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18543. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18544. * @returns the RGB alpha texture
  18545. */
  18546. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18547. /**
  18548. * Creates a RGBA texture from some data.
  18549. * @param data Define the texture data
  18550. * @param width Define the width of the texture
  18551. * @param height Define the height of the texture
  18552. * @param scene Define the scene the texture belongs to
  18553. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18554. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18555. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18556. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18557. * @returns the RGBA texture
  18558. */
  18559. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18560. /**
  18561. * Creates a R texture from some data.
  18562. * @param data Define the texture data
  18563. * @param width Define the width of the texture
  18564. * @param height Define the height of the texture
  18565. * @param scene Define the scene the texture belongs to
  18566. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18567. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18568. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18569. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18570. * @returns the R texture
  18571. */
  18572. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18573. }
  18574. }
  18575. declare module BABYLON {
  18576. /**
  18577. * Defines a runtime animation
  18578. */
  18579. export class RuntimeAnimation {
  18580. private _events;
  18581. /**
  18582. * The current frame of the runtime animation
  18583. */
  18584. private _currentFrame;
  18585. /**
  18586. * The animation used by the runtime animation
  18587. */
  18588. private _animation;
  18589. /**
  18590. * The target of the runtime animation
  18591. */
  18592. private _target;
  18593. /**
  18594. * The initiating animatable
  18595. */
  18596. private _host;
  18597. /**
  18598. * The original value of the runtime animation
  18599. */
  18600. private _originalValue;
  18601. /**
  18602. * The original blend value of the runtime animation
  18603. */
  18604. private _originalBlendValue;
  18605. /**
  18606. * The offsets cache of the runtime animation
  18607. */
  18608. private _offsetsCache;
  18609. /**
  18610. * The high limits cache of the runtime animation
  18611. */
  18612. private _highLimitsCache;
  18613. /**
  18614. * Specifies if the runtime animation has been stopped
  18615. */
  18616. private _stopped;
  18617. /**
  18618. * The blending factor of the runtime animation
  18619. */
  18620. private _blendingFactor;
  18621. /**
  18622. * The BabylonJS scene
  18623. */
  18624. private _scene;
  18625. /**
  18626. * The current value of the runtime animation
  18627. */
  18628. private _currentValue;
  18629. /** @hidden */
  18630. _animationState: _IAnimationState;
  18631. /**
  18632. * The active target of the runtime animation
  18633. */
  18634. private _activeTargets;
  18635. private _currentActiveTarget;
  18636. private _directTarget;
  18637. /**
  18638. * The target path of the runtime animation
  18639. */
  18640. private _targetPath;
  18641. /**
  18642. * The weight of the runtime animation
  18643. */
  18644. private _weight;
  18645. /**
  18646. * The ratio offset of the runtime animation
  18647. */
  18648. private _ratioOffset;
  18649. /**
  18650. * The previous delay of the runtime animation
  18651. */
  18652. private _previousDelay;
  18653. /**
  18654. * The previous ratio of the runtime animation
  18655. */
  18656. private _previousRatio;
  18657. private _enableBlending;
  18658. private _keys;
  18659. private _minFrame;
  18660. private _maxFrame;
  18661. private _minValue;
  18662. private _maxValue;
  18663. private _targetIsArray;
  18664. /**
  18665. * Gets the current frame of the runtime animation
  18666. */
  18667. readonly currentFrame: number;
  18668. /**
  18669. * Gets the weight of the runtime animation
  18670. */
  18671. readonly weight: number;
  18672. /**
  18673. * Gets the current value of the runtime animation
  18674. */
  18675. readonly currentValue: any;
  18676. /**
  18677. * Gets the target path of the runtime animation
  18678. */
  18679. readonly targetPath: string;
  18680. /**
  18681. * Gets the actual target of the runtime animation
  18682. */
  18683. readonly target: any;
  18684. /** @hidden */
  18685. _onLoop: () => void;
  18686. /**
  18687. * Create a new RuntimeAnimation object
  18688. * @param target defines the target of the animation
  18689. * @param animation defines the source animation object
  18690. * @param scene defines the hosting scene
  18691. * @param host defines the initiating Animatable
  18692. */
  18693. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  18694. private _preparePath;
  18695. /**
  18696. * Gets the animation from the runtime animation
  18697. */
  18698. readonly animation: Animation;
  18699. /**
  18700. * Resets the runtime animation to the beginning
  18701. * @param restoreOriginal defines whether to restore the target property to the original value
  18702. */
  18703. reset(restoreOriginal?: boolean): void;
  18704. /**
  18705. * Specifies if the runtime animation is stopped
  18706. * @returns Boolean specifying if the runtime animation is stopped
  18707. */
  18708. isStopped(): boolean;
  18709. /**
  18710. * Disposes of the runtime animation
  18711. */
  18712. dispose(): void;
  18713. /**
  18714. * Apply the interpolated value to the target
  18715. * @param currentValue defines the value computed by the animation
  18716. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  18717. */
  18718. setValue(currentValue: any, weight: number): void;
  18719. private _getOriginalValues;
  18720. private _setValue;
  18721. /**
  18722. * Gets the loop pmode of the runtime animation
  18723. * @returns Loop Mode
  18724. */
  18725. private _getCorrectLoopMode;
  18726. /**
  18727. * Move the current animation to a given frame
  18728. * @param frame defines the frame to move to
  18729. */
  18730. goToFrame(frame: number): void;
  18731. /**
  18732. * @hidden Internal use only
  18733. */
  18734. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  18735. /**
  18736. * Execute the current animation
  18737. * @param delay defines the delay to add to the current frame
  18738. * @param from defines the lower bound of the animation range
  18739. * @param to defines the upper bound of the animation range
  18740. * @param loop defines if the current animation must loop
  18741. * @param speedRatio defines the current speed ratio
  18742. * @param weight defines the weight of the animation (default is -1 so no weight)
  18743. * @param onLoop optional callback called when animation loops
  18744. * @returns a boolean indicating if the animation is running
  18745. */
  18746. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  18747. }
  18748. }
  18749. declare module BABYLON {
  18750. /**
  18751. * Class used to store an actual running animation
  18752. */
  18753. export class Animatable {
  18754. /** defines the target object */
  18755. target: any;
  18756. /** defines the starting frame number (default is 0) */
  18757. fromFrame: number;
  18758. /** defines the ending frame number (default is 100) */
  18759. toFrame: number;
  18760. /** defines if the animation must loop (default is false) */
  18761. loopAnimation: boolean;
  18762. /** defines a callback to call when animation ends if it is not looping */
  18763. onAnimationEnd?: (() => void) | null | undefined;
  18764. /** defines a callback to call when animation loops */
  18765. onAnimationLoop?: (() => void) | null | undefined;
  18766. private _localDelayOffset;
  18767. private _pausedDelay;
  18768. private _runtimeAnimations;
  18769. private _paused;
  18770. private _scene;
  18771. private _speedRatio;
  18772. private _weight;
  18773. private _syncRoot;
  18774. /**
  18775. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  18776. * This will only apply for non looping animation (default is true)
  18777. */
  18778. disposeOnEnd: boolean;
  18779. /**
  18780. * Gets a boolean indicating if the animation has started
  18781. */
  18782. animationStarted: boolean;
  18783. /**
  18784. * Observer raised when the animation ends
  18785. */
  18786. onAnimationEndObservable: Observable<Animatable>;
  18787. /**
  18788. * Observer raised when the animation loops
  18789. */
  18790. onAnimationLoopObservable: Observable<Animatable>;
  18791. /**
  18792. * Gets the root Animatable used to synchronize and normalize animations
  18793. */
  18794. readonly syncRoot: Nullable<Animatable>;
  18795. /**
  18796. * Gets the current frame of the first RuntimeAnimation
  18797. * Used to synchronize Animatables
  18798. */
  18799. readonly masterFrame: number;
  18800. /**
  18801. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  18802. */
  18803. weight: number;
  18804. /**
  18805. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  18806. */
  18807. speedRatio: number;
  18808. /**
  18809. * Creates a new Animatable
  18810. * @param scene defines the hosting scene
  18811. * @param target defines the target object
  18812. * @param fromFrame defines the starting frame number (default is 0)
  18813. * @param toFrame defines the ending frame number (default is 100)
  18814. * @param loopAnimation defines if the animation must loop (default is false)
  18815. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  18816. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  18817. * @param animations defines a group of animation to add to the new Animatable
  18818. * @param onAnimationLoop defines a callback to call when animation loops
  18819. */
  18820. constructor(scene: Scene,
  18821. /** defines the target object */
  18822. target: any,
  18823. /** defines the starting frame number (default is 0) */
  18824. fromFrame?: number,
  18825. /** defines the ending frame number (default is 100) */
  18826. toFrame?: number,
  18827. /** defines if the animation must loop (default is false) */
  18828. loopAnimation?: boolean, speedRatio?: number,
  18829. /** defines a callback to call when animation ends if it is not looping */
  18830. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  18831. /** defines a callback to call when animation loops */
  18832. onAnimationLoop?: (() => void) | null | undefined);
  18833. /**
  18834. * Synchronize and normalize current Animatable with a source Animatable
  18835. * This is useful when using animation weights and when animations are not of the same length
  18836. * @param root defines the root Animatable to synchronize with
  18837. * @returns the current Animatable
  18838. */
  18839. syncWith(root: Animatable): Animatable;
  18840. /**
  18841. * Gets the list of runtime animations
  18842. * @returns an array of RuntimeAnimation
  18843. */
  18844. getAnimations(): RuntimeAnimation[];
  18845. /**
  18846. * Adds more animations to the current animatable
  18847. * @param target defines the target of the animations
  18848. * @param animations defines the new animations to add
  18849. */
  18850. appendAnimations(target: any, animations: Animation[]): void;
  18851. /**
  18852. * Gets the source animation for a specific property
  18853. * @param property defines the propertyu to look for
  18854. * @returns null or the source animation for the given property
  18855. */
  18856. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  18857. /**
  18858. * Gets the runtime animation for a specific property
  18859. * @param property defines the propertyu to look for
  18860. * @returns null or the runtime animation for the given property
  18861. */
  18862. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  18863. /**
  18864. * Resets the animatable to its original state
  18865. */
  18866. reset(): void;
  18867. /**
  18868. * Allows the animatable to blend with current running animations
  18869. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18870. * @param blendingSpeed defines the blending speed to use
  18871. */
  18872. enableBlending(blendingSpeed: number): void;
  18873. /**
  18874. * Disable animation blending
  18875. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18876. */
  18877. disableBlending(): void;
  18878. /**
  18879. * Jump directly to a given frame
  18880. * @param frame defines the frame to jump to
  18881. */
  18882. goToFrame(frame: number): void;
  18883. /**
  18884. * Pause the animation
  18885. */
  18886. pause(): void;
  18887. /**
  18888. * Restart the animation
  18889. */
  18890. restart(): void;
  18891. private _raiseOnAnimationEnd;
  18892. /**
  18893. * Stop and delete the current animation
  18894. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  18895. * @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)
  18896. */
  18897. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  18898. /**
  18899. * Wait asynchronously for the animation to end
  18900. * @returns a promise which will be fullfilled when the animation ends
  18901. */
  18902. waitAsync(): Promise<Animatable>;
  18903. /** @hidden */
  18904. _animate(delay: number): boolean;
  18905. }
  18906. interface Scene {
  18907. /** @hidden */
  18908. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  18909. /** @hidden */
  18910. _processLateAnimationBindingsForMatrices(holder: {
  18911. totalWeight: number;
  18912. animations: RuntimeAnimation[];
  18913. originalValue: Matrix;
  18914. }): any;
  18915. /** @hidden */
  18916. _processLateAnimationBindingsForQuaternions(holder: {
  18917. totalWeight: number;
  18918. animations: RuntimeAnimation[];
  18919. originalValue: Quaternion;
  18920. }, refQuaternion: Quaternion): Quaternion;
  18921. /** @hidden */
  18922. _processLateAnimationBindings(): void;
  18923. /**
  18924. * Will start the animation sequence of a given target
  18925. * @param target defines the target
  18926. * @param from defines from which frame should animation start
  18927. * @param to defines until which frame should animation run.
  18928. * @param weight defines the weight to apply to the animation (1.0 by default)
  18929. * @param loop defines if the animation loops
  18930. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18931. * @param onAnimationEnd defines the function to be executed when the animation ends
  18932. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18933. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18934. * @param onAnimationLoop defines the callback to call when an animation loops
  18935. * @returns the animatable object created for this animation
  18936. */
  18937. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18938. /**
  18939. * Will start the animation sequence of a given target
  18940. * @param target defines the target
  18941. * @param from defines from which frame should animation start
  18942. * @param to defines until which frame should animation run.
  18943. * @param loop defines if the animation loops
  18944. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18945. * @param onAnimationEnd defines the function to be executed when the animation ends
  18946. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18947. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18948. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  18949. * @param onAnimationLoop defines the callback to call when an animation loops
  18950. * @returns the animatable object created for this animation
  18951. */
  18952. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18953. /**
  18954. * Will start the animation sequence of a given target and its hierarchy
  18955. * @param target defines the target
  18956. * @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.
  18957. * @param from defines from which frame should animation start
  18958. * @param to defines until which frame should animation run.
  18959. * @param loop defines if the animation loops
  18960. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18961. * @param onAnimationEnd defines the function to be executed when the animation ends
  18962. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18963. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18964. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18965. * @param onAnimationLoop defines the callback to call when an animation loops
  18966. * @returns the list of created animatables
  18967. */
  18968. 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[];
  18969. /**
  18970. * Begin a new animation on a given node
  18971. * @param target defines the target where the animation will take place
  18972. * @param animations defines the list of animations to start
  18973. * @param from defines the initial value
  18974. * @param to defines the final value
  18975. * @param loop defines if you want animation to loop (off by default)
  18976. * @param speedRatio defines the speed ratio to apply to all animations
  18977. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18978. * @param onAnimationLoop defines the callback to call when an animation loops
  18979. * @returns the list of created animatables
  18980. */
  18981. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  18982. /**
  18983. * Begin a new animation on a given node and its hierarchy
  18984. * @param target defines the root node where the animation will take place
  18985. * @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.
  18986. * @param animations defines the list of animations to start
  18987. * @param from defines the initial value
  18988. * @param to defines the final value
  18989. * @param loop defines if you want animation to loop (off by default)
  18990. * @param speedRatio defines the speed ratio to apply to all animations
  18991. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18992. * @param onAnimationLoop defines the callback to call when an animation loops
  18993. * @returns the list of animatables created for all nodes
  18994. */
  18995. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  18996. /**
  18997. * Gets the animatable associated with a specific target
  18998. * @param target defines the target of the animatable
  18999. * @returns the required animatable if found
  19000. */
  19001. getAnimatableByTarget(target: any): Nullable<Animatable>;
  19002. /**
  19003. * Gets all animatables associated with a given target
  19004. * @param target defines the target to look animatables for
  19005. * @returns an array of Animatables
  19006. */
  19007. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  19008. /**
  19009. * Stops and removes all animations that have been applied to the scene
  19010. */
  19011. stopAllAnimations(): void;
  19012. }
  19013. interface Bone {
  19014. /**
  19015. * Copy an animation range from another bone
  19016. * @param source defines the source bone
  19017. * @param rangeName defines the range name to copy
  19018. * @param frameOffset defines the frame offset
  19019. * @param rescaleAsRequired defines if rescaling must be applied if required
  19020. * @param skelDimensionsRatio defines the scaling ratio
  19021. * @returns true if operation was successful
  19022. */
  19023. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  19024. }
  19025. }
  19026. declare module BABYLON {
  19027. /**
  19028. * Class used to handle skinning animations
  19029. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  19030. */
  19031. export class Skeleton implements IAnimatable {
  19032. /** defines the skeleton name */
  19033. name: string;
  19034. /** defines the skeleton Id */
  19035. id: string;
  19036. /**
  19037. * Defines the list of child bones
  19038. */
  19039. bones: Bone[];
  19040. /**
  19041. * Defines an estimate of the dimension of the skeleton at rest
  19042. */
  19043. dimensionsAtRest: Vector3;
  19044. /**
  19045. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  19046. */
  19047. needInitialSkinMatrix: boolean;
  19048. /**
  19049. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  19050. */
  19051. overrideMesh: Nullable<AbstractMesh>;
  19052. /**
  19053. * Gets the list of animations attached to this skeleton
  19054. */
  19055. animations: Array<Animation>;
  19056. private _scene;
  19057. private _isDirty;
  19058. private _transformMatrices;
  19059. private _transformMatrixTexture;
  19060. private _meshesWithPoseMatrix;
  19061. private _animatables;
  19062. private _identity;
  19063. private _synchronizedWithMesh;
  19064. private _ranges;
  19065. private _lastAbsoluteTransformsUpdateId;
  19066. private _canUseTextureForBones;
  19067. private _uniqueId;
  19068. /** @hidden */
  19069. _numBonesWithLinkedTransformNode: number;
  19070. /** @hidden */
  19071. _hasWaitingData: Nullable<boolean>;
  19072. /**
  19073. * Specifies if the skeleton should be serialized
  19074. */
  19075. doNotSerialize: boolean;
  19076. private _useTextureToStoreBoneMatrices;
  19077. /**
  19078. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  19079. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  19080. */
  19081. useTextureToStoreBoneMatrices: boolean;
  19082. private _animationPropertiesOverride;
  19083. /**
  19084. * Gets or sets the animation properties override
  19085. */
  19086. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19087. /**
  19088. * List of inspectable custom properties (used by the Inspector)
  19089. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19090. */
  19091. inspectableCustomProperties: IInspectable[];
  19092. /**
  19093. * An observable triggered before computing the skeleton's matrices
  19094. */
  19095. onBeforeComputeObservable: Observable<Skeleton>;
  19096. /**
  19097. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  19098. */
  19099. readonly isUsingTextureForMatrices: boolean;
  19100. /**
  19101. * Gets the unique ID of this skeleton
  19102. */
  19103. readonly uniqueId: number;
  19104. /**
  19105. * Creates a new skeleton
  19106. * @param name defines the skeleton name
  19107. * @param id defines the skeleton Id
  19108. * @param scene defines the hosting scene
  19109. */
  19110. constructor(
  19111. /** defines the skeleton name */
  19112. name: string,
  19113. /** defines the skeleton Id */
  19114. id: string, scene: Scene);
  19115. /**
  19116. * Gets the current object class name.
  19117. * @return the class name
  19118. */
  19119. getClassName(): string;
  19120. /**
  19121. * Returns an array containing the root bones
  19122. * @returns an array containing the root bones
  19123. */
  19124. getChildren(): Array<Bone>;
  19125. /**
  19126. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  19127. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  19128. * @returns a Float32Array containing matrices data
  19129. */
  19130. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  19131. /**
  19132. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  19133. * @returns a raw texture containing the data
  19134. */
  19135. getTransformMatrixTexture(): Nullable<RawTexture>;
  19136. /**
  19137. * Gets the current hosting scene
  19138. * @returns a scene object
  19139. */
  19140. getScene(): Scene;
  19141. /**
  19142. * Gets a string representing the current skeleton data
  19143. * @param fullDetails defines a boolean indicating if we want a verbose version
  19144. * @returns a string representing the current skeleton data
  19145. */
  19146. toString(fullDetails?: boolean): string;
  19147. /**
  19148. * Get bone's index searching by name
  19149. * @param name defines bone's name to search for
  19150. * @return the indice of the bone. Returns -1 if not found
  19151. */
  19152. getBoneIndexByName(name: string): number;
  19153. /**
  19154. * Creater a new animation range
  19155. * @param name defines the name of the range
  19156. * @param from defines the start key
  19157. * @param to defines the end key
  19158. */
  19159. createAnimationRange(name: string, from: number, to: number): void;
  19160. /**
  19161. * Delete a specific animation range
  19162. * @param name defines the name of the range
  19163. * @param deleteFrames defines if frames must be removed as well
  19164. */
  19165. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  19166. /**
  19167. * Gets a specific animation range
  19168. * @param name defines the name of the range to look for
  19169. * @returns the requested animation range or null if not found
  19170. */
  19171. getAnimationRange(name: string): Nullable<AnimationRange>;
  19172. /**
  19173. * Gets the list of all animation ranges defined on this skeleton
  19174. * @returns an array
  19175. */
  19176. getAnimationRanges(): Nullable<AnimationRange>[];
  19177. /**
  19178. * Copy animation range from a source skeleton.
  19179. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  19180. * @param source defines the source skeleton
  19181. * @param name defines the name of the range to copy
  19182. * @param rescaleAsRequired defines if rescaling must be applied if required
  19183. * @returns true if operation was successful
  19184. */
  19185. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  19186. /**
  19187. * Forces the skeleton to go to rest pose
  19188. */
  19189. returnToRest(): void;
  19190. private _getHighestAnimationFrame;
  19191. /**
  19192. * Begin a specific animation range
  19193. * @param name defines the name of the range to start
  19194. * @param loop defines if looping must be turned on (false by default)
  19195. * @param speedRatio defines the speed ratio to apply (1 by default)
  19196. * @param onAnimationEnd defines a callback which will be called when animation will end
  19197. * @returns a new animatable
  19198. */
  19199. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  19200. /** @hidden */
  19201. _markAsDirty(): void;
  19202. /** @hidden */
  19203. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19204. /** @hidden */
  19205. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19206. private _computeTransformMatrices;
  19207. /**
  19208. * Build all resources required to render a skeleton
  19209. */
  19210. prepare(): void;
  19211. /**
  19212. * Gets the list of animatables currently running for this skeleton
  19213. * @returns an array of animatables
  19214. */
  19215. getAnimatables(): IAnimatable[];
  19216. /**
  19217. * Clone the current skeleton
  19218. * @param name defines the name of the new skeleton
  19219. * @param id defines the id of the new skeleton
  19220. * @returns the new skeleton
  19221. */
  19222. clone(name: string, id: string): Skeleton;
  19223. /**
  19224. * Enable animation blending for this skeleton
  19225. * @param blendingSpeed defines the blending speed to apply
  19226. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19227. */
  19228. enableBlending(blendingSpeed?: number): void;
  19229. /**
  19230. * Releases all resources associated with the current skeleton
  19231. */
  19232. dispose(): void;
  19233. /**
  19234. * Serialize the skeleton in a JSON object
  19235. * @returns a JSON object
  19236. */
  19237. serialize(): any;
  19238. /**
  19239. * Creates a new skeleton from serialized data
  19240. * @param parsedSkeleton defines the serialized data
  19241. * @param scene defines the hosting scene
  19242. * @returns a new skeleton
  19243. */
  19244. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19245. /**
  19246. * Compute all node absolute transforms
  19247. * @param forceUpdate defines if computation must be done even if cache is up to date
  19248. */
  19249. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19250. /**
  19251. * Gets the root pose matrix
  19252. * @returns a matrix
  19253. */
  19254. getPoseMatrix(): Nullable<Matrix>;
  19255. /**
  19256. * Sorts bones per internal index
  19257. */
  19258. sortBones(): void;
  19259. private _sortBones;
  19260. }
  19261. }
  19262. declare module BABYLON {
  19263. /**
  19264. * Defines a target to use with MorphTargetManager
  19265. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19266. */
  19267. export class MorphTarget implements IAnimatable {
  19268. /** defines the name of the target */
  19269. name: string;
  19270. /**
  19271. * Gets or sets the list of animations
  19272. */
  19273. animations: Animation[];
  19274. private _scene;
  19275. private _positions;
  19276. private _normals;
  19277. private _tangents;
  19278. private _influence;
  19279. /**
  19280. * Observable raised when the influence changes
  19281. */
  19282. onInfluenceChanged: Observable<boolean>;
  19283. /** @hidden */
  19284. _onDataLayoutChanged: Observable<void>;
  19285. /**
  19286. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19287. */
  19288. influence: number;
  19289. /**
  19290. * Gets or sets the id of the morph Target
  19291. */
  19292. id: string;
  19293. private _animationPropertiesOverride;
  19294. /**
  19295. * Gets or sets the animation properties override
  19296. */
  19297. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19298. /**
  19299. * Creates a new MorphTarget
  19300. * @param name defines the name of the target
  19301. * @param influence defines the influence to use
  19302. * @param scene defines the scene the morphtarget belongs to
  19303. */
  19304. constructor(
  19305. /** defines the name of the target */
  19306. name: string, influence?: number, scene?: Nullable<Scene>);
  19307. /**
  19308. * Gets a boolean defining if the target contains position data
  19309. */
  19310. readonly hasPositions: boolean;
  19311. /**
  19312. * Gets a boolean defining if the target contains normal data
  19313. */
  19314. readonly hasNormals: boolean;
  19315. /**
  19316. * Gets a boolean defining if the target contains tangent data
  19317. */
  19318. readonly hasTangents: boolean;
  19319. /**
  19320. * Affects position data to this target
  19321. * @param data defines the position data to use
  19322. */
  19323. setPositions(data: Nullable<FloatArray>): void;
  19324. /**
  19325. * Gets the position data stored in this target
  19326. * @returns a FloatArray containing the position data (or null if not present)
  19327. */
  19328. getPositions(): Nullable<FloatArray>;
  19329. /**
  19330. * Affects normal data to this target
  19331. * @param data defines the normal data to use
  19332. */
  19333. setNormals(data: Nullable<FloatArray>): void;
  19334. /**
  19335. * Gets the normal data stored in this target
  19336. * @returns a FloatArray containing the normal data (or null if not present)
  19337. */
  19338. getNormals(): Nullable<FloatArray>;
  19339. /**
  19340. * Affects tangent data to this target
  19341. * @param data defines the tangent data to use
  19342. */
  19343. setTangents(data: Nullable<FloatArray>): void;
  19344. /**
  19345. * Gets the tangent data stored in this target
  19346. * @returns a FloatArray containing the tangent data (or null if not present)
  19347. */
  19348. getTangents(): Nullable<FloatArray>;
  19349. /**
  19350. * Serializes the current target into a Serialization object
  19351. * @returns the serialized object
  19352. */
  19353. serialize(): any;
  19354. /**
  19355. * Returns the string "MorphTarget"
  19356. * @returns "MorphTarget"
  19357. */
  19358. getClassName(): string;
  19359. /**
  19360. * Creates a new target from serialized data
  19361. * @param serializationObject defines the serialized data to use
  19362. * @returns a new MorphTarget
  19363. */
  19364. static Parse(serializationObject: any): MorphTarget;
  19365. /**
  19366. * Creates a MorphTarget from mesh data
  19367. * @param mesh defines the source mesh
  19368. * @param name defines the name to use for the new target
  19369. * @param influence defines the influence to attach to the target
  19370. * @returns a new MorphTarget
  19371. */
  19372. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  19373. }
  19374. }
  19375. declare module BABYLON {
  19376. /**
  19377. * This class is used to deform meshes using morphing between different targets
  19378. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19379. */
  19380. export class MorphTargetManager {
  19381. private _targets;
  19382. private _targetInfluenceChangedObservers;
  19383. private _targetDataLayoutChangedObservers;
  19384. private _activeTargets;
  19385. private _scene;
  19386. private _influences;
  19387. private _supportsNormals;
  19388. private _supportsTangents;
  19389. private _vertexCount;
  19390. private _uniqueId;
  19391. private _tempInfluences;
  19392. /**
  19393. * Creates a new MorphTargetManager
  19394. * @param scene defines the current scene
  19395. */
  19396. constructor(scene?: Nullable<Scene>);
  19397. /**
  19398. * Gets the unique ID of this manager
  19399. */
  19400. readonly uniqueId: number;
  19401. /**
  19402. * Gets the number of vertices handled by this manager
  19403. */
  19404. readonly vertexCount: number;
  19405. /**
  19406. * Gets a boolean indicating if this manager supports morphing of normals
  19407. */
  19408. readonly supportsNormals: boolean;
  19409. /**
  19410. * Gets a boolean indicating if this manager supports morphing of tangents
  19411. */
  19412. readonly supportsTangents: boolean;
  19413. /**
  19414. * Gets the number of targets stored in this manager
  19415. */
  19416. readonly numTargets: number;
  19417. /**
  19418. * Gets the number of influencers (ie. the number of targets with influences > 0)
  19419. */
  19420. readonly numInfluencers: number;
  19421. /**
  19422. * Gets the list of influences (one per target)
  19423. */
  19424. readonly influences: Float32Array;
  19425. /**
  19426. * Gets the active target at specified index. An active target is a target with an influence > 0
  19427. * @param index defines the index to check
  19428. * @returns the requested target
  19429. */
  19430. getActiveTarget(index: number): MorphTarget;
  19431. /**
  19432. * Gets the target at specified index
  19433. * @param index defines the index to check
  19434. * @returns the requested target
  19435. */
  19436. getTarget(index: number): MorphTarget;
  19437. /**
  19438. * Add a new target to this manager
  19439. * @param target defines the target to add
  19440. */
  19441. addTarget(target: MorphTarget): void;
  19442. /**
  19443. * Removes a target from the manager
  19444. * @param target defines the target to remove
  19445. */
  19446. removeTarget(target: MorphTarget): void;
  19447. /**
  19448. * Serializes the current manager into a Serialization object
  19449. * @returns the serialized object
  19450. */
  19451. serialize(): any;
  19452. private _syncActiveTargets;
  19453. /**
  19454. * Syncrhonize the targets with all the meshes using this morph target manager
  19455. */
  19456. synchronize(): void;
  19457. /**
  19458. * Creates a new MorphTargetManager from serialized data
  19459. * @param serializationObject defines the serialized data
  19460. * @param scene defines the hosting scene
  19461. * @returns the new MorphTargetManager
  19462. */
  19463. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  19464. }
  19465. }
  19466. declare module BABYLON {
  19467. /**
  19468. * Class used to represent a specific level of detail of a mesh
  19469. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  19470. */
  19471. export class MeshLODLevel {
  19472. /** Defines the distance where this level should star being displayed */
  19473. distance: number;
  19474. /** Defines the mesh to use to render this level */
  19475. mesh: Nullable<Mesh>;
  19476. /**
  19477. * Creates a new LOD level
  19478. * @param distance defines the distance where this level should star being displayed
  19479. * @param mesh defines the mesh to use to render this level
  19480. */
  19481. constructor(
  19482. /** Defines the distance where this level should star being displayed */
  19483. distance: number,
  19484. /** Defines the mesh to use to render this level */
  19485. mesh: Nullable<Mesh>);
  19486. }
  19487. }
  19488. declare module BABYLON {
  19489. /**
  19490. * Mesh representing the gorund
  19491. */
  19492. export class GroundMesh extends Mesh {
  19493. /** If octree should be generated */
  19494. generateOctree: boolean;
  19495. private _heightQuads;
  19496. /** @hidden */
  19497. _subdivisionsX: number;
  19498. /** @hidden */
  19499. _subdivisionsY: number;
  19500. /** @hidden */
  19501. _width: number;
  19502. /** @hidden */
  19503. _height: number;
  19504. /** @hidden */
  19505. _minX: number;
  19506. /** @hidden */
  19507. _maxX: number;
  19508. /** @hidden */
  19509. _minZ: number;
  19510. /** @hidden */
  19511. _maxZ: number;
  19512. constructor(name: string, scene: Scene);
  19513. /**
  19514. * "GroundMesh"
  19515. * @returns "GroundMesh"
  19516. */
  19517. getClassName(): string;
  19518. /**
  19519. * The minimum of x and y subdivisions
  19520. */
  19521. readonly subdivisions: number;
  19522. /**
  19523. * X subdivisions
  19524. */
  19525. readonly subdivisionsX: number;
  19526. /**
  19527. * Y subdivisions
  19528. */
  19529. readonly subdivisionsY: number;
  19530. /**
  19531. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  19532. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19533. * @param chunksCount the number of subdivisions for x and y
  19534. * @param octreeBlocksSize (Default: 32)
  19535. */
  19536. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  19537. /**
  19538. * Returns a height (y) value in the Worl system :
  19539. * the ground altitude at the coordinates (x, z) expressed in the World system.
  19540. * @param x x coordinate
  19541. * @param z z coordinate
  19542. * @returns the ground y position if (x, z) are outside the ground surface.
  19543. */
  19544. getHeightAtCoordinates(x: number, z: number): number;
  19545. /**
  19546. * Returns a normalized vector (Vector3) orthogonal to the ground
  19547. * at the ground coordinates (x, z) expressed in the World system.
  19548. * @param x x coordinate
  19549. * @param z z coordinate
  19550. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  19551. */
  19552. getNormalAtCoordinates(x: number, z: number): Vector3;
  19553. /**
  19554. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  19555. * at the ground coordinates (x, z) expressed in the World system.
  19556. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  19557. * @param x x coordinate
  19558. * @param z z coordinate
  19559. * @param ref vector to store the result
  19560. * @returns the GroundMesh.
  19561. */
  19562. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  19563. /**
  19564. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  19565. * if the ground has been updated.
  19566. * This can be used in the render loop.
  19567. * @returns the GroundMesh.
  19568. */
  19569. updateCoordinateHeights(): GroundMesh;
  19570. private _getFacetAt;
  19571. private _initHeightQuads;
  19572. private _computeHeightQuads;
  19573. /**
  19574. * Serializes this ground mesh
  19575. * @param serializationObject object to write serialization to
  19576. */
  19577. serialize(serializationObject: any): void;
  19578. /**
  19579. * Parses a serialized ground mesh
  19580. * @param parsedMesh the serialized mesh
  19581. * @param scene the scene to create the ground mesh in
  19582. * @returns the created ground mesh
  19583. */
  19584. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  19585. }
  19586. }
  19587. declare module BABYLON {
  19588. /**
  19589. * Interface for Physics-Joint data
  19590. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19591. */
  19592. export interface PhysicsJointData {
  19593. /**
  19594. * The main pivot of the joint
  19595. */
  19596. mainPivot?: Vector3;
  19597. /**
  19598. * The connected pivot of the joint
  19599. */
  19600. connectedPivot?: Vector3;
  19601. /**
  19602. * The main axis of the joint
  19603. */
  19604. mainAxis?: Vector3;
  19605. /**
  19606. * The connected axis of the joint
  19607. */
  19608. connectedAxis?: Vector3;
  19609. /**
  19610. * The collision of the joint
  19611. */
  19612. collision?: boolean;
  19613. /**
  19614. * Native Oimo/Cannon/Energy data
  19615. */
  19616. nativeParams?: any;
  19617. }
  19618. /**
  19619. * This is a holder class for the physics joint created by the physics plugin
  19620. * It holds a set of functions to control the underlying joint
  19621. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19622. */
  19623. export class PhysicsJoint {
  19624. /**
  19625. * The type of the physics joint
  19626. */
  19627. type: number;
  19628. /**
  19629. * The data for the physics joint
  19630. */
  19631. jointData: PhysicsJointData;
  19632. private _physicsJoint;
  19633. protected _physicsPlugin: IPhysicsEnginePlugin;
  19634. /**
  19635. * Initializes the physics joint
  19636. * @param type The type of the physics joint
  19637. * @param jointData The data for the physics joint
  19638. */
  19639. constructor(
  19640. /**
  19641. * The type of the physics joint
  19642. */
  19643. type: number,
  19644. /**
  19645. * The data for the physics joint
  19646. */
  19647. jointData: PhysicsJointData);
  19648. /**
  19649. * Gets the physics joint
  19650. */
  19651. /**
  19652. * Sets the physics joint
  19653. */
  19654. physicsJoint: any;
  19655. /**
  19656. * Sets the physics plugin
  19657. */
  19658. physicsPlugin: IPhysicsEnginePlugin;
  19659. /**
  19660. * Execute a function that is physics-plugin specific.
  19661. * @param {Function} func the function that will be executed.
  19662. * It accepts two parameters: the physics world and the physics joint
  19663. */
  19664. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19665. /**
  19666. * Distance-Joint type
  19667. */
  19668. static DistanceJoint: number;
  19669. /**
  19670. * Hinge-Joint type
  19671. */
  19672. static HingeJoint: number;
  19673. /**
  19674. * Ball-and-Socket joint type
  19675. */
  19676. static BallAndSocketJoint: number;
  19677. /**
  19678. * Wheel-Joint type
  19679. */
  19680. static WheelJoint: number;
  19681. /**
  19682. * Slider-Joint type
  19683. */
  19684. static SliderJoint: number;
  19685. /**
  19686. * Prismatic-Joint type
  19687. */
  19688. static PrismaticJoint: number;
  19689. /**
  19690. * Universal-Joint type
  19691. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  19692. */
  19693. static UniversalJoint: number;
  19694. /**
  19695. * Hinge-Joint 2 type
  19696. */
  19697. static Hinge2Joint: number;
  19698. /**
  19699. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  19700. */
  19701. static PointToPointJoint: number;
  19702. /**
  19703. * Spring-Joint type
  19704. */
  19705. static SpringJoint: number;
  19706. /**
  19707. * Lock-Joint type
  19708. */
  19709. static LockJoint: number;
  19710. }
  19711. /**
  19712. * A class representing a physics distance joint
  19713. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19714. */
  19715. export class DistanceJoint extends PhysicsJoint {
  19716. /**
  19717. *
  19718. * @param jointData The data for the Distance-Joint
  19719. */
  19720. constructor(jointData: DistanceJointData);
  19721. /**
  19722. * Update the predefined distance.
  19723. * @param maxDistance The maximum preferred distance
  19724. * @param minDistance The minimum preferred distance
  19725. */
  19726. updateDistance(maxDistance: number, minDistance?: number): void;
  19727. }
  19728. /**
  19729. * Represents a Motor-Enabled Joint
  19730. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19731. */
  19732. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19733. /**
  19734. * Initializes the Motor-Enabled Joint
  19735. * @param type The type of the joint
  19736. * @param jointData The physica joint data for the joint
  19737. */
  19738. constructor(type: number, jointData: PhysicsJointData);
  19739. /**
  19740. * Set the motor values.
  19741. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19742. * @param force the force to apply
  19743. * @param maxForce max force for this motor.
  19744. */
  19745. setMotor(force?: number, maxForce?: number): void;
  19746. /**
  19747. * Set the motor's limits.
  19748. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19749. * @param upperLimit The upper limit of the motor
  19750. * @param lowerLimit The lower limit of the motor
  19751. */
  19752. setLimit(upperLimit: number, lowerLimit?: number): void;
  19753. }
  19754. /**
  19755. * This class represents a single physics Hinge-Joint
  19756. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19757. */
  19758. export class HingeJoint extends MotorEnabledJoint {
  19759. /**
  19760. * Initializes the Hinge-Joint
  19761. * @param jointData The joint data for the Hinge-Joint
  19762. */
  19763. constructor(jointData: PhysicsJointData);
  19764. /**
  19765. * Set the motor values.
  19766. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19767. * @param {number} force the force to apply
  19768. * @param {number} maxForce max force for this motor.
  19769. */
  19770. setMotor(force?: number, maxForce?: number): void;
  19771. /**
  19772. * Set the motor's limits.
  19773. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19774. * @param upperLimit The upper limit of the motor
  19775. * @param lowerLimit The lower limit of the motor
  19776. */
  19777. setLimit(upperLimit: number, lowerLimit?: number): void;
  19778. }
  19779. /**
  19780. * This class represents a dual hinge physics joint (same as wheel joint)
  19781. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19782. */
  19783. export class Hinge2Joint extends MotorEnabledJoint {
  19784. /**
  19785. * Initializes the Hinge2-Joint
  19786. * @param jointData The joint data for the Hinge2-Joint
  19787. */
  19788. constructor(jointData: PhysicsJointData);
  19789. /**
  19790. * Set the motor values.
  19791. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19792. * @param {number} targetSpeed the speed the motor is to reach
  19793. * @param {number} maxForce max force for this motor.
  19794. * @param {motorIndex} the motor's index, 0 or 1.
  19795. */
  19796. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  19797. /**
  19798. * Set the motor limits.
  19799. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19800. * @param {number} upperLimit the upper limit
  19801. * @param {number} lowerLimit lower limit
  19802. * @param {motorIndex} the motor's index, 0 or 1.
  19803. */
  19804. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19805. }
  19806. /**
  19807. * Interface for a motor enabled joint
  19808. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19809. */
  19810. export interface IMotorEnabledJoint {
  19811. /**
  19812. * Physics joint
  19813. */
  19814. physicsJoint: any;
  19815. /**
  19816. * Sets the motor of the motor-enabled joint
  19817. * @param force The force of the motor
  19818. * @param maxForce The maximum force of the motor
  19819. * @param motorIndex The index of the motor
  19820. */
  19821. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  19822. /**
  19823. * Sets the limit of the motor
  19824. * @param upperLimit The upper limit of the motor
  19825. * @param lowerLimit The lower limit of the motor
  19826. * @param motorIndex The index of the motor
  19827. */
  19828. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19829. }
  19830. /**
  19831. * Joint data for a Distance-Joint
  19832. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19833. */
  19834. export interface DistanceJointData extends PhysicsJointData {
  19835. /**
  19836. * Max distance the 2 joint objects can be apart
  19837. */
  19838. maxDistance: number;
  19839. }
  19840. /**
  19841. * Joint data from a spring joint
  19842. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19843. */
  19844. export interface SpringJointData extends PhysicsJointData {
  19845. /**
  19846. * Length of the spring
  19847. */
  19848. length: number;
  19849. /**
  19850. * Stiffness of the spring
  19851. */
  19852. stiffness: number;
  19853. /**
  19854. * Damping of the spring
  19855. */
  19856. damping: number;
  19857. /** this callback will be called when applying the force to the impostors. */
  19858. forceApplicationCallback: () => void;
  19859. }
  19860. }
  19861. declare module BABYLON {
  19862. /**
  19863. * Holds the data for the raycast result
  19864. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19865. */
  19866. export class PhysicsRaycastResult {
  19867. private _hasHit;
  19868. private _hitDistance;
  19869. private _hitNormalWorld;
  19870. private _hitPointWorld;
  19871. private _rayFromWorld;
  19872. private _rayToWorld;
  19873. /**
  19874. * Gets if there was a hit
  19875. */
  19876. readonly hasHit: boolean;
  19877. /**
  19878. * Gets the distance from the hit
  19879. */
  19880. readonly hitDistance: number;
  19881. /**
  19882. * Gets the hit normal/direction in the world
  19883. */
  19884. readonly hitNormalWorld: Vector3;
  19885. /**
  19886. * Gets the hit point in the world
  19887. */
  19888. readonly hitPointWorld: Vector3;
  19889. /**
  19890. * Gets the ray "start point" of the ray in the world
  19891. */
  19892. readonly rayFromWorld: Vector3;
  19893. /**
  19894. * Gets the ray "end point" of the ray in the world
  19895. */
  19896. readonly rayToWorld: Vector3;
  19897. /**
  19898. * Sets the hit data (normal & point in world space)
  19899. * @param hitNormalWorld defines the normal in world space
  19900. * @param hitPointWorld defines the point in world space
  19901. */
  19902. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  19903. /**
  19904. * Sets the distance from the start point to the hit point
  19905. * @param distance
  19906. */
  19907. setHitDistance(distance: number): void;
  19908. /**
  19909. * Calculates the distance manually
  19910. */
  19911. calculateHitDistance(): void;
  19912. /**
  19913. * Resets all the values to default
  19914. * @param from The from point on world space
  19915. * @param to The to point on world space
  19916. */
  19917. reset(from?: Vector3, to?: Vector3): void;
  19918. }
  19919. /**
  19920. * Interface for the size containing width and height
  19921. */
  19922. interface IXYZ {
  19923. /**
  19924. * X
  19925. */
  19926. x: number;
  19927. /**
  19928. * Y
  19929. */
  19930. y: number;
  19931. /**
  19932. * Z
  19933. */
  19934. z: number;
  19935. }
  19936. }
  19937. declare module BABYLON {
  19938. /**
  19939. * Interface used to describe a physics joint
  19940. */
  19941. export interface PhysicsImpostorJoint {
  19942. /** Defines the main impostor to which the joint is linked */
  19943. mainImpostor: PhysicsImpostor;
  19944. /** Defines the impostor that is connected to the main impostor using this joint */
  19945. connectedImpostor: PhysicsImpostor;
  19946. /** Defines the joint itself */
  19947. joint: PhysicsJoint;
  19948. }
  19949. /** @hidden */
  19950. export interface IPhysicsEnginePlugin {
  19951. world: any;
  19952. name: string;
  19953. setGravity(gravity: Vector3): void;
  19954. setTimeStep(timeStep: number): void;
  19955. getTimeStep(): number;
  19956. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  19957. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19958. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19959. generatePhysicsBody(impostor: PhysicsImpostor): void;
  19960. removePhysicsBody(impostor: PhysicsImpostor): void;
  19961. generateJoint(joint: PhysicsImpostorJoint): void;
  19962. removeJoint(joint: PhysicsImpostorJoint): void;
  19963. isSupported(): boolean;
  19964. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  19965. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  19966. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19967. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19968. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19969. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19970. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  19971. getBodyMass(impostor: PhysicsImpostor): number;
  19972. getBodyFriction(impostor: PhysicsImpostor): number;
  19973. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  19974. getBodyRestitution(impostor: PhysicsImpostor): number;
  19975. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  19976. getBodyPressure?(impostor: PhysicsImpostor): number;
  19977. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  19978. getBodyStiffness?(impostor: PhysicsImpostor): number;
  19979. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  19980. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  19981. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  19982. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  19983. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  19984. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  19985. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  19986. sleepBody(impostor: PhysicsImpostor): void;
  19987. wakeUpBody(impostor: PhysicsImpostor): void;
  19988. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  19989. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  19990. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  19991. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19992. getRadius(impostor: PhysicsImpostor): number;
  19993. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  19994. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  19995. dispose(): void;
  19996. }
  19997. /**
  19998. * Interface used to define a physics engine
  19999. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  20000. */
  20001. export interface IPhysicsEngine {
  20002. /**
  20003. * Gets the gravity vector used by the simulation
  20004. */
  20005. gravity: Vector3;
  20006. /**
  20007. * Sets the gravity vector used by the simulation
  20008. * @param gravity defines the gravity vector to use
  20009. */
  20010. setGravity(gravity: Vector3): void;
  20011. /**
  20012. * Set the time step of the physics engine.
  20013. * Default is 1/60.
  20014. * To slow it down, enter 1/600 for example.
  20015. * To speed it up, 1/30
  20016. * @param newTimeStep the new timestep to apply to this world.
  20017. */
  20018. setTimeStep(newTimeStep: number): void;
  20019. /**
  20020. * Get the time step of the physics engine.
  20021. * @returns the current time step
  20022. */
  20023. getTimeStep(): number;
  20024. /**
  20025. * Release all resources
  20026. */
  20027. dispose(): void;
  20028. /**
  20029. * Gets the name of the current physics plugin
  20030. * @returns the name of the plugin
  20031. */
  20032. getPhysicsPluginName(): string;
  20033. /**
  20034. * Adding a new impostor for the impostor tracking.
  20035. * This will be done by the impostor itself.
  20036. * @param impostor the impostor to add
  20037. */
  20038. addImpostor(impostor: PhysicsImpostor): void;
  20039. /**
  20040. * Remove an impostor from the engine.
  20041. * This impostor and its mesh will not longer be updated by the physics engine.
  20042. * @param impostor the impostor to remove
  20043. */
  20044. removeImpostor(impostor: PhysicsImpostor): void;
  20045. /**
  20046. * Add a joint to the physics engine
  20047. * @param mainImpostor defines the main impostor to which the joint is added.
  20048. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  20049. * @param joint defines the joint that will connect both impostors.
  20050. */
  20051. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20052. /**
  20053. * Removes a joint from the simulation
  20054. * @param mainImpostor defines the impostor used with the joint
  20055. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  20056. * @param joint defines the joint to remove
  20057. */
  20058. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20059. /**
  20060. * Gets the current plugin used to run the simulation
  20061. * @returns current plugin
  20062. */
  20063. getPhysicsPlugin(): IPhysicsEnginePlugin;
  20064. /**
  20065. * Gets the list of physic impostors
  20066. * @returns an array of PhysicsImpostor
  20067. */
  20068. getImpostors(): Array<PhysicsImpostor>;
  20069. /**
  20070. * Gets the impostor for a physics enabled object
  20071. * @param object defines the object impersonated by the impostor
  20072. * @returns the PhysicsImpostor or null if not found
  20073. */
  20074. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20075. /**
  20076. * Gets the impostor for a physics body object
  20077. * @param body defines physics body used by the impostor
  20078. * @returns the PhysicsImpostor or null if not found
  20079. */
  20080. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  20081. /**
  20082. * Does a raycast in the physics world
  20083. * @param from when should the ray start?
  20084. * @param to when should the ray end?
  20085. * @returns PhysicsRaycastResult
  20086. */
  20087. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20088. /**
  20089. * Called by the scene. No need to call it.
  20090. * @param delta defines the timespam between frames
  20091. */
  20092. _step(delta: number): void;
  20093. }
  20094. }
  20095. declare module BABYLON {
  20096. /**
  20097. * The interface for the physics imposter parameters
  20098. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20099. */
  20100. export interface PhysicsImpostorParameters {
  20101. /**
  20102. * The mass of the physics imposter
  20103. */
  20104. mass: number;
  20105. /**
  20106. * The friction of the physics imposter
  20107. */
  20108. friction?: number;
  20109. /**
  20110. * The coefficient of restitution of the physics imposter
  20111. */
  20112. restitution?: number;
  20113. /**
  20114. * The native options of the physics imposter
  20115. */
  20116. nativeOptions?: any;
  20117. /**
  20118. * Specifies if the parent should be ignored
  20119. */
  20120. ignoreParent?: boolean;
  20121. /**
  20122. * Specifies if bi-directional transformations should be disabled
  20123. */
  20124. disableBidirectionalTransformation?: boolean;
  20125. /**
  20126. * The pressure inside the physics imposter, soft object only
  20127. */
  20128. pressure?: number;
  20129. /**
  20130. * The stiffness the physics imposter, soft object only
  20131. */
  20132. stiffness?: number;
  20133. /**
  20134. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  20135. */
  20136. velocityIterations?: number;
  20137. /**
  20138. * The number of iterations used in maintaining consistent vertex positions, soft object only
  20139. */
  20140. positionIterations?: number;
  20141. /**
  20142. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  20143. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  20144. * Add to fix multiple points
  20145. */
  20146. fixedPoints?: number;
  20147. /**
  20148. * The collision margin around a soft object
  20149. */
  20150. margin?: number;
  20151. /**
  20152. * The collision margin around a soft object
  20153. */
  20154. damping?: number;
  20155. /**
  20156. * The path for a rope based on an extrusion
  20157. */
  20158. path?: any;
  20159. /**
  20160. * The shape of an extrusion used for a rope based on an extrusion
  20161. */
  20162. shape?: any;
  20163. }
  20164. /**
  20165. * Interface for a physics-enabled object
  20166. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20167. */
  20168. export interface IPhysicsEnabledObject {
  20169. /**
  20170. * The position of the physics-enabled object
  20171. */
  20172. position: Vector3;
  20173. /**
  20174. * The rotation of the physics-enabled object
  20175. */
  20176. rotationQuaternion: Nullable<Quaternion>;
  20177. /**
  20178. * The scale of the physics-enabled object
  20179. */
  20180. scaling: Vector3;
  20181. /**
  20182. * The rotation of the physics-enabled object
  20183. */
  20184. rotation?: Vector3;
  20185. /**
  20186. * The parent of the physics-enabled object
  20187. */
  20188. parent?: any;
  20189. /**
  20190. * The bounding info of the physics-enabled object
  20191. * @returns The bounding info of the physics-enabled object
  20192. */
  20193. getBoundingInfo(): BoundingInfo;
  20194. /**
  20195. * Computes the world matrix
  20196. * @param force Specifies if the world matrix should be computed by force
  20197. * @returns A world matrix
  20198. */
  20199. computeWorldMatrix(force: boolean): Matrix;
  20200. /**
  20201. * Gets the world matrix
  20202. * @returns A world matrix
  20203. */
  20204. getWorldMatrix?(): Matrix;
  20205. /**
  20206. * Gets the child meshes
  20207. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  20208. * @returns An array of abstract meshes
  20209. */
  20210. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  20211. /**
  20212. * Gets the vertex data
  20213. * @param kind The type of vertex data
  20214. * @returns A nullable array of numbers, or a float32 array
  20215. */
  20216. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  20217. /**
  20218. * Gets the indices from the mesh
  20219. * @returns A nullable array of index arrays
  20220. */
  20221. getIndices?(): Nullable<IndicesArray>;
  20222. /**
  20223. * Gets the scene from the mesh
  20224. * @returns the indices array or null
  20225. */
  20226. getScene?(): Scene;
  20227. /**
  20228. * Gets the absolute position from the mesh
  20229. * @returns the absolute position
  20230. */
  20231. getAbsolutePosition(): Vector3;
  20232. /**
  20233. * Gets the absolute pivot point from the mesh
  20234. * @returns the absolute pivot point
  20235. */
  20236. getAbsolutePivotPoint(): Vector3;
  20237. /**
  20238. * Rotates the mesh
  20239. * @param axis The axis of rotation
  20240. * @param amount The amount of rotation
  20241. * @param space The space of the rotation
  20242. * @returns The rotation transform node
  20243. */
  20244. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  20245. /**
  20246. * Translates the mesh
  20247. * @param axis The axis of translation
  20248. * @param distance The distance of translation
  20249. * @param space The space of the translation
  20250. * @returns The transform node
  20251. */
  20252. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  20253. /**
  20254. * Sets the absolute position of the mesh
  20255. * @param absolutePosition The absolute position of the mesh
  20256. * @returns The transform node
  20257. */
  20258. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  20259. /**
  20260. * Gets the class name of the mesh
  20261. * @returns The class name
  20262. */
  20263. getClassName(): string;
  20264. }
  20265. /**
  20266. * Represents a physics imposter
  20267. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20268. */
  20269. export class PhysicsImpostor {
  20270. /**
  20271. * The physics-enabled object used as the physics imposter
  20272. */
  20273. object: IPhysicsEnabledObject;
  20274. /**
  20275. * The type of the physics imposter
  20276. */
  20277. type: number;
  20278. private _options;
  20279. private _scene?;
  20280. /**
  20281. * The default object size of the imposter
  20282. */
  20283. static DEFAULT_OBJECT_SIZE: Vector3;
  20284. /**
  20285. * The identity quaternion of the imposter
  20286. */
  20287. static IDENTITY_QUATERNION: Quaternion;
  20288. /** @hidden */
  20289. _pluginData: any;
  20290. private _physicsEngine;
  20291. private _physicsBody;
  20292. private _bodyUpdateRequired;
  20293. private _onBeforePhysicsStepCallbacks;
  20294. private _onAfterPhysicsStepCallbacks;
  20295. /** @hidden */
  20296. _onPhysicsCollideCallbacks: Array<{
  20297. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  20298. otherImpostors: Array<PhysicsImpostor>;
  20299. }>;
  20300. private _deltaPosition;
  20301. private _deltaRotation;
  20302. private _deltaRotationConjugated;
  20303. /** hidden */
  20304. _isFromLine: boolean;
  20305. private _parent;
  20306. private _isDisposed;
  20307. private static _tmpVecs;
  20308. private static _tmpQuat;
  20309. /**
  20310. * Specifies if the physics imposter is disposed
  20311. */
  20312. readonly isDisposed: boolean;
  20313. /**
  20314. * Gets the mass of the physics imposter
  20315. */
  20316. mass: number;
  20317. /**
  20318. * Gets the coefficient of friction
  20319. */
  20320. /**
  20321. * Sets the coefficient of friction
  20322. */
  20323. friction: number;
  20324. /**
  20325. * Gets the coefficient of restitution
  20326. */
  20327. /**
  20328. * Sets the coefficient of restitution
  20329. */
  20330. restitution: number;
  20331. /**
  20332. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  20333. */
  20334. /**
  20335. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  20336. */
  20337. pressure: number;
  20338. /**
  20339. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20340. */
  20341. /**
  20342. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20343. */
  20344. stiffness: number;
  20345. /**
  20346. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20347. */
  20348. /**
  20349. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20350. */
  20351. velocityIterations: number;
  20352. /**
  20353. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20354. */
  20355. /**
  20356. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20357. */
  20358. positionIterations: number;
  20359. /**
  20360. * The unique id of the physics imposter
  20361. * set by the physics engine when adding this impostor to the array
  20362. */
  20363. uniqueId: number;
  20364. /**
  20365. * @hidden
  20366. */
  20367. soft: boolean;
  20368. /**
  20369. * @hidden
  20370. */
  20371. segments: number;
  20372. private _joints;
  20373. /**
  20374. * Initializes the physics imposter
  20375. * @param object The physics-enabled object used as the physics imposter
  20376. * @param type The type of the physics imposter
  20377. * @param _options The options for the physics imposter
  20378. * @param _scene The Babylon scene
  20379. */
  20380. constructor(
  20381. /**
  20382. * The physics-enabled object used as the physics imposter
  20383. */
  20384. object: IPhysicsEnabledObject,
  20385. /**
  20386. * The type of the physics imposter
  20387. */
  20388. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  20389. /**
  20390. * This function will completly initialize this impostor.
  20391. * It will create a new body - but only if this mesh has no parent.
  20392. * If it has, this impostor will not be used other than to define the impostor
  20393. * of the child mesh.
  20394. * @hidden
  20395. */
  20396. _init(): void;
  20397. private _getPhysicsParent;
  20398. /**
  20399. * Should a new body be generated.
  20400. * @returns boolean specifying if body initialization is required
  20401. */
  20402. isBodyInitRequired(): boolean;
  20403. /**
  20404. * Sets the updated scaling
  20405. * @param updated Specifies if the scaling is updated
  20406. */
  20407. setScalingUpdated(): void;
  20408. /**
  20409. * Force a regeneration of this or the parent's impostor's body.
  20410. * Use under cautious - This will remove all joints already implemented.
  20411. */
  20412. forceUpdate(): void;
  20413. /**
  20414. * Gets the body that holds this impostor. Either its own, or its parent.
  20415. */
  20416. /**
  20417. * Set the physics body. Used mainly by the physics engine/plugin
  20418. */
  20419. physicsBody: any;
  20420. /**
  20421. * Get the parent of the physics imposter
  20422. * @returns Physics imposter or null
  20423. */
  20424. /**
  20425. * Sets the parent of the physics imposter
  20426. */
  20427. parent: Nullable<PhysicsImpostor>;
  20428. /**
  20429. * Resets the update flags
  20430. */
  20431. resetUpdateFlags(): void;
  20432. /**
  20433. * Gets the object extend size
  20434. * @returns the object extend size
  20435. */
  20436. getObjectExtendSize(): Vector3;
  20437. /**
  20438. * Gets the object center
  20439. * @returns The object center
  20440. */
  20441. getObjectCenter(): Vector3;
  20442. /**
  20443. * Get a specific parametes from the options parameter
  20444. * @param paramName The object parameter name
  20445. * @returns The object parameter
  20446. */
  20447. getParam(paramName: string): any;
  20448. /**
  20449. * Sets a specific parameter in the options given to the physics plugin
  20450. * @param paramName The parameter name
  20451. * @param value The value of the parameter
  20452. */
  20453. setParam(paramName: string, value: number): void;
  20454. /**
  20455. * Specifically change the body's mass option. Won't recreate the physics body object
  20456. * @param mass The mass of the physics imposter
  20457. */
  20458. setMass(mass: number): void;
  20459. /**
  20460. * Gets the linear velocity
  20461. * @returns linear velocity or null
  20462. */
  20463. getLinearVelocity(): Nullable<Vector3>;
  20464. /**
  20465. * Sets the linear velocity
  20466. * @param velocity linear velocity or null
  20467. */
  20468. setLinearVelocity(velocity: Nullable<Vector3>): void;
  20469. /**
  20470. * Gets the angular velocity
  20471. * @returns angular velocity or null
  20472. */
  20473. getAngularVelocity(): Nullable<Vector3>;
  20474. /**
  20475. * Sets the angular velocity
  20476. * @param velocity The velocity or null
  20477. */
  20478. setAngularVelocity(velocity: Nullable<Vector3>): void;
  20479. /**
  20480. * Execute a function with the physics plugin native code
  20481. * Provide a function the will have two variables - the world object and the physics body object
  20482. * @param func The function to execute with the physics plugin native code
  20483. */
  20484. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  20485. /**
  20486. * Register a function that will be executed before the physics world is stepping forward
  20487. * @param func The function to execute before the physics world is stepped forward
  20488. */
  20489. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20490. /**
  20491. * Unregister a function that will be executed before the physics world is stepping forward
  20492. * @param func The function to execute before the physics world is stepped forward
  20493. */
  20494. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20495. /**
  20496. * Register a function that will be executed after the physics step
  20497. * @param func The function to execute after physics step
  20498. */
  20499. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20500. /**
  20501. * Unregisters a function that will be executed after the physics step
  20502. * @param func The function to execute after physics step
  20503. */
  20504. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20505. /**
  20506. * register a function that will be executed when this impostor collides against a different body
  20507. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  20508. * @param func Callback that is executed on collision
  20509. */
  20510. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  20511. /**
  20512. * Unregisters the physics imposter on contact
  20513. * @param collideAgainst The physics object to collide against
  20514. * @param func Callback to execute on collision
  20515. */
  20516. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  20517. private _tmpQuat;
  20518. private _tmpQuat2;
  20519. /**
  20520. * Get the parent rotation
  20521. * @returns The parent rotation
  20522. */
  20523. getParentsRotation(): Quaternion;
  20524. /**
  20525. * this function is executed by the physics engine.
  20526. */
  20527. beforeStep: () => void;
  20528. /**
  20529. * this function is executed by the physics engine
  20530. */
  20531. afterStep: () => void;
  20532. /**
  20533. * Legacy collision detection event support
  20534. */
  20535. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  20536. /**
  20537. * event and body object due to cannon's event-based architecture.
  20538. */
  20539. onCollide: (e: {
  20540. body: any;
  20541. }) => void;
  20542. /**
  20543. * Apply a force
  20544. * @param force The force to apply
  20545. * @param contactPoint The contact point for the force
  20546. * @returns The physics imposter
  20547. */
  20548. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20549. /**
  20550. * Apply an impulse
  20551. * @param force The impulse force
  20552. * @param contactPoint The contact point for the impulse force
  20553. * @returns The physics imposter
  20554. */
  20555. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20556. /**
  20557. * A help function to create a joint
  20558. * @param otherImpostor A physics imposter used to create a joint
  20559. * @param jointType The type of joint
  20560. * @param jointData The data for the joint
  20561. * @returns The physics imposter
  20562. */
  20563. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  20564. /**
  20565. * Add a joint to this impostor with a different impostor
  20566. * @param otherImpostor A physics imposter used to add a joint
  20567. * @param joint The joint to add
  20568. * @returns The physics imposter
  20569. */
  20570. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  20571. /**
  20572. * Add an anchor to a cloth impostor
  20573. * @param otherImpostor rigid impostor to anchor to
  20574. * @param width ratio across width from 0 to 1
  20575. * @param height ratio up height from 0 to 1
  20576. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  20577. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  20578. * @returns impostor the soft imposter
  20579. */
  20580. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20581. /**
  20582. * Add a hook to a rope impostor
  20583. * @param otherImpostor rigid impostor to anchor to
  20584. * @param length ratio across rope from 0 to 1
  20585. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  20586. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  20587. * @returns impostor the rope imposter
  20588. */
  20589. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20590. /**
  20591. * Will keep this body still, in a sleep mode.
  20592. * @returns the physics imposter
  20593. */
  20594. sleep(): PhysicsImpostor;
  20595. /**
  20596. * Wake the body up.
  20597. * @returns The physics imposter
  20598. */
  20599. wakeUp(): PhysicsImpostor;
  20600. /**
  20601. * Clones the physics imposter
  20602. * @param newObject The physics imposter clones to this physics-enabled object
  20603. * @returns A nullable physics imposter
  20604. */
  20605. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20606. /**
  20607. * Disposes the physics imposter
  20608. */
  20609. dispose(): void;
  20610. /**
  20611. * Sets the delta position
  20612. * @param position The delta position amount
  20613. */
  20614. setDeltaPosition(position: Vector3): void;
  20615. /**
  20616. * Sets the delta rotation
  20617. * @param rotation The delta rotation amount
  20618. */
  20619. setDeltaRotation(rotation: Quaternion): void;
  20620. /**
  20621. * Gets the box size of the physics imposter and stores the result in the input parameter
  20622. * @param result Stores the box size
  20623. * @returns The physics imposter
  20624. */
  20625. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  20626. /**
  20627. * Gets the radius of the physics imposter
  20628. * @returns Radius of the physics imposter
  20629. */
  20630. getRadius(): number;
  20631. /**
  20632. * Sync a bone with this impostor
  20633. * @param bone The bone to sync to the impostor.
  20634. * @param boneMesh The mesh that the bone is influencing.
  20635. * @param jointPivot The pivot of the joint / bone in local space.
  20636. * @param distToJoint Optional distance from the impostor to the joint.
  20637. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20638. */
  20639. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  20640. /**
  20641. * Sync impostor to a bone
  20642. * @param bone The bone that the impostor will be synced to.
  20643. * @param boneMesh The mesh that the bone is influencing.
  20644. * @param jointPivot The pivot of the joint / bone in local space.
  20645. * @param distToJoint Optional distance from the impostor to the joint.
  20646. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20647. * @param boneAxis Optional vector3 axis the bone is aligned with
  20648. */
  20649. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  20650. /**
  20651. * No-Imposter type
  20652. */
  20653. static NoImpostor: number;
  20654. /**
  20655. * Sphere-Imposter type
  20656. */
  20657. static SphereImpostor: number;
  20658. /**
  20659. * Box-Imposter type
  20660. */
  20661. static BoxImpostor: number;
  20662. /**
  20663. * Plane-Imposter type
  20664. */
  20665. static PlaneImpostor: number;
  20666. /**
  20667. * Mesh-imposter type
  20668. */
  20669. static MeshImpostor: number;
  20670. /**
  20671. * Cylinder-Imposter type
  20672. */
  20673. static CylinderImpostor: number;
  20674. /**
  20675. * Particle-Imposter type
  20676. */
  20677. static ParticleImpostor: number;
  20678. /**
  20679. * Heightmap-Imposter type
  20680. */
  20681. static HeightmapImpostor: number;
  20682. /**
  20683. * ConvexHull-Impostor type (Ammo.js plugin only)
  20684. */
  20685. static ConvexHullImpostor: number;
  20686. /**
  20687. * Rope-Imposter type
  20688. */
  20689. static RopeImpostor: number;
  20690. /**
  20691. * Cloth-Imposter type
  20692. */
  20693. static ClothImpostor: number;
  20694. /**
  20695. * Softbody-Imposter type
  20696. */
  20697. static SoftbodyImpostor: number;
  20698. }
  20699. }
  20700. declare module BABYLON {
  20701. /**
  20702. * @hidden
  20703. **/
  20704. export class _CreationDataStorage {
  20705. closePath?: boolean;
  20706. closeArray?: boolean;
  20707. idx: number[];
  20708. dashSize: number;
  20709. gapSize: number;
  20710. path3D: Path3D;
  20711. pathArray: Vector3[][];
  20712. arc: number;
  20713. radius: number;
  20714. cap: number;
  20715. tessellation: number;
  20716. }
  20717. /**
  20718. * @hidden
  20719. **/
  20720. class _InstanceDataStorage {
  20721. visibleInstances: any;
  20722. batchCache: _InstancesBatch;
  20723. instancesBufferSize: number;
  20724. instancesBuffer: Nullable<Buffer>;
  20725. instancesData: Float32Array;
  20726. overridenInstanceCount: number;
  20727. isFrozen: boolean;
  20728. previousBatch: _InstancesBatch;
  20729. hardwareInstancedRendering: boolean;
  20730. sideOrientation: number;
  20731. }
  20732. /**
  20733. * @hidden
  20734. **/
  20735. export class _InstancesBatch {
  20736. mustReturn: boolean;
  20737. visibleInstances: Nullable<InstancedMesh[]>[];
  20738. renderSelf: boolean[];
  20739. hardwareInstancedRendering: boolean[];
  20740. }
  20741. /**
  20742. * Class used to represent renderable models
  20743. */
  20744. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  20745. /**
  20746. * Mesh side orientation : usually the external or front surface
  20747. */
  20748. static readonly FRONTSIDE: number;
  20749. /**
  20750. * Mesh side orientation : usually the internal or back surface
  20751. */
  20752. static readonly BACKSIDE: number;
  20753. /**
  20754. * Mesh side orientation : both internal and external or front and back surfaces
  20755. */
  20756. static readonly DOUBLESIDE: number;
  20757. /**
  20758. * Mesh side orientation : by default, `FRONTSIDE`
  20759. */
  20760. static readonly DEFAULTSIDE: number;
  20761. /**
  20762. * Mesh cap setting : no cap
  20763. */
  20764. static readonly NO_CAP: number;
  20765. /**
  20766. * Mesh cap setting : one cap at the beginning of the mesh
  20767. */
  20768. static readonly CAP_START: number;
  20769. /**
  20770. * Mesh cap setting : one cap at the end of the mesh
  20771. */
  20772. static readonly CAP_END: number;
  20773. /**
  20774. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  20775. */
  20776. static readonly CAP_ALL: number;
  20777. /**
  20778. * Mesh pattern setting : no flip or rotate
  20779. */
  20780. static readonly NO_FLIP: number;
  20781. /**
  20782. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  20783. */
  20784. static readonly FLIP_TILE: number;
  20785. /**
  20786. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  20787. */
  20788. static readonly ROTATE_TILE: number;
  20789. /**
  20790. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  20791. */
  20792. static readonly FLIP_ROW: number;
  20793. /**
  20794. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  20795. */
  20796. static readonly ROTATE_ROW: number;
  20797. /**
  20798. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  20799. */
  20800. static readonly FLIP_N_ROTATE_TILE: number;
  20801. /**
  20802. * Mesh pattern setting : rotate pattern and rotate
  20803. */
  20804. static readonly FLIP_N_ROTATE_ROW: number;
  20805. /**
  20806. * Mesh tile positioning : part tiles same on left/right or top/bottom
  20807. */
  20808. static readonly CENTER: number;
  20809. /**
  20810. * Mesh tile positioning : part tiles on left
  20811. */
  20812. static readonly LEFT: number;
  20813. /**
  20814. * Mesh tile positioning : part tiles on right
  20815. */
  20816. static readonly RIGHT: number;
  20817. /**
  20818. * Mesh tile positioning : part tiles on top
  20819. */
  20820. static readonly TOP: number;
  20821. /**
  20822. * Mesh tile positioning : part tiles on bottom
  20823. */
  20824. static readonly BOTTOM: number;
  20825. /**
  20826. * Gets the default side orientation.
  20827. * @param orientation the orientation to value to attempt to get
  20828. * @returns the default orientation
  20829. * @hidden
  20830. */
  20831. static _GetDefaultSideOrientation(orientation?: number): number;
  20832. private _internalMeshDataInfo;
  20833. /**
  20834. * An event triggered before rendering the mesh
  20835. */
  20836. readonly onBeforeRenderObservable: Observable<Mesh>;
  20837. /**
  20838. * An event triggered before binding the mesh
  20839. */
  20840. readonly onBeforeBindObservable: Observable<Mesh>;
  20841. /**
  20842. * An event triggered after rendering the mesh
  20843. */
  20844. readonly onAfterRenderObservable: Observable<Mesh>;
  20845. /**
  20846. * An event triggered before drawing the mesh
  20847. */
  20848. readonly onBeforeDrawObservable: Observable<Mesh>;
  20849. private _onBeforeDrawObserver;
  20850. /**
  20851. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  20852. */
  20853. onBeforeDraw: () => void;
  20854. /**
  20855. * Gets the delay loading state of the mesh (when delay loading is turned on)
  20856. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  20857. */
  20858. delayLoadState: number;
  20859. /**
  20860. * Gets the list of instances created from this mesh
  20861. * it is not supposed to be modified manually.
  20862. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  20863. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20864. */
  20865. instances: InstancedMesh[];
  20866. /**
  20867. * Gets the file containing delay loading data for this mesh
  20868. */
  20869. delayLoadingFile: string;
  20870. /** @hidden */
  20871. _binaryInfo: any;
  20872. /**
  20873. * User defined function used to change how LOD level selection is done
  20874. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20875. */
  20876. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  20877. /**
  20878. * Gets or sets the morph target manager
  20879. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  20880. */
  20881. morphTargetManager: Nullable<MorphTargetManager>;
  20882. /** @hidden */
  20883. _creationDataStorage: Nullable<_CreationDataStorage>;
  20884. /** @hidden */
  20885. _geometry: Nullable<Geometry>;
  20886. /** @hidden */
  20887. _delayInfo: Array<string>;
  20888. /** @hidden */
  20889. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  20890. /** @hidden */
  20891. _instanceDataStorage: _InstanceDataStorage;
  20892. private _effectiveMaterial;
  20893. /** @hidden */
  20894. _shouldGenerateFlatShading: boolean;
  20895. /** @hidden */
  20896. _originalBuilderSideOrientation: number;
  20897. /**
  20898. * Use this property to change the original side orientation defined at construction time
  20899. */
  20900. overrideMaterialSideOrientation: Nullable<number>;
  20901. /**
  20902. * Gets the source mesh (the one used to clone this one from)
  20903. */
  20904. readonly source: Nullable<Mesh>;
  20905. /**
  20906. * Gets or sets a boolean indicating that this mesh does not use index buffer
  20907. */
  20908. isUnIndexed: boolean;
  20909. /**
  20910. * @constructor
  20911. * @param name The value used by scene.getMeshByName() to do a lookup.
  20912. * @param scene The scene to add this mesh to.
  20913. * @param parent The parent of this mesh, if it has one
  20914. * @param source An optional Mesh from which geometry is shared, cloned.
  20915. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20916. * When false, achieved by calling a clone(), also passing False.
  20917. * This will make creation of children, recursive.
  20918. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  20919. */
  20920. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  20921. /**
  20922. * Gets the class name
  20923. * @returns the string "Mesh".
  20924. */
  20925. getClassName(): string;
  20926. /** @hidden */
  20927. readonly _isMesh: boolean;
  20928. /**
  20929. * Returns a description of this mesh
  20930. * @param fullDetails define if full details about this mesh must be used
  20931. * @returns a descriptive string representing this mesh
  20932. */
  20933. toString(fullDetails?: boolean): string;
  20934. /** @hidden */
  20935. _unBindEffect(): void;
  20936. /**
  20937. * Gets a boolean indicating if this mesh has LOD
  20938. */
  20939. readonly hasLODLevels: boolean;
  20940. /**
  20941. * Gets the list of MeshLODLevel associated with the current mesh
  20942. * @returns an array of MeshLODLevel
  20943. */
  20944. getLODLevels(): MeshLODLevel[];
  20945. private _sortLODLevels;
  20946. /**
  20947. * Add a mesh as LOD level triggered at the given distance.
  20948. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20949. * @param distance The distance from the center of the object to show this level
  20950. * @param mesh The mesh to be added as LOD level (can be null)
  20951. * @return This mesh (for chaining)
  20952. */
  20953. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  20954. /**
  20955. * Returns the LOD level mesh at the passed distance or null if not found.
  20956. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20957. * @param distance The distance from the center of the object to show this level
  20958. * @returns a Mesh or `null`
  20959. */
  20960. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  20961. /**
  20962. * Remove a mesh from the LOD array
  20963. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20964. * @param mesh defines the mesh to be removed
  20965. * @return This mesh (for chaining)
  20966. */
  20967. removeLODLevel(mesh: Mesh): Mesh;
  20968. /**
  20969. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  20970. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20971. * @param camera defines the camera to use to compute distance
  20972. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  20973. * @return This mesh (for chaining)
  20974. */
  20975. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  20976. /**
  20977. * Gets the mesh internal Geometry object
  20978. */
  20979. readonly geometry: Nullable<Geometry>;
  20980. /**
  20981. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  20982. * @returns the total number of vertices
  20983. */
  20984. getTotalVertices(): number;
  20985. /**
  20986. * Returns the content of an associated vertex buffer
  20987. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20988. * - VertexBuffer.PositionKind
  20989. * - VertexBuffer.UVKind
  20990. * - VertexBuffer.UV2Kind
  20991. * - VertexBuffer.UV3Kind
  20992. * - VertexBuffer.UV4Kind
  20993. * - VertexBuffer.UV5Kind
  20994. * - VertexBuffer.UV6Kind
  20995. * - VertexBuffer.ColorKind
  20996. * - VertexBuffer.MatricesIndicesKind
  20997. * - VertexBuffer.MatricesIndicesExtraKind
  20998. * - VertexBuffer.MatricesWeightsKind
  20999. * - VertexBuffer.MatricesWeightsExtraKind
  21000. * @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
  21001. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  21002. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  21003. */
  21004. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21005. /**
  21006. * Returns the mesh VertexBuffer object from the requested `kind`
  21007. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21008. * - VertexBuffer.PositionKind
  21009. * - VertexBuffer.NormalKind
  21010. * - VertexBuffer.UVKind
  21011. * - VertexBuffer.UV2Kind
  21012. * - VertexBuffer.UV3Kind
  21013. * - VertexBuffer.UV4Kind
  21014. * - VertexBuffer.UV5Kind
  21015. * - VertexBuffer.UV6Kind
  21016. * - VertexBuffer.ColorKind
  21017. * - VertexBuffer.MatricesIndicesKind
  21018. * - VertexBuffer.MatricesIndicesExtraKind
  21019. * - VertexBuffer.MatricesWeightsKind
  21020. * - VertexBuffer.MatricesWeightsExtraKind
  21021. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  21022. */
  21023. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21024. /**
  21025. * Tests if a specific vertex buffer is associated with this mesh
  21026. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21027. * - VertexBuffer.PositionKind
  21028. * - VertexBuffer.NormalKind
  21029. * - VertexBuffer.UVKind
  21030. * - VertexBuffer.UV2Kind
  21031. * - VertexBuffer.UV3Kind
  21032. * - VertexBuffer.UV4Kind
  21033. * - VertexBuffer.UV5Kind
  21034. * - VertexBuffer.UV6Kind
  21035. * - VertexBuffer.ColorKind
  21036. * - VertexBuffer.MatricesIndicesKind
  21037. * - VertexBuffer.MatricesIndicesExtraKind
  21038. * - VertexBuffer.MatricesWeightsKind
  21039. * - VertexBuffer.MatricesWeightsExtraKind
  21040. * @returns a boolean
  21041. */
  21042. isVerticesDataPresent(kind: string): boolean;
  21043. /**
  21044. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  21045. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21046. * - VertexBuffer.PositionKind
  21047. * - VertexBuffer.UVKind
  21048. * - VertexBuffer.UV2Kind
  21049. * - VertexBuffer.UV3Kind
  21050. * - VertexBuffer.UV4Kind
  21051. * - VertexBuffer.UV5Kind
  21052. * - VertexBuffer.UV6Kind
  21053. * - VertexBuffer.ColorKind
  21054. * - VertexBuffer.MatricesIndicesKind
  21055. * - VertexBuffer.MatricesIndicesExtraKind
  21056. * - VertexBuffer.MatricesWeightsKind
  21057. * - VertexBuffer.MatricesWeightsExtraKind
  21058. * @returns a boolean
  21059. */
  21060. isVertexBufferUpdatable(kind: string): boolean;
  21061. /**
  21062. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  21063. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21064. * - VertexBuffer.PositionKind
  21065. * - VertexBuffer.NormalKind
  21066. * - VertexBuffer.UVKind
  21067. * - VertexBuffer.UV2Kind
  21068. * - VertexBuffer.UV3Kind
  21069. * - VertexBuffer.UV4Kind
  21070. * - VertexBuffer.UV5Kind
  21071. * - VertexBuffer.UV6Kind
  21072. * - VertexBuffer.ColorKind
  21073. * - VertexBuffer.MatricesIndicesKind
  21074. * - VertexBuffer.MatricesIndicesExtraKind
  21075. * - VertexBuffer.MatricesWeightsKind
  21076. * - VertexBuffer.MatricesWeightsExtraKind
  21077. * @returns an array of strings
  21078. */
  21079. getVerticesDataKinds(): string[];
  21080. /**
  21081. * Returns a positive integer : the total number of indices in this mesh geometry.
  21082. * @returns the numner of indices or zero if the mesh has no geometry.
  21083. */
  21084. getTotalIndices(): number;
  21085. /**
  21086. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21087. * @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.
  21088. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21089. * @returns the indices array or an empty array if the mesh has no geometry
  21090. */
  21091. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21092. readonly isBlocked: boolean;
  21093. /**
  21094. * Determine if the current mesh is ready to be rendered
  21095. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21096. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  21097. * @returns true if all associated assets are ready (material, textures, shaders)
  21098. */
  21099. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  21100. /**
  21101. * 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.
  21102. */
  21103. readonly areNormalsFrozen: boolean;
  21104. /**
  21105. * 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.
  21106. * @returns the current mesh
  21107. */
  21108. freezeNormals(): Mesh;
  21109. /**
  21110. * 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
  21111. * @returns the current mesh
  21112. */
  21113. unfreezeNormals(): Mesh;
  21114. /**
  21115. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  21116. */
  21117. overridenInstanceCount: number;
  21118. /** @hidden */
  21119. _preActivate(): Mesh;
  21120. /** @hidden */
  21121. _preActivateForIntermediateRendering(renderId: number): Mesh;
  21122. /** @hidden */
  21123. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  21124. /**
  21125. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  21126. * This means the mesh underlying bounding box and sphere are recomputed.
  21127. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  21128. * @returns the current mesh
  21129. */
  21130. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  21131. /** @hidden */
  21132. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  21133. /**
  21134. * This function will subdivide the mesh into multiple submeshes
  21135. * @param count defines the expected number of submeshes
  21136. */
  21137. subdivide(count: number): void;
  21138. /**
  21139. * Copy a FloatArray into a specific associated vertex buffer
  21140. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21141. * - VertexBuffer.PositionKind
  21142. * - VertexBuffer.UVKind
  21143. * - VertexBuffer.UV2Kind
  21144. * - VertexBuffer.UV3Kind
  21145. * - VertexBuffer.UV4Kind
  21146. * - VertexBuffer.UV5Kind
  21147. * - VertexBuffer.UV6Kind
  21148. * - VertexBuffer.ColorKind
  21149. * - VertexBuffer.MatricesIndicesKind
  21150. * - VertexBuffer.MatricesIndicesExtraKind
  21151. * - VertexBuffer.MatricesWeightsKind
  21152. * - VertexBuffer.MatricesWeightsExtraKind
  21153. * @param data defines the data source
  21154. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21155. * @param stride defines the data stride size (can be null)
  21156. * @returns the current mesh
  21157. */
  21158. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21159. /**
  21160. * Flags an associated vertex buffer as updatable
  21161. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  21162. * - VertexBuffer.PositionKind
  21163. * - VertexBuffer.UVKind
  21164. * - VertexBuffer.UV2Kind
  21165. * - VertexBuffer.UV3Kind
  21166. * - VertexBuffer.UV4Kind
  21167. * - VertexBuffer.UV5Kind
  21168. * - VertexBuffer.UV6Kind
  21169. * - VertexBuffer.ColorKind
  21170. * - VertexBuffer.MatricesIndicesKind
  21171. * - VertexBuffer.MatricesIndicesExtraKind
  21172. * - VertexBuffer.MatricesWeightsKind
  21173. * - VertexBuffer.MatricesWeightsExtraKind
  21174. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21175. */
  21176. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  21177. /**
  21178. * Sets the mesh global Vertex Buffer
  21179. * @param buffer defines the buffer to use
  21180. * @returns the current mesh
  21181. */
  21182. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  21183. /**
  21184. * Update a specific associated vertex buffer
  21185. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21186. * - VertexBuffer.PositionKind
  21187. * - VertexBuffer.UVKind
  21188. * - VertexBuffer.UV2Kind
  21189. * - VertexBuffer.UV3Kind
  21190. * - VertexBuffer.UV4Kind
  21191. * - VertexBuffer.UV5Kind
  21192. * - VertexBuffer.UV6Kind
  21193. * - VertexBuffer.ColorKind
  21194. * - VertexBuffer.MatricesIndicesKind
  21195. * - VertexBuffer.MatricesIndicesExtraKind
  21196. * - VertexBuffer.MatricesWeightsKind
  21197. * - VertexBuffer.MatricesWeightsExtraKind
  21198. * @param data defines the data source
  21199. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21200. * @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)
  21201. * @returns the current mesh
  21202. */
  21203. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21204. /**
  21205. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  21206. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  21207. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  21208. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  21209. * @returns the current mesh
  21210. */
  21211. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  21212. /**
  21213. * Creates a un-shared specific occurence of the geometry for the mesh.
  21214. * @returns the current mesh
  21215. */
  21216. makeGeometryUnique(): Mesh;
  21217. /**
  21218. * Set the index buffer of this mesh
  21219. * @param indices defines the source data
  21220. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  21221. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  21222. * @returns the current mesh
  21223. */
  21224. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  21225. /**
  21226. * Update the current index buffer
  21227. * @param indices defines the source data
  21228. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  21229. * @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)
  21230. * @returns the current mesh
  21231. */
  21232. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  21233. /**
  21234. * Invert the geometry to move from a right handed system to a left handed one.
  21235. * @returns the current mesh
  21236. */
  21237. toLeftHanded(): Mesh;
  21238. /** @hidden */
  21239. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  21240. /** @hidden */
  21241. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  21242. /**
  21243. * Registers for this mesh a javascript function called just before the rendering process
  21244. * @param func defines the function to call before rendering this mesh
  21245. * @returns the current mesh
  21246. */
  21247. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21248. /**
  21249. * Disposes a previously registered javascript function called before the rendering
  21250. * @param func defines the function to remove
  21251. * @returns the current mesh
  21252. */
  21253. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21254. /**
  21255. * Registers for this mesh a javascript function called just after the rendering is complete
  21256. * @param func defines the function to call after rendering this mesh
  21257. * @returns the current mesh
  21258. */
  21259. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21260. /**
  21261. * Disposes a previously registered javascript function called after the rendering.
  21262. * @param func defines the function to remove
  21263. * @returns the current mesh
  21264. */
  21265. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21266. /** @hidden */
  21267. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  21268. /** @hidden */
  21269. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  21270. /** @hidden */
  21271. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  21272. /** @hidden */
  21273. _freeze(): void;
  21274. /** @hidden */
  21275. _unFreeze(): void;
  21276. /**
  21277. * 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
  21278. * @param subMesh defines the subMesh to render
  21279. * @param enableAlphaMode defines if alpha mode can be changed
  21280. * @returns the current mesh
  21281. */
  21282. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  21283. private _onBeforeDraw;
  21284. /**
  21285. * Renormalize the mesh and patch it up if there are no weights
  21286. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  21287. * However in the case of zero weights then we set just a single influence to 1.
  21288. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  21289. */
  21290. cleanMatrixWeights(): void;
  21291. private normalizeSkinFourWeights;
  21292. private normalizeSkinWeightsAndExtra;
  21293. /**
  21294. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  21295. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  21296. * the user know there was an issue with importing the mesh
  21297. * @returns a validation object with skinned, valid and report string
  21298. */
  21299. validateSkinning(): {
  21300. skinned: boolean;
  21301. valid: boolean;
  21302. report: string;
  21303. };
  21304. /** @hidden */
  21305. _checkDelayState(): Mesh;
  21306. private _queueLoad;
  21307. /**
  21308. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  21309. * A mesh is in the frustum if its bounding box intersects the frustum
  21310. * @param frustumPlanes defines the frustum to test
  21311. * @returns true if the mesh is in the frustum planes
  21312. */
  21313. isInFrustum(frustumPlanes: Plane[]): boolean;
  21314. /**
  21315. * Sets the mesh material by the material or multiMaterial `id` property
  21316. * @param id is a string identifying the material or the multiMaterial
  21317. * @returns the current mesh
  21318. */
  21319. setMaterialByID(id: string): Mesh;
  21320. /**
  21321. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21322. * @returns an array of IAnimatable
  21323. */
  21324. getAnimatables(): IAnimatable[];
  21325. /**
  21326. * Modifies the mesh geometry according to the passed transformation matrix.
  21327. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21328. * The mesh normals are modified using the same transformation.
  21329. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21330. * @param transform defines the transform matrix to use
  21331. * @see http://doc.babylonjs.com/resources/baking_transformations
  21332. * @returns the current mesh
  21333. */
  21334. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21335. /**
  21336. * Modifies the mesh geometry according to its own current World Matrix.
  21337. * The mesh World Matrix is then reset.
  21338. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  21339. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21340. * @see http://doc.babylonjs.com/resources/baking_transformations
  21341. * @returns the current mesh
  21342. */
  21343. bakeCurrentTransformIntoVertices(): Mesh;
  21344. /** @hidden */
  21345. readonly _positions: Nullable<Vector3[]>;
  21346. /** @hidden */
  21347. _resetPointsArrayCache(): Mesh;
  21348. /** @hidden */
  21349. _generatePointsArray(): boolean;
  21350. /**
  21351. * Returns a new Mesh object generated from the current mesh properties.
  21352. * This method must not get confused with createInstance()
  21353. * @param name is a string, the name given to the new mesh
  21354. * @param newParent can be any Node object (default `null`)
  21355. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  21356. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  21357. * @returns a new mesh
  21358. */
  21359. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21360. /**
  21361. * Releases resources associated with this mesh.
  21362. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21363. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21364. */
  21365. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21366. /**
  21367. * Modifies the mesh geometry according to a displacement map.
  21368. * 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.
  21369. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21370. * @param url is a string, the URL from the image file is to be downloaded.
  21371. * @param minHeight is the lower limit of the displacement.
  21372. * @param maxHeight is the upper limit of the displacement.
  21373. * @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.
  21374. * @param uvOffset is an optional vector2 used to offset UV.
  21375. * @param uvScale is an optional vector2 used to scale UV.
  21376. * @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.
  21377. * @returns the Mesh.
  21378. */
  21379. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21380. /**
  21381. * Modifies the mesh geometry according to a displacementMap buffer.
  21382. * 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.
  21383. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21384. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  21385. * @param heightMapWidth is the width of the buffer image.
  21386. * @param heightMapHeight is the height of the buffer image.
  21387. * @param minHeight is the lower limit of the displacement.
  21388. * @param maxHeight is the upper limit of the displacement.
  21389. * @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.
  21390. * @param uvOffset is an optional vector2 used to offset UV.
  21391. * @param uvScale is an optional vector2 used to scale UV.
  21392. * @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.
  21393. * @returns the Mesh.
  21394. */
  21395. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21396. /**
  21397. * Modify the mesh to get a flat shading rendering.
  21398. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21399. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21400. * @returns current mesh
  21401. */
  21402. convertToFlatShadedMesh(): Mesh;
  21403. /**
  21404. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21405. * In other words, more vertices, no more indices and a single bigger VBO.
  21406. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21407. * @returns current mesh
  21408. */
  21409. convertToUnIndexedMesh(): Mesh;
  21410. /**
  21411. * Inverses facet orientations.
  21412. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21413. * @param flipNormals will also inverts the normals
  21414. * @returns current mesh
  21415. */
  21416. flipFaces(flipNormals?: boolean): Mesh;
  21417. /**
  21418. * Increase the number of facets and hence vertices in a mesh
  21419. * Vertex normals are interpolated from existing vertex normals
  21420. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21421. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  21422. */
  21423. increaseVertices(numberPerEdge: number): void;
  21424. /**
  21425. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  21426. * This will undo any application of covertToFlatShadedMesh
  21427. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21428. */
  21429. forceSharedVertices(): void;
  21430. /** @hidden */
  21431. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  21432. /** @hidden */
  21433. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  21434. /**
  21435. * Creates a new InstancedMesh object from the mesh model.
  21436. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21437. * @param name defines the name of the new instance
  21438. * @returns a new InstancedMesh
  21439. */
  21440. createInstance(name: string): InstancedMesh;
  21441. /**
  21442. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21443. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21444. * @returns the current mesh
  21445. */
  21446. synchronizeInstances(): Mesh;
  21447. /**
  21448. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21449. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21450. * This should be used together with the simplification to avoid disappearing triangles.
  21451. * @param successCallback an optional success callback to be called after the optimization finished.
  21452. * @returns the current mesh
  21453. */
  21454. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21455. /**
  21456. * Serialize current mesh
  21457. * @param serializationObject defines the object which will receive the serialization data
  21458. */
  21459. serialize(serializationObject: any): void;
  21460. /** @hidden */
  21461. _syncGeometryWithMorphTargetManager(): void;
  21462. /** @hidden */
  21463. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  21464. /**
  21465. * Returns a new Mesh object parsed from the source provided.
  21466. * @param parsedMesh is the source
  21467. * @param scene defines the hosting scene
  21468. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  21469. * @returns a new Mesh
  21470. */
  21471. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21472. /**
  21473. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  21474. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21475. * @param name defines the name of the mesh to create
  21476. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21477. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  21478. * @param closePath creates a seam between the first and the last points of each path of the path array
  21479. * @param offset is taken in account only if the `pathArray` is containing a single path
  21480. * @param scene defines the hosting scene
  21481. * @param updatable defines if the mesh must be flagged as updatable
  21482. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21483. * @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)
  21484. * @returns a new Mesh
  21485. */
  21486. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21487. /**
  21488. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  21489. * @param name defines the name of the mesh to create
  21490. * @param radius sets the radius size (float) of the polygon (default 0.5)
  21491. * @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
  21492. * @param scene defines the hosting scene
  21493. * @param updatable defines if the mesh must be flagged as updatable
  21494. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21495. * @returns a new Mesh
  21496. */
  21497. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21498. /**
  21499. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  21500. * @param name defines the name of the mesh to create
  21501. * @param size sets the size (float) of each box side (default 1)
  21502. * @param scene defines the hosting scene
  21503. * @param updatable defines if the mesh must be flagged as updatable
  21504. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21505. * @returns a new Mesh
  21506. */
  21507. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21508. /**
  21509. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  21510. * @param name defines the name of the mesh to create
  21511. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21512. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21513. * @param scene defines the hosting scene
  21514. * @param updatable defines if the mesh must be flagged as updatable
  21515. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21516. * @returns a new Mesh
  21517. */
  21518. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21519. /**
  21520. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  21521. * @param name defines the name of the mesh to create
  21522. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21523. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21524. * @param scene defines the hosting scene
  21525. * @returns a new Mesh
  21526. */
  21527. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  21528. /**
  21529. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  21530. * @param name defines the name of the mesh to create
  21531. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  21532. * @param diameterTop set the top cap diameter (floats, default 1)
  21533. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  21534. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  21535. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  21536. * @param scene defines the hosting scene
  21537. * @param updatable defines if the mesh must be flagged as updatable
  21538. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21539. * @returns a new Mesh
  21540. */
  21541. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21542. /**
  21543. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  21544. * @param name defines the name of the mesh to create
  21545. * @param diameter sets the diameter size (float) of the torus (default 1)
  21546. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  21547. * @param tessellation sets the number of torus sides (postive integer, default 16)
  21548. * @param scene defines the hosting scene
  21549. * @param updatable defines if the mesh must be flagged as updatable
  21550. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21551. * @returns a new Mesh
  21552. */
  21553. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21554. /**
  21555. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  21556. * @param name defines the name of the mesh to create
  21557. * @param radius sets the global radius size (float) of the torus knot (default 2)
  21558. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  21559. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  21560. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  21561. * @param p the number of windings on X axis (positive integers, default 2)
  21562. * @param q the number of windings on Y axis (positive integers, default 3)
  21563. * @param scene defines the hosting scene
  21564. * @param updatable defines if the mesh must be flagged as updatable
  21565. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21566. * @returns a new Mesh
  21567. */
  21568. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21569. /**
  21570. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  21571. * @param name defines the name of the mesh to create
  21572. * @param points is an array successive Vector3
  21573. * @param scene defines the hosting scene
  21574. * @param updatable defines if the mesh must be flagged as updatable
  21575. * @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).
  21576. * @returns a new Mesh
  21577. */
  21578. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21579. /**
  21580. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  21581. * @param name defines the name of the mesh to create
  21582. * @param points is an array successive Vector3
  21583. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  21584. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  21585. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  21586. * @param scene defines the hosting scene
  21587. * @param updatable defines if the mesh must be flagged as updatable
  21588. * @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)
  21589. * @returns a new Mesh
  21590. */
  21591. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21592. /**
  21593. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  21594. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21595. * 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.
  21596. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21597. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21598. * Remember you can only change the shape positions, not their number when updating a polygon.
  21599. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  21600. * @param name defines the name of the mesh to create
  21601. * @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
  21602. * @param scene defines the hosting scene
  21603. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21604. * @param updatable defines if the mesh must be flagged as updatable
  21605. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21606. * @param earcutInjection can be used to inject your own earcut reference
  21607. * @returns a new Mesh
  21608. */
  21609. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21610. /**
  21611. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  21612. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  21613. * @param name defines the name of the mesh to create
  21614. * @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
  21615. * @param depth defines the height of extrusion
  21616. * @param scene defines the hosting scene
  21617. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21618. * @param updatable defines if the mesh must be flagged as updatable
  21619. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21620. * @param earcutInjection can be used to inject your own earcut reference
  21621. * @returns a new Mesh
  21622. */
  21623. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21624. /**
  21625. * Creates an extruded shape mesh.
  21626. * 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
  21627. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21628. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21629. * @param name defines the name of the mesh to create
  21630. * @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
  21631. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21632. * @param scale is the value to scale the shape
  21633. * @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
  21634. * @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
  21635. * @param scene defines the hosting scene
  21636. * @param updatable defines if the mesh must be flagged as updatable
  21637. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21638. * @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)
  21639. * @returns a new Mesh
  21640. */
  21641. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21642. /**
  21643. * Creates an custom extruded shape mesh.
  21644. * The custom extrusion is a parametric shape.
  21645. * It has no predefined shape. Its final shape will depend on the input parameters.
  21646. * Please consider using the same method from the MeshBuilder class instead
  21647. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21648. * @param name defines the name of the mesh to create
  21649. * @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
  21650. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21651. * @param scaleFunction is a custom Javascript function called on each path point
  21652. * @param rotationFunction is a custom Javascript function called on each path point
  21653. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  21654. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  21655. * @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
  21656. * @param scene defines the hosting scene
  21657. * @param updatable defines if the mesh must be flagged as updatable
  21658. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21659. * @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)
  21660. * @returns a new Mesh
  21661. */
  21662. 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;
  21663. /**
  21664. * Creates lathe mesh.
  21665. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21666. * Please consider using the same method from the MeshBuilder class instead
  21667. * @param name defines the name of the mesh to create
  21668. * @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
  21669. * @param radius is the radius value of the lathe
  21670. * @param tessellation is the side number of the lathe.
  21671. * @param scene defines the hosting scene
  21672. * @param updatable defines if the mesh must be flagged as updatable
  21673. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21674. * @returns a new Mesh
  21675. */
  21676. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21677. /**
  21678. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  21679. * @param name defines the name of the mesh to create
  21680. * @param size sets the size (float) of both sides of the plane at once (default 1)
  21681. * @param scene defines the hosting scene
  21682. * @param updatable defines if the mesh must be flagged as updatable
  21683. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21684. * @returns a new Mesh
  21685. */
  21686. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21687. /**
  21688. * Creates a ground mesh.
  21689. * Please consider using the same method from the MeshBuilder class instead
  21690. * @param name defines the name of the mesh to create
  21691. * @param width set the width of the ground
  21692. * @param height set the height of the ground
  21693. * @param subdivisions sets the number of subdivisions per side
  21694. * @param scene defines the hosting scene
  21695. * @param updatable defines if the mesh must be flagged as updatable
  21696. * @returns a new Mesh
  21697. */
  21698. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21699. /**
  21700. * Creates a tiled ground mesh.
  21701. * Please consider using the same method from the MeshBuilder class instead
  21702. * @param name defines the name of the mesh to create
  21703. * @param xmin set the ground minimum X coordinate
  21704. * @param zmin set the ground minimum Y coordinate
  21705. * @param xmax set the ground maximum X coordinate
  21706. * @param zmax set the ground maximum Z coordinate
  21707. * @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
  21708. * @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
  21709. * @param scene defines the hosting scene
  21710. * @param updatable defines if the mesh must be flagged as updatable
  21711. * @returns a new Mesh
  21712. */
  21713. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21714. w: number;
  21715. h: number;
  21716. }, precision: {
  21717. w: number;
  21718. h: number;
  21719. }, scene: Scene, updatable?: boolean): Mesh;
  21720. /**
  21721. * Creates a ground mesh from a height map.
  21722. * Please consider using the same method from the MeshBuilder class instead
  21723. * @see http://doc.babylonjs.com/babylon101/height_map
  21724. * @param name defines the name of the mesh to create
  21725. * @param url sets the URL of the height map image resource
  21726. * @param width set the ground width size
  21727. * @param height set the ground height size
  21728. * @param subdivisions sets the number of subdivision per side
  21729. * @param minHeight is the minimum altitude on the ground
  21730. * @param maxHeight is the maximum altitude on the ground
  21731. * @param scene defines the hosting scene
  21732. * @param updatable defines if the mesh must be flagged as updatable
  21733. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  21734. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  21735. * @returns a new Mesh
  21736. */
  21737. 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;
  21738. /**
  21739. * Creates a tube mesh.
  21740. * The tube is a parametric shape.
  21741. * It has no predefined shape. Its final shape will depend on the input parameters.
  21742. * Please consider using the same method from the MeshBuilder class instead
  21743. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21744. * @param name defines the name of the mesh to create
  21745. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  21746. * @param radius sets the tube radius size
  21747. * @param tessellation is the number of sides on the tubular surface
  21748. * @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
  21749. * @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
  21750. * @param scene defines the hosting scene
  21751. * @param updatable defines if the mesh must be flagged as updatable
  21752. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21753. * @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)
  21754. * @returns a new Mesh
  21755. */
  21756. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21757. (i: number, distance: number): number;
  21758. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21759. /**
  21760. * Creates a polyhedron mesh.
  21761. * Please consider using the same method from the MeshBuilder class instead.
  21762. * * 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
  21763. * * The parameter `size` (positive float, default 1) sets the polygon size
  21764. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  21765. * * 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`
  21766. * * 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
  21767. * * 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)`)
  21768. * * 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
  21769. * * 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
  21770. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21771. * * 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
  21772. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21773. * @param name defines the name of the mesh to create
  21774. * @param options defines the options used to create the mesh
  21775. * @param scene defines the hosting scene
  21776. * @returns a new Mesh
  21777. */
  21778. static CreatePolyhedron(name: string, options: {
  21779. type?: number;
  21780. size?: number;
  21781. sizeX?: number;
  21782. sizeY?: number;
  21783. sizeZ?: number;
  21784. custom?: any;
  21785. faceUV?: Vector4[];
  21786. faceColors?: Color4[];
  21787. updatable?: boolean;
  21788. sideOrientation?: number;
  21789. }, scene: Scene): Mesh;
  21790. /**
  21791. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  21792. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  21793. * * 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`)
  21794. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  21795. * * 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
  21796. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21797. * * 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
  21798. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21799. * @param name defines the name of the mesh
  21800. * @param options defines the options used to create the mesh
  21801. * @param scene defines the hosting scene
  21802. * @returns a new Mesh
  21803. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  21804. */
  21805. static CreateIcoSphere(name: string, options: {
  21806. radius?: number;
  21807. flat?: boolean;
  21808. subdivisions?: number;
  21809. sideOrientation?: number;
  21810. updatable?: boolean;
  21811. }, scene: Scene): Mesh;
  21812. /**
  21813. * Creates a decal mesh.
  21814. * Please consider using the same method from the MeshBuilder class instead.
  21815. * A decal is a mesh usually applied as a model onto the surface of another mesh
  21816. * @param name defines the name of the mesh
  21817. * @param sourceMesh defines the mesh receiving the decal
  21818. * @param position sets the position of the decal in world coordinates
  21819. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  21820. * @param size sets the decal scaling
  21821. * @param angle sets the angle to rotate the decal
  21822. * @returns a new Mesh
  21823. */
  21824. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  21825. /**
  21826. * Prepare internal position array for software CPU skinning
  21827. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  21828. */
  21829. setPositionsForCPUSkinning(): Float32Array;
  21830. /**
  21831. * Prepare internal normal array for software CPU skinning
  21832. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21833. */
  21834. setNormalsForCPUSkinning(): Float32Array;
  21835. /**
  21836. * Updates the vertex buffer by applying transformation from the bones
  21837. * @param skeleton defines the skeleton to apply to current mesh
  21838. * @returns the current mesh
  21839. */
  21840. applySkeleton(skeleton: Skeleton): Mesh;
  21841. /**
  21842. * 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
  21843. * @param meshes defines the list of meshes to scan
  21844. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  21845. */
  21846. static MinMax(meshes: AbstractMesh[]): {
  21847. min: Vector3;
  21848. max: Vector3;
  21849. };
  21850. /**
  21851. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  21852. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  21853. * @returns a vector3
  21854. */
  21855. static Center(meshesOrMinMaxVector: {
  21856. min: Vector3;
  21857. max: Vector3;
  21858. } | AbstractMesh[]): Vector3;
  21859. /**
  21860. * Merge the array of meshes into a single mesh for performance reasons.
  21861. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  21862. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  21863. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  21864. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  21865. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  21866. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  21867. * @returns a new mesh
  21868. */
  21869. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  21870. /** @hidden */
  21871. addInstance(instance: InstancedMesh): void;
  21872. /** @hidden */
  21873. removeInstance(instance: InstancedMesh): void;
  21874. }
  21875. }
  21876. declare module BABYLON {
  21877. /**
  21878. * Base class for the main features of a material in Babylon.js
  21879. */
  21880. export class Material implements IAnimatable {
  21881. /**
  21882. * Returns the triangle fill mode
  21883. */
  21884. static readonly TriangleFillMode: number;
  21885. /**
  21886. * Returns the wireframe mode
  21887. */
  21888. static readonly WireFrameFillMode: number;
  21889. /**
  21890. * Returns the point fill mode
  21891. */
  21892. static readonly PointFillMode: number;
  21893. /**
  21894. * Returns the point list draw mode
  21895. */
  21896. static readonly PointListDrawMode: number;
  21897. /**
  21898. * Returns the line list draw mode
  21899. */
  21900. static readonly LineListDrawMode: number;
  21901. /**
  21902. * Returns the line loop draw mode
  21903. */
  21904. static readonly LineLoopDrawMode: number;
  21905. /**
  21906. * Returns the line strip draw mode
  21907. */
  21908. static readonly LineStripDrawMode: number;
  21909. /**
  21910. * Returns the triangle strip draw mode
  21911. */
  21912. static readonly TriangleStripDrawMode: number;
  21913. /**
  21914. * Returns the triangle fan draw mode
  21915. */
  21916. static readonly TriangleFanDrawMode: number;
  21917. /**
  21918. * Stores the clock-wise side orientation
  21919. */
  21920. static readonly ClockWiseSideOrientation: number;
  21921. /**
  21922. * Stores the counter clock-wise side orientation
  21923. */
  21924. static readonly CounterClockWiseSideOrientation: number;
  21925. /**
  21926. * The dirty texture flag value
  21927. */
  21928. static readonly TextureDirtyFlag: number;
  21929. /**
  21930. * The dirty light flag value
  21931. */
  21932. static readonly LightDirtyFlag: number;
  21933. /**
  21934. * The dirty fresnel flag value
  21935. */
  21936. static readonly FresnelDirtyFlag: number;
  21937. /**
  21938. * The dirty attribute flag value
  21939. */
  21940. static readonly AttributesDirtyFlag: number;
  21941. /**
  21942. * The dirty misc flag value
  21943. */
  21944. static readonly MiscDirtyFlag: number;
  21945. /**
  21946. * The all dirty flag value
  21947. */
  21948. static readonly AllDirtyFlag: number;
  21949. /**
  21950. * The ID of the material
  21951. */
  21952. id: string;
  21953. /**
  21954. * Gets or sets the unique id of the material
  21955. */
  21956. uniqueId: number;
  21957. /**
  21958. * The name of the material
  21959. */
  21960. name: string;
  21961. /**
  21962. * Gets or sets user defined metadata
  21963. */
  21964. metadata: any;
  21965. /**
  21966. * For internal use only. Please do not use.
  21967. */
  21968. reservedDataStore: any;
  21969. /**
  21970. * Specifies if the ready state should be checked on each call
  21971. */
  21972. checkReadyOnEveryCall: boolean;
  21973. /**
  21974. * Specifies if the ready state should be checked once
  21975. */
  21976. checkReadyOnlyOnce: boolean;
  21977. /**
  21978. * The state of the material
  21979. */
  21980. state: string;
  21981. /**
  21982. * The alpha value of the material
  21983. */
  21984. protected _alpha: number;
  21985. /**
  21986. * List of inspectable custom properties (used by the Inspector)
  21987. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21988. */
  21989. inspectableCustomProperties: IInspectable[];
  21990. /**
  21991. * Sets the alpha value of the material
  21992. */
  21993. /**
  21994. * Gets the alpha value of the material
  21995. */
  21996. alpha: number;
  21997. /**
  21998. * Specifies if back face culling is enabled
  21999. */
  22000. protected _backFaceCulling: boolean;
  22001. /**
  22002. * Sets the back-face culling state
  22003. */
  22004. /**
  22005. * Gets the back-face culling state
  22006. */
  22007. backFaceCulling: boolean;
  22008. /**
  22009. * Stores the value for side orientation
  22010. */
  22011. sideOrientation: number;
  22012. /**
  22013. * Callback triggered when the material is compiled
  22014. */
  22015. onCompiled: Nullable<(effect: Effect) => void>;
  22016. /**
  22017. * Callback triggered when an error occurs
  22018. */
  22019. onError: Nullable<(effect: Effect, errors: string) => void>;
  22020. /**
  22021. * Callback triggered to get the render target textures
  22022. */
  22023. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  22024. /**
  22025. * Gets a boolean indicating that current material needs to register RTT
  22026. */
  22027. readonly hasRenderTargetTextures: boolean;
  22028. /**
  22029. * Specifies if the material should be serialized
  22030. */
  22031. doNotSerialize: boolean;
  22032. /**
  22033. * @hidden
  22034. */
  22035. _storeEffectOnSubMeshes: boolean;
  22036. /**
  22037. * Stores the animations for the material
  22038. */
  22039. animations: Nullable<Array<Animation>>;
  22040. /**
  22041. * An event triggered when the material is disposed
  22042. */
  22043. onDisposeObservable: Observable<Material>;
  22044. /**
  22045. * An observer which watches for dispose events
  22046. */
  22047. private _onDisposeObserver;
  22048. private _onUnBindObservable;
  22049. /**
  22050. * Called during a dispose event
  22051. */
  22052. onDispose: () => void;
  22053. private _onBindObservable;
  22054. /**
  22055. * An event triggered when the material is bound
  22056. */
  22057. readonly onBindObservable: Observable<AbstractMesh>;
  22058. /**
  22059. * An observer which watches for bind events
  22060. */
  22061. private _onBindObserver;
  22062. /**
  22063. * Called during a bind event
  22064. */
  22065. onBind: (Mesh: AbstractMesh) => void;
  22066. /**
  22067. * An event triggered when the material is unbound
  22068. */
  22069. readonly onUnBindObservable: Observable<Material>;
  22070. /**
  22071. * Stores the value of the alpha mode
  22072. */
  22073. private _alphaMode;
  22074. /**
  22075. * Sets the value of the alpha mode.
  22076. *
  22077. * | Value | Type | Description |
  22078. * | --- | --- | --- |
  22079. * | 0 | ALPHA_DISABLE | |
  22080. * | 1 | ALPHA_ADD | |
  22081. * | 2 | ALPHA_COMBINE | |
  22082. * | 3 | ALPHA_SUBTRACT | |
  22083. * | 4 | ALPHA_MULTIPLY | |
  22084. * | 5 | ALPHA_MAXIMIZED | |
  22085. * | 6 | ALPHA_ONEONE | |
  22086. * | 7 | ALPHA_PREMULTIPLIED | |
  22087. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22088. * | 9 | ALPHA_INTERPOLATE | |
  22089. * | 10 | ALPHA_SCREENMODE | |
  22090. *
  22091. */
  22092. /**
  22093. * Gets the value of the alpha mode
  22094. */
  22095. alphaMode: number;
  22096. /**
  22097. * Stores the state of the need depth pre-pass value
  22098. */
  22099. private _needDepthPrePass;
  22100. /**
  22101. * Sets the need depth pre-pass value
  22102. */
  22103. /**
  22104. * Gets the depth pre-pass value
  22105. */
  22106. needDepthPrePass: boolean;
  22107. /**
  22108. * Specifies if depth writing should be disabled
  22109. */
  22110. disableDepthWrite: boolean;
  22111. /**
  22112. * Specifies if depth writing should be forced
  22113. */
  22114. forceDepthWrite: boolean;
  22115. /**
  22116. * Specifies if there should be a separate pass for culling
  22117. */
  22118. separateCullingPass: boolean;
  22119. /**
  22120. * Stores the state specifing if fog should be enabled
  22121. */
  22122. private _fogEnabled;
  22123. /**
  22124. * Sets the state for enabling fog
  22125. */
  22126. /**
  22127. * Gets the value of the fog enabled state
  22128. */
  22129. fogEnabled: boolean;
  22130. /**
  22131. * Stores the size of points
  22132. */
  22133. pointSize: number;
  22134. /**
  22135. * Stores the z offset value
  22136. */
  22137. zOffset: number;
  22138. /**
  22139. * Gets a value specifying if wireframe mode is enabled
  22140. */
  22141. /**
  22142. * Sets the state of wireframe mode
  22143. */
  22144. wireframe: boolean;
  22145. /**
  22146. * Gets the value specifying if point clouds are enabled
  22147. */
  22148. /**
  22149. * Sets the state of point cloud mode
  22150. */
  22151. pointsCloud: boolean;
  22152. /**
  22153. * Gets the material fill mode
  22154. */
  22155. /**
  22156. * Sets the material fill mode
  22157. */
  22158. fillMode: number;
  22159. /**
  22160. * @hidden
  22161. * Stores the effects for the material
  22162. */
  22163. _effect: Nullable<Effect>;
  22164. /**
  22165. * @hidden
  22166. * Specifies if the material was previously ready
  22167. */
  22168. _wasPreviouslyReady: boolean;
  22169. /**
  22170. * Specifies if uniform buffers should be used
  22171. */
  22172. private _useUBO;
  22173. /**
  22174. * Stores a reference to the scene
  22175. */
  22176. private _scene;
  22177. /**
  22178. * Stores the fill mode state
  22179. */
  22180. private _fillMode;
  22181. /**
  22182. * Specifies if the depth write state should be cached
  22183. */
  22184. private _cachedDepthWriteState;
  22185. /**
  22186. * Stores the uniform buffer
  22187. */
  22188. protected _uniformBuffer: UniformBuffer;
  22189. /** @hidden */
  22190. _indexInSceneMaterialArray: number;
  22191. /** @hidden */
  22192. meshMap: Nullable<{
  22193. [id: string]: AbstractMesh | undefined;
  22194. }>;
  22195. /**
  22196. * Creates a material instance
  22197. * @param name defines the name of the material
  22198. * @param scene defines the scene to reference
  22199. * @param doNotAdd specifies if the material should be added to the scene
  22200. */
  22201. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22202. /**
  22203. * Returns a string representation of the current material
  22204. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22205. * @returns a string with material information
  22206. */
  22207. toString(fullDetails?: boolean): string;
  22208. /**
  22209. * Gets the class name of the material
  22210. * @returns a string with the class name of the material
  22211. */
  22212. getClassName(): string;
  22213. /**
  22214. * Specifies if updates for the material been locked
  22215. */
  22216. readonly isFrozen: boolean;
  22217. /**
  22218. * Locks updates for the material
  22219. */
  22220. freeze(): void;
  22221. /**
  22222. * Unlocks updates for the material
  22223. */
  22224. unfreeze(): void;
  22225. /**
  22226. * Specifies if the material is ready to be used
  22227. * @param mesh defines the mesh to check
  22228. * @param useInstances specifies if instances should be used
  22229. * @returns a boolean indicating if the material is ready to be used
  22230. */
  22231. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22232. /**
  22233. * Specifies that the submesh is ready to be used
  22234. * @param mesh defines the mesh to check
  22235. * @param subMesh defines which submesh to check
  22236. * @param useInstances specifies that instances should be used
  22237. * @returns a boolean indicating that the submesh is ready or not
  22238. */
  22239. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22240. /**
  22241. * Returns the material effect
  22242. * @returns the effect associated with the material
  22243. */
  22244. getEffect(): Nullable<Effect>;
  22245. /**
  22246. * Returns the current scene
  22247. * @returns a Scene
  22248. */
  22249. getScene(): Scene;
  22250. /**
  22251. * Specifies if the material will require alpha blending
  22252. * @returns a boolean specifying if alpha blending is needed
  22253. */
  22254. needAlphaBlending(): boolean;
  22255. /**
  22256. * Specifies if the mesh will require alpha blending
  22257. * @param mesh defines the mesh to check
  22258. * @returns a boolean specifying if alpha blending is needed for the mesh
  22259. */
  22260. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22261. /**
  22262. * Specifies if this material should be rendered in alpha test mode
  22263. * @returns a boolean specifying if an alpha test is needed.
  22264. */
  22265. needAlphaTesting(): boolean;
  22266. /**
  22267. * Gets the texture used for the alpha test
  22268. * @returns the texture to use for alpha testing
  22269. */
  22270. getAlphaTestTexture(): Nullable<BaseTexture>;
  22271. /**
  22272. * Marks the material to indicate that it needs to be re-calculated
  22273. */
  22274. markDirty(): void;
  22275. /** @hidden */
  22276. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22277. /**
  22278. * Binds the material to the mesh
  22279. * @param world defines the world transformation matrix
  22280. * @param mesh defines the mesh to bind the material to
  22281. */
  22282. bind(world: Matrix, mesh?: Mesh): void;
  22283. /**
  22284. * Binds the submesh to the material
  22285. * @param world defines the world transformation matrix
  22286. * @param mesh defines the mesh containing the submesh
  22287. * @param subMesh defines the submesh to bind the material to
  22288. */
  22289. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22290. /**
  22291. * Binds the world matrix to the material
  22292. * @param world defines the world transformation matrix
  22293. */
  22294. bindOnlyWorldMatrix(world: Matrix): void;
  22295. /**
  22296. * Binds the scene's uniform buffer to the effect.
  22297. * @param effect defines the effect to bind to the scene uniform buffer
  22298. * @param sceneUbo defines the uniform buffer storing scene data
  22299. */
  22300. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22301. /**
  22302. * Binds the view matrix to the effect
  22303. * @param effect defines the effect to bind the view matrix to
  22304. */
  22305. bindView(effect: Effect): void;
  22306. /**
  22307. * Binds the view projection matrix to the effect
  22308. * @param effect defines the effect to bind the view projection matrix to
  22309. */
  22310. bindViewProjection(effect: Effect): void;
  22311. /**
  22312. * Specifies if material alpha testing should be turned on for the mesh
  22313. * @param mesh defines the mesh to check
  22314. */
  22315. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22316. /**
  22317. * Processes to execute after binding the material to a mesh
  22318. * @param mesh defines the rendered mesh
  22319. */
  22320. protected _afterBind(mesh?: Mesh): void;
  22321. /**
  22322. * Unbinds the material from the mesh
  22323. */
  22324. unbind(): void;
  22325. /**
  22326. * Gets the active textures from the material
  22327. * @returns an array of textures
  22328. */
  22329. getActiveTextures(): BaseTexture[];
  22330. /**
  22331. * Specifies if the material uses a texture
  22332. * @param texture defines the texture to check against the material
  22333. * @returns a boolean specifying if the material uses the texture
  22334. */
  22335. hasTexture(texture: BaseTexture): boolean;
  22336. /**
  22337. * Makes a duplicate of the material, and gives it a new name
  22338. * @param name defines the new name for the duplicated material
  22339. * @returns the cloned material
  22340. */
  22341. clone(name: string): Nullable<Material>;
  22342. /**
  22343. * Gets the meshes bound to the material
  22344. * @returns an array of meshes bound to the material
  22345. */
  22346. getBindedMeshes(): AbstractMesh[];
  22347. /**
  22348. * Force shader compilation
  22349. * @param mesh defines the mesh associated with this material
  22350. * @param onCompiled defines a function to execute once the material is compiled
  22351. * @param options defines the options to configure the compilation
  22352. */
  22353. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  22354. clipPlane: boolean;
  22355. }>): void;
  22356. /**
  22357. * Force shader compilation
  22358. * @param mesh defines the mesh that will use this material
  22359. * @param options defines additional options for compiling the shaders
  22360. * @returns a promise that resolves when the compilation completes
  22361. */
  22362. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  22363. clipPlane: boolean;
  22364. }>): Promise<void>;
  22365. private static readonly _AllDirtyCallBack;
  22366. private static readonly _ImageProcessingDirtyCallBack;
  22367. private static readonly _TextureDirtyCallBack;
  22368. private static readonly _FresnelDirtyCallBack;
  22369. private static readonly _MiscDirtyCallBack;
  22370. private static readonly _LightsDirtyCallBack;
  22371. private static readonly _AttributeDirtyCallBack;
  22372. private static _FresnelAndMiscDirtyCallBack;
  22373. private static _TextureAndMiscDirtyCallBack;
  22374. private static readonly _DirtyCallbackArray;
  22375. private static readonly _RunDirtyCallBacks;
  22376. /**
  22377. * Marks a define in the material to indicate that it needs to be re-computed
  22378. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22379. */
  22380. markAsDirty(flag: number): void;
  22381. /**
  22382. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22383. * @param func defines a function which checks material defines against the submeshes
  22384. */
  22385. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22386. /**
  22387. * Indicates that we need to re-calculated for all submeshes
  22388. */
  22389. protected _markAllSubMeshesAsAllDirty(): void;
  22390. /**
  22391. * Indicates that image processing needs to be re-calculated for all submeshes
  22392. */
  22393. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22394. /**
  22395. * Indicates that textures need to be re-calculated for all submeshes
  22396. */
  22397. protected _markAllSubMeshesAsTexturesDirty(): void;
  22398. /**
  22399. * Indicates that fresnel needs to be re-calculated for all submeshes
  22400. */
  22401. protected _markAllSubMeshesAsFresnelDirty(): void;
  22402. /**
  22403. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22404. */
  22405. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22406. /**
  22407. * Indicates that lights need to be re-calculated for all submeshes
  22408. */
  22409. protected _markAllSubMeshesAsLightsDirty(): void;
  22410. /**
  22411. * Indicates that attributes need to be re-calculated for all submeshes
  22412. */
  22413. protected _markAllSubMeshesAsAttributesDirty(): void;
  22414. /**
  22415. * Indicates that misc needs to be re-calculated for all submeshes
  22416. */
  22417. protected _markAllSubMeshesAsMiscDirty(): void;
  22418. /**
  22419. * Indicates that textures and misc need to be re-calculated for all submeshes
  22420. */
  22421. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22422. /**
  22423. * Disposes the material
  22424. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22425. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22426. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22427. */
  22428. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22429. /** @hidden */
  22430. private releaseVertexArrayObject;
  22431. /**
  22432. * Serializes this material
  22433. * @returns the serialized material object
  22434. */
  22435. serialize(): any;
  22436. /**
  22437. * Creates a material from parsed material data
  22438. * @param parsedMaterial defines parsed material data
  22439. * @param scene defines the hosting scene
  22440. * @param rootUrl defines the root URL to use to load textures
  22441. * @returns a new material
  22442. */
  22443. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  22444. }
  22445. }
  22446. declare module BABYLON {
  22447. /**
  22448. * Base class for submeshes
  22449. */
  22450. export class BaseSubMesh {
  22451. /** @hidden */
  22452. _materialDefines: Nullable<MaterialDefines>;
  22453. /** @hidden */
  22454. _materialEffect: Nullable<Effect>;
  22455. /**
  22456. * Gets associated effect
  22457. */
  22458. readonly effect: Nullable<Effect>;
  22459. /**
  22460. * Sets associated effect (effect used to render this submesh)
  22461. * @param effect defines the effect to associate with
  22462. * @param defines defines the set of defines used to compile this effect
  22463. */
  22464. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22465. }
  22466. /**
  22467. * Defines a subdivision inside a mesh
  22468. */
  22469. export class SubMesh extends BaseSubMesh implements ICullable {
  22470. /** the material index to use */
  22471. materialIndex: number;
  22472. /** vertex index start */
  22473. verticesStart: number;
  22474. /** vertices count */
  22475. verticesCount: number;
  22476. /** index start */
  22477. indexStart: number;
  22478. /** indices count */
  22479. indexCount: number;
  22480. /** @hidden */
  22481. _linesIndexCount: number;
  22482. private _mesh;
  22483. private _renderingMesh;
  22484. private _boundingInfo;
  22485. private _linesIndexBuffer;
  22486. /** @hidden */
  22487. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22488. /** @hidden */
  22489. _trianglePlanes: Plane[];
  22490. /** @hidden */
  22491. _lastColliderTransformMatrix: Nullable<Matrix>;
  22492. /** @hidden */
  22493. _renderId: number;
  22494. /** @hidden */
  22495. _alphaIndex: number;
  22496. /** @hidden */
  22497. _distanceToCamera: number;
  22498. /** @hidden */
  22499. _id: number;
  22500. private _currentMaterial;
  22501. /**
  22502. * Add a new submesh to a mesh
  22503. * @param materialIndex defines the material index to use
  22504. * @param verticesStart defines vertex index start
  22505. * @param verticesCount defines vertices count
  22506. * @param indexStart defines index start
  22507. * @param indexCount defines indices count
  22508. * @param mesh defines the parent mesh
  22509. * @param renderingMesh defines an optional rendering mesh
  22510. * @param createBoundingBox defines if bounding box should be created for this submesh
  22511. * @returns the new submesh
  22512. */
  22513. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22514. /**
  22515. * Creates a new submesh
  22516. * @param materialIndex defines the material index to use
  22517. * @param verticesStart defines vertex index start
  22518. * @param verticesCount defines vertices count
  22519. * @param indexStart defines index start
  22520. * @param indexCount defines indices count
  22521. * @param mesh defines the parent mesh
  22522. * @param renderingMesh defines an optional rendering mesh
  22523. * @param createBoundingBox defines if bounding box should be created for this submesh
  22524. */
  22525. constructor(
  22526. /** the material index to use */
  22527. materialIndex: number,
  22528. /** vertex index start */
  22529. verticesStart: number,
  22530. /** vertices count */
  22531. verticesCount: number,
  22532. /** index start */
  22533. indexStart: number,
  22534. /** indices count */
  22535. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22536. /**
  22537. * Returns true if this submesh covers the entire parent mesh
  22538. * @ignorenaming
  22539. */
  22540. readonly IsGlobal: boolean;
  22541. /**
  22542. * Returns the submesh BoudingInfo object
  22543. * @returns current bounding info (or mesh's one if the submesh is global)
  22544. */
  22545. getBoundingInfo(): BoundingInfo;
  22546. /**
  22547. * Sets the submesh BoundingInfo
  22548. * @param boundingInfo defines the new bounding info to use
  22549. * @returns the SubMesh
  22550. */
  22551. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22552. /**
  22553. * Returns the mesh of the current submesh
  22554. * @return the parent mesh
  22555. */
  22556. getMesh(): AbstractMesh;
  22557. /**
  22558. * Returns the rendering mesh of the submesh
  22559. * @returns the rendering mesh (could be different from parent mesh)
  22560. */
  22561. getRenderingMesh(): Mesh;
  22562. /**
  22563. * Returns the submesh material
  22564. * @returns null or the current material
  22565. */
  22566. getMaterial(): Nullable<Material>;
  22567. /**
  22568. * Sets a new updated BoundingInfo object to the submesh
  22569. * @param data defines an optional position array to use to determine the bounding info
  22570. * @returns the SubMesh
  22571. */
  22572. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22573. /** @hidden */
  22574. _checkCollision(collider: Collider): boolean;
  22575. /**
  22576. * Updates the submesh BoundingInfo
  22577. * @param world defines the world matrix to use to update the bounding info
  22578. * @returns the submesh
  22579. */
  22580. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22581. /**
  22582. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22583. * @param frustumPlanes defines the frustum planes
  22584. * @returns true if the submesh is intersecting with the frustum
  22585. */
  22586. isInFrustum(frustumPlanes: Plane[]): boolean;
  22587. /**
  22588. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22589. * @param frustumPlanes defines the frustum planes
  22590. * @returns true if the submesh is inside the frustum
  22591. */
  22592. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22593. /**
  22594. * Renders the submesh
  22595. * @param enableAlphaMode defines if alpha needs to be used
  22596. * @returns the submesh
  22597. */
  22598. render(enableAlphaMode: boolean): SubMesh;
  22599. /**
  22600. * @hidden
  22601. */
  22602. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22603. /**
  22604. * Checks if the submesh intersects with a ray
  22605. * @param ray defines the ray to test
  22606. * @returns true is the passed ray intersects the submesh bounding box
  22607. */
  22608. canIntersects(ray: Ray): boolean;
  22609. /**
  22610. * Intersects current submesh with a ray
  22611. * @param ray defines the ray to test
  22612. * @param positions defines mesh's positions array
  22613. * @param indices defines mesh's indices array
  22614. * @param fastCheck defines if only bounding info should be used
  22615. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22616. * @returns intersection info or null if no intersection
  22617. */
  22618. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22619. /** @hidden */
  22620. private _intersectLines;
  22621. /** @hidden */
  22622. private _intersectUnIndexedLines;
  22623. /** @hidden */
  22624. private _intersectTriangles;
  22625. /** @hidden */
  22626. private _intersectUnIndexedTriangles;
  22627. /** @hidden */
  22628. _rebuild(): void;
  22629. /**
  22630. * Creates a new submesh from the passed mesh
  22631. * @param newMesh defines the new hosting mesh
  22632. * @param newRenderingMesh defines an optional rendering mesh
  22633. * @returns the new submesh
  22634. */
  22635. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22636. /**
  22637. * Release associated resources
  22638. */
  22639. dispose(): void;
  22640. /**
  22641. * Gets the class name
  22642. * @returns the string "SubMesh".
  22643. */
  22644. getClassName(): string;
  22645. /**
  22646. * Creates a new submesh from indices data
  22647. * @param materialIndex the index of the main mesh material
  22648. * @param startIndex the index where to start the copy in the mesh indices array
  22649. * @param indexCount the number of indices to copy then from the startIndex
  22650. * @param mesh the main mesh to create the submesh from
  22651. * @param renderingMesh the optional rendering mesh
  22652. * @returns a new submesh
  22653. */
  22654. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22655. }
  22656. }
  22657. declare module BABYLON {
  22658. /**
  22659. * Class used to store geometry data (vertex buffers + index buffer)
  22660. */
  22661. export class Geometry implements IGetSetVerticesData {
  22662. /**
  22663. * Gets or sets the ID of the geometry
  22664. */
  22665. id: string;
  22666. /**
  22667. * Gets or sets the unique ID of the geometry
  22668. */
  22669. uniqueId: number;
  22670. /**
  22671. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22672. */
  22673. delayLoadState: number;
  22674. /**
  22675. * Gets the file containing the data to load when running in delay load state
  22676. */
  22677. delayLoadingFile: Nullable<string>;
  22678. /**
  22679. * Callback called when the geometry is updated
  22680. */
  22681. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22682. private _scene;
  22683. private _engine;
  22684. private _meshes;
  22685. private _totalVertices;
  22686. /** @hidden */
  22687. _indices: IndicesArray;
  22688. /** @hidden */
  22689. _vertexBuffers: {
  22690. [key: string]: VertexBuffer;
  22691. };
  22692. private _isDisposed;
  22693. private _extend;
  22694. private _boundingBias;
  22695. /** @hidden */
  22696. _delayInfo: Array<string>;
  22697. private _indexBuffer;
  22698. private _indexBufferIsUpdatable;
  22699. /** @hidden */
  22700. _boundingInfo: Nullable<BoundingInfo>;
  22701. /** @hidden */
  22702. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22703. /** @hidden */
  22704. _softwareSkinningFrameId: number;
  22705. private _vertexArrayObjects;
  22706. private _updatable;
  22707. /** @hidden */
  22708. _positions: Nullable<Vector3[]>;
  22709. /**
  22710. * 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
  22711. */
  22712. /**
  22713. * 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
  22714. */
  22715. boundingBias: Vector2;
  22716. /**
  22717. * Static function used to attach a new empty geometry to a mesh
  22718. * @param mesh defines the mesh to attach the geometry to
  22719. * @returns the new Geometry
  22720. */
  22721. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22722. /**
  22723. * Creates a new geometry
  22724. * @param id defines the unique ID
  22725. * @param scene defines the hosting scene
  22726. * @param vertexData defines the VertexData used to get geometry data
  22727. * @param updatable defines if geometry must be updatable (false by default)
  22728. * @param mesh defines the mesh that will be associated with the geometry
  22729. */
  22730. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22731. /**
  22732. * Gets the current extend of the geometry
  22733. */
  22734. readonly extend: {
  22735. minimum: Vector3;
  22736. maximum: Vector3;
  22737. };
  22738. /**
  22739. * Gets the hosting scene
  22740. * @returns the hosting Scene
  22741. */
  22742. getScene(): Scene;
  22743. /**
  22744. * Gets the hosting engine
  22745. * @returns the hosting Engine
  22746. */
  22747. getEngine(): Engine;
  22748. /**
  22749. * Defines if the geometry is ready to use
  22750. * @returns true if the geometry is ready to be used
  22751. */
  22752. isReady(): boolean;
  22753. /**
  22754. * Gets a value indicating that the geometry should not be serialized
  22755. */
  22756. readonly doNotSerialize: boolean;
  22757. /** @hidden */
  22758. _rebuild(): void;
  22759. /**
  22760. * Affects all geometry data in one call
  22761. * @param vertexData defines the geometry data
  22762. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22763. */
  22764. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22765. /**
  22766. * Set specific vertex data
  22767. * @param kind defines the data kind (Position, normal, etc...)
  22768. * @param data defines the vertex data to use
  22769. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22770. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22771. */
  22772. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22773. /**
  22774. * Removes a specific vertex data
  22775. * @param kind defines the data kind (Position, normal, etc...)
  22776. */
  22777. removeVerticesData(kind: string): void;
  22778. /**
  22779. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22780. * @param buffer defines the vertex buffer to use
  22781. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22782. */
  22783. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22784. /**
  22785. * Update a specific vertex buffer
  22786. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22787. * It will do nothing if the buffer is not updatable
  22788. * @param kind defines the data kind (Position, normal, etc...)
  22789. * @param data defines the data to use
  22790. * @param offset defines the offset in the target buffer where to store the data
  22791. * @param useBytes set to true if the offset is in bytes
  22792. */
  22793. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22794. /**
  22795. * Update a specific vertex buffer
  22796. * This function will create a new buffer if the current one is not updatable
  22797. * @param kind defines the data kind (Position, normal, etc...)
  22798. * @param data defines the data to use
  22799. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22800. */
  22801. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22802. private _updateBoundingInfo;
  22803. /** @hidden */
  22804. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22805. /**
  22806. * Gets total number of vertices
  22807. * @returns the total number of vertices
  22808. */
  22809. getTotalVertices(): number;
  22810. /**
  22811. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22812. * @param kind defines the data kind (Position, normal, etc...)
  22813. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22814. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22815. * @returns a float array containing vertex data
  22816. */
  22817. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22818. /**
  22819. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22820. * @param kind defines the data kind (Position, normal, etc...)
  22821. * @returns true if the vertex buffer with the specified kind is updatable
  22822. */
  22823. isVertexBufferUpdatable(kind: string): boolean;
  22824. /**
  22825. * Gets a specific vertex buffer
  22826. * @param kind defines the data kind (Position, normal, etc...)
  22827. * @returns a VertexBuffer
  22828. */
  22829. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22830. /**
  22831. * Returns all vertex buffers
  22832. * @return an object holding all vertex buffers indexed by kind
  22833. */
  22834. getVertexBuffers(): Nullable<{
  22835. [key: string]: VertexBuffer;
  22836. }>;
  22837. /**
  22838. * Gets a boolean indicating if specific vertex buffer is present
  22839. * @param kind defines the data kind (Position, normal, etc...)
  22840. * @returns true if data is present
  22841. */
  22842. isVerticesDataPresent(kind: string): boolean;
  22843. /**
  22844. * Gets a list of all attached data kinds (Position, normal, etc...)
  22845. * @returns a list of string containing all kinds
  22846. */
  22847. getVerticesDataKinds(): string[];
  22848. /**
  22849. * Update index buffer
  22850. * @param indices defines the indices to store in the index buffer
  22851. * @param offset defines the offset in the target buffer where to store the data
  22852. * @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)
  22853. */
  22854. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22855. /**
  22856. * Creates a new index buffer
  22857. * @param indices defines the indices to store in the index buffer
  22858. * @param totalVertices defines the total number of vertices (could be null)
  22859. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22860. */
  22861. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22862. /**
  22863. * Return the total number of indices
  22864. * @returns the total number of indices
  22865. */
  22866. getTotalIndices(): number;
  22867. /**
  22868. * Gets the index buffer array
  22869. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22870. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22871. * @returns the index buffer array
  22872. */
  22873. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22874. /**
  22875. * Gets the index buffer
  22876. * @return the index buffer
  22877. */
  22878. getIndexBuffer(): Nullable<DataBuffer>;
  22879. /** @hidden */
  22880. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22881. /**
  22882. * Release the associated resources for a specific mesh
  22883. * @param mesh defines the source mesh
  22884. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22885. */
  22886. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22887. /**
  22888. * Apply current geometry to a given mesh
  22889. * @param mesh defines the mesh to apply geometry to
  22890. */
  22891. applyToMesh(mesh: Mesh): void;
  22892. private _updateExtend;
  22893. private _applyToMesh;
  22894. private notifyUpdate;
  22895. /**
  22896. * Load the geometry if it was flagged as delay loaded
  22897. * @param scene defines the hosting scene
  22898. * @param onLoaded defines a callback called when the geometry is loaded
  22899. */
  22900. load(scene: Scene, onLoaded?: () => void): void;
  22901. private _queueLoad;
  22902. /**
  22903. * Invert the geometry to move from a right handed system to a left handed one.
  22904. */
  22905. toLeftHanded(): void;
  22906. /** @hidden */
  22907. _resetPointsArrayCache(): void;
  22908. /** @hidden */
  22909. _generatePointsArray(): boolean;
  22910. /**
  22911. * Gets a value indicating if the geometry is disposed
  22912. * @returns true if the geometry was disposed
  22913. */
  22914. isDisposed(): boolean;
  22915. private _disposeVertexArrayObjects;
  22916. /**
  22917. * Free all associated resources
  22918. */
  22919. dispose(): void;
  22920. /**
  22921. * Clone the current geometry into a new geometry
  22922. * @param id defines the unique ID of the new geometry
  22923. * @returns a new geometry object
  22924. */
  22925. copy(id: string): Geometry;
  22926. /**
  22927. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22928. * @return a JSON representation of the current geometry data (without the vertices data)
  22929. */
  22930. serialize(): any;
  22931. private toNumberArray;
  22932. /**
  22933. * Serialize all vertices data into a JSON oject
  22934. * @returns a JSON representation of the current geometry data
  22935. */
  22936. serializeVerticeData(): any;
  22937. /**
  22938. * Extracts a clone of a mesh geometry
  22939. * @param mesh defines the source mesh
  22940. * @param id defines the unique ID of the new geometry object
  22941. * @returns the new geometry object
  22942. */
  22943. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22944. /**
  22945. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22946. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22947. * Be aware Math.random() could cause collisions, but:
  22948. * "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"
  22949. * @returns a string containing a new GUID
  22950. */
  22951. static RandomId(): string;
  22952. /** @hidden */
  22953. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22954. private static _CleanMatricesWeights;
  22955. /**
  22956. * Create a new geometry from persisted data (Using .babylon file format)
  22957. * @param parsedVertexData defines the persisted data
  22958. * @param scene defines the hosting scene
  22959. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22960. * @returns the new geometry object
  22961. */
  22962. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22963. }
  22964. }
  22965. declare module BABYLON {
  22966. /**
  22967. * Define an interface for all classes that will get and set the data on vertices
  22968. */
  22969. export interface IGetSetVerticesData {
  22970. /**
  22971. * Gets a boolean indicating if specific vertex data is present
  22972. * @param kind defines the vertex data kind to use
  22973. * @returns true is data kind is present
  22974. */
  22975. isVerticesDataPresent(kind: string): boolean;
  22976. /**
  22977. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22978. * @param kind defines the data kind (Position, normal, etc...)
  22979. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22980. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22981. * @returns a float array containing vertex data
  22982. */
  22983. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22984. /**
  22985. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22986. * @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.
  22987. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22988. * @returns the indices array or an empty array if the mesh has no geometry
  22989. */
  22990. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22991. /**
  22992. * Set specific vertex data
  22993. * @param kind defines the data kind (Position, normal, etc...)
  22994. * @param data defines the vertex data to use
  22995. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22996. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22997. */
  22998. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22999. /**
  23000. * Update a specific associated vertex buffer
  23001. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23002. * - VertexBuffer.PositionKind
  23003. * - VertexBuffer.UVKind
  23004. * - VertexBuffer.UV2Kind
  23005. * - VertexBuffer.UV3Kind
  23006. * - VertexBuffer.UV4Kind
  23007. * - VertexBuffer.UV5Kind
  23008. * - VertexBuffer.UV6Kind
  23009. * - VertexBuffer.ColorKind
  23010. * - VertexBuffer.MatricesIndicesKind
  23011. * - VertexBuffer.MatricesIndicesExtraKind
  23012. * - VertexBuffer.MatricesWeightsKind
  23013. * - VertexBuffer.MatricesWeightsExtraKind
  23014. * @param data defines the data source
  23015. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23016. * @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)
  23017. */
  23018. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23019. /**
  23020. * Creates a new index buffer
  23021. * @param indices defines the indices to store in the index buffer
  23022. * @param totalVertices defines the total number of vertices (could be null)
  23023. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23024. */
  23025. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23026. }
  23027. /**
  23028. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23029. */
  23030. export class VertexData {
  23031. /**
  23032. * Mesh side orientation : usually the external or front surface
  23033. */
  23034. static readonly FRONTSIDE: number;
  23035. /**
  23036. * Mesh side orientation : usually the internal or back surface
  23037. */
  23038. static readonly BACKSIDE: number;
  23039. /**
  23040. * Mesh side orientation : both internal and external or front and back surfaces
  23041. */
  23042. static readonly DOUBLESIDE: number;
  23043. /**
  23044. * Mesh side orientation : by default, `FRONTSIDE`
  23045. */
  23046. static readonly DEFAULTSIDE: number;
  23047. /**
  23048. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23049. */
  23050. positions: Nullable<FloatArray>;
  23051. /**
  23052. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23053. */
  23054. normals: Nullable<FloatArray>;
  23055. /**
  23056. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23057. */
  23058. tangents: Nullable<FloatArray>;
  23059. /**
  23060. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23061. */
  23062. uvs: Nullable<FloatArray>;
  23063. /**
  23064. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23065. */
  23066. uvs2: Nullable<FloatArray>;
  23067. /**
  23068. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23069. */
  23070. uvs3: Nullable<FloatArray>;
  23071. /**
  23072. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23073. */
  23074. uvs4: Nullable<FloatArray>;
  23075. /**
  23076. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23077. */
  23078. uvs5: Nullable<FloatArray>;
  23079. /**
  23080. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23081. */
  23082. uvs6: Nullable<FloatArray>;
  23083. /**
  23084. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23085. */
  23086. colors: Nullable<FloatArray>;
  23087. /**
  23088. * 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).
  23089. */
  23090. matricesIndices: Nullable<FloatArray>;
  23091. /**
  23092. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23093. */
  23094. matricesWeights: Nullable<FloatArray>;
  23095. /**
  23096. * An array extending the number of possible indices
  23097. */
  23098. matricesIndicesExtra: Nullable<FloatArray>;
  23099. /**
  23100. * An array extending the number of possible weights when the number of indices is extended
  23101. */
  23102. matricesWeightsExtra: Nullable<FloatArray>;
  23103. /**
  23104. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23105. */
  23106. indices: Nullable<IndicesArray>;
  23107. /**
  23108. * Uses the passed data array to set the set the values for the specified kind of data
  23109. * @param data a linear array of floating numbers
  23110. * @param kind the type of data that is being set, eg positions, colors etc
  23111. */
  23112. set(data: FloatArray, kind: string): void;
  23113. /**
  23114. * Associates the vertexData to the passed Mesh.
  23115. * Sets it as updatable or not (default `false`)
  23116. * @param mesh the mesh the vertexData is applied to
  23117. * @param updatable when used and having the value true allows new data to update the vertexData
  23118. * @returns the VertexData
  23119. */
  23120. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23121. /**
  23122. * Associates the vertexData to the passed Geometry.
  23123. * Sets it as updatable or not (default `false`)
  23124. * @param geometry the geometry the vertexData is applied to
  23125. * @param updatable when used and having the value true allows new data to update the vertexData
  23126. * @returns VertexData
  23127. */
  23128. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23129. /**
  23130. * Updates the associated mesh
  23131. * @param mesh the mesh to be updated
  23132. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23133. * @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
  23134. * @returns VertexData
  23135. */
  23136. updateMesh(mesh: Mesh): VertexData;
  23137. /**
  23138. * Updates the associated geometry
  23139. * @param geometry the geometry to be updated
  23140. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23141. * @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
  23142. * @returns VertexData.
  23143. */
  23144. updateGeometry(geometry: Geometry): VertexData;
  23145. private _applyTo;
  23146. private _update;
  23147. /**
  23148. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23149. * @param matrix the transforming matrix
  23150. * @returns the VertexData
  23151. */
  23152. transform(matrix: Matrix): VertexData;
  23153. /**
  23154. * Merges the passed VertexData into the current one
  23155. * @param other the VertexData to be merged into the current one
  23156. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23157. * @returns the modified VertexData
  23158. */
  23159. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23160. private _mergeElement;
  23161. private _validate;
  23162. /**
  23163. * Serializes the VertexData
  23164. * @returns a serialized object
  23165. */
  23166. serialize(): any;
  23167. /**
  23168. * Extracts the vertexData from a mesh
  23169. * @param mesh the mesh from which to extract the VertexData
  23170. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23171. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23172. * @returns the object VertexData associated to the passed mesh
  23173. */
  23174. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23175. /**
  23176. * Extracts the vertexData from the geometry
  23177. * @param geometry the geometry from which to extract the VertexData
  23178. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23179. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23180. * @returns the object VertexData associated to the passed mesh
  23181. */
  23182. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23183. private static _ExtractFrom;
  23184. /**
  23185. * Creates the VertexData for a Ribbon
  23186. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23187. * * pathArray array of paths, each of which an array of successive Vector3
  23188. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23189. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23190. * * 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
  23191. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23192. * * 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)
  23193. * * 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)
  23194. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23195. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23196. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23197. * @returns the VertexData of the ribbon
  23198. */
  23199. static CreateRibbon(options: {
  23200. pathArray: Vector3[][];
  23201. closeArray?: boolean;
  23202. closePath?: boolean;
  23203. offset?: number;
  23204. sideOrientation?: number;
  23205. frontUVs?: Vector4;
  23206. backUVs?: Vector4;
  23207. invertUV?: boolean;
  23208. uvs?: Vector2[];
  23209. colors?: Color4[];
  23210. }): VertexData;
  23211. /**
  23212. * Creates the VertexData for a box
  23213. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23214. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23215. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23216. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23217. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23218. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23219. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23220. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23221. * * 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)
  23222. * * 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)
  23223. * @returns the VertexData of the box
  23224. */
  23225. static CreateBox(options: {
  23226. size?: number;
  23227. width?: number;
  23228. height?: number;
  23229. depth?: number;
  23230. faceUV?: Vector4[];
  23231. faceColors?: Color4[];
  23232. sideOrientation?: number;
  23233. frontUVs?: Vector4;
  23234. backUVs?: Vector4;
  23235. }): VertexData;
  23236. /**
  23237. * Creates the VertexData for a tiled box
  23238. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23239. * * faceTiles sets the pattern, tile size and number of tiles for a face
  23240. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23241. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23242. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23243. * @returns the VertexData of the box
  23244. */
  23245. static CreateTiledBox(options: {
  23246. pattern?: number;
  23247. width?: number;
  23248. height?: number;
  23249. depth?: number;
  23250. tileSize?: number;
  23251. tileWidth?: number;
  23252. tileHeight?: number;
  23253. alignHorizontal?: number;
  23254. alignVertical?: number;
  23255. faceUV?: Vector4[];
  23256. faceColors?: Color4[];
  23257. sideOrientation?: number;
  23258. }): VertexData;
  23259. /**
  23260. * Creates the VertexData for a tiled plane
  23261. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23262. * * pattern a limited pattern arrangement depending on the number
  23263. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  23264. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  23265. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  23266. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23267. * * 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)
  23268. * * 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)
  23269. * @returns the VertexData of the tiled plane
  23270. */
  23271. static CreateTiledPlane(options: {
  23272. pattern?: number;
  23273. tileSize?: number;
  23274. tileWidth?: number;
  23275. tileHeight?: number;
  23276. size?: number;
  23277. width?: number;
  23278. height?: number;
  23279. alignHorizontal?: number;
  23280. alignVertical?: number;
  23281. sideOrientation?: number;
  23282. frontUVs?: Vector4;
  23283. backUVs?: Vector4;
  23284. }): VertexData;
  23285. /**
  23286. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23287. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23288. * * segments sets the number of horizontal strips optional, default 32
  23289. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23290. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23291. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23292. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23293. * * 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
  23294. * * 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
  23295. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23296. * * 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)
  23297. * * 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)
  23298. * @returns the VertexData of the ellipsoid
  23299. */
  23300. static CreateSphere(options: {
  23301. segments?: number;
  23302. diameter?: number;
  23303. diameterX?: number;
  23304. diameterY?: number;
  23305. diameterZ?: number;
  23306. arc?: number;
  23307. slice?: number;
  23308. sideOrientation?: number;
  23309. frontUVs?: Vector4;
  23310. backUVs?: Vector4;
  23311. }): VertexData;
  23312. /**
  23313. * Creates the VertexData for a cylinder, cone or prism
  23314. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23315. * * height sets the height (y direction) of the cylinder, optional, default 2
  23316. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23317. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23318. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23319. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23320. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23321. * * 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
  23322. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23323. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23324. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23325. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23326. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23327. * * 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)
  23328. * * 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)
  23329. * @returns the VertexData of the cylinder, cone or prism
  23330. */
  23331. static CreateCylinder(options: {
  23332. height?: number;
  23333. diameterTop?: number;
  23334. diameterBottom?: number;
  23335. diameter?: number;
  23336. tessellation?: number;
  23337. subdivisions?: number;
  23338. arc?: number;
  23339. faceColors?: Color4[];
  23340. faceUV?: Vector4[];
  23341. hasRings?: boolean;
  23342. enclose?: boolean;
  23343. sideOrientation?: number;
  23344. frontUVs?: Vector4;
  23345. backUVs?: Vector4;
  23346. }): VertexData;
  23347. /**
  23348. * Creates the VertexData for a torus
  23349. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23350. * * diameter the diameter of the torus, optional default 1
  23351. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23352. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23353. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23354. * * 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)
  23355. * * 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)
  23356. * @returns the VertexData of the torus
  23357. */
  23358. static CreateTorus(options: {
  23359. diameter?: number;
  23360. thickness?: number;
  23361. tessellation?: number;
  23362. sideOrientation?: number;
  23363. frontUVs?: Vector4;
  23364. backUVs?: Vector4;
  23365. }): VertexData;
  23366. /**
  23367. * Creates the VertexData of the LineSystem
  23368. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23369. * - lines an array of lines, each line being an array of successive Vector3
  23370. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23371. * @returns the VertexData of the LineSystem
  23372. */
  23373. static CreateLineSystem(options: {
  23374. lines: Vector3[][];
  23375. colors?: Nullable<Color4[][]>;
  23376. }): VertexData;
  23377. /**
  23378. * Create the VertexData for a DashedLines
  23379. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23380. * - points an array successive Vector3
  23381. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23382. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23383. * - dashNb the intended total number of dashes, optional, default 200
  23384. * @returns the VertexData for the DashedLines
  23385. */
  23386. static CreateDashedLines(options: {
  23387. points: Vector3[];
  23388. dashSize?: number;
  23389. gapSize?: number;
  23390. dashNb?: number;
  23391. }): VertexData;
  23392. /**
  23393. * Creates the VertexData for a Ground
  23394. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23395. * - width the width (x direction) of the ground, optional, default 1
  23396. * - height the height (z direction) of the ground, optional, default 1
  23397. * - subdivisions the number of subdivisions per side, optional, default 1
  23398. * @returns the VertexData of the Ground
  23399. */
  23400. static CreateGround(options: {
  23401. width?: number;
  23402. height?: number;
  23403. subdivisions?: number;
  23404. subdivisionsX?: number;
  23405. subdivisionsY?: number;
  23406. }): VertexData;
  23407. /**
  23408. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23409. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23410. * * xmin the ground minimum X coordinate, optional, default -1
  23411. * * zmin the ground minimum Z coordinate, optional, default -1
  23412. * * xmax the ground maximum X coordinate, optional, default 1
  23413. * * zmax the ground maximum Z coordinate, optional, default 1
  23414. * * 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}
  23415. * * 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}
  23416. * @returns the VertexData of the TiledGround
  23417. */
  23418. static CreateTiledGround(options: {
  23419. xmin: number;
  23420. zmin: number;
  23421. xmax: number;
  23422. zmax: number;
  23423. subdivisions?: {
  23424. w: number;
  23425. h: number;
  23426. };
  23427. precision?: {
  23428. w: number;
  23429. h: number;
  23430. };
  23431. }): VertexData;
  23432. /**
  23433. * Creates the VertexData of the Ground designed from a heightmap
  23434. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23435. * * width the width (x direction) of the ground
  23436. * * height the height (z direction) of the ground
  23437. * * subdivisions the number of subdivisions per side
  23438. * * minHeight the minimum altitude on the ground, optional, default 0
  23439. * * maxHeight the maximum altitude on the ground, optional default 1
  23440. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23441. * * buffer the array holding the image color data
  23442. * * bufferWidth the width of image
  23443. * * bufferHeight the height of image
  23444. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23445. * @returns the VertexData of the Ground designed from a heightmap
  23446. */
  23447. static CreateGroundFromHeightMap(options: {
  23448. width: number;
  23449. height: number;
  23450. subdivisions: number;
  23451. minHeight: number;
  23452. maxHeight: number;
  23453. colorFilter: Color3;
  23454. buffer: Uint8Array;
  23455. bufferWidth: number;
  23456. bufferHeight: number;
  23457. alphaFilter: number;
  23458. }): VertexData;
  23459. /**
  23460. * Creates the VertexData for a Plane
  23461. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23462. * * size sets the width and height of the plane to the value of size, optional default 1
  23463. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23464. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23465. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23466. * * 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)
  23467. * * 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)
  23468. * @returns the VertexData of the box
  23469. */
  23470. static CreatePlane(options: {
  23471. size?: number;
  23472. width?: number;
  23473. height?: number;
  23474. sideOrientation?: number;
  23475. frontUVs?: Vector4;
  23476. backUVs?: Vector4;
  23477. }): VertexData;
  23478. /**
  23479. * Creates the VertexData of the Disc or regular Polygon
  23480. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23481. * * radius the radius of the disc, optional default 0.5
  23482. * * tessellation the number of polygon sides, optional, default 64
  23483. * * 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
  23484. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23485. * * 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)
  23486. * * 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)
  23487. * @returns the VertexData of the box
  23488. */
  23489. static CreateDisc(options: {
  23490. radius?: number;
  23491. tessellation?: number;
  23492. arc?: number;
  23493. sideOrientation?: number;
  23494. frontUVs?: Vector4;
  23495. backUVs?: Vector4;
  23496. }): VertexData;
  23497. /**
  23498. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23499. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23500. * @param polygon a mesh built from polygonTriangulation.build()
  23501. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23502. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23503. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23504. * @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)
  23505. * @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)
  23506. * @returns the VertexData of the Polygon
  23507. */
  23508. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23509. /**
  23510. * Creates the VertexData of the IcoSphere
  23511. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23512. * * radius the radius of the IcoSphere, optional default 1
  23513. * * radiusX allows stretching in the x direction, optional, default radius
  23514. * * radiusY allows stretching in the y direction, optional, default radius
  23515. * * radiusZ allows stretching in the z direction, optional, default radius
  23516. * * flat when true creates a flat shaded mesh, optional, default true
  23517. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23518. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23519. * * 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)
  23520. * * 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)
  23521. * @returns the VertexData of the IcoSphere
  23522. */
  23523. static CreateIcoSphere(options: {
  23524. radius?: number;
  23525. radiusX?: number;
  23526. radiusY?: number;
  23527. radiusZ?: number;
  23528. flat?: boolean;
  23529. subdivisions?: number;
  23530. sideOrientation?: number;
  23531. frontUVs?: Vector4;
  23532. backUVs?: Vector4;
  23533. }): VertexData;
  23534. /**
  23535. * Creates the VertexData for a Polyhedron
  23536. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23537. * * type provided types are:
  23538. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23539. * * 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)
  23540. * * size the size of the IcoSphere, optional default 1
  23541. * * sizeX allows stretching in the x direction, optional, default size
  23542. * * sizeY allows stretching in the y direction, optional, default size
  23543. * * sizeZ allows stretching in the z direction, optional, default size
  23544. * * 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
  23545. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23546. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23547. * * flat when true creates a flat shaded mesh, optional, default true
  23548. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23549. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23550. * * 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)
  23551. * * 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)
  23552. * @returns the VertexData of the Polyhedron
  23553. */
  23554. static CreatePolyhedron(options: {
  23555. type?: number;
  23556. size?: number;
  23557. sizeX?: number;
  23558. sizeY?: number;
  23559. sizeZ?: number;
  23560. custom?: any;
  23561. faceUV?: Vector4[];
  23562. faceColors?: Color4[];
  23563. flat?: boolean;
  23564. sideOrientation?: number;
  23565. frontUVs?: Vector4;
  23566. backUVs?: Vector4;
  23567. }): VertexData;
  23568. /**
  23569. * Creates the VertexData for a TorusKnot
  23570. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23571. * * radius the radius of the torus knot, optional, default 2
  23572. * * tube the thickness of the tube, optional, default 0.5
  23573. * * radialSegments the number of sides on each tube segments, optional, default 32
  23574. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23575. * * p the number of windings around the z axis, optional, default 2
  23576. * * q the number of windings around the x axis, optional, default 3
  23577. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23578. * * 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)
  23579. * * 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)
  23580. * @returns the VertexData of the Torus Knot
  23581. */
  23582. static CreateTorusKnot(options: {
  23583. radius?: number;
  23584. tube?: number;
  23585. radialSegments?: number;
  23586. tubularSegments?: number;
  23587. p?: number;
  23588. q?: number;
  23589. sideOrientation?: number;
  23590. frontUVs?: Vector4;
  23591. backUVs?: Vector4;
  23592. }): VertexData;
  23593. /**
  23594. * Compute normals for given positions and indices
  23595. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23596. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23597. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23598. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23599. * * facetNormals : optional array of facet normals (vector3)
  23600. * * facetPositions : optional array of facet positions (vector3)
  23601. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23602. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23603. * * bInfo : optional bounding info, required for facetPartitioning computation
  23604. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23605. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23606. * * useRightHandedSystem: optional boolean to for right handed system computation
  23607. * * depthSort : optional boolean to enable the facet depth sort computation
  23608. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23609. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23610. */
  23611. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23612. facetNormals?: any;
  23613. facetPositions?: any;
  23614. facetPartitioning?: any;
  23615. ratio?: number;
  23616. bInfo?: any;
  23617. bbSize?: Vector3;
  23618. subDiv?: any;
  23619. useRightHandedSystem?: boolean;
  23620. depthSort?: boolean;
  23621. distanceTo?: Vector3;
  23622. depthSortedFacets?: any;
  23623. }): void;
  23624. /** @hidden */
  23625. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23626. /**
  23627. * Applies VertexData created from the imported parameters to the geometry
  23628. * @param parsedVertexData the parsed data from an imported file
  23629. * @param geometry the geometry to apply the VertexData to
  23630. */
  23631. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23632. }
  23633. }
  23634. declare module BABYLON {
  23635. /**
  23636. * Class containing static functions to help procedurally build meshes
  23637. */
  23638. export class DiscBuilder {
  23639. /**
  23640. * Creates a plane polygonal mesh. By default, this is a disc
  23641. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23642. * * 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
  23643. * * 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
  23644. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23645. * * 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
  23646. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23647. * @param name defines the name of the mesh
  23648. * @param options defines the options used to create the mesh
  23649. * @param scene defines the hosting scene
  23650. * @returns the plane polygonal mesh
  23651. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23652. */
  23653. static CreateDisc(name: string, options: {
  23654. radius?: number;
  23655. tessellation?: number;
  23656. arc?: number;
  23657. updatable?: boolean;
  23658. sideOrientation?: number;
  23659. frontUVs?: Vector4;
  23660. backUVs?: Vector4;
  23661. }, scene?: Nullable<Scene>): Mesh;
  23662. }
  23663. }
  23664. declare module BABYLON {
  23665. /**
  23666. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23667. *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.
  23668. * The SPS is also a particle system. It provides some methods to manage the particles.
  23669. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23670. *
  23671. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23672. */
  23673. export class SolidParticleSystem implements IDisposable {
  23674. /**
  23675. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23676. * Example : var p = SPS.particles[i];
  23677. */
  23678. particles: SolidParticle[];
  23679. /**
  23680. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23681. */
  23682. nbParticles: number;
  23683. /**
  23684. * If the particles must ever face the camera (default false). Useful for planar particles.
  23685. */
  23686. billboard: boolean;
  23687. /**
  23688. * Recompute normals when adding a shape
  23689. */
  23690. recomputeNormals: boolean;
  23691. /**
  23692. * This a counter ofr your own usage. It's not set by any SPS functions.
  23693. */
  23694. counter: number;
  23695. /**
  23696. * The SPS name. This name is also given to the underlying mesh.
  23697. */
  23698. name: string;
  23699. /**
  23700. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23701. */
  23702. mesh: Mesh;
  23703. /**
  23704. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23705. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23706. */
  23707. vars: any;
  23708. /**
  23709. * This array is populated when the SPS is set as 'pickable'.
  23710. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23711. * Each element of this array is an object `{idx: int, faceId: int}`.
  23712. * `idx` is the picked particle index in the `SPS.particles` array
  23713. * `faceId` is the picked face index counted within this particle.
  23714. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23715. */
  23716. pickedParticles: {
  23717. idx: number;
  23718. faceId: number;
  23719. }[];
  23720. /**
  23721. * This array is populated when `enableDepthSort` is set to true.
  23722. * Each element of this array is an instance of the class DepthSortedParticle.
  23723. */
  23724. depthSortedParticles: DepthSortedParticle[];
  23725. /**
  23726. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23727. * @hidden
  23728. */
  23729. _bSphereOnly: boolean;
  23730. /**
  23731. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23732. * @hidden
  23733. */
  23734. _bSphereRadiusFactor: number;
  23735. private _scene;
  23736. private _positions;
  23737. private _indices;
  23738. private _normals;
  23739. private _colors;
  23740. private _uvs;
  23741. private _indices32;
  23742. private _positions32;
  23743. private _normals32;
  23744. private _fixedNormal32;
  23745. private _colors32;
  23746. private _uvs32;
  23747. private _index;
  23748. private _updatable;
  23749. private _pickable;
  23750. private _isVisibilityBoxLocked;
  23751. private _alwaysVisible;
  23752. private _depthSort;
  23753. private _shapeCounter;
  23754. private _copy;
  23755. private _color;
  23756. private _computeParticleColor;
  23757. private _computeParticleTexture;
  23758. private _computeParticleRotation;
  23759. private _computeParticleVertex;
  23760. private _computeBoundingBox;
  23761. private _depthSortParticles;
  23762. private _camera;
  23763. private _mustUnrotateFixedNormals;
  23764. private _particlesIntersect;
  23765. private _needs32Bits;
  23766. /**
  23767. * Creates a SPS (Solid Particle System) object.
  23768. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23769. * @param scene (Scene) is the scene in which the SPS is added.
  23770. * @param options defines the options of the sps e.g.
  23771. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23772. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23773. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23774. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23775. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23776. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23777. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23778. */
  23779. constructor(name: string, scene: Scene, options?: {
  23780. updatable?: boolean;
  23781. isPickable?: boolean;
  23782. enableDepthSort?: boolean;
  23783. particleIntersection?: boolean;
  23784. boundingSphereOnly?: boolean;
  23785. bSphereRadiusFactor?: number;
  23786. });
  23787. /**
  23788. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23789. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23790. * @returns the created mesh
  23791. */
  23792. buildMesh(): Mesh;
  23793. /**
  23794. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  23795. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  23796. * Thus the particles generated from `digest()` have their property `position` set yet.
  23797. * @param mesh ( Mesh ) is the mesh to be digested
  23798. * @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
  23799. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  23800. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  23801. * @returns the current SPS
  23802. */
  23803. digest(mesh: Mesh, options?: {
  23804. facetNb?: number;
  23805. number?: number;
  23806. delta?: number;
  23807. }): SolidParticleSystem;
  23808. private _unrotateFixedNormals;
  23809. private _resetCopy;
  23810. private _meshBuilder;
  23811. private _posToShape;
  23812. private _uvsToShapeUV;
  23813. private _addParticle;
  23814. /**
  23815. * Adds some particles to the SPS from the model shape. Returns the shape id.
  23816. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  23817. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  23818. * @param nb (positive integer) the number of particles to be created from this model
  23819. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  23820. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  23821. * @returns the number of shapes in the system
  23822. */
  23823. addShape(mesh: Mesh, nb: number, options?: {
  23824. positionFunction?: any;
  23825. vertexFunction?: any;
  23826. }): number;
  23827. private _rebuildParticle;
  23828. /**
  23829. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  23830. * @returns the SPS.
  23831. */
  23832. rebuildMesh(): SolidParticleSystem;
  23833. /**
  23834. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  23835. * This method calls `updateParticle()` for each particle of the SPS.
  23836. * For an animated SPS, it is usually called within the render loop.
  23837. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  23838. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  23839. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  23840. * @returns the SPS.
  23841. */
  23842. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  23843. /**
  23844. * Disposes the SPS.
  23845. */
  23846. dispose(): void;
  23847. /**
  23848. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  23849. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23850. * @returns the SPS.
  23851. */
  23852. refreshVisibleSize(): SolidParticleSystem;
  23853. /**
  23854. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  23855. * @param size the size (float) of the visibility box
  23856. * note : this doesn't lock the SPS mesh bounding box.
  23857. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23858. */
  23859. setVisibilityBox(size: number): void;
  23860. /**
  23861. * Gets whether the SPS as always visible or not
  23862. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23863. */
  23864. /**
  23865. * Sets the SPS as always visible or not
  23866. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23867. */
  23868. isAlwaysVisible: boolean;
  23869. /**
  23870. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23871. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23872. */
  23873. /**
  23874. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23875. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23876. */
  23877. isVisibilityBoxLocked: boolean;
  23878. /**
  23879. * Tells to `setParticles()` to compute the particle rotations or not.
  23880. * Default value : true. The SPS is faster when it's set to false.
  23881. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23882. */
  23883. /**
  23884. * Gets if `setParticles()` computes the particle rotations or not.
  23885. * Default value : true. The SPS is faster when it's set to false.
  23886. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23887. */
  23888. computeParticleRotation: boolean;
  23889. /**
  23890. * Tells to `setParticles()` to compute the particle colors or not.
  23891. * Default value : true. The SPS is faster when it's set to false.
  23892. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23893. */
  23894. /**
  23895. * Gets if `setParticles()` computes the particle colors or not.
  23896. * Default value : true. The SPS is faster when it's set to false.
  23897. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23898. */
  23899. computeParticleColor: boolean;
  23900. /**
  23901. * Gets if `setParticles()` computes the particle textures or not.
  23902. * Default value : true. The SPS is faster when it's set to false.
  23903. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  23904. */
  23905. computeParticleTexture: boolean;
  23906. /**
  23907. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  23908. * Default value : false. The SPS is faster when it's set to false.
  23909. * Note : the particle custom vertex positions aren't stored values.
  23910. */
  23911. /**
  23912. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  23913. * Default value : false. The SPS is faster when it's set to false.
  23914. * Note : the particle custom vertex positions aren't stored values.
  23915. */
  23916. computeParticleVertex: boolean;
  23917. /**
  23918. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  23919. */
  23920. /**
  23921. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  23922. */
  23923. computeBoundingBox: boolean;
  23924. /**
  23925. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  23926. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23927. * Default : `true`
  23928. */
  23929. /**
  23930. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  23931. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23932. * Default : `true`
  23933. */
  23934. depthSortParticles: boolean;
  23935. /**
  23936. * This function does nothing. It may be overwritten to set all the particle first values.
  23937. * The SPS doesn't call this function, you may have to call it by your own.
  23938. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23939. */
  23940. initParticles(): void;
  23941. /**
  23942. * This function does nothing. It may be overwritten to recycle a particle.
  23943. * The SPS doesn't call this function, you may have to call it by your own.
  23944. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23945. * @param particle The particle to recycle
  23946. * @returns the recycled particle
  23947. */
  23948. recycleParticle(particle: SolidParticle): SolidParticle;
  23949. /**
  23950. * Updates a particle : this function should be overwritten by the user.
  23951. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  23952. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23953. * @example : just set a particle position or velocity and recycle conditions
  23954. * @param particle The particle to update
  23955. * @returns the updated particle
  23956. */
  23957. updateParticle(particle: SolidParticle): SolidParticle;
  23958. /**
  23959. * Updates a vertex of a particle : it can be overwritten by the user.
  23960. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  23961. * @param particle the current particle
  23962. * @param vertex the current index of the current particle
  23963. * @param pt the index of the current vertex in the particle shape
  23964. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  23965. * @example : just set a vertex particle position
  23966. * @returns the updated vertex
  23967. */
  23968. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  23969. /**
  23970. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  23971. * This does nothing and may be overwritten by the user.
  23972. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23973. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23974. * @param update the boolean update value actually passed to setParticles()
  23975. */
  23976. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23977. /**
  23978. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  23979. * This will be passed three parameters.
  23980. * This does nothing and may be overwritten by the user.
  23981. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23982. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23983. * @param update the boolean update value actually passed to setParticles()
  23984. */
  23985. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23986. }
  23987. }
  23988. declare module BABYLON {
  23989. /**
  23990. * Represents one particle of a solid particle system.
  23991. */
  23992. export class SolidParticle {
  23993. /**
  23994. * particle global index
  23995. */
  23996. idx: number;
  23997. /**
  23998. * The color of the particle
  23999. */
  24000. color: Nullable<Color4>;
  24001. /**
  24002. * The world space position of the particle.
  24003. */
  24004. position: Vector3;
  24005. /**
  24006. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24007. */
  24008. rotation: Vector3;
  24009. /**
  24010. * The world space rotation quaternion of the particle.
  24011. */
  24012. rotationQuaternion: Nullable<Quaternion>;
  24013. /**
  24014. * The scaling of the particle.
  24015. */
  24016. scaling: Vector3;
  24017. /**
  24018. * The uvs of the particle.
  24019. */
  24020. uvs: Vector4;
  24021. /**
  24022. * The current speed of the particle.
  24023. */
  24024. velocity: Vector3;
  24025. /**
  24026. * The pivot point in the particle local space.
  24027. */
  24028. pivot: Vector3;
  24029. /**
  24030. * Must the particle be translated from its pivot point in its local space ?
  24031. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24032. * Default : false
  24033. */
  24034. translateFromPivot: boolean;
  24035. /**
  24036. * Is the particle active or not ?
  24037. */
  24038. alive: boolean;
  24039. /**
  24040. * Is the particle visible or not ?
  24041. */
  24042. isVisible: boolean;
  24043. /**
  24044. * Index of this particle in the global "positions" array (Internal use)
  24045. * @hidden
  24046. */
  24047. _pos: number;
  24048. /**
  24049. * @hidden Index of this particle in the global "indices" array (Internal use)
  24050. */
  24051. _ind: number;
  24052. /**
  24053. * @hidden ModelShape of this particle (Internal use)
  24054. */
  24055. _model: ModelShape;
  24056. /**
  24057. * ModelShape id of this particle
  24058. */
  24059. shapeId: number;
  24060. /**
  24061. * Index of the particle in its shape id (Internal use)
  24062. */
  24063. idxInShape: number;
  24064. /**
  24065. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24066. */
  24067. _modelBoundingInfo: BoundingInfo;
  24068. /**
  24069. * @hidden Particle BoundingInfo object (Internal use)
  24070. */
  24071. _boundingInfo: BoundingInfo;
  24072. /**
  24073. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24074. */
  24075. _sps: SolidParticleSystem;
  24076. /**
  24077. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24078. */
  24079. _stillInvisible: boolean;
  24080. /**
  24081. * @hidden Last computed particle rotation matrix
  24082. */
  24083. _rotationMatrix: number[];
  24084. /**
  24085. * Parent particle Id, if any.
  24086. * Default null.
  24087. */
  24088. parentId: Nullable<number>;
  24089. /**
  24090. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24091. * The possible values are :
  24092. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24093. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24094. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24095. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24096. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24097. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24098. * */
  24099. cullingStrategy: number;
  24100. /**
  24101. * @hidden Internal global position in the SPS.
  24102. */
  24103. _globalPosition: Vector3;
  24104. /**
  24105. * Creates a Solid Particle object.
  24106. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24107. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24108. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24109. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24110. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24111. * @param shapeId (integer) is the model shape identifier in the SPS.
  24112. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24113. * @param sps defines the sps it is associated to
  24114. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24115. */
  24116. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24117. /**
  24118. * Legacy support, changed scale to scaling
  24119. */
  24120. /**
  24121. * Legacy support, changed scale to scaling
  24122. */
  24123. scale: Vector3;
  24124. /**
  24125. * Legacy support, changed quaternion to rotationQuaternion
  24126. */
  24127. /**
  24128. * Legacy support, changed quaternion to rotationQuaternion
  24129. */
  24130. quaternion: Nullable<Quaternion>;
  24131. /**
  24132. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  24133. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  24134. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  24135. * @returns true if it intersects
  24136. */
  24137. intersectsMesh(target: Mesh | SolidParticle): boolean;
  24138. /**
  24139. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  24140. * A particle is in the frustum if its bounding box intersects the frustum
  24141. * @param frustumPlanes defines the frustum to test
  24142. * @returns true if the particle is in the frustum planes
  24143. */
  24144. isInFrustum(frustumPlanes: Plane[]): boolean;
  24145. /**
  24146. * get the rotation matrix of the particle
  24147. * @hidden
  24148. */
  24149. getRotationMatrix(m: Matrix): void;
  24150. }
  24151. /**
  24152. * Represents the shape of the model used by one particle of a solid particle system.
  24153. * SPS internal tool, don't use it manually.
  24154. */
  24155. export class ModelShape {
  24156. /**
  24157. * The shape id
  24158. * @hidden
  24159. */
  24160. shapeID: number;
  24161. /**
  24162. * flat array of model positions (internal use)
  24163. * @hidden
  24164. */
  24165. _shape: Vector3[];
  24166. /**
  24167. * flat array of model UVs (internal use)
  24168. * @hidden
  24169. */
  24170. _shapeUV: number[];
  24171. /**
  24172. * length of the shape in the model indices array (internal use)
  24173. * @hidden
  24174. */
  24175. _indicesLength: number;
  24176. /**
  24177. * Custom position function (internal use)
  24178. * @hidden
  24179. */
  24180. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  24181. /**
  24182. * Custom vertex function (internal use)
  24183. * @hidden
  24184. */
  24185. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  24186. /**
  24187. * 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.
  24188. * SPS internal tool, don't use it manually.
  24189. * @hidden
  24190. */
  24191. 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>);
  24192. }
  24193. /**
  24194. * Represents a Depth Sorted Particle in the solid particle system.
  24195. */
  24196. export class DepthSortedParticle {
  24197. /**
  24198. * Index of the particle in the "indices" array
  24199. */
  24200. ind: number;
  24201. /**
  24202. * Length of the particle shape in the "indices" array
  24203. */
  24204. indicesLength: number;
  24205. /**
  24206. * Squared distance from the particle to the camera
  24207. */
  24208. sqDistance: number;
  24209. }
  24210. }
  24211. declare module BABYLON {
  24212. /**
  24213. * @hidden
  24214. */
  24215. export class _MeshCollisionData {
  24216. _checkCollisions: boolean;
  24217. _collisionMask: number;
  24218. _collisionGroup: number;
  24219. _collider: Nullable<Collider>;
  24220. _oldPositionForCollisions: Vector3;
  24221. _diffPositionForCollisions: Vector3;
  24222. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  24223. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  24224. }
  24225. }
  24226. declare module BABYLON {
  24227. /** @hidden */
  24228. class _FacetDataStorage {
  24229. facetPositions: Vector3[];
  24230. facetNormals: Vector3[];
  24231. facetPartitioning: number[][];
  24232. facetNb: number;
  24233. partitioningSubdivisions: number;
  24234. partitioningBBoxRatio: number;
  24235. facetDataEnabled: boolean;
  24236. facetParameters: any;
  24237. bbSize: Vector3;
  24238. subDiv: {
  24239. max: number;
  24240. X: number;
  24241. Y: number;
  24242. Z: number;
  24243. };
  24244. facetDepthSort: boolean;
  24245. facetDepthSortEnabled: boolean;
  24246. depthSortedIndices: IndicesArray;
  24247. depthSortedFacets: {
  24248. ind: number;
  24249. sqDistance: number;
  24250. }[];
  24251. facetDepthSortFunction: (f1: {
  24252. ind: number;
  24253. sqDistance: number;
  24254. }, f2: {
  24255. ind: number;
  24256. sqDistance: number;
  24257. }) => number;
  24258. facetDepthSortFrom: Vector3;
  24259. facetDepthSortOrigin: Vector3;
  24260. invertedMatrix: Matrix;
  24261. }
  24262. /**
  24263. * @hidden
  24264. **/
  24265. class _InternalAbstractMeshDataInfo {
  24266. _hasVertexAlpha: boolean;
  24267. _useVertexColors: boolean;
  24268. _numBoneInfluencers: number;
  24269. _applyFog: boolean;
  24270. _receiveShadows: boolean;
  24271. _facetData: _FacetDataStorage;
  24272. _visibility: number;
  24273. _skeleton: Nullable<Skeleton>;
  24274. _layerMask: number;
  24275. _computeBonesUsingShaders: boolean;
  24276. _isActive: boolean;
  24277. _onlyForInstances: boolean;
  24278. _isActiveIntermediate: boolean;
  24279. _onlyForInstancesIntermediate: boolean;
  24280. }
  24281. /**
  24282. * Class used to store all common mesh properties
  24283. */
  24284. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24285. /** No occlusion */
  24286. static OCCLUSION_TYPE_NONE: number;
  24287. /** Occlusion set to optimisitic */
  24288. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24289. /** Occlusion set to strict */
  24290. static OCCLUSION_TYPE_STRICT: number;
  24291. /** Use an accurante occlusion algorithm */
  24292. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24293. /** Use a conservative occlusion algorithm */
  24294. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24295. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  24296. * Test order :
  24297. * Is the bounding sphere outside the frustum ?
  24298. * If not, are the bounding box vertices outside the frustum ?
  24299. * It not, then the cullable object is in the frustum.
  24300. */
  24301. static readonly CULLINGSTRATEGY_STANDARD: number;
  24302. /** Culling strategy : Bounding Sphere Only.
  24303. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  24304. * It's also less accurate than the standard because some not visible objects can still be selected.
  24305. * Test : is the bounding sphere outside the frustum ?
  24306. * If not, then the cullable object is in the frustum.
  24307. */
  24308. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24309. /** Culling strategy : Optimistic Inclusion.
  24310. * This in an inclusion test first, then the standard exclusion test.
  24311. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  24312. * 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.
  24313. * Anyway, it's as accurate as the standard strategy.
  24314. * Test :
  24315. * Is the cullable object bounding sphere center in the frustum ?
  24316. * If not, apply the default culling strategy.
  24317. */
  24318. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  24319. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  24320. * This in an inclusion test first, then the bounding sphere only exclusion test.
  24321. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  24322. * 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.
  24323. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  24324. * Test :
  24325. * Is the cullable object bounding sphere center in the frustum ?
  24326. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  24327. */
  24328. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  24329. /**
  24330. * No billboard
  24331. */
  24332. static readonly BILLBOARDMODE_NONE: number;
  24333. /** Billboard on X axis */
  24334. static readonly BILLBOARDMODE_X: number;
  24335. /** Billboard on Y axis */
  24336. static readonly BILLBOARDMODE_Y: number;
  24337. /** Billboard on Z axis */
  24338. static readonly BILLBOARDMODE_Z: number;
  24339. /** Billboard on all axes */
  24340. static readonly BILLBOARDMODE_ALL: number;
  24341. /** @hidden */
  24342. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  24343. /**
  24344. * The culling strategy to use to check whether the mesh must be rendered or not.
  24345. * This value can be changed at any time and will be used on the next render mesh selection.
  24346. * The possible values are :
  24347. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24348. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24349. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24350. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24351. * Please read each static variable documentation to get details about the culling process.
  24352. * */
  24353. cullingStrategy: number;
  24354. /**
  24355. * Gets the number of facets in the mesh
  24356. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24357. */
  24358. readonly facetNb: number;
  24359. /**
  24360. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24361. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24362. */
  24363. partitioningSubdivisions: number;
  24364. /**
  24365. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24366. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24367. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24368. */
  24369. partitioningBBoxRatio: number;
  24370. /**
  24371. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24372. * Works only for updatable meshes.
  24373. * Doesn't work with multi-materials
  24374. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24375. */
  24376. mustDepthSortFacets: boolean;
  24377. /**
  24378. * The location (Vector3) where the facet depth sort must be computed from.
  24379. * By default, the active camera position.
  24380. * Used only when facet depth sort is enabled
  24381. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24382. */
  24383. facetDepthSortFrom: Vector3;
  24384. /**
  24385. * gets a boolean indicating if facetData is enabled
  24386. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24387. */
  24388. readonly isFacetDataEnabled: boolean;
  24389. /** @hidden */
  24390. _updateNonUniformScalingState(value: boolean): boolean;
  24391. /**
  24392. * An event triggered when this mesh collides with another one
  24393. */
  24394. onCollideObservable: Observable<AbstractMesh>;
  24395. /** Set a function to call when this mesh collides with another one */
  24396. onCollide: () => void;
  24397. /**
  24398. * An event triggered when the collision's position changes
  24399. */
  24400. onCollisionPositionChangeObservable: Observable<Vector3>;
  24401. /** Set a function to call when the collision's position changes */
  24402. onCollisionPositionChange: () => void;
  24403. /**
  24404. * An event triggered when material is changed
  24405. */
  24406. onMaterialChangedObservable: Observable<AbstractMesh>;
  24407. /**
  24408. * Gets or sets the orientation for POV movement & rotation
  24409. */
  24410. definedFacingForward: boolean;
  24411. /** @hidden */
  24412. _occlusionQuery: Nullable<WebGLQuery>;
  24413. /** @hidden */
  24414. _renderingGroup: Nullable<RenderingGroup>;
  24415. /**
  24416. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24417. */
  24418. /**
  24419. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24420. */
  24421. visibility: number;
  24422. /** Gets or sets the alpha index used to sort transparent meshes
  24423. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24424. */
  24425. alphaIndex: number;
  24426. /**
  24427. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24428. */
  24429. isVisible: boolean;
  24430. /**
  24431. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24432. */
  24433. isPickable: boolean;
  24434. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24435. showSubMeshesBoundingBox: boolean;
  24436. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24437. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24438. */
  24439. isBlocker: boolean;
  24440. /**
  24441. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24442. */
  24443. enablePointerMoveEvents: boolean;
  24444. /**
  24445. * Specifies the rendering group id for this mesh (0 by default)
  24446. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24447. */
  24448. renderingGroupId: number;
  24449. private _material;
  24450. /** Gets or sets current material */
  24451. material: Nullable<Material>;
  24452. /**
  24453. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24454. * @see http://doc.babylonjs.com/babylon101/shadows
  24455. */
  24456. receiveShadows: boolean;
  24457. /** Defines color to use when rendering outline */
  24458. outlineColor: Color3;
  24459. /** Define width to use when rendering outline */
  24460. outlineWidth: number;
  24461. /** Defines color to use when rendering overlay */
  24462. overlayColor: Color3;
  24463. /** Defines alpha to use when rendering overlay */
  24464. overlayAlpha: number;
  24465. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24466. hasVertexAlpha: boolean;
  24467. /** 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) */
  24468. useVertexColors: boolean;
  24469. /**
  24470. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24471. */
  24472. computeBonesUsingShaders: boolean;
  24473. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24474. numBoneInfluencers: number;
  24475. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24476. applyFog: boolean;
  24477. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24478. useOctreeForRenderingSelection: boolean;
  24479. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24480. useOctreeForPicking: boolean;
  24481. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24482. useOctreeForCollisions: boolean;
  24483. /**
  24484. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24485. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24486. */
  24487. layerMask: number;
  24488. /**
  24489. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24490. */
  24491. alwaysSelectAsActiveMesh: boolean;
  24492. /**
  24493. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  24494. */
  24495. doNotSyncBoundingInfo: boolean;
  24496. /**
  24497. * Gets or sets the current action manager
  24498. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24499. */
  24500. actionManager: Nullable<AbstractActionManager>;
  24501. private _meshCollisionData;
  24502. /**
  24503. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24504. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24505. */
  24506. ellipsoid: Vector3;
  24507. /**
  24508. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24509. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24510. */
  24511. ellipsoidOffset: Vector3;
  24512. /**
  24513. * Gets or sets a collision mask used to mask collisions (default is -1).
  24514. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24515. */
  24516. collisionMask: number;
  24517. /**
  24518. * Gets or sets the current collision group mask (-1 by default).
  24519. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24520. */
  24521. collisionGroup: number;
  24522. /**
  24523. * Defines edge width used when edgesRenderer is enabled
  24524. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24525. */
  24526. edgesWidth: number;
  24527. /**
  24528. * Defines edge color used when edgesRenderer is enabled
  24529. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24530. */
  24531. edgesColor: Color4;
  24532. /** @hidden */
  24533. _edgesRenderer: Nullable<IEdgesRenderer>;
  24534. /** @hidden */
  24535. _masterMesh: Nullable<AbstractMesh>;
  24536. /** @hidden */
  24537. _boundingInfo: Nullable<BoundingInfo>;
  24538. /** @hidden */
  24539. _renderId: number;
  24540. /**
  24541. * Gets or sets the list of subMeshes
  24542. * @see http://doc.babylonjs.com/how_to/multi_materials
  24543. */
  24544. subMeshes: SubMesh[];
  24545. /** @hidden */
  24546. _intersectionsInProgress: AbstractMesh[];
  24547. /** @hidden */
  24548. _unIndexed: boolean;
  24549. /** @hidden */
  24550. _lightSources: Light[];
  24551. /** Gets the list of lights affecting that mesh */
  24552. readonly lightSources: Light[];
  24553. /** @hidden */
  24554. readonly _positions: Nullable<Vector3[]>;
  24555. /** @hidden */
  24556. _waitingData: {
  24557. lods: Nullable<any>;
  24558. actions: Nullable<any>;
  24559. freezeWorldMatrix: Nullable<boolean>;
  24560. };
  24561. /** @hidden */
  24562. _bonesTransformMatrices: Nullable<Float32Array>;
  24563. /**
  24564. * Gets or sets a skeleton to apply skining transformations
  24565. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24566. */
  24567. skeleton: Nullable<Skeleton>;
  24568. /**
  24569. * An event triggered when the mesh is rebuilt.
  24570. */
  24571. onRebuildObservable: Observable<AbstractMesh>;
  24572. /**
  24573. * Creates a new AbstractMesh
  24574. * @param name defines the name of the mesh
  24575. * @param scene defines the hosting scene
  24576. */
  24577. constructor(name: string, scene?: Nullable<Scene>);
  24578. /**
  24579. * Returns the string "AbstractMesh"
  24580. * @returns "AbstractMesh"
  24581. */
  24582. getClassName(): string;
  24583. /**
  24584. * Gets a string representation of the current mesh
  24585. * @param fullDetails defines a boolean indicating if full details must be included
  24586. * @returns a string representation of the current mesh
  24587. */
  24588. toString(fullDetails?: boolean): string;
  24589. /**
  24590. * @hidden
  24591. */
  24592. protected _getEffectiveParent(): Nullable<Node>;
  24593. /** @hidden */
  24594. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24595. /** @hidden */
  24596. _rebuild(): void;
  24597. /** @hidden */
  24598. _resyncLightSources(): void;
  24599. /** @hidden */
  24600. _resyncLighSource(light: Light): void;
  24601. /** @hidden */
  24602. _unBindEffect(): void;
  24603. /** @hidden */
  24604. _removeLightSource(light: Light): void;
  24605. private _markSubMeshesAsDirty;
  24606. /** @hidden */
  24607. _markSubMeshesAsLightDirty(): void;
  24608. /** @hidden */
  24609. _markSubMeshesAsAttributesDirty(): void;
  24610. /** @hidden */
  24611. _markSubMeshesAsMiscDirty(): void;
  24612. /**
  24613. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24614. */
  24615. scaling: Vector3;
  24616. /**
  24617. * Returns true if the mesh is blocked. Implemented by child classes
  24618. */
  24619. readonly isBlocked: boolean;
  24620. /**
  24621. * Returns the mesh itself by default. Implemented by child classes
  24622. * @param camera defines the camera to use to pick the right LOD level
  24623. * @returns the currentAbstractMesh
  24624. */
  24625. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24626. /**
  24627. * Returns 0 by default. Implemented by child classes
  24628. * @returns an integer
  24629. */
  24630. getTotalVertices(): number;
  24631. /**
  24632. * Returns a positive integer : the total number of indices in this mesh geometry.
  24633. * @returns the numner of indices or zero if the mesh has no geometry.
  24634. */
  24635. getTotalIndices(): number;
  24636. /**
  24637. * Returns null by default. Implemented by child classes
  24638. * @returns null
  24639. */
  24640. getIndices(): Nullable<IndicesArray>;
  24641. /**
  24642. * Returns the array of the requested vertex data kind. Implemented by child classes
  24643. * @param kind defines the vertex data kind to use
  24644. * @returns null
  24645. */
  24646. getVerticesData(kind: string): Nullable<FloatArray>;
  24647. /**
  24648. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24649. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24650. * Note that a new underlying VertexBuffer object is created each call.
  24651. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24652. * @param kind defines vertex data kind:
  24653. * * VertexBuffer.PositionKind
  24654. * * VertexBuffer.UVKind
  24655. * * VertexBuffer.UV2Kind
  24656. * * VertexBuffer.UV3Kind
  24657. * * VertexBuffer.UV4Kind
  24658. * * VertexBuffer.UV5Kind
  24659. * * VertexBuffer.UV6Kind
  24660. * * VertexBuffer.ColorKind
  24661. * * VertexBuffer.MatricesIndicesKind
  24662. * * VertexBuffer.MatricesIndicesExtraKind
  24663. * * VertexBuffer.MatricesWeightsKind
  24664. * * VertexBuffer.MatricesWeightsExtraKind
  24665. * @param data defines the data source
  24666. * @param updatable defines if the data must be flagged as updatable (or static)
  24667. * @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
  24668. * @returns the current mesh
  24669. */
  24670. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24671. /**
  24672. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24673. * If the mesh has no geometry, it is simply returned as it is.
  24674. * @param kind defines vertex data kind:
  24675. * * VertexBuffer.PositionKind
  24676. * * VertexBuffer.UVKind
  24677. * * VertexBuffer.UV2Kind
  24678. * * VertexBuffer.UV3Kind
  24679. * * VertexBuffer.UV4Kind
  24680. * * VertexBuffer.UV5Kind
  24681. * * VertexBuffer.UV6Kind
  24682. * * VertexBuffer.ColorKind
  24683. * * VertexBuffer.MatricesIndicesKind
  24684. * * VertexBuffer.MatricesIndicesExtraKind
  24685. * * VertexBuffer.MatricesWeightsKind
  24686. * * VertexBuffer.MatricesWeightsExtraKind
  24687. * @param data defines the data source
  24688. * @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
  24689. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24690. * @returns the current mesh
  24691. */
  24692. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24693. /**
  24694. * Sets the mesh indices,
  24695. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24696. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24697. * @param totalVertices Defines the total number of vertices
  24698. * @returns the current mesh
  24699. */
  24700. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24701. /**
  24702. * Gets a boolean indicating if specific vertex data is present
  24703. * @param kind defines the vertex data kind to use
  24704. * @returns true is data kind is present
  24705. */
  24706. isVerticesDataPresent(kind: string): boolean;
  24707. /**
  24708. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24709. * @returns a BoundingInfo
  24710. */
  24711. getBoundingInfo(): BoundingInfo;
  24712. /**
  24713. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24714. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  24715. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  24716. * @returns the current mesh
  24717. */
  24718. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  24719. /**
  24720. * Overwrite the current bounding info
  24721. * @param boundingInfo defines the new bounding info
  24722. * @returns the current mesh
  24723. */
  24724. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24725. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24726. readonly useBones: boolean;
  24727. /** @hidden */
  24728. _preActivate(): void;
  24729. /** @hidden */
  24730. _preActivateForIntermediateRendering(renderId: number): void;
  24731. /** @hidden */
  24732. _activate(renderId: number, intermediateRendering: boolean): boolean;
  24733. /** @hidden */
  24734. _postActivate(): void;
  24735. /** @hidden */
  24736. _freeze(): void;
  24737. /** @hidden */
  24738. _unFreeze(): void;
  24739. /**
  24740. * Gets the current world matrix
  24741. * @returns a Matrix
  24742. */
  24743. getWorldMatrix(): Matrix;
  24744. /** @hidden */
  24745. _getWorldMatrixDeterminant(): number;
  24746. /**
  24747. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  24748. */
  24749. readonly isAnInstance: boolean;
  24750. /**
  24751. * Perform relative position change from the point of view of behind the front of the mesh.
  24752. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24753. * Supports definition of mesh facing forward or backward
  24754. * @param amountRight defines the distance on the right axis
  24755. * @param amountUp defines the distance on the up axis
  24756. * @param amountForward defines the distance on the forward axis
  24757. * @returns the current mesh
  24758. */
  24759. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24760. /**
  24761. * Calculate relative position change from the point of view of behind the front of the mesh.
  24762. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24763. * Supports definition of mesh facing forward or backward
  24764. * @param amountRight defines the distance on the right axis
  24765. * @param amountUp defines the distance on the up axis
  24766. * @param amountForward defines the distance on the forward axis
  24767. * @returns the new displacement vector
  24768. */
  24769. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24770. /**
  24771. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24772. * Supports definition of mesh facing forward or backward
  24773. * @param flipBack defines the flip
  24774. * @param twirlClockwise defines the twirl
  24775. * @param tiltRight defines the tilt
  24776. * @returns the current mesh
  24777. */
  24778. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24779. /**
  24780. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24781. * Supports definition of mesh facing forward or backward.
  24782. * @param flipBack defines the flip
  24783. * @param twirlClockwise defines the twirl
  24784. * @param tiltRight defines the tilt
  24785. * @returns the new rotation vector
  24786. */
  24787. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24788. /**
  24789. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24790. * This means the mesh underlying bounding box and sphere are recomputed.
  24791. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24792. * @returns the current mesh
  24793. */
  24794. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24795. /** @hidden */
  24796. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24797. /** @hidden */
  24798. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24799. /** @hidden */
  24800. _updateBoundingInfo(): AbstractMesh;
  24801. /** @hidden */
  24802. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24803. /** @hidden */
  24804. protected _afterComputeWorldMatrix(): void;
  24805. /** @hidden */
  24806. readonly _effectiveMesh: AbstractMesh;
  24807. /**
  24808. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24809. * A mesh is in the frustum if its bounding box intersects the frustum
  24810. * @param frustumPlanes defines the frustum to test
  24811. * @returns true if the mesh is in the frustum planes
  24812. */
  24813. isInFrustum(frustumPlanes: Plane[]): boolean;
  24814. /**
  24815. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24816. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24817. * @param frustumPlanes defines the frustum to test
  24818. * @returns true if the mesh is completely in the frustum planes
  24819. */
  24820. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24821. /**
  24822. * True if the mesh intersects another mesh or a SolidParticle object
  24823. * @param mesh defines a target mesh or SolidParticle to test
  24824. * @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)
  24825. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24826. * @returns true if there is an intersection
  24827. */
  24828. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24829. /**
  24830. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24831. * @param point defines the point to test
  24832. * @returns true if there is an intersection
  24833. */
  24834. intersectsPoint(point: Vector3): boolean;
  24835. /**
  24836. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24837. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24838. */
  24839. checkCollisions: boolean;
  24840. /**
  24841. * Gets Collider object used to compute collisions (not physics)
  24842. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24843. */
  24844. readonly collider: Nullable<Collider>;
  24845. /**
  24846. * Move the mesh using collision engine
  24847. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24848. * @param displacement defines the requested displacement vector
  24849. * @returns the current mesh
  24850. */
  24851. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24852. private _onCollisionPositionChange;
  24853. /** @hidden */
  24854. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24855. /** @hidden */
  24856. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24857. /** @hidden */
  24858. _checkCollision(collider: Collider): AbstractMesh;
  24859. /** @hidden */
  24860. _generatePointsArray(): boolean;
  24861. /**
  24862. * Checks if the passed Ray intersects with the mesh
  24863. * @param ray defines the ray to use
  24864. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24865. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24866. * @returns the picking info
  24867. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24868. */
  24869. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  24870. /**
  24871. * Clones the current mesh
  24872. * @param name defines the mesh name
  24873. * @param newParent defines the new mesh parent
  24874. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24875. * @returns the new mesh
  24876. */
  24877. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24878. /**
  24879. * Disposes all the submeshes of the current meshnp
  24880. * @returns the current mesh
  24881. */
  24882. releaseSubMeshes(): AbstractMesh;
  24883. /**
  24884. * Releases resources associated with this abstract mesh.
  24885. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24886. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24887. */
  24888. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24889. /**
  24890. * Adds the passed mesh as a child to the current mesh
  24891. * @param mesh defines the child mesh
  24892. * @returns the current mesh
  24893. */
  24894. addChild(mesh: AbstractMesh): AbstractMesh;
  24895. /**
  24896. * Removes the passed mesh from the current mesh children list
  24897. * @param mesh defines the child mesh
  24898. * @returns the current mesh
  24899. */
  24900. removeChild(mesh: AbstractMesh): AbstractMesh;
  24901. /** @hidden */
  24902. private _initFacetData;
  24903. /**
  24904. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24905. * This method can be called within the render loop.
  24906. * 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
  24907. * @returns the current mesh
  24908. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24909. */
  24910. updateFacetData(): AbstractMesh;
  24911. /**
  24912. * Returns the facetLocalNormals array.
  24913. * The normals are expressed in the mesh local spac
  24914. * @returns an array of Vector3
  24915. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24916. */
  24917. getFacetLocalNormals(): Vector3[];
  24918. /**
  24919. * Returns the facetLocalPositions array.
  24920. * The facet positions are expressed in the mesh local space
  24921. * @returns an array of Vector3
  24922. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24923. */
  24924. getFacetLocalPositions(): Vector3[];
  24925. /**
  24926. * Returns the facetLocalPartioning array
  24927. * @returns an array of array of numbers
  24928. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24929. */
  24930. getFacetLocalPartitioning(): number[][];
  24931. /**
  24932. * Returns the i-th facet position in the world system.
  24933. * This method allocates a new Vector3 per call
  24934. * @param i defines the facet index
  24935. * @returns a new Vector3
  24936. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24937. */
  24938. getFacetPosition(i: number): Vector3;
  24939. /**
  24940. * Sets the reference Vector3 with the i-th facet position in the world system
  24941. * @param i defines the facet index
  24942. * @param ref defines the target vector
  24943. * @returns the current mesh
  24944. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24945. */
  24946. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24947. /**
  24948. * Returns the i-th facet normal in the world system.
  24949. * This method allocates a new Vector3 per call
  24950. * @param i defines the facet index
  24951. * @returns a new Vector3
  24952. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24953. */
  24954. getFacetNormal(i: number): Vector3;
  24955. /**
  24956. * Sets the reference Vector3 with the i-th facet normal in the world system
  24957. * @param i defines the facet index
  24958. * @param ref defines the target vector
  24959. * @returns the current mesh
  24960. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24961. */
  24962. getFacetNormalToRef(i: number, ref: Vector3): this;
  24963. /**
  24964. * 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)
  24965. * @param x defines x coordinate
  24966. * @param y defines y coordinate
  24967. * @param z defines z coordinate
  24968. * @returns the array of facet indexes
  24969. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24970. */
  24971. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24972. /**
  24973. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24974. * @param projected sets as the (x,y,z) world projection on the facet
  24975. * @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
  24976. * @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
  24977. * @param x defines x coordinate
  24978. * @param y defines y coordinate
  24979. * @param z defines z coordinate
  24980. * @returns the face index if found (or null instead)
  24981. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24982. */
  24983. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24984. /**
  24985. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24986. * @param projected sets as the (x,y,z) local projection on the facet
  24987. * @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
  24988. * @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
  24989. * @param x defines x coordinate
  24990. * @param y defines y coordinate
  24991. * @param z defines z coordinate
  24992. * @returns the face index if found (or null instead)
  24993. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24994. */
  24995. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24996. /**
  24997. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24998. * @returns the parameters
  24999. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25000. */
  25001. getFacetDataParameters(): any;
  25002. /**
  25003. * Disables the feature FacetData and frees the related memory
  25004. * @returns the current mesh
  25005. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25006. */
  25007. disableFacetData(): AbstractMesh;
  25008. /**
  25009. * Updates the AbstractMesh indices array
  25010. * @param indices defines the data source
  25011. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25012. * @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)
  25013. * @returns the current mesh
  25014. */
  25015. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25016. /**
  25017. * Creates new normals data for the mesh
  25018. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25019. * @returns the current mesh
  25020. */
  25021. createNormals(updatable: boolean): AbstractMesh;
  25022. /**
  25023. * Align the mesh with a normal
  25024. * @param normal defines the normal to use
  25025. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25026. * @returns the current mesh
  25027. */
  25028. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25029. /** @hidden */
  25030. _checkOcclusionQuery(): boolean;
  25031. /**
  25032. * Disables the mesh edge rendering mode
  25033. * @returns the currentAbstractMesh
  25034. */
  25035. disableEdgesRendering(): AbstractMesh;
  25036. /**
  25037. * Enables the edge rendering mode on the mesh.
  25038. * This mode makes the mesh edges visible
  25039. * @param epsilon defines the maximal distance between two angles to detect a face
  25040. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  25041. * @returns the currentAbstractMesh
  25042. * @see https://www.babylonjs-playground.com/#19O9TU#0
  25043. */
  25044. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  25045. }
  25046. }
  25047. declare module BABYLON {
  25048. /**
  25049. * Interface used to define ActionEvent
  25050. */
  25051. export interface IActionEvent {
  25052. /** The mesh or sprite that triggered the action */
  25053. source: any;
  25054. /** The X mouse cursor position at the time of the event */
  25055. pointerX: number;
  25056. /** The Y mouse cursor position at the time of the event */
  25057. pointerY: number;
  25058. /** The mesh that is currently pointed at (can be null) */
  25059. meshUnderPointer: Nullable<AbstractMesh>;
  25060. /** the original (browser) event that triggered the ActionEvent */
  25061. sourceEvent?: any;
  25062. /** additional data for the event */
  25063. additionalData?: any;
  25064. }
  25065. /**
  25066. * ActionEvent is the event being sent when an action is triggered.
  25067. */
  25068. export class ActionEvent implements IActionEvent {
  25069. /** The mesh or sprite that triggered the action */
  25070. source: any;
  25071. /** The X mouse cursor position at the time of the event */
  25072. pointerX: number;
  25073. /** The Y mouse cursor position at the time of the event */
  25074. pointerY: number;
  25075. /** The mesh that is currently pointed at (can be null) */
  25076. meshUnderPointer: Nullable<AbstractMesh>;
  25077. /** the original (browser) event that triggered the ActionEvent */
  25078. sourceEvent?: any;
  25079. /** additional data for the event */
  25080. additionalData?: any;
  25081. /**
  25082. * Creates a new ActionEvent
  25083. * @param source The mesh or sprite that triggered the action
  25084. * @param pointerX The X mouse cursor position at the time of the event
  25085. * @param pointerY The Y mouse cursor position at the time of the event
  25086. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  25087. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  25088. * @param additionalData additional data for the event
  25089. */
  25090. constructor(
  25091. /** The mesh or sprite that triggered the action */
  25092. source: any,
  25093. /** The X mouse cursor position at the time of the event */
  25094. pointerX: number,
  25095. /** The Y mouse cursor position at the time of the event */
  25096. pointerY: number,
  25097. /** The mesh that is currently pointed at (can be null) */
  25098. meshUnderPointer: Nullable<AbstractMesh>,
  25099. /** the original (browser) event that triggered the ActionEvent */
  25100. sourceEvent?: any,
  25101. /** additional data for the event */
  25102. additionalData?: any);
  25103. /**
  25104. * Helper function to auto-create an ActionEvent from a source mesh.
  25105. * @param source The source mesh that triggered the event
  25106. * @param evt The original (browser) event
  25107. * @param additionalData additional data for the event
  25108. * @returns the new ActionEvent
  25109. */
  25110. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  25111. /**
  25112. * Helper function to auto-create an ActionEvent from a source sprite
  25113. * @param source The source sprite that triggered the event
  25114. * @param scene Scene associated with the sprite
  25115. * @param evt The original (browser) event
  25116. * @param additionalData additional data for the event
  25117. * @returns the new ActionEvent
  25118. */
  25119. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  25120. /**
  25121. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  25122. * @param scene the scene where the event occurred
  25123. * @param evt The original (browser) event
  25124. * @returns the new ActionEvent
  25125. */
  25126. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  25127. /**
  25128. * Helper function to auto-create an ActionEvent from a primitive
  25129. * @param prim defines the target primitive
  25130. * @param pointerPos defines the pointer position
  25131. * @param evt The original (browser) event
  25132. * @param additionalData additional data for the event
  25133. * @returns the new ActionEvent
  25134. */
  25135. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  25136. }
  25137. }
  25138. declare module BABYLON {
  25139. /**
  25140. * Abstract class used to decouple action Manager from scene and meshes.
  25141. * Do not instantiate.
  25142. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25143. */
  25144. export abstract class AbstractActionManager implements IDisposable {
  25145. /** Gets the list of active triggers */
  25146. static Triggers: {
  25147. [key: string]: number;
  25148. };
  25149. /** Gets the cursor to use when hovering items */
  25150. hoverCursor: string;
  25151. /** Gets the list of actions */
  25152. actions: IAction[];
  25153. /**
  25154. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  25155. */
  25156. isRecursive: boolean;
  25157. /**
  25158. * Releases all associated resources
  25159. */
  25160. abstract dispose(): void;
  25161. /**
  25162. * Does this action manager has pointer triggers
  25163. */
  25164. abstract readonly hasPointerTriggers: boolean;
  25165. /**
  25166. * Does this action manager has pick triggers
  25167. */
  25168. abstract readonly hasPickTriggers: boolean;
  25169. /**
  25170. * Process a specific trigger
  25171. * @param trigger defines the trigger to process
  25172. * @param evt defines the event details to be processed
  25173. */
  25174. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  25175. /**
  25176. * Does this action manager handles actions of any of the given triggers
  25177. * @param triggers defines the triggers to be tested
  25178. * @return a boolean indicating whether one (or more) of the triggers is handled
  25179. */
  25180. abstract hasSpecificTriggers(triggers: number[]): boolean;
  25181. /**
  25182. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  25183. * speed.
  25184. * @param triggerA defines the trigger to be tested
  25185. * @param triggerB defines the trigger to be tested
  25186. * @return a boolean indicating whether one (or more) of the triggers is handled
  25187. */
  25188. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  25189. /**
  25190. * Does this action manager handles actions of a given trigger
  25191. * @param trigger defines the trigger to be tested
  25192. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  25193. * @return whether the trigger is handled
  25194. */
  25195. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  25196. /**
  25197. * Serialize this manager to a JSON object
  25198. * @param name defines the property name to store this manager
  25199. * @returns a JSON representation of this manager
  25200. */
  25201. abstract serialize(name: string): any;
  25202. /**
  25203. * Registers an action to this action manager
  25204. * @param action defines the action to be registered
  25205. * @return the action amended (prepared) after registration
  25206. */
  25207. abstract registerAction(action: IAction): Nullable<IAction>;
  25208. /**
  25209. * Unregisters an action to this action manager
  25210. * @param action defines the action to be unregistered
  25211. * @return a boolean indicating whether the action has been unregistered
  25212. */
  25213. abstract unregisterAction(action: IAction): Boolean;
  25214. /**
  25215. * Does exist one action manager with at least one trigger
  25216. **/
  25217. static readonly HasTriggers: boolean;
  25218. /**
  25219. * Does exist one action manager with at least one pick trigger
  25220. **/
  25221. static readonly HasPickTriggers: boolean;
  25222. /**
  25223. * Does exist one action manager that handles actions of a given trigger
  25224. * @param trigger defines the trigger to be tested
  25225. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  25226. **/
  25227. static HasSpecificTrigger(trigger: number): boolean;
  25228. }
  25229. }
  25230. declare module BABYLON {
  25231. /**
  25232. * Defines how a node can be built from a string name.
  25233. */
  25234. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  25235. /**
  25236. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  25237. */
  25238. export class Node implements IBehaviorAware<Node> {
  25239. /** @hidden */
  25240. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  25241. private static _NodeConstructors;
  25242. /**
  25243. * Add a new node constructor
  25244. * @param type defines the type name of the node to construct
  25245. * @param constructorFunc defines the constructor function
  25246. */
  25247. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  25248. /**
  25249. * Returns a node constructor based on type name
  25250. * @param type defines the type name
  25251. * @param name defines the new node name
  25252. * @param scene defines the hosting scene
  25253. * @param options defines optional options to transmit to constructors
  25254. * @returns the new constructor or null
  25255. */
  25256. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  25257. /**
  25258. * Gets or sets the name of the node
  25259. */
  25260. name: string;
  25261. /**
  25262. * Gets or sets the id of the node
  25263. */
  25264. id: string;
  25265. /**
  25266. * Gets or sets the unique id of the node
  25267. */
  25268. uniqueId: number;
  25269. /**
  25270. * Gets or sets a string used to store user defined state for the node
  25271. */
  25272. state: string;
  25273. /**
  25274. * Gets or sets an object used to store user defined information for the node
  25275. */
  25276. metadata: any;
  25277. /**
  25278. * For internal use only. Please do not use.
  25279. */
  25280. reservedDataStore: any;
  25281. /**
  25282. * List of inspectable custom properties (used by the Inspector)
  25283. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25284. */
  25285. inspectableCustomProperties: IInspectable[];
  25286. /**
  25287. * Gets or sets a boolean used to define if the node must be serialized
  25288. */
  25289. doNotSerialize: boolean;
  25290. /** @hidden */
  25291. _isDisposed: boolean;
  25292. /**
  25293. * Gets a list of Animations associated with the node
  25294. */
  25295. animations: Animation[];
  25296. protected _ranges: {
  25297. [name: string]: Nullable<AnimationRange>;
  25298. };
  25299. /**
  25300. * Callback raised when the node is ready to be used
  25301. */
  25302. onReady: Nullable<(node: Node) => void>;
  25303. private _isEnabled;
  25304. private _isParentEnabled;
  25305. private _isReady;
  25306. /** @hidden */
  25307. _currentRenderId: number;
  25308. private _parentUpdateId;
  25309. /** @hidden */
  25310. _childUpdateId: number;
  25311. /** @hidden */
  25312. _waitingParentId: Nullable<string>;
  25313. /** @hidden */
  25314. _scene: Scene;
  25315. /** @hidden */
  25316. _cache: any;
  25317. private _parentNode;
  25318. private _children;
  25319. /** @hidden */
  25320. _worldMatrix: Matrix;
  25321. /** @hidden */
  25322. _worldMatrixDeterminant: number;
  25323. /** @hidden */
  25324. _worldMatrixDeterminantIsDirty: boolean;
  25325. /** @hidden */
  25326. private _sceneRootNodesIndex;
  25327. /**
  25328. * Gets a boolean indicating if the node has been disposed
  25329. * @returns true if the node was disposed
  25330. */
  25331. isDisposed(): boolean;
  25332. /**
  25333. * Gets or sets the parent of the node (without keeping the current position in the scene)
  25334. * @see https://doc.babylonjs.com/how_to/parenting
  25335. */
  25336. parent: Nullable<Node>;
  25337. private addToSceneRootNodes;
  25338. private removeFromSceneRootNodes;
  25339. private _animationPropertiesOverride;
  25340. /**
  25341. * Gets or sets the animation properties override
  25342. */
  25343. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  25344. /**
  25345. * Gets a string idenfifying the name of the class
  25346. * @returns "Node" string
  25347. */
  25348. getClassName(): string;
  25349. /** @hidden */
  25350. readonly _isNode: boolean;
  25351. /**
  25352. * An event triggered when the mesh is disposed
  25353. */
  25354. onDisposeObservable: Observable<Node>;
  25355. private _onDisposeObserver;
  25356. /**
  25357. * Sets a callback that will be raised when the node will be disposed
  25358. */
  25359. onDispose: () => void;
  25360. /**
  25361. * Creates a new Node
  25362. * @param name the name and id to be given to this node
  25363. * @param scene the scene this node will be added to
  25364. * @param addToRootNodes the node will be added to scene.rootNodes
  25365. */
  25366. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  25367. /**
  25368. * Gets the scene of the node
  25369. * @returns a scene
  25370. */
  25371. getScene(): Scene;
  25372. /**
  25373. * Gets the engine of the node
  25374. * @returns a Engine
  25375. */
  25376. getEngine(): Engine;
  25377. private _behaviors;
  25378. /**
  25379. * Attach a behavior to the node
  25380. * @see http://doc.babylonjs.com/features/behaviour
  25381. * @param behavior defines the behavior to attach
  25382. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  25383. * @returns the current Node
  25384. */
  25385. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  25386. /**
  25387. * Remove an attached behavior
  25388. * @see http://doc.babylonjs.com/features/behaviour
  25389. * @param behavior defines the behavior to attach
  25390. * @returns the current Node
  25391. */
  25392. removeBehavior(behavior: Behavior<Node>): Node;
  25393. /**
  25394. * Gets the list of attached behaviors
  25395. * @see http://doc.babylonjs.com/features/behaviour
  25396. */
  25397. readonly behaviors: Behavior<Node>[];
  25398. /**
  25399. * Gets an attached behavior by name
  25400. * @param name defines the name of the behavior to look for
  25401. * @see http://doc.babylonjs.com/features/behaviour
  25402. * @returns null if behavior was not found else the requested behavior
  25403. */
  25404. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  25405. /**
  25406. * Returns the latest update of the World matrix
  25407. * @returns a Matrix
  25408. */
  25409. getWorldMatrix(): Matrix;
  25410. /** @hidden */
  25411. _getWorldMatrixDeterminant(): number;
  25412. /**
  25413. * Returns directly the latest state of the mesh World matrix.
  25414. * A Matrix is returned.
  25415. */
  25416. readonly worldMatrixFromCache: Matrix;
  25417. /** @hidden */
  25418. _initCache(): void;
  25419. /** @hidden */
  25420. updateCache(force?: boolean): void;
  25421. /** @hidden */
  25422. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25423. /** @hidden */
  25424. _updateCache(ignoreParentClass?: boolean): void;
  25425. /** @hidden */
  25426. _isSynchronized(): boolean;
  25427. /** @hidden */
  25428. _markSyncedWithParent(): void;
  25429. /** @hidden */
  25430. isSynchronizedWithParent(): boolean;
  25431. /** @hidden */
  25432. isSynchronized(): boolean;
  25433. /**
  25434. * Is this node ready to be used/rendered
  25435. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25436. * @return true if the node is ready
  25437. */
  25438. isReady(completeCheck?: boolean): boolean;
  25439. /**
  25440. * Is this node enabled?
  25441. * 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
  25442. * @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
  25443. * @return whether this node (and its parent) is enabled
  25444. */
  25445. isEnabled(checkAncestors?: boolean): boolean;
  25446. /** @hidden */
  25447. protected _syncParentEnabledState(): void;
  25448. /**
  25449. * Set the enabled state of this node
  25450. * @param value defines the new enabled state
  25451. */
  25452. setEnabled(value: boolean): void;
  25453. /**
  25454. * Is this node a descendant of the given node?
  25455. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  25456. * @param ancestor defines the parent node to inspect
  25457. * @returns a boolean indicating if this node is a descendant of the given node
  25458. */
  25459. isDescendantOf(ancestor: Node): boolean;
  25460. /** @hidden */
  25461. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  25462. /**
  25463. * Will return all nodes that have this node as ascendant
  25464. * @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
  25465. * @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
  25466. * @return all children nodes of all types
  25467. */
  25468. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  25469. /**
  25470. * Get all child-meshes of this node
  25471. * @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)
  25472. * @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
  25473. * @returns an array of AbstractMesh
  25474. */
  25475. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  25476. /**
  25477. * Get all direct children of this node
  25478. * @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
  25479. * @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)
  25480. * @returns an array of Node
  25481. */
  25482. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  25483. /** @hidden */
  25484. _setReady(state: boolean): void;
  25485. /**
  25486. * Get an animation by name
  25487. * @param name defines the name of the animation to look for
  25488. * @returns null if not found else the requested animation
  25489. */
  25490. getAnimationByName(name: string): Nullable<Animation>;
  25491. /**
  25492. * Creates an animation range for this node
  25493. * @param name defines the name of the range
  25494. * @param from defines the starting key
  25495. * @param to defines the end key
  25496. */
  25497. createAnimationRange(name: string, from: number, to: number): void;
  25498. /**
  25499. * Delete a specific animation range
  25500. * @param name defines the name of the range to delete
  25501. * @param deleteFrames defines if animation frames from the range must be deleted as well
  25502. */
  25503. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25504. /**
  25505. * Get an animation range by name
  25506. * @param name defines the name of the animation range to look for
  25507. * @returns null if not found else the requested animation range
  25508. */
  25509. getAnimationRange(name: string): Nullable<AnimationRange>;
  25510. /**
  25511. * Gets the list of all animation ranges defined on this node
  25512. * @returns an array
  25513. */
  25514. getAnimationRanges(): Nullable<AnimationRange>[];
  25515. /**
  25516. * Will start the animation sequence
  25517. * @param name defines the range frames for animation sequence
  25518. * @param loop defines if the animation should loop (false by default)
  25519. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25520. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25521. * @returns the object created for this animation. If range does not exist, it will return null
  25522. */
  25523. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25524. /**
  25525. * Serialize animation ranges into a JSON compatible object
  25526. * @returns serialization object
  25527. */
  25528. serializeAnimationRanges(): any;
  25529. /**
  25530. * Computes the world matrix of the node
  25531. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25532. * @returns the world matrix
  25533. */
  25534. computeWorldMatrix(force?: boolean): Matrix;
  25535. /**
  25536. * Releases resources associated with this node.
  25537. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25538. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25539. */
  25540. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25541. /**
  25542. * Parse animation range data from a serialization object and store them into a given node
  25543. * @param node defines where to store the animation ranges
  25544. * @param parsedNode defines the serialization object to read data from
  25545. * @param scene defines the hosting scene
  25546. */
  25547. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25548. /**
  25549. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  25550. * @param includeDescendants Include bounding info from descendants as well (true by default)
  25551. * @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
  25552. * @returns the new bounding vectors
  25553. */
  25554. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  25555. min: Vector3;
  25556. max: Vector3;
  25557. };
  25558. }
  25559. }
  25560. declare module BABYLON {
  25561. /**
  25562. * @hidden
  25563. */
  25564. export class _IAnimationState {
  25565. key: number;
  25566. repeatCount: number;
  25567. workValue?: any;
  25568. loopMode?: number;
  25569. offsetValue?: any;
  25570. highLimitValue?: any;
  25571. }
  25572. /**
  25573. * Class used to store any kind of animation
  25574. */
  25575. export class Animation {
  25576. /**Name of the animation */
  25577. name: string;
  25578. /**Property to animate */
  25579. targetProperty: string;
  25580. /**The frames per second of the animation */
  25581. framePerSecond: number;
  25582. /**The data type of the animation */
  25583. dataType: number;
  25584. /**The loop mode of the animation */
  25585. loopMode?: number | undefined;
  25586. /**Specifies if blending should be enabled */
  25587. enableBlending?: boolean | undefined;
  25588. /**
  25589. * Use matrix interpolation instead of using direct key value when animating matrices
  25590. */
  25591. static AllowMatricesInterpolation: boolean;
  25592. /**
  25593. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25594. */
  25595. static AllowMatrixDecomposeForInterpolation: boolean;
  25596. /**
  25597. * Stores the key frames of the animation
  25598. */
  25599. private _keys;
  25600. /**
  25601. * Stores the easing function of the animation
  25602. */
  25603. private _easingFunction;
  25604. /**
  25605. * @hidden Internal use only
  25606. */
  25607. _runtimeAnimations: RuntimeAnimation[];
  25608. /**
  25609. * The set of event that will be linked to this animation
  25610. */
  25611. private _events;
  25612. /**
  25613. * Stores an array of target property paths
  25614. */
  25615. targetPropertyPath: string[];
  25616. /**
  25617. * Stores the blending speed of the animation
  25618. */
  25619. blendingSpeed: number;
  25620. /**
  25621. * Stores the animation ranges for the animation
  25622. */
  25623. private _ranges;
  25624. /**
  25625. * @hidden Internal use
  25626. */
  25627. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25628. /**
  25629. * Sets up an animation
  25630. * @param property The property to animate
  25631. * @param animationType The animation type to apply
  25632. * @param framePerSecond The frames per second of the animation
  25633. * @param easingFunction The easing function used in the animation
  25634. * @returns The created animation
  25635. */
  25636. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25637. /**
  25638. * Create and start an animation on a node
  25639. * @param name defines the name of the global animation that will be run on all nodes
  25640. * @param node defines the root node where the animation will take place
  25641. * @param targetProperty defines property to animate
  25642. * @param framePerSecond defines the number of frame per second yo use
  25643. * @param totalFrame defines the number of frames in total
  25644. * @param from defines the initial value
  25645. * @param to defines the final value
  25646. * @param loopMode defines which loop mode you want to use (off by default)
  25647. * @param easingFunction defines the easing function to use (linear by default)
  25648. * @param onAnimationEnd defines the callback to call when animation end
  25649. * @returns the animatable created for this animation
  25650. */
  25651. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25652. /**
  25653. * Create and start an animation on a node and its descendants
  25654. * @param name defines the name of the global animation that will be run on all nodes
  25655. * @param node defines the root node where the animation will take place
  25656. * @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
  25657. * @param targetProperty defines property to animate
  25658. * @param framePerSecond defines the number of frame per second to use
  25659. * @param totalFrame defines the number of frames in total
  25660. * @param from defines the initial value
  25661. * @param to defines the final value
  25662. * @param loopMode defines which loop mode you want to use (off by default)
  25663. * @param easingFunction defines the easing function to use (linear by default)
  25664. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25665. * @returns the list of animatables created for all nodes
  25666. * @example https://www.babylonjs-playground.com/#MH0VLI
  25667. */
  25668. 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[]>;
  25669. /**
  25670. * Creates a new animation, merges it with the existing animations and starts it
  25671. * @param name Name of the animation
  25672. * @param node Node which contains the scene that begins the animations
  25673. * @param targetProperty Specifies which property to animate
  25674. * @param framePerSecond The frames per second of the animation
  25675. * @param totalFrame The total number of frames
  25676. * @param from The frame at the beginning of the animation
  25677. * @param to The frame at the end of the animation
  25678. * @param loopMode Specifies the loop mode of the animation
  25679. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25680. * @param onAnimationEnd Callback to run once the animation is complete
  25681. * @returns Nullable animation
  25682. */
  25683. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25684. /**
  25685. * Transition property of an host to the target Value
  25686. * @param property The property to transition
  25687. * @param targetValue The target Value of the property
  25688. * @param host The object where the property to animate belongs
  25689. * @param scene Scene used to run the animation
  25690. * @param frameRate Framerate (in frame/s) to use
  25691. * @param transition The transition type we want to use
  25692. * @param duration The duration of the animation, in milliseconds
  25693. * @param onAnimationEnd Callback trigger at the end of the animation
  25694. * @returns Nullable animation
  25695. */
  25696. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25697. /**
  25698. * Return the array of runtime animations currently using this animation
  25699. */
  25700. readonly runtimeAnimations: RuntimeAnimation[];
  25701. /**
  25702. * Specifies if any of the runtime animations are currently running
  25703. */
  25704. readonly hasRunningRuntimeAnimations: boolean;
  25705. /**
  25706. * Initializes the animation
  25707. * @param name Name of the animation
  25708. * @param targetProperty Property to animate
  25709. * @param framePerSecond The frames per second of the animation
  25710. * @param dataType The data type of the animation
  25711. * @param loopMode The loop mode of the animation
  25712. * @param enableBlending Specifies if blending should be enabled
  25713. */
  25714. constructor(
  25715. /**Name of the animation */
  25716. name: string,
  25717. /**Property to animate */
  25718. targetProperty: string,
  25719. /**The frames per second of the animation */
  25720. framePerSecond: number,
  25721. /**The data type of the animation */
  25722. dataType: number,
  25723. /**The loop mode of the animation */
  25724. loopMode?: number | undefined,
  25725. /**Specifies if blending should be enabled */
  25726. enableBlending?: boolean | undefined);
  25727. /**
  25728. * Converts the animation to a string
  25729. * @param fullDetails support for multiple levels of logging within scene loading
  25730. * @returns String form of the animation
  25731. */
  25732. toString(fullDetails?: boolean): string;
  25733. /**
  25734. * Add an event to this animation
  25735. * @param event Event to add
  25736. */
  25737. addEvent(event: AnimationEvent): void;
  25738. /**
  25739. * Remove all events found at the given frame
  25740. * @param frame The frame to remove events from
  25741. */
  25742. removeEvents(frame: number): void;
  25743. /**
  25744. * Retrieves all the events from the animation
  25745. * @returns Events from the animation
  25746. */
  25747. getEvents(): AnimationEvent[];
  25748. /**
  25749. * Creates an animation range
  25750. * @param name Name of the animation range
  25751. * @param from Starting frame of the animation range
  25752. * @param to Ending frame of the animation
  25753. */
  25754. createRange(name: string, from: number, to: number): void;
  25755. /**
  25756. * Deletes an animation range by name
  25757. * @param name Name of the animation range to delete
  25758. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25759. */
  25760. deleteRange(name: string, deleteFrames?: boolean): void;
  25761. /**
  25762. * Gets the animation range by name, or null if not defined
  25763. * @param name Name of the animation range
  25764. * @returns Nullable animation range
  25765. */
  25766. getRange(name: string): Nullable<AnimationRange>;
  25767. /**
  25768. * Gets the key frames from the animation
  25769. * @returns The key frames of the animation
  25770. */
  25771. getKeys(): Array<IAnimationKey>;
  25772. /**
  25773. * Gets the highest frame rate of the animation
  25774. * @returns Highest frame rate of the animation
  25775. */
  25776. getHighestFrame(): number;
  25777. /**
  25778. * Gets the easing function of the animation
  25779. * @returns Easing function of the animation
  25780. */
  25781. getEasingFunction(): IEasingFunction;
  25782. /**
  25783. * Sets the easing function of the animation
  25784. * @param easingFunction A custom mathematical formula for animation
  25785. */
  25786. setEasingFunction(easingFunction: EasingFunction): void;
  25787. /**
  25788. * Interpolates a scalar linearly
  25789. * @param startValue Start value of the animation curve
  25790. * @param endValue End value of the animation curve
  25791. * @param gradient Scalar amount to interpolate
  25792. * @returns Interpolated scalar value
  25793. */
  25794. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25795. /**
  25796. * Interpolates a scalar cubically
  25797. * @param startValue Start value of the animation curve
  25798. * @param outTangent End tangent of the animation
  25799. * @param endValue End value of the animation curve
  25800. * @param inTangent Start tangent of the animation curve
  25801. * @param gradient Scalar amount to interpolate
  25802. * @returns Interpolated scalar value
  25803. */
  25804. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25805. /**
  25806. * Interpolates a quaternion using a spherical linear interpolation
  25807. * @param startValue Start value of the animation curve
  25808. * @param endValue End value of the animation curve
  25809. * @param gradient Scalar amount to interpolate
  25810. * @returns Interpolated quaternion value
  25811. */
  25812. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25813. /**
  25814. * Interpolates a quaternion cubically
  25815. * @param startValue Start value of the animation curve
  25816. * @param outTangent End tangent of the animation curve
  25817. * @param endValue End value of the animation curve
  25818. * @param inTangent Start tangent of the animation curve
  25819. * @param gradient Scalar amount to interpolate
  25820. * @returns Interpolated quaternion value
  25821. */
  25822. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25823. /**
  25824. * Interpolates a Vector3 linearl
  25825. * @param startValue Start value of the animation curve
  25826. * @param endValue End value of the animation curve
  25827. * @param gradient Scalar amount to interpolate
  25828. * @returns Interpolated scalar value
  25829. */
  25830. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25831. /**
  25832. * Interpolates a Vector3 cubically
  25833. * @param startValue Start value of the animation curve
  25834. * @param outTangent End tangent of the animation
  25835. * @param endValue End value of the animation curve
  25836. * @param inTangent Start tangent of the animation curve
  25837. * @param gradient Scalar amount to interpolate
  25838. * @returns InterpolatedVector3 value
  25839. */
  25840. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  25841. /**
  25842. * Interpolates a Vector2 linearly
  25843. * @param startValue Start value of the animation curve
  25844. * @param endValue End value of the animation curve
  25845. * @param gradient Scalar amount to interpolate
  25846. * @returns Interpolated Vector2 value
  25847. */
  25848. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  25849. /**
  25850. * Interpolates a Vector2 cubically
  25851. * @param startValue Start value of the animation curve
  25852. * @param outTangent End tangent of the animation
  25853. * @param endValue End value of the animation curve
  25854. * @param inTangent Start tangent of the animation curve
  25855. * @param gradient Scalar amount to interpolate
  25856. * @returns Interpolated Vector2 value
  25857. */
  25858. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  25859. /**
  25860. * Interpolates a size linearly
  25861. * @param startValue Start value of the animation curve
  25862. * @param endValue End value of the animation curve
  25863. * @param gradient Scalar amount to interpolate
  25864. * @returns Interpolated Size value
  25865. */
  25866. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  25867. /**
  25868. * Interpolates a Color3 linearly
  25869. * @param startValue Start value of the animation curve
  25870. * @param endValue End value of the animation curve
  25871. * @param gradient Scalar amount to interpolate
  25872. * @returns Interpolated Color3 value
  25873. */
  25874. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  25875. /**
  25876. * @hidden Internal use only
  25877. */
  25878. _getKeyValue(value: any): any;
  25879. /**
  25880. * @hidden Internal use only
  25881. */
  25882. _interpolate(currentFrame: number, state: _IAnimationState): any;
  25883. /**
  25884. * Defines the function to use to interpolate matrices
  25885. * @param startValue defines the start matrix
  25886. * @param endValue defines the end matrix
  25887. * @param gradient defines the gradient between both matrices
  25888. * @param result defines an optional target matrix where to store the interpolation
  25889. * @returns the interpolated matrix
  25890. */
  25891. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  25892. /**
  25893. * Makes a copy of the animation
  25894. * @returns Cloned animation
  25895. */
  25896. clone(): Animation;
  25897. /**
  25898. * Sets the key frames of the animation
  25899. * @param values The animation key frames to set
  25900. */
  25901. setKeys(values: Array<IAnimationKey>): void;
  25902. /**
  25903. * Serializes the animation to an object
  25904. * @returns Serialized object
  25905. */
  25906. serialize(): any;
  25907. /**
  25908. * Float animation type
  25909. */
  25910. private static _ANIMATIONTYPE_FLOAT;
  25911. /**
  25912. * Vector3 animation type
  25913. */
  25914. private static _ANIMATIONTYPE_VECTOR3;
  25915. /**
  25916. * Quaternion animation type
  25917. */
  25918. private static _ANIMATIONTYPE_QUATERNION;
  25919. /**
  25920. * Matrix animation type
  25921. */
  25922. private static _ANIMATIONTYPE_MATRIX;
  25923. /**
  25924. * Color3 animation type
  25925. */
  25926. private static _ANIMATIONTYPE_COLOR3;
  25927. /**
  25928. * Vector2 animation type
  25929. */
  25930. private static _ANIMATIONTYPE_VECTOR2;
  25931. /**
  25932. * Size animation type
  25933. */
  25934. private static _ANIMATIONTYPE_SIZE;
  25935. /**
  25936. * Relative Loop Mode
  25937. */
  25938. private static _ANIMATIONLOOPMODE_RELATIVE;
  25939. /**
  25940. * Cycle Loop Mode
  25941. */
  25942. private static _ANIMATIONLOOPMODE_CYCLE;
  25943. /**
  25944. * Constant Loop Mode
  25945. */
  25946. private static _ANIMATIONLOOPMODE_CONSTANT;
  25947. /**
  25948. * Get the float animation type
  25949. */
  25950. static readonly ANIMATIONTYPE_FLOAT: number;
  25951. /**
  25952. * Get the Vector3 animation type
  25953. */
  25954. static readonly ANIMATIONTYPE_VECTOR3: number;
  25955. /**
  25956. * Get the Vector2 animation type
  25957. */
  25958. static readonly ANIMATIONTYPE_VECTOR2: number;
  25959. /**
  25960. * Get the Size animation type
  25961. */
  25962. static readonly ANIMATIONTYPE_SIZE: number;
  25963. /**
  25964. * Get the Quaternion animation type
  25965. */
  25966. static readonly ANIMATIONTYPE_QUATERNION: number;
  25967. /**
  25968. * Get the Matrix animation type
  25969. */
  25970. static readonly ANIMATIONTYPE_MATRIX: number;
  25971. /**
  25972. * Get the Color3 animation type
  25973. */
  25974. static readonly ANIMATIONTYPE_COLOR3: number;
  25975. /**
  25976. * Get the Relative Loop Mode
  25977. */
  25978. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  25979. /**
  25980. * Get the Cycle Loop Mode
  25981. */
  25982. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  25983. /**
  25984. * Get the Constant Loop Mode
  25985. */
  25986. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  25987. /** @hidden */
  25988. static _UniversalLerp(left: any, right: any, amount: number): any;
  25989. /**
  25990. * Parses an animation object and creates an animation
  25991. * @param parsedAnimation Parsed animation object
  25992. * @returns Animation object
  25993. */
  25994. static Parse(parsedAnimation: any): Animation;
  25995. /**
  25996. * Appends the serialized animations from the source animations
  25997. * @param source Source containing the animations
  25998. * @param destination Target to store the animations
  25999. */
  26000. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26001. }
  26002. }
  26003. declare module BABYLON {
  26004. /**
  26005. * Base class of all the textures in babylon.
  26006. * It groups all the common properties the materials, post process, lights... might need
  26007. * in order to make a correct use of the texture.
  26008. */
  26009. export class BaseTexture implements IAnimatable {
  26010. /**
  26011. * Default anisotropic filtering level for the application.
  26012. * It is set to 4 as a good tradeoff between perf and quality.
  26013. */
  26014. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  26015. /**
  26016. * Gets or sets the unique id of the texture
  26017. */
  26018. uniqueId: number;
  26019. /**
  26020. * Define the name of the texture.
  26021. */
  26022. name: string;
  26023. /**
  26024. * Gets or sets an object used to store user defined information.
  26025. */
  26026. metadata: any;
  26027. /**
  26028. * For internal use only. Please do not use.
  26029. */
  26030. reservedDataStore: any;
  26031. private _hasAlpha;
  26032. /**
  26033. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  26034. */
  26035. hasAlpha: boolean;
  26036. /**
  26037. * Defines if the alpha value should be determined via the rgb values.
  26038. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  26039. */
  26040. getAlphaFromRGB: boolean;
  26041. /**
  26042. * Intensity or strength of the texture.
  26043. * It is commonly used by materials to fine tune the intensity of the texture
  26044. */
  26045. level: number;
  26046. /**
  26047. * Define the UV chanel to use starting from 0 and defaulting to 0.
  26048. * This is part of the texture as textures usually maps to one uv set.
  26049. */
  26050. coordinatesIndex: number;
  26051. private _coordinatesMode;
  26052. /**
  26053. * How a texture is mapped.
  26054. *
  26055. * | Value | Type | Description |
  26056. * | ----- | ----------------------------------- | ----------- |
  26057. * | 0 | EXPLICIT_MODE | |
  26058. * | 1 | SPHERICAL_MODE | |
  26059. * | 2 | PLANAR_MODE | |
  26060. * | 3 | CUBIC_MODE | |
  26061. * | 4 | PROJECTION_MODE | |
  26062. * | 5 | SKYBOX_MODE | |
  26063. * | 6 | INVCUBIC_MODE | |
  26064. * | 7 | EQUIRECTANGULAR_MODE | |
  26065. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  26066. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  26067. */
  26068. coordinatesMode: number;
  26069. /**
  26070. * | Value | Type | Description |
  26071. * | ----- | ------------------ | ----------- |
  26072. * | 0 | CLAMP_ADDRESSMODE | |
  26073. * | 1 | WRAP_ADDRESSMODE | |
  26074. * | 2 | MIRROR_ADDRESSMODE | |
  26075. */
  26076. wrapU: number;
  26077. /**
  26078. * | Value | Type | Description |
  26079. * | ----- | ------------------ | ----------- |
  26080. * | 0 | CLAMP_ADDRESSMODE | |
  26081. * | 1 | WRAP_ADDRESSMODE | |
  26082. * | 2 | MIRROR_ADDRESSMODE | |
  26083. */
  26084. wrapV: number;
  26085. /**
  26086. * | Value | Type | Description |
  26087. * | ----- | ------------------ | ----------- |
  26088. * | 0 | CLAMP_ADDRESSMODE | |
  26089. * | 1 | WRAP_ADDRESSMODE | |
  26090. * | 2 | MIRROR_ADDRESSMODE | |
  26091. */
  26092. wrapR: number;
  26093. /**
  26094. * With compliant hardware and browser (supporting anisotropic filtering)
  26095. * this defines the level of anisotropic filtering in the texture.
  26096. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  26097. */
  26098. anisotropicFilteringLevel: number;
  26099. /**
  26100. * Define if the texture is a cube texture or if false a 2d texture.
  26101. */
  26102. isCube: boolean;
  26103. /**
  26104. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  26105. */
  26106. is3D: boolean;
  26107. /**
  26108. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  26109. * HDR texture are usually stored in linear space.
  26110. * This only impacts the PBR and Background materials
  26111. */
  26112. gammaSpace: boolean;
  26113. /**
  26114. * Gets whether or not the texture contains RGBD data.
  26115. */
  26116. readonly isRGBD: boolean;
  26117. /**
  26118. * Is Z inverted in the texture (useful in a cube texture).
  26119. */
  26120. invertZ: boolean;
  26121. /**
  26122. * Are mip maps generated for this texture or not.
  26123. */
  26124. readonly noMipmap: boolean;
  26125. /**
  26126. * @hidden
  26127. */
  26128. lodLevelInAlpha: boolean;
  26129. /**
  26130. * With prefiltered texture, defined the offset used during the prefiltering steps.
  26131. */
  26132. lodGenerationOffset: number;
  26133. /**
  26134. * With prefiltered texture, defined the scale used during the prefiltering steps.
  26135. */
  26136. lodGenerationScale: number;
  26137. /**
  26138. * Define if the texture is a render target.
  26139. */
  26140. isRenderTarget: boolean;
  26141. /**
  26142. * Define the unique id of the texture in the scene.
  26143. */
  26144. readonly uid: string;
  26145. /**
  26146. * Return a string representation of the texture.
  26147. * @returns the texture as a string
  26148. */
  26149. toString(): string;
  26150. /**
  26151. * Get the class name of the texture.
  26152. * @returns "BaseTexture"
  26153. */
  26154. getClassName(): string;
  26155. /**
  26156. * Define the list of animation attached to the texture.
  26157. */
  26158. animations: Animation[];
  26159. /**
  26160. * An event triggered when the texture is disposed.
  26161. */
  26162. onDisposeObservable: Observable<BaseTexture>;
  26163. private _onDisposeObserver;
  26164. /**
  26165. * Callback triggered when the texture has been disposed.
  26166. * Kept for back compatibility, you can use the onDisposeObservable instead.
  26167. */
  26168. onDispose: () => void;
  26169. /**
  26170. * Define the current state of the loading sequence when in delayed load mode.
  26171. */
  26172. delayLoadState: number;
  26173. private _scene;
  26174. /** @hidden */
  26175. _texture: Nullable<InternalTexture>;
  26176. private _uid;
  26177. /**
  26178. * Define if the texture is preventinga material to render or not.
  26179. * If not and the texture is not ready, the engine will use a default black texture instead.
  26180. */
  26181. readonly isBlocking: boolean;
  26182. /**
  26183. * Instantiates a new BaseTexture.
  26184. * Base class of all the textures in babylon.
  26185. * It groups all the common properties the materials, post process, lights... might need
  26186. * in order to make a correct use of the texture.
  26187. * @param scene Define the scene the texture blongs to
  26188. */
  26189. constructor(scene: Nullable<Scene>);
  26190. /**
  26191. * Get the scene the texture belongs to.
  26192. * @returns the scene or null if undefined
  26193. */
  26194. getScene(): Nullable<Scene>;
  26195. /**
  26196. * Get the texture transform matrix used to offset tile the texture for istance.
  26197. * @returns the transformation matrix
  26198. */
  26199. getTextureMatrix(): Matrix;
  26200. /**
  26201. * Get the texture reflection matrix used to rotate/transform the reflection.
  26202. * @returns the reflection matrix
  26203. */
  26204. getReflectionTextureMatrix(): Matrix;
  26205. /**
  26206. * Get the underlying lower level texture from Babylon.
  26207. * @returns the insternal texture
  26208. */
  26209. getInternalTexture(): Nullable<InternalTexture>;
  26210. /**
  26211. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  26212. * @returns true if ready or not blocking
  26213. */
  26214. isReadyOrNotBlocking(): boolean;
  26215. /**
  26216. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  26217. * @returns true if fully ready
  26218. */
  26219. isReady(): boolean;
  26220. private _cachedSize;
  26221. /**
  26222. * Get the size of the texture.
  26223. * @returns the texture size.
  26224. */
  26225. getSize(): ISize;
  26226. /**
  26227. * Get the base size of the texture.
  26228. * It can be different from the size if the texture has been resized for POT for instance
  26229. * @returns the base size
  26230. */
  26231. getBaseSize(): ISize;
  26232. /**
  26233. * Update the sampling mode of the texture.
  26234. * Default is Trilinear mode.
  26235. *
  26236. * | Value | Type | Description |
  26237. * | ----- | ------------------ | ----------- |
  26238. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  26239. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  26240. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  26241. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  26242. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  26243. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  26244. * | 7 | NEAREST_LINEAR | |
  26245. * | 8 | NEAREST_NEAREST | |
  26246. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  26247. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  26248. * | 11 | LINEAR_LINEAR | |
  26249. * | 12 | LINEAR_NEAREST | |
  26250. *
  26251. * > _mag_: magnification filter (close to the viewer)
  26252. * > _min_: minification filter (far from the viewer)
  26253. * > _mip_: filter used between mip map levels
  26254. *@param samplingMode Define the new sampling mode of the texture
  26255. */
  26256. updateSamplingMode(samplingMode: number): void;
  26257. /**
  26258. * Scales the texture if is `canRescale()`
  26259. * @param ratio the resize factor we want to use to rescale
  26260. */
  26261. scale(ratio: number): void;
  26262. /**
  26263. * Get if the texture can rescale.
  26264. */
  26265. readonly canRescale: boolean;
  26266. /** @hidden */
  26267. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  26268. /** @hidden */
  26269. _rebuild(): void;
  26270. /**
  26271. * Triggers the load sequence in delayed load mode.
  26272. */
  26273. delayLoad(): void;
  26274. /**
  26275. * Clones the texture.
  26276. * @returns the cloned texture
  26277. */
  26278. clone(): Nullable<BaseTexture>;
  26279. /**
  26280. * Get the texture underlying type (INT, FLOAT...)
  26281. */
  26282. readonly textureType: number;
  26283. /**
  26284. * Get the texture underlying format (RGB, RGBA...)
  26285. */
  26286. readonly textureFormat: number;
  26287. /**
  26288. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  26289. * This will returns an RGBA array buffer containing either in values (0-255) or
  26290. * float values (0-1) depending of the underlying buffer type.
  26291. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  26292. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  26293. * @param buffer defines a user defined buffer to fill with data (can be null)
  26294. * @returns The Array buffer containing the pixels data.
  26295. */
  26296. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  26297. /**
  26298. * Release and destroy the underlying lower level texture aka internalTexture.
  26299. */
  26300. releaseInternalTexture(): void;
  26301. /**
  26302. * Get the polynomial representation of the texture data.
  26303. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  26304. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  26305. */
  26306. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26307. /** @hidden */
  26308. readonly _lodTextureHigh: Nullable<BaseTexture>;
  26309. /** @hidden */
  26310. readonly _lodTextureMid: Nullable<BaseTexture>;
  26311. /** @hidden */
  26312. readonly _lodTextureLow: Nullable<BaseTexture>;
  26313. /**
  26314. * Dispose the texture and release its associated resources.
  26315. */
  26316. dispose(): void;
  26317. /**
  26318. * Serialize the texture into a JSON representation that can be parsed later on.
  26319. * @returns the JSON representation of the texture
  26320. */
  26321. serialize(): any;
  26322. /**
  26323. * Helper function to be called back once a list of texture contains only ready textures.
  26324. * @param textures Define the list of textures to wait for
  26325. * @param callback Define the callback triggered once the entire list will be ready
  26326. */
  26327. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  26328. }
  26329. }
  26330. declare module BABYLON {
  26331. /**
  26332. * Uniform buffer objects.
  26333. *
  26334. * Handles blocks of uniform on the GPU.
  26335. *
  26336. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26337. *
  26338. * For more information, please refer to :
  26339. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26340. */
  26341. export class UniformBuffer {
  26342. private _engine;
  26343. private _buffer;
  26344. private _data;
  26345. private _bufferData;
  26346. private _dynamic?;
  26347. private _uniformLocations;
  26348. private _uniformSizes;
  26349. private _uniformLocationPointer;
  26350. private _needSync;
  26351. private _noUBO;
  26352. private _currentEffect;
  26353. private static _MAX_UNIFORM_SIZE;
  26354. private static _tempBuffer;
  26355. /**
  26356. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  26357. * This is dynamic to allow compat with webgl 1 and 2.
  26358. * You will need to pass the name of the uniform as well as the value.
  26359. */
  26360. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  26361. /**
  26362. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  26363. * This is dynamic to allow compat with webgl 1 and 2.
  26364. * You will need to pass the name of the uniform as well as the value.
  26365. */
  26366. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  26367. /**
  26368. * Lambda to Update a single float in a uniform buffer.
  26369. * This is dynamic to allow compat with webgl 1 and 2.
  26370. * You will need to pass the name of the uniform as well as the value.
  26371. */
  26372. updateFloat: (name: string, x: number) => void;
  26373. /**
  26374. * Lambda to Update a vec2 of float in a uniform buffer.
  26375. * This is dynamic to allow compat with webgl 1 and 2.
  26376. * You will need to pass the name of the uniform as well as the value.
  26377. */
  26378. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  26379. /**
  26380. * Lambda to Update a vec3 of float in a uniform buffer.
  26381. * This is dynamic to allow compat with webgl 1 and 2.
  26382. * You will need to pass the name of the uniform as well as the value.
  26383. */
  26384. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  26385. /**
  26386. * Lambda to Update a vec4 of float in a uniform buffer.
  26387. * This is dynamic to allow compat with webgl 1 and 2.
  26388. * You will need to pass the name of the uniform as well as the value.
  26389. */
  26390. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  26391. /**
  26392. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  26393. * This is dynamic to allow compat with webgl 1 and 2.
  26394. * You will need to pass the name of the uniform as well as the value.
  26395. */
  26396. updateMatrix: (name: string, mat: Matrix) => void;
  26397. /**
  26398. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  26399. * This is dynamic to allow compat with webgl 1 and 2.
  26400. * You will need to pass the name of the uniform as well as the value.
  26401. */
  26402. updateVector3: (name: string, vector: Vector3) => void;
  26403. /**
  26404. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  26405. * This is dynamic to allow compat with webgl 1 and 2.
  26406. * You will need to pass the name of the uniform as well as the value.
  26407. */
  26408. updateVector4: (name: string, vector: Vector4) => void;
  26409. /**
  26410. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  26411. * This is dynamic to allow compat with webgl 1 and 2.
  26412. * You will need to pass the name of the uniform as well as the value.
  26413. */
  26414. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  26415. /**
  26416. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  26417. * This is dynamic to allow compat with webgl 1 and 2.
  26418. * You will need to pass the name of the uniform as well as the value.
  26419. */
  26420. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  26421. /**
  26422. * Instantiates a new Uniform buffer objects.
  26423. *
  26424. * Handles blocks of uniform on the GPU.
  26425. *
  26426. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26427. *
  26428. * For more information, please refer to :
  26429. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26430. * @param engine Define the engine the buffer is associated with
  26431. * @param data Define the data contained in the buffer
  26432. * @param dynamic Define if the buffer is updatable
  26433. */
  26434. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  26435. /**
  26436. * Indicates if the buffer is using the WebGL2 UBO implementation,
  26437. * or just falling back on setUniformXXX calls.
  26438. */
  26439. readonly useUbo: boolean;
  26440. /**
  26441. * Indicates if the WebGL underlying uniform buffer is in sync
  26442. * with the javascript cache data.
  26443. */
  26444. readonly isSync: boolean;
  26445. /**
  26446. * Indicates if the WebGL underlying uniform buffer is dynamic.
  26447. * Also, a dynamic UniformBuffer will disable cache verification and always
  26448. * update the underlying WebGL uniform buffer to the GPU.
  26449. * @returns if Dynamic, otherwise false
  26450. */
  26451. isDynamic(): boolean;
  26452. /**
  26453. * The data cache on JS side.
  26454. * @returns the underlying data as a float array
  26455. */
  26456. getData(): Float32Array;
  26457. /**
  26458. * The underlying WebGL Uniform buffer.
  26459. * @returns the webgl buffer
  26460. */
  26461. getBuffer(): Nullable<DataBuffer>;
  26462. /**
  26463. * std140 layout specifies how to align data within an UBO structure.
  26464. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  26465. * for specs.
  26466. */
  26467. private _fillAlignment;
  26468. /**
  26469. * Adds an uniform in the buffer.
  26470. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  26471. * for the layout to be correct !
  26472. * @param name Name of the uniform, as used in the uniform block in the shader.
  26473. * @param size Data size, or data directly.
  26474. */
  26475. addUniform(name: string, size: number | number[]): void;
  26476. /**
  26477. * Adds a Matrix 4x4 to the uniform buffer.
  26478. * @param name Name of the uniform, as used in the uniform block in the shader.
  26479. * @param mat A 4x4 matrix.
  26480. */
  26481. addMatrix(name: string, mat: Matrix): void;
  26482. /**
  26483. * Adds a vec2 to the uniform buffer.
  26484. * @param name Name of the uniform, as used in the uniform block in the shader.
  26485. * @param x Define the x component value of the vec2
  26486. * @param y Define the y component value of the vec2
  26487. */
  26488. addFloat2(name: string, x: number, y: number): void;
  26489. /**
  26490. * Adds a vec3 to the uniform buffer.
  26491. * @param name Name of the uniform, as used in the uniform block in the shader.
  26492. * @param x Define the x component value of the vec3
  26493. * @param y Define the y component value of the vec3
  26494. * @param z Define the z component value of the vec3
  26495. */
  26496. addFloat3(name: string, x: number, y: number, z: number): void;
  26497. /**
  26498. * Adds a vec3 to the uniform buffer.
  26499. * @param name Name of the uniform, as used in the uniform block in the shader.
  26500. * @param color Define the vec3 from a Color
  26501. */
  26502. addColor3(name: string, color: Color3): void;
  26503. /**
  26504. * Adds a vec4 to the uniform buffer.
  26505. * @param name Name of the uniform, as used in the uniform block in the shader.
  26506. * @param color Define the rgb components from a Color
  26507. * @param alpha Define the a component of the vec4
  26508. */
  26509. addColor4(name: string, color: Color3, alpha: number): void;
  26510. /**
  26511. * Adds a vec3 to the uniform buffer.
  26512. * @param name Name of the uniform, as used in the uniform block in the shader.
  26513. * @param vector Define the vec3 components from a Vector
  26514. */
  26515. addVector3(name: string, vector: Vector3): void;
  26516. /**
  26517. * Adds a Matrix 3x3 to the uniform buffer.
  26518. * @param name Name of the uniform, as used in the uniform block in the shader.
  26519. */
  26520. addMatrix3x3(name: string): void;
  26521. /**
  26522. * Adds a Matrix 2x2 to the uniform buffer.
  26523. * @param name Name of the uniform, as used in the uniform block in the shader.
  26524. */
  26525. addMatrix2x2(name: string): void;
  26526. /**
  26527. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  26528. */
  26529. create(): void;
  26530. /** @hidden */
  26531. _rebuild(): void;
  26532. /**
  26533. * Updates the WebGL Uniform Buffer on the GPU.
  26534. * If the `dynamic` flag is set to true, no cache comparison is done.
  26535. * Otherwise, the buffer will be updated only if the cache differs.
  26536. */
  26537. update(): void;
  26538. /**
  26539. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  26540. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26541. * @param data Define the flattened data
  26542. * @param size Define the size of the data.
  26543. */
  26544. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26545. private _updateMatrix3x3ForUniform;
  26546. private _updateMatrix3x3ForEffect;
  26547. private _updateMatrix2x2ForEffect;
  26548. private _updateMatrix2x2ForUniform;
  26549. private _updateFloatForEffect;
  26550. private _updateFloatForUniform;
  26551. private _updateFloat2ForEffect;
  26552. private _updateFloat2ForUniform;
  26553. private _updateFloat3ForEffect;
  26554. private _updateFloat3ForUniform;
  26555. private _updateFloat4ForEffect;
  26556. private _updateFloat4ForUniform;
  26557. private _updateMatrixForEffect;
  26558. private _updateMatrixForUniform;
  26559. private _updateVector3ForEffect;
  26560. private _updateVector3ForUniform;
  26561. private _updateVector4ForEffect;
  26562. private _updateVector4ForUniform;
  26563. private _updateColor3ForEffect;
  26564. private _updateColor3ForUniform;
  26565. private _updateColor4ForEffect;
  26566. private _updateColor4ForUniform;
  26567. /**
  26568. * Sets a sampler uniform on the effect.
  26569. * @param name Define the name of the sampler.
  26570. * @param texture Define the texture to set in the sampler
  26571. */
  26572. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26573. /**
  26574. * Directly updates the value of the uniform in the cache AND on the GPU.
  26575. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26576. * @param data Define the flattened data
  26577. */
  26578. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26579. /**
  26580. * Binds this uniform buffer to an effect.
  26581. * @param effect Define the effect to bind the buffer to
  26582. * @param name Name of the uniform block in the shader.
  26583. */
  26584. bindToEffect(effect: Effect, name: string): void;
  26585. /**
  26586. * Disposes the uniform buffer.
  26587. */
  26588. dispose(): void;
  26589. }
  26590. }
  26591. declare module BABYLON {
  26592. /**
  26593. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26594. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26595. */
  26596. export class Analyser {
  26597. /**
  26598. * Gets or sets the smoothing
  26599. * @ignorenaming
  26600. */
  26601. SMOOTHING: number;
  26602. /**
  26603. * Gets or sets the FFT table size
  26604. * @ignorenaming
  26605. */
  26606. FFT_SIZE: number;
  26607. /**
  26608. * Gets or sets the bar graph amplitude
  26609. * @ignorenaming
  26610. */
  26611. BARGRAPHAMPLITUDE: number;
  26612. /**
  26613. * Gets or sets the position of the debug canvas
  26614. * @ignorenaming
  26615. */
  26616. DEBUGCANVASPOS: {
  26617. x: number;
  26618. y: number;
  26619. };
  26620. /**
  26621. * Gets or sets the debug canvas size
  26622. * @ignorenaming
  26623. */
  26624. DEBUGCANVASSIZE: {
  26625. width: number;
  26626. height: number;
  26627. };
  26628. private _byteFreqs;
  26629. private _byteTime;
  26630. private _floatFreqs;
  26631. private _webAudioAnalyser;
  26632. private _debugCanvas;
  26633. private _debugCanvasContext;
  26634. private _scene;
  26635. private _registerFunc;
  26636. private _audioEngine;
  26637. /**
  26638. * Creates a new analyser
  26639. * @param scene defines hosting scene
  26640. */
  26641. constructor(scene: Scene);
  26642. /**
  26643. * Get the number of data values you will have to play with for the visualization
  26644. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26645. * @returns a number
  26646. */
  26647. getFrequencyBinCount(): number;
  26648. /**
  26649. * Gets the current frequency data as a byte array
  26650. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26651. * @returns a Uint8Array
  26652. */
  26653. getByteFrequencyData(): Uint8Array;
  26654. /**
  26655. * Gets the current waveform as a byte array
  26656. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26657. * @returns a Uint8Array
  26658. */
  26659. getByteTimeDomainData(): Uint8Array;
  26660. /**
  26661. * Gets the current frequency data as a float array
  26662. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26663. * @returns a Float32Array
  26664. */
  26665. getFloatFrequencyData(): Float32Array;
  26666. /**
  26667. * Renders the debug canvas
  26668. */
  26669. drawDebugCanvas(): void;
  26670. /**
  26671. * Stops rendering the debug canvas and removes it
  26672. */
  26673. stopDebugCanvas(): void;
  26674. /**
  26675. * Connects two audio nodes
  26676. * @param inputAudioNode defines first node to connect
  26677. * @param outputAudioNode defines second node to connect
  26678. */
  26679. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26680. /**
  26681. * Releases all associated resources
  26682. */
  26683. dispose(): void;
  26684. }
  26685. }
  26686. declare module BABYLON {
  26687. /**
  26688. * This represents an audio engine and it is responsible
  26689. * to play, synchronize and analyse sounds throughout the application.
  26690. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26691. */
  26692. export interface IAudioEngine extends IDisposable {
  26693. /**
  26694. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26695. */
  26696. readonly canUseWebAudio: boolean;
  26697. /**
  26698. * Gets the current AudioContext if available.
  26699. */
  26700. readonly audioContext: Nullable<AudioContext>;
  26701. /**
  26702. * The master gain node defines the global audio volume of your audio engine.
  26703. */
  26704. readonly masterGain: GainNode;
  26705. /**
  26706. * Gets whether or not mp3 are supported by your browser.
  26707. */
  26708. readonly isMP3supported: boolean;
  26709. /**
  26710. * Gets whether or not ogg are supported by your browser.
  26711. */
  26712. readonly isOGGsupported: boolean;
  26713. /**
  26714. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26715. * @ignoreNaming
  26716. */
  26717. WarnedWebAudioUnsupported: boolean;
  26718. /**
  26719. * Defines if the audio engine relies on a custom unlocked button.
  26720. * In this case, the embedded button will not be displayed.
  26721. */
  26722. useCustomUnlockedButton: boolean;
  26723. /**
  26724. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  26725. */
  26726. readonly unlocked: boolean;
  26727. /**
  26728. * Event raised when audio has been unlocked on the browser.
  26729. */
  26730. onAudioUnlockedObservable: Observable<AudioEngine>;
  26731. /**
  26732. * Event raised when audio has been locked on the browser.
  26733. */
  26734. onAudioLockedObservable: Observable<AudioEngine>;
  26735. /**
  26736. * Flags the audio engine in Locked state.
  26737. * This happens due to new browser policies preventing audio to autoplay.
  26738. */
  26739. lock(): void;
  26740. /**
  26741. * Unlocks the audio engine once a user action has been done on the dom.
  26742. * This is helpful to resume play once browser policies have been satisfied.
  26743. */
  26744. unlock(): void;
  26745. }
  26746. /**
  26747. * This represents the default audio engine used in babylon.
  26748. * It is responsible to play, synchronize and analyse sounds throughout the application.
  26749. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26750. */
  26751. export class AudioEngine implements IAudioEngine {
  26752. private _audioContext;
  26753. private _audioContextInitialized;
  26754. private _muteButton;
  26755. private _hostElement;
  26756. /**
  26757. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26758. */
  26759. canUseWebAudio: boolean;
  26760. /**
  26761. * The master gain node defines the global audio volume of your audio engine.
  26762. */
  26763. masterGain: GainNode;
  26764. /**
  26765. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26766. * @ignoreNaming
  26767. */
  26768. WarnedWebAudioUnsupported: boolean;
  26769. /**
  26770. * Gets whether or not mp3 are supported by your browser.
  26771. */
  26772. isMP3supported: boolean;
  26773. /**
  26774. * Gets whether or not ogg are supported by your browser.
  26775. */
  26776. isOGGsupported: boolean;
  26777. /**
  26778. * Gets whether audio has been unlocked on the device.
  26779. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  26780. * a user interaction has happened.
  26781. */
  26782. unlocked: boolean;
  26783. /**
  26784. * Defines if the audio engine relies on a custom unlocked button.
  26785. * In this case, the embedded button will not be displayed.
  26786. */
  26787. useCustomUnlockedButton: boolean;
  26788. /**
  26789. * Event raised when audio has been unlocked on the browser.
  26790. */
  26791. onAudioUnlockedObservable: Observable<AudioEngine>;
  26792. /**
  26793. * Event raised when audio has been locked on the browser.
  26794. */
  26795. onAudioLockedObservable: Observable<AudioEngine>;
  26796. /**
  26797. * Gets the current AudioContext if available.
  26798. */
  26799. readonly audioContext: Nullable<AudioContext>;
  26800. private _connectedAnalyser;
  26801. /**
  26802. * Instantiates a new audio engine.
  26803. *
  26804. * There should be only one per page as some browsers restrict the number
  26805. * of audio contexts you can create.
  26806. * @param hostElement defines the host element where to display the mute icon if necessary
  26807. */
  26808. constructor(hostElement?: Nullable<HTMLElement>);
  26809. /**
  26810. * Flags the audio engine in Locked state.
  26811. * This happens due to new browser policies preventing audio to autoplay.
  26812. */
  26813. lock(): void;
  26814. /**
  26815. * Unlocks the audio engine once a user action has been done on the dom.
  26816. * This is helpful to resume play once browser policies have been satisfied.
  26817. */
  26818. unlock(): void;
  26819. private _resumeAudioContext;
  26820. private _initializeAudioContext;
  26821. private _tryToRun;
  26822. private _triggerRunningState;
  26823. private _triggerSuspendedState;
  26824. private _displayMuteButton;
  26825. private _moveButtonToTopLeft;
  26826. private _onResize;
  26827. private _hideMuteButton;
  26828. /**
  26829. * Destroy and release the resources associated with the audio ccontext.
  26830. */
  26831. dispose(): void;
  26832. /**
  26833. * Gets the global volume sets on the master gain.
  26834. * @returns the global volume if set or -1 otherwise
  26835. */
  26836. getGlobalVolume(): number;
  26837. /**
  26838. * Sets the global volume of your experience (sets on the master gain).
  26839. * @param newVolume Defines the new global volume of the application
  26840. */
  26841. setGlobalVolume(newVolume: number): void;
  26842. /**
  26843. * Connect the audio engine to an audio analyser allowing some amazing
  26844. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  26845. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  26846. * @param analyser The analyser to connect to the engine
  26847. */
  26848. connectToAnalyser(analyser: Analyser): void;
  26849. }
  26850. }
  26851. declare module BABYLON {
  26852. /**
  26853. * Interface used to present a loading screen while loading a scene
  26854. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26855. */
  26856. export interface ILoadingScreen {
  26857. /**
  26858. * Function called to display the loading screen
  26859. */
  26860. displayLoadingUI: () => void;
  26861. /**
  26862. * Function called to hide the loading screen
  26863. */
  26864. hideLoadingUI: () => void;
  26865. /**
  26866. * Gets or sets the color to use for the background
  26867. */
  26868. loadingUIBackgroundColor: string;
  26869. /**
  26870. * Gets or sets the text to display while loading
  26871. */
  26872. loadingUIText: string;
  26873. }
  26874. /**
  26875. * Class used for the default loading screen
  26876. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26877. */
  26878. export class DefaultLoadingScreen implements ILoadingScreen {
  26879. private _renderingCanvas;
  26880. private _loadingText;
  26881. private _loadingDivBackgroundColor;
  26882. private _loadingDiv;
  26883. private _loadingTextDiv;
  26884. /** Gets or sets the logo url to use for the default loading screen */
  26885. static DefaultLogoUrl: string;
  26886. /** Gets or sets the spinner url to use for the default loading screen */
  26887. static DefaultSpinnerUrl: string;
  26888. /**
  26889. * Creates a new default loading screen
  26890. * @param _renderingCanvas defines the canvas used to render the scene
  26891. * @param _loadingText defines the default text to display
  26892. * @param _loadingDivBackgroundColor defines the default background color
  26893. */
  26894. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  26895. /**
  26896. * Function called to display the loading screen
  26897. */
  26898. displayLoadingUI(): void;
  26899. /**
  26900. * Function called to hide the loading screen
  26901. */
  26902. hideLoadingUI(): void;
  26903. /**
  26904. * Gets or sets the text to display while loading
  26905. */
  26906. loadingUIText: string;
  26907. /**
  26908. * Gets or sets the color to use for the background
  26909. */
  26910. loadingUIBackgroundColor: string;
  26911. private _resizeLoadingUI;
  26912. }
  26913. }
  26914. declare module BABYLON {
  26915. /** @hidden */
  26916. export class WebGLPipelineContext implements IPipelineContext {
  26917. engine: Engine;
  26918. program: Nullable<WebGLProgram>;
  26919. context?: WebGLRenderingContext;
  26920. vertexShader?: WebGLShader;
  26921. fragmentShader?: WebGLShader;
  26922. isParallelCompiled: boolean;
  26923. onCompiled?: () => void;
  26924. transformFeedback?: WebGLTransformFeedback | null;
  26925. readonly isAsync: boolean;
  26926. readonly isReady: boolean;
  26927. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  26928. }
  26929. }
  26930. declare module BABYLON {
  26931. /** @hidden */
  26932. export class WebGLDataBuffer extends DataBuffer {
  26933. private _buffer;
  26934. constructor(resource: WebGLBuffer);
  26935. readonly underlyingResource: any;
  26936. }
  26937. }
  26938. declare module BABYLON {
  26939. /**
  26940. * Settings for finer control over video usage
  26941. */
  26942. export interface VideoTextureSettings {
  26943. /**
  26944. * Applies `autoplay` to video, if specified
  26945. */
  26946. autoPlay?: boolean;
  26947. /**
  26948. * Applies `loop` to video, if specified
  26949. */
  26950. loop?: boolean;
  26951. /**
  26952. * Automatically updates internal texture from video at every frame in the render loop
  26953. */
  26954. autoUpdateTexture: boolean;
  26955. /**
  26956. * Image src displayed during the video loading or until the user interacts with the video.
  26957. */
  26958. poster?: string;
  26959. }
  26960. /**
  26961. * If you want to display a video in your scene, this is the special texture for that.
  26962. * This special texture works similar to other textures, with the exception of a few parameters.
  26963. * @see https://doc.babylonjs.com/how_to/video_texture
  26964. */
  26965. export class VideoTexture extends Texture {
  26966. /**
  26967. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  26968. */
  26969. readonly autoUpdateTexture: boolean;
  26970. /**
  26971. * The video instance used by the texture internally
  26972. */
  26973. readonly video: HTMLVideoElement;
  26974. private _onUserActionRequestedObservable;
  26975. /**
  26976. * Event triggerd when a dom action is required by the user to play the video.
  26977. * This happens due to recent changes in browser policies preventing video to auto start.
  26978. */
  26979. readonly onUserActionRequestedObservable: Observable<Texture>;
  26980. private _generateMipMaps;
  26981. private _engine;
  26982. private _stillImageCaptured;
  26983. private _displayingPosterTexture;
  26984. private _settings;
  26985. private _createInternalTextureOnEvent;
  26986. /**
  26987. * Creates a video texture.
  26988. * If you want to display a video in your scene, this is the special texture for that.
  26989. * This special texture works similar to other textures, with the exception of a few parameters.
  26990. * @see https://doc.babylonjs.com/how_to/video_texture
  26991. * @param name optional name, will detect from video source, if not defined
  26992. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  26993. * @param scene is obviously the current scene.
  26994. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  26995. * @param invertY is false by default but can be used to invert video on Y axis
  26996. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  26997. * @param settings allows finer control over video usage
  26998. */
  26999. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  27000. private _getName;
  27001. private _getVideo;
  27002. private _createInternalTexture;
  27003. private reset;
  27004. /**
  27005. * @hidden Internal method to initiate `update`.
  27006. */
  27007. _rebuild(): void;
  27008. /**
  27009. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  27010. */
  27011. update(): void;
  27012. /**
  27013. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  27014. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  27015. */
  27016. updateTexture(isVisible: boolean): void;
  27017. protected _updateInternalTexture: () => void;
  27018. /**
  27019. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  27020. * @param url New url.
  27021. */
  27022. updateURL(url: string): void;
  27023. /**
  27024. * Dispose the texture and release its associated resources.
  27025. */
  27026. dispose(): void;
  27027. /**
  27028. * Creates a video texture straight from a stream.
  27029. * @param scene Define the scene the texture should be created in
  27030. * @param stream Define the stream the texture should be created from
  27031. * @returns The created video texture as a promise
  27032. */
  27033. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  27034. /**
  27035. * Creates a video texture straight from your WebCam video feed.
  27036. * @param scene Define the scene the texture should be created in
  27037. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27038. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27039. * @returns The created video texture as a promise
  27040. */
  27041. static CreateFromWebCamAsync(scene: Scene, constraints: {
  27042. minWidth: number;
  27043. maxWidth: number;
  27044. minHeight: number;
  27045. maxHeight: number;
  27046. deviceId: string;
  27047. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  27048. /**
  27049. * Creates a video texture straight from your WebCam video feed.
  27050. * @param scene Define the scene the texture should be created in
  27051. * @param onReady Define a callback to triggered once the texture will be ready
  27052. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27053. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27054. */
  27055. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  27056. minWidth: number;
  27057. maxWidth: number;
  27058. minHeight: number;
  27059. maxHeight: number;
  27060. deviceId: string;
  27061. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  27062. }
  27063. }
  27064. declare module BABYLON {
  27065. /**
  27066. * Interface for attribute information associated with buffer instanciation
  27067. */
  27068. export class InstancingAttributeInfo {
  27069. /**
  27070. * Index/offset of the attribute in the vertex shader
  27071. */
  27072. index: number;
  27073. /**
  27074. * size of the attribute, 1, 2, 3 or 4
  27075. */
  27076. attributeSize: number;
  27077. /**
  27078. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  27079. * default is FLOAT
  27080. */
  27081. attribyteType: number;
  27082. /**
  27083. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  27084. */
  27085. normalized: boolean;
  27086. /**
  27087. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  27088. */
  27089. offset: number;
  27090. /**
  27091. * Name of the GLSL attribute, for debugging purpose only
  27092. */
  27093. attributeName: string;
  27094. }
  27095. /**
  27096. * Define options used to create a depth texture
  27097. */
  27098. export class DepthTextureCreationOptions {
  27099. /** Specifies whether or not a stencil should be allocated in the texture */
  27100. generateStencil?: boolean;
  27101. /** Specifies whether or not bilinear filtering is enable on the texture */
  27102. bilinearFiltering?: boolean;
  27103. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  27104. comparisonFunction?: number;
  27105. /** Specifies if the created texture is a cube texture */
  27106. isCube?: boolean;
  27107. }
  27108. /**
  27109. * Class used to describe the capabilities of the engine relatively to the current browser
  27110. */
  27111. export class EngineCapabilities {
  27112. /** Maximum textures units per fragment shader */
  27113. maxTexturesImageUnits: number;
  27114. /** Maximum texture units per vertex shader */
  27115. maxVertexTextureImageUnits: number;
  27116. /** Maximum textures units in the entire pipeline */
  27117. maxCombinedTexturesImageUnits: number;
  27118. /** Maximum texture size */
  27119. maxTextureSize: number;
  27120. /** Maximum cube texture size */
  27121. maxCubemapTextureSize: number;
  27122. /** Maximum render texture size */
  27123. maxRenderTextureSize: number;
  27124. /** Maximum number of vertex attributes */
  27125. maxVertexAttribs: number;
  27126. /** Maximum number of varyings */
  27127. maxVaryingVectors: number;
  27128. /** Maximum number of uniforms per vertex shader */
  27129. maxVertexUniformVectors: number;
  27130. /** Maximum number of uniforms per fragment shader */
  27131. maxFragmentUniformVectors: number;
  27132. /** Defines if standard derivates (dx/dy) are supported */
  27133. standardDerivatives: boolean;
  27134. /** Defines if s3tc texture compression is supported */
  27135. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  27136. /** Defines if pvrtc texture compression is supported */
  27137. pvrtc: any;
  27138. /** Defines if etc1 texture compression is supported */
  27139. etc1: any;
  27140. /** Defines if etc2 texture compression is supported */
  27141. etc2: any;
  27142. /** Defines if astc texture compression is supported */
  27143. astc: any;
  27144. /** Defines if float textures are supported */
  27145. textureFloat: boolean;
  27146. /** Defines if vertex array objects are supported */
  27147. vertexArrayObject: boolean;
  27148. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  27149. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  27150. /** Gets the maximum level of anisotropy supported */
  27151. maxAnisotropy: number;
  27152. /** Defines if instancing is supported */
  27153. instancedArrays: boolean;
  27154. /** Defines if 32 bits indices are supported */
  27155. uintIndices: boolean;
  27156. /** Defines if high precision shaders are supported */
  27157. highPrecisionShaderSupported: boolean;
  27158. /** Defines if depth reading in the fragment shader is supported */
  27159. fragmentDepthSupported: boolean;
  27160. /** Defines if float texture linear filtering is supported*/
  27161. textureFloatLinearFiltering: boolean;
  27162. /** Defines if rendering to float textures is supported */
  27163. textureFloatRender: boolean;
  27164. /** Defines if half float textures are supported*/
  27165. textureHalfFloat: boolean;
  27166. /** Defines if half float texture linear filtering is supported*/
  27167. textureHalfFloatLinearFiltering: boolean;
  27168. /** Defines if rendering to half float textures is supported */
  27169. textureHalfFloatRender: boolean;
  27170. /** Defines if textureLOD shader command is supported */
  27171. textureLOD: boolean;
  27172. /** Defines if draw buffers extension is supported */
  27173. drawBuffersExtension: boolean;
  27174. /** Defines if depth textures are supported */
  27175. depthTextureExtension: boolean;
  27176. /** Defines if float color buffer are supported */
  27177. colorBufferFloat: boolean;
  27178. /** Gets disjoint timer query extension (null if not supported) */
  27179. timerQuery: EXT_disjoint_timer_query;
  27180. /** Defines if timestamp can be used with timer query */
  27181. canUseTimestampForTimerQuery: boolean;
  27182. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  27183. multiview: any;
  27184. /** Function used to let the system compiles shaders in background */
  27185. parallelShaderCompile: {
  27186. COMPLETION_STATUS_KHR: number;
  27187. };
  27188. }
  27189. /** Interface defining initialization parameters for Engine class */
  27190. export interface EngineOptions extends WebGLContextAttributes {
  27191. /**
  27192. * Defines if the engine should no exceed a specified device ratio
  27193. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  27194. */
  27195. limitDeviceRatio?: number;
  27196. /**
  27197. * Defines if webvr should be enabled automatically
  27198. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27199. */
  27200. autoEnableWebVR?: boolean;
  27201. /**
  27202. * Defines if webgl2 should be turned off even if supported
  27203. * @see http://doc.babylonjs.com/features/webgl2
  27204. */
  27205. disableWebGL2Support?: boolean;
  27206. /**
  27207. * Defines if webaudio should be initialized as well
  27208. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27209. */
  27210. audioEngine?: boolean;
  27211. /**
  27212. * Defines if animations should run using a deterministic lock step
  27213. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27214. */
  27215. deterministicLockstep?: boolean;
  27216. /** Defines the maximum steps to use with deterministic lock step mode */
  27217. lockstepMaxSteps?: number;
  27218. /**
  27219. * Defines that engine should ignore context lost events
  27220. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  27221. */
  27222. doNotHandleContextLost?: boolean;
  27223. /**
  27224. * Defines that engine should ignore modifying touch action attribute and style
  27225. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  27226. */
  27227. doNotHandleTouchAction?: boolean;
  27228. /**
  27229. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  27230. */
  27231. useHighPrecisionFloats?: boolean;
  27232. }
  27233. /**
  27234. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27235. */
  27236. export class Engine {
  27237. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  27238. static ExceptionList: ({
  27239. key: string;
  27240. capture: string;
  27241. captureConstraint: number;
  27242. targets: string[];
  27243. } | {
  27244. key: string;
  27245. capture: null;
  27246. captureConstraint: null;
  27247. targets: string[];
  27248. })[];
  27249. /** Gets the list of created engines */
  27250. static readonly Instances: Engine[];
  27251. /**
  27252. * Gets the latest created engine
  27253. */
  27254. static readonly LastCreatedEngine: Nullable<Engine>;
  27255. /**
  27256. * Gets the latest created scene
  27257. */
  27258. static readonly LastCreatedScene: Nullable<Scene>;
  27259. /**
  27260. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27261. * @param flag defines which part of the materials must be marked as dirty
  27262. * @param predicate defines a predicate used to filter which materials should be affected
  27263. */
  27264. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  27265. /**
  27266. * Hidden
  27267. */
  27268. static _TextureLoaders: IInternalTextureLoader[];
  27269. /** Defines that alpha blending is disabled */
  27270. static readonly ALPHA_DISABLE: number;
  27271. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27272. static readonly ALPHA_ADD: number;
  27273. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27274. static readonly ALPHA_COMBINE: number;
  27275. /** Defines that alpha blending to DEST - SRC * DEST */
  27276. static readonly ALPHA_SUBTRACT: number;
  27277. /** Defines that alpha blending to SRC * DEST */
  27278. static readonly ALPHA_MULTIPLY: number;
  27279. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27280. static readonly ALPHA_MAXIMIZED: number;
  27281. /** Defines that alpha blending to SRC + DEST */
  27282. static readonly ALPHA_ONEONE: number;
  27283. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27284. static readonly ALPHA_PREMULTIPLIED: number;
  27285. /**
  27286. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27287. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27288. */
  27289. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  27290. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27291. static readonly ALPHA_INTERPOLATE: number;
  27292. /**
  27293. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27294. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27295. */
  27296. static readonly ALPHA_SCREENMODE: number;
  27297. /** Defines that the ressource is not delayed*/
  27298. static readonly DELAYLOADSTATE_NONE: number;
  27299. /** Defines that the ressource was successfully delay loaded */
  27300. static readonly DELAYLOADSTATE_LOADED: number;
  27301. /** Defines that the ressource is currently delay loading */
  27302. static readonly DELAYLOADSTATE_LOADING: number;
  27303. /** Defines that the ressource is delayed and has not started loading */
  27304. static readonly DELAYLOADSTATE_NOTLOADED: number;
  27305. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27306. static readonly NEVER: number;
  27307. /** 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 */
  27308. static readonly ALWAYS: number;
  27309. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27310. static readonly LESS: number;
  27311. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27312. static readonly EQUAL: number;
  27313. /** 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 */
  27314. static readonly LEQUAL: number;
  27315. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27316. static readonly GREATER: number;
  27317. /** 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 */
  27318. static readonly GEQUAL: number;
  27319. /** 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 */
  27320. static readonly NOTEQUAL: number;
  27321. /** Passed to stencilOperation to specify that stencil value must be kept */
  27322. static readonly KEEP: number;
  27323. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27324. static readonly REPLACE: number;
  27325. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27326. static readonly INCR: number;
  27327. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27328. static readonly DECR: number;
  27329. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27330. static readonly INVERT: number;
  27331. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27332. static readonly INCR_WRAP: number;
  27333. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27334. static readonly DECR_WRAP: number;
  27335. /** Texture is not repeating outside of 0..1 UVs */
  27336. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  27337. /** Texture is repeating outside of 0..1 UVs */
  27338. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  27339. /** Texture is repeating and mirrored */
  27340. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  27341. /** ALPHA */
  27342. static readonly TEXTUREFORMAT_ALPHA: number;
  27343. /** LUMINANCE */
  27344. static readonly TEXTUREFORMAT_LUMINANCE: number;
  27345. /** LUMINANCE_ALPHA */
  27346. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  27347. /** RGB */
  27348. static readonly TEXTUREFORMAT_RGB: number;
  27349. /** RGBA */
  27350. static readonly TEXTUREFORMAT_RGBA: number;
  27351. /** RED */
  27352. static readonly TEXTUREFORMAT_RED: number;
  27353. /** RED (2nd reference) */
  27354. static readonly TEXTUREFORMAT_R: number;
  27355. /** RG */
  27356. static readonly TEXTUREFORMAT_RG: number;
  27357. /** RED_INTEGER */
  27358. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  27359. /** RED_INTEGER (2nd reference) */
  27360. static readonly TEXTUREFORMAT_R_INTEGER: number;
  27361. /** RG_INTEGER */
  27362. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  27363. /** RGB_INTEGER */
  27364. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  27365. /** RGBA_INTEGER */
  27366. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  27367. /** UNSIGNED_BYTE */
  27368. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  27369. /** UNSIGNED_BYTE (2nd reference) */
  27370. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  27371. /** FLOAT */
  27372. static readonly TEXTURETYPE_FLOAT: number;
  27373. /** HALF_FLOAT */
  27374. static readonly TEXTURETYPE_HALF_FLOAT: number;
  27375. /** BYTE */
  27376. static readonly TEXTURETYPE_BYTE: number;
  27377. /** SHORT */
  27378. static readonly TEXTURETYPE_SHORT: number;
  27379. /** UNSIGNED_SHORT */
  27380. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  27381. /** INT */
  27382. static readonly TEXTURETYPE_INT: number;
  27383. /** UNSIGNED_INT */
  27384. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  27385. /** UNSIGNED_SHORT_4_4_4_4 */
  27386. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  27387. /** UNSIGNED_SHORT_5_5_5_1 */
  27388. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  27389. /** UNSIGNED_SHORT_5_6_5 */
  27390. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  27391. /** UNSIGNED_INT_2_10_10_10_REV */
  27392. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  27393. /** UNSIGNED_INT_24_8 */
  27394. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  27395. /** UNSIGNED_INT_10F_11F_11F_REV */
  27396. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27397. /** UNSIGNED_INT_5_9_9_9_REV */
  27398. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27399. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27400. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27401. /** nearest is mag = nearest and min = nearest and mip = linear */
  27402. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27403. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27404. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27405. /** Trilinear is mag = linear and min = linear and mip = linear */
  27406. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27407. /** nearest is mag = nearest and min = nearest and mip = linear */
  27408. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27409. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27410. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27411. /** Trilinear is mag = linear and min = linear and mip = linear */
  27412. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27413. /** mag = nearest and min = nearest and mip = nearest */
  27414. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27415. /** mag = nearest and min = linear and mip = nearest */
  27416. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27417. /** mag = nearest and min = linear and mip = linear */
  27418. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27419. /** mag = nearest and min = linear and mip = none */
  27420. static readonly TEXTURE_NEAREST_LINEAR: number;
  27421. /** mag = nearest and min = nearest and mip = none */
  27422. static readonly TEXTURE_NEAREST_NEAREST: number;
  27423. /** mag = linear and min = nearest and mip = nearest */
  27424. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27425. /** mag = linear and min = nearest and mip = linear */
  27426. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27427. /** mag = linear and min = linear and mip = none */
  27428. static readonly TEXTURE_LINEAR_LINEAR: number;
  27429. /** mag = linear and min = nearest and mip = none */
  27430. static readonly TEXTURE_LINEAR_NEAREST: number;
  27431. /** Explicit coordinates mode */
  27432. static readonly TEXTURE_EXPLICIT_MODE: number;
  27433. /** Spherical coordinates mode */
  27434. static readonly TEXTURE_SPHERICAL_MODE: number;
  27435. /** Planar coordinates mode */
  27436. static readonly TEXTURE_PLANAR_MODE: number;
  27437. /** Cubic coordinates mode */
  27438. static readonly TEXTURE_CUBIC_MODE: number;
  27439. /** Projection coordinates mode */
  27440. static readonly TEXTURE_PROJECTION_MODE: number;
  27441. /** Skybox coordinates mode */
  27442. static readonly TEXTURE_SKYBOX_MODE: number;
  27443. /** Inverse Cubic coordinates mode */
  27444. static readonly TEXTURE_INVCUBIC_MODE: number;
  27445. /** Equirectangular coordinates mode */
  27446. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27447. /** Equirectangular Fixed coordinates mode */
  27448. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27449. /** Equirectangular Fixed Mirrored coordinates mode */
  27450. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27451. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27452. static readonly SCALEMODE_FLOOR: number;
  27453. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27454. static readonly SCALEMODE_NEAREST: number;
  27455. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27456. static readonly SCALEMODE_CEILING: number;
  27457. /**
  27458. * Returns the current npm package of the sdk
  27459. */
  27460. static readonly NpmPackage: string;
  27461. /**
  27462. * Returns the current version of the framework
  27463. */
  27464. static readonly Version: string;
  27465. /**
  27466. * Returns a string describing the current engine
  27467. */
  27468. readonly description: string;
  27469. /**
  27470. * Gets or sets the epsilon value used by collision engine
  27471. */
  27472. static CollisionsEpsilon: number;
  27473. /**
  27474. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27475. */
  27476. static ShadersRepository: string;
  27477. /**
  27478. * Method called to create the default loading screen.
  27479. * This can be overriden in your own app.
  27480. * @param canvas The rendering canvas element
  27481. * @returns The loading screen
  27482. */
  27483. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27484. /**
  27485. * Method called to create the default rescale post process on each engine.
  27486. */
  27487. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27488. /**
  27489. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27490. */
  27491. forcePOTTextures: boolean;
  27492. /**
  27493. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27494. */
  27495. isFullscreen: boolean;
  27496. /**
  27497. * Gets a boolean indicating if the pointer is currently locked
  27498. */
  27499. isPointerLock: boolean;
  27500. /**
  27501. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27502. */
  27503. cullBackFaces: boolean;
  27504. /**
  27505. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27506. */
  27507. renderEvenInBackground: boolean;
  27508. /**
  27509. * Gets or sets a boolean indicating that cache can be kept between frames
  27510. */
  27511. preventCacheWipeBetweenFrames: boolean;
  27512. /**
  27513. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27514. **/
  27515. enableOfflineSupport: boolean;
  27516. /**
  27517. * 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)
  27518. **/
  27519. disableManifestCheck: boolean;
  27520. /**
  27521. * Gets the list of created scenes
  27522. */
  27523. scenes: Scene[];
  27524. /**
  27525. * Event raised when a new scene is created
  27526. */
  27527. onNewSceneAddedObservable: Observable<Scene>;
  27528. /**
  27529. * Gets the list of created postprocesses
  27530. */
  27531. postProcesses: PostProcess[];
  27532. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27533. validateShaderPrograms: boolean;
  27534. /**
  27535. * Observable event triggered each time the rendering canvas is resized
  27536. */
  27537. onResizeObservable: Observable<Engine>;
  27538. /**
  27539. * Observable event triggered each time the canvas loses focus
  27540. */
  27541. onCanvasBlurObservable: Observable<Engine>;
  27542. /**
  27543. * Observable event triggered each time the canvas gains focus
  27544. */
  27545. onCanvasFocusObservable: Observable<Engine>;
  27546. /**
  27547. * Observable event triggered each time the canvas receives pointerout event
  27548. */
  27549. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27550. /**
  27551. * Observable event triggered before each texture is initialized
  27552. */
  27553. onBeforeTextureInitObservable: Observable<Texture>;
  27554. /**
  27555. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27556. */
  27557. disableUniformBuffers: boolean;
  27558. /** @hidden */
  27559. _uniformBuffers: UniformBuffer[];
  27560. /**
  27561. * Gets a boolean indicating that the engine supports uniform buffers
  27562. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27563. */
  27564. readonly supportsUniformBuffers: boolean;
  27565. /**
  27566. * Observable raised when the engine begins a new frame
  27567. */
  27568. onBeginFrameObservable: Observable<Engine>;
  27569. /**
  27570. * If set, will be used to request the next animation frame for the render loop
  27571. */
  27572. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27573. /**
  27574. * Observable raised when the engine ends the current frame
  27575. */
  27576. onEndFrameObservable: Observable<Engine>;
  27577. /**
  27578. * Observable raised when the engine is about to compile a shader
  27579. */
  27580. onBeforeShaderCompilationObservable: Observable<Engine>;
  27581. /**
  27582. * Observable raised when the engine has jsut compiled a shader
  27583. */
  27584. onAfterShaderCompilationObservable: Observable<Engine>;
  27585. /** @hidden */
  27586. _gl: WebGLRenderingContext;
  27587. private _renderingCanvas;
  27588. private _windowIsBackground;
  27589. private _webGLVersion;
  27590. protected _highPrecisionShadersAllowed: boolean;
  27591. /** @hidden */
  27592. readonly _shouldUseHighPrecisionShader: boolean;
  27593. /**
  27594. * Gets a boolean indicating that only power of 2 textures are supported
  27595. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27596. */
  27597. readonly needPOTTextures: boolean;
  27598. /** @hidden */
  27599. _badOS: boolean;
  27600. /** @hidden */
  27601. _badDesktopOS: boolean;
  27602. /**
  27603. * Gets the audio engine
  27604. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27605. * @ignorenaming
  27606. */
  27607. static audioEngine: IAudioEngine;
  27608. /**
  27609. * Default AudioEngine factory responsible of creating the Audio Engine.
  27610. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27611. */
  27612. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27613. /**
  27614. * Default offline support factory responsible of creating a tool used to store data locally.
  27615. * By default, this will create a Database object if the workload has been embedded.
  27616. */
  27617. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27618. private _onFocus;
  27619. private _onBlur;
  27620. private _onCanvasPointerOut;
  27621. private _onCanvasBlur;
  27622. private _onCanvasFocus;
  27623. private _onFullscreenChange;
  27624. private _onPointerLockChange;
  27625. private _hardwareScalingLevel;
  27626. /** @hidden */
  27627. _caps: EngineCapabilities;
  27628. private _pointerLockRequested;
  27629. private _isStencilEnable;
  27630. private _colorWrite;
  27631. private _loadingScreen;
  27632. /** @hidden */
  27633. _drawCalls: PerfCounter;
  27634. private _glVersion;
  27635. private _glRenderer;
  27636. private _glVendor;
  27637. private _videoTextureSupported;
  27638. private _renderingQueueLaunched;
  27639. private _activeRenderLoops;
  27640. private _deterministicLockstep;
  27641. private _lockstepMaxSteps;
  27642. /**
  27643. * Observable signaled when a context lost event is raised
  27644. */
  27645. onContextLostObservable: Observable<Engine>;
  27646. /**
  27647. * Observable signaled when a context restored event is raised
  27648. */
  27649. onContextRestoredObservable: Observable<Engine>;
  27650. private _onContextLost;
  27651. private _onContextRestored;
  27652. private _contextWasLost;
  27653. /** @hidden */
  27654. _doNotHandleContextLost: boolean;
  27655. /**
  27656. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27657. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27658. */
  27659. doNotHandleContextLost: boolean;
  27660. private _performanceMonitor;
  27661. private _fps;
  27662. private _deltaTime;
  27663. /**
  27664. * Turn this value on if you want to pause FPS computation when in background
  27665. */
  27666. disablePerformanceMonitorInBackground: boolean;
  27667. /**
  27668. * Gets the performance monitor attached to this engine
  27669. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27670. */
  27671. readonly performanceMonitor: PerformanceMonitor;
  27672. /**
  27673. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  27674. */
  27675. disableVertexArrayObjects: boolean;
  27676. /** @hidden */
  27677. protected _depthCullingState: _DepthCullingState;
  27678. /** @hidden */
  27679. protected _stencilState: _StencilState;
  27680. /** @hidden */
  27681. protected _alphaState: _AlphaState;
  27682. /** @hidden */
  27683. protected _alphaMode: number;
  27684. /** @hidden */
  27685. _internalTexturesCache: InternalTexture[];
  27686. /** @hidden */
  27687. protected _activeChannel: number;
  27688. private _currentTextureChannel;
  27689. /** @hidden */
  27690. protected _boundTexturesCache: {
  27691. [key: string]: Nullable<InternalTexture>;
  27692. };
  27693. /** @hidden */
  27694. protected _currentEffect: Nullable<Effect>;
  27695. /** @hidden */
  27696. protected _currentProgram: Nullable<WebGLProgram>;
  27697. private _compiledEffects;
  27698. private _vertexAttribArraysEnabled;
  27699. /** @hidden */
  27700. protected _cachedViewport: Nullable<Viewport>;
  27701. private _cachedVertexArrayObject;
  27702. /** @hidden */
  27703. protected _cachedVertexBuffers: any;
  27704. /** @hidden */
  27705. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  27706. /** @hidden */
  27707. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  27708. /** @hidden */
  27709. _currentRenderTarget: Nullable<InternalTexture>;
  27710. private _uintIndicesCurrentlySet;
  27711. private _currentBoundBuffer;
  27712. /** @hidden */
  27713. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  27714. private _currentBufferPointers;
  27715. private _currentInstanceLocations;
  27716. private _currentInstanceBuffers;
  27717. private _textureUnits;
  27718. /** @hidden */
  27719. _workingCanvas: Nullable<HTMLCanvasElement>;
  27720. /** @hidden */
  27721. _workingContext: Nullable<CanvasRenderingContext2D>;
  27722. private _rescalePostProcess;
  27723. private _dummyFramebuffer;
  27724. private _externalData;
  27725. /** @hidden */
  27726. _bindedRenderFunction: any;
  27727. private _vaoRecordInProgress;
  27728. private _mustWipeVertexAttributes;
  27729. private _emptyTexture;
  27730. private _emptyCubeTexture;
  27731. private _emptyTexture3D;
  27732. /** @hidden */
  27733. _frameHandler: number;
  27734. private _nextFreeTextureSlots;
  27735. private _maxSimultaneousTextures;
  27736. private _activeRequests;
  27737. private _texturesSupported;
  27738. /** @hidden */
  27739. _textureFormatInUse: Nullable<string>;
  27740. /**
  27741. * Gets the list of texture formats supported
  27742. */
  27743. readonly texturesSupported: Array<string>;
  27744. /**
  27745. * Gets the list of texture formats in use
  27746. */
  27747. readonly textureFormatInUse: Nullable<string>;
  27748. /**
  27749. * Gets the current viewport
  27750. */
  27751. readonly currentViewport: Nullable<Viewport>;
  27752. /**
  27753. * Gets the default empty texture
  27754. */
  27755. readonly emptyTexture: InternalTexture;
  27756. /**
  27757. * Gets the default empty 3D texture
  27758. */
  27759. readonly emptyTexture3D: InternalTexture;
  27760. /**
  27761. * Gets the default empty cube texture
  27762. */
  27763. readonly emptyCubeTexture: InternalTexture;
  27764. /**
  27765. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27766. */
  27767. readonly premultipliedAlpha: boolean;
  27768. /**
  27769. * Creates a new engine
  27770. * @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
  27771. * @param antialias defines enable antialiasing (default: false)
  27772. * @param options defines further options to be sent to the getContext() function
  27773. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27774. */
  27775. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  27776. /**
  27777. * Initializes a webVR display and starts listening to display change events
  27778. * The onVRDisplayChangedObservable will be notified upon these changes
  27779. * @returns The onVRDisplayChangedObservable
  27780. */
  27781. initWebVR(): Observable<IDisplayChangedEventArgs>;
  27782. /** @hidden */
  27783. _prepareVRComponent(): void;
  27784. /** @hidden */
  27785. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  27786. /** @hidden */
  27787. _submitVRFrame(): void;
  27788. /**
  27789. * Call this function to leave webVR mode
  27790. * Will do nothing if webVR is not supported or if there is no webVR device
  27791. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27792. */
  27793. disableVR(): void;
  27794. /**
  27795. * Gets a boolean indicating that the system is in VR mode and is presenting
  27796. * @returns true if VR mode is engaged
  27797. */
  27798. isVRPresenting(): boolean;
  27799. /** @hidden */
  27800. _requestVRFrame(): void;
  27801. private _disableTouchAction;
  27802. private _rebuildInternalTextures;
  27803. private _rebuildEffects;
  27804. /**
  27805. * Gets a boolean indicating if all created effects are ready
  27806. * @returns true if all effects are ready
  27807. */
  27808. areAllEffectsReady(): boolean;
  27809. private _rebuildBuffers;
  27810. private _initGLContext;
  27811. /**
  27812. * Gets version of the current webGL context
  27813. */
  27814. readonly webGLVersion: number;
  27815. /**
  27816. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27817. */
  27818. readonly isStencilEnable: boolean;
  27819. /** @hidden */
  27820. _prepareWorkingCanvas(): void;
  27821. /**
  27822. * Reset the texture cache to empty state
  27823. */
  27824. resetTextureCache(): void;
  27825. /**
  27826. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27827. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27828. * @returns true if engine is in deterministic lock step mode
  27829. */
  27830. isDeterministicLockStep(): boolean;
  27831. /**
  27832. * Gets the max steps when engine is running in deterministic lock step
  27833. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27834. * @returns the max steps
  27835. */
  27836. getLockstepMaxSteps(): number;
  27837. /**
  27838. * Gets an object containing information about the current webGL context
  27839. * @returns an object containing the vender, the renderer and the version of the current webGL context
  27840. */
  27841. getGlInfo(): {
  27842. vendor: string;
  27843. renderer: string;
  27844. version: string;
  27845. };
  27846. /**
  27847. * Gets current aspect ratio
  27848. * @param camera defines the camera to use to get the aspect ratio
  27849. * @param useScreen defines if screen size must be used (or the current render target if any)
  27850. * @returns a number defining the aspect ratio
  27851. */
  27852. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  27853. /**
  27854. * Gets current screen aspect ratio
  27855. * @returns a number defining the aspect ratio
  27856. */
  27857. getScreenAspectRatio(): number;
  27858. /**
  27859. * Gets the current render width
  27860. * @param useScreen defines if screen size must be used (or the current render target if any)
  27861. * @returns a number defining the current render width
  27862. */
  27863. getRenderWidth(useScreen?: boolean): number;
  27864. /**
  27865. * Gets the current render height
  27866. * @param useScreen defines if screen size must be used (or the current render target if any)
  27867. * @returns a number defining the current render height
  27868. */
  27869. getRenderHeight(useScreen?: boolean): number;
  27870. /**
  27871. * Gets the HTML canvas attached with the current webGL context
  27872. * @returns a HTML canvas
  27873. */
  27874. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  27875. /**
  27876. * Gets the client rect of the HTML canvas attached with the current webGL context
  27877. * @returns a client rectanglee
  27878. */
  27879. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  27880. /**
  27881. * Defines the hardware scaling level.
  27882. * By default the hardware scaling level is computed from the window device ratio.
  27883. * 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.
  27884. * @param level defines the level to use
  27885. */
  27886. setHardwareScalingLevel(level: number): void;
  27887. /**
  27888. * Gets the current hardware scaling level.
  27889. * By default the hardware scaling level is computed from the window device ratio.
  27890. * 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.
  27891. * @returns a number indicating the current hardware scaling level
  27892. */
  27893. getHardwareScalingLevel(): number;
  27894. /**
  27895. * Gets the list of loaded textures
  27896. * @returns an array containing all loaded textures
  27897. */
  27898. getLoadedTexturesCache(): InternalTexture[];
  27899. /**
  27900. * Gets the object containing all engine capabilities
  27901. * @returns the EngineCapabilities object
  27902. */
  27903. getCaps(): EngineCapabilities;
  27904. /**
  27905. * Gets the current depth function
  27906. * @returns a number defining the depth function
  27907. */
  27908. getDepthFunction(): Nullable<number>;
  27909. /**
  27910. * Sets the current depth function
  27911. * @param depthFunc defines the function to use
  27912. */
  27913. setDepthFunction(depthFunc: number): void;
  27914. /**
  27915. * Sets the current depth function to GREATER
  27916. */
  27917. setDepthFunctionToGreater(): void;
  27918. /**
  27919. * Sets the current depth function to GEQUAL
  27920. */
  27921. setDepthFunctionToGreaterOrEqual(): void;
  27922. /**
  27923. * Sets the current depth function to LESS
  27924. */
  27925. setDepthFunctionToLess(): void;
  27926. private _cachedStencilBuffer;
  27927. private _cachedStencilFunction;
  27928. private _cachedStencilMask;
  27929. private _cachedStencilOperationPass;
  27930. private _cachedStencilOperationFail;
  27931. private _cachedStencilOperationDepthFail;
  27932. private _cachedStencilReference;
  27933. /**
  27934. * Caches the the state of the stencil buffer
  27935. */
  27936. cacheStencilState(): void;
  27937. /**
  27938. * Restores the state of the stencil buffer
  27939. */
  27940. restoreStencilState(): void;
  27941. /**
  27942. * Sets the current depth function to LEQUAL
  27943. */
  27944. setDepthFunctionToLessOrEqual(): void;
  27945. /**
  27946. * Gets a boolean indicating if stencil buffer is enabled
  27947. * @returns the current stencil buffer state
  27948. */
  27949. getStencilBuffer(): boolean;
  27950. /**
  27951. * Enable or disable the stencil buffer
  27952. * @param enable defines if the stencil buffer must be enabled or disabled
  27953. */
  27954. setStencilBuffer(enable: boolean): void;
  27955. /**
  27956. * Gets the current stencil mask
  27957. * @returns a number defining the new stencil mask to use
  27958. */
  27959. getStencilMask(): number;
  27960. /**
  27961. * Sets the current stencil mask
  27962. * @param mask defines the new stencil mask to use
  27963. */
  27964. setStencilMask(mask: number): void;
  27965. /**
  27966. * Gets the current stencil function
  27967. * @returns a number defining the stencil function to use
  27968. */
  27969. getStencilFunction(): number;
  27970. /**
  27971. * Gets the current stencil reference value
  27972. * @returns a number defining the stencil reference value to use
  27973. */
  27974. getStencilFunctionReference(): number;
  27975. /**
  27976. * Gets the current stencil mask
  27977. * @returns a number defining the stencil mask to use
  27978. */
  27979. getStencilFunctionMask(): number;
  27980. /**
  27981. * Sets the current stencil function
  27982. * @param stencilFunc defines the new stencil function to use
  27983. */
  27984. setStencilFunction(stencilFunc: number): void;
  27985. /**
  27986. * Sets the current stencil reference
  27987. * @param reference defines the new stencil reference to use
  27988. */
  27989. setStencilFunctionReference(reference: number): void;
  27990. /**
  27991. * Sets the current stencil mask
  27992. * @param mask defines the new stencil mask to use
  27993. */
  27994. setStencilFunctionMask(mask: number): void;
  27995. /**
  27996. * Gets the current stencil operation when stencil fails
  27997. * @returns a number defining stencil operation to use when stencil fails
  27998. */
  27999. getStencilOperationFail(): number;
  28000. /**
  28001. * Gets the current stencil operation when depth fails
  28002. * @returns a number defining stencil operation to use when depth fails
  28003. */
  28004. getStencilOperationDepthFail(): number;
  28005. /**
  28006. * Gets the current stencil operation when stencil passes
  28007. * @returns a number defining stencil operation to use when stencil passes
  28008. */
  28009. getStencilOperationPass(): number;
  28010. /**
  28011. * Sets the stencil operation to use when stencil fails
  28012. * @param operation defines the stencil operation to use when stencil fails
  28013. */
  28014. setStencilOperationFail(operation: number): void;
  28015. /**
  28016. * Sets the stencil operation to use when depth fails
  28017. * @param operation defines the stencil operation to use when depth fails
  28018. */
  28019. setStencilOperationDepthFail(operation: number): void;
  28020. /**
  28021. * Sets the stencil operation to use when stencil passes
  28022. * @param operation defines the stencil operation to use when stencil passes
  28023. */
  28024. setStencilOperationPass(operation: number): void;
  28025. /**
  28026. * Sets a boolean indicating if the dithering state is enabled or disabled
  28027. * @param value defines the dithering state
  28028. */
  28029. setDitheringState(value: boolean): void;
  28030. /**
  28031. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  28032. * @param value defines the rasterizer state
  28033. */
  28034. setRasterizerState(value: boolean): void;
  28035. /**
  28036. * stop executing a render loop function and remove it from the execution array
  28037. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28038. */
  28039. stopRenderLoop(renderFunction?: () => void): void;
  28040. /** @hidden */
  28041. _renderLoop(): void;
  28042. /**
  28043. * Register and execute a render loop. The engine can have more than one render function
  28044. * @param renderFunction defines the function to continuously execute
  28045. */
  28046. runRenderLoop(renderFunction: () => void): void;
  28047. /**
  28048. * Toggle full screen mode
  28049. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28050. */
  28051. switchFullscreen(requestPointerLock: boolean): void;
  28052. /**
  28053. * Enters full screen mode
  28054. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28055. */
  28056. enterFullscreen(requestPointerLock: boolean): void;
  28057. /**
  28058. * Exits full screen mode
  28059. */
  28060. exitFullscreen(): void;
  28061. /**
  28062. * Clear the current render buffer or the current render target (if any is set up)
  28063. * @param color defines the color to use
  28064. * @param backBuffer defines if the back buffer must be cleared
  28065. * @param depth defines if the depth buffer must be cleared
  28066. * @param stencil defines if the stencil buffer must be cleared
  28067. */
  28068. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  28069. /**
  28070. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  28071. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28072. * @param y defines the y-coordinate of the corner of the clear rectangle
  28073. * @param width defines the width of the clear rectangle
  28074. * @param height defines the height of the clear rectangle
  28075. * @param clearColor defines the clear color
  28076. */
  28077. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  28078. /**
  28079. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  28080. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28081. * @param y defines the y-coordinate of the corner of the clear rectangle
  28082. * @param width defines the width of the clear rectangle
  28083. * @param height defines the height of the clear rectangle
  28084. */
  28085. enableScissor(x: number, y: number, width: number, height: number): void;
  28086. /**
  28087. * Disable previously set scissor test rectangle
  28088. */
  28089. disableScissor(): void;
  28090. private _viewportCached;
  28091. /** @hidden */
  28092. _viewport(x: number, y: number, width: number, height: number): void;
  28093. /**
  28094. * Set the WebGL's viewport
  28095. * @param viewport defines the viewport element to be used
  28096. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28097. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28098. */
  28099. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  28100. /**
  28101. * Directly set the WebGL Viewport
  28102. * @param x defines the x coordinate of the viewport (in screen space)
  28103. * @param y defines the y coordinate of the viewport (in screen space)
  28104. * @param width defines the width of the viewport (in screen space)
  28105. * @param height defines the height of the viewport (in screen space)
  28106. * @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
  28107. */
  28108. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  28109. /**
  28110. * Begin a new frame
  28111. */
  28112. beginFrame(): void;
  28113. /**
  28114. * Enf the current frame
  28115. */
  28116. endFrame(): void;
  28117. /**
  28118. * Resize the view according to the canvas' size
  28119. */
  28120. resize(): void;
  28121. /**
  28122. * Force a specific size of the canvas
  28123. * @param width defines the new canvas' width
  28124. * @param height defines the new canvas' height
  28125. */
  28126. setSize(width: number, height: number): void;
  28127. /**
  28128. * Binds the frame buffer to the specified texture.
  28129. * @param texture The texture to render to or null for the default canvas
  28130. * @param faceIndex The face of the texture to render to in case of cube texture
  28131. * @param requiredWidth The width of the target to render to
  28132. * @param requiredHeight The height of the target to render to
  28133. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  28134. * @param depthStencilTexture The depth stencil texture to use to render
  28135. * @param lodLevel defines le lod level to bind to the frame buffer
  28136. */
  28137. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  28138. /** @hidden */
  28139. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  28140. /**
  28141. * Unbind the current render target texture from the webGL context
  28142. * @param texture defines the render target texture to unbind
  28143. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28144. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28145. */
  28146. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28147. /**
  28148. * Force the mipmap generation for the given render target texture
  28149. * @param texture defines the render target texture to use
  28150. */
  28151. generateMipMapsForCubemap(texture: InternalTexture): void;
  28152. /**
  28153. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  28154. */
  28155. flushFramebuffer(): void;
  28156. /**
  28157. * Unbind the current render target and bind the default framebuffer
  28158. */
  28159. restoreDefaultFramebuffer(): void;
  28160. /**
  28161. * Create an uniform buffer
  28162. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28163. * @param elements defines the content of the uniform buffer
  28164. * @returns the webGL uniform buffer
  28165. */
  28166. createUniformBuffer(elements: FloatArray): DataBuffer;
  28167. /**
  28168. * Create a dynamic uniform buffer
  28169. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28170. * @param elements defines the content of the uniform buffer
  28171. * @returns the webGL uniform buffer
  28172. */
  28173. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  28174. /**
  28175. * Update an existing uniform buffer
  28176. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28177. * @param uniformBuffer defines the target uniform buffer
  28178. * @param elements defines the content to update
  28179. * @param offset defines the offset in the uniform buffer where update should start
  28180. * @param count defines the size of the data to update
  28181. */
  28182. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  28183. private _resetVertexBufferBinding;
  28184. /**
  28185. * Creates a vertex buffer
  28186. * @param data the data for the vertex buffer
  28187. * @returns the new WebGL static buffer
  28188. */
  28189. createVertexBuffer(data: DataArray): DataBuffer;
  28190. /**
  28191. * Creates a dynamic vertex buffer
  28192. * @param data the data for the dynamic vertex buffer
  28193. * @returns the new WebGL dynamic buffer
  28194. */
  28195. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  28196. /**
  28197. * Update a dynamic index buffer
  28198. * @param indexBuffer defines the target index buffer
  28199. * @param indices defines the data to update
  28200. * @param offset defines the offset in the target index buffer where update should start
  28201. */
  28202. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  28203. /**
  28204. * Updates a dynamic vertex buffer.
  28205. * @param vertexBuffer the vertex buffer to update
  28206. * @param data the data used to update the vertex buffer
  28207. * @param byteOffset the byte offset of the data
  28208. * @param byteLength the byte length of the data
  28209. */
  28210. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  28211. private _resetIndexBufferBinding;
  28212. /**
  28213. * Creates a new index buffer
  28214. * @param indices defines the content of the index buffer
  28215. * @param updatable defines if the index buffer must be updatable
  28216. * @returns a new webGL buffer
  28217. */
  28218. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  28219. /**
  28220. * Bind a webGL buffer to the webGL context
  28221. * @param buffer defines the buffer to bind
  28222. */
  28223. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  28224. /**
  28225. * Bind an uniform buffer to the current webGL context
  28226. * @param buffer defines the buffer to bind
  28227. */
  28228. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  28229. /**
  28230. * Bind a buffer to the current webGL context at a given location
  28231. * @param buffer defines the buffer to bind
  28232. * @param location defines the index where to bind the buffer
  28233. */
  28234. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  28235. /**
  28236. * Bind a specific block at a given index in a specific shader program
  28237. * @param pipelineContext defines the pipeline context to use
  28238. * @param blockName defines the block name
  28239. * @param index defines the index where to bind the block
  28240. */
  28241. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  28242. private bindIndexBuffer;
  28243. private bindBuffer;
  28244. /**
  28245. * update the bound buffer with the given data
  28246. * @param data defines the data to update
  28247. */
  28248. updateArrayBuffer(data: Float32Array): void;
  28249. private _vertexAttribPointer;
  28250. private _bindIndexBufferWithCache;
  28251. private _bindVertexBuffersAttributes;
  28252. /**
  28253. * Records a vertex array object
  28254. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28255. * @param vertexBuffers defines the list of vertex buffers to store
  28256. * @param indexBuffer defines the index buffer to store
  28257. * @param effect defines the effect to store
  28258. * @returns the new vertex array object
  28259. */
  28260. recordVertexArrayObject(vertexBuffers: {
  28261. [key: string]: VertexBuffer;
  28262. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  28263. /**
  28264. * Bind a specific vertex array object
  28265. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28266. * @param vertexArrayObject defines the vertex array object to bind
  28267. * @param indexBuffer defines the index buffer to bind
  28268. */
  28269. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  28270. /**
  28271. * Bind webGl buffers directly to the webGL context
  28272. * @param vertexBuffer defines the vertex buffer to bind
  28273. * @param indexBuffer defines the index buffer to bind
  28274. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28275. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28276. * @param effect defines the effect associated with the vertex buffer
  28277. */
  28278. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28279. private _unbindVertexArrayObject;
  28280. /**
  28281. * Bind a list of vertex buffers to the webGL context
  28282. * @param vertexBuffers defines the list of vertex buffers to bind
  28283. * @param indexBuffer defines the index buffer to bind
  28284. * @param effect defines the effect associated with the vertex buffers
  28285. */
  28286. bindBuffers(vertexBuffers: {
  28287. [key: string]: Nullable<VertexBuffer>;
  28288. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  28289. /**
  28290. * Unbind all instance attributes
  28291. */
  28292. unbindInstanceAttributes(): void;
  28293. /**
  28294. * Release and free the memory of a vertex array object
  28295. * @param vao defines the vertex array object to delete
  28296. */
  28297. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28298. /** @hidden */
  28299. _releaseBuffer(buffer: DataBuffer): boolean;
  28300. /**
  28301. * Creates a webGL buffer to use with instanciation
  28302. * @param capacity defines the size of the buffer
  28303. * @returns the webGL buffer
  28304. */
  28305. createInstancesBuffer(capacity: number): DataBuffer;
  28306. /**
  28307. * Delete a webGL buffer used with instanciation
  28308. * @param buffer defines the webGL buffer to delete
  28309. */
  28310. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  28311. /**
  28312. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28313. * @param instancesBuffer defines the webGL buffer to update and bind
  28314. * @param data defines the data to store in the buffer
  28315. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28316. */
  28317. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  28318. /**
  28319. * Apply all cached states (depth, culling, stencil and alpha)
  28320. */
  28321. applyStates(): void;
  28322. /**
  28323. * Send a draw order
  28324. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28325. * @param indexStart defines the starting index
  28326. * @param indexCount defines the number of index to draw
  28327. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28328. */
  28329. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  28330. /**
  28331. * Draw a list of points
  28332. * @param verticesStart defines the index of first vertex to draw
  28333. * @param verticesCount defines the count of vertices to draw
  28334. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28335. */
  28336. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28337. /**
  28338. * Draw a list of unindexed primitives
  28339. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28340. * @param verticesStart defines the index of first vertex to draw
  28341. * @param verticesCount defines the count of vertices to draw
  28342. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28343. */
  28344. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28345. /**
  28346. * Draw a list of indexed primitives
  28347. * @param fillMode defines the primitive to use
  28348. * @param indexStart defines the starting index
  28349. * @param indexCount defines the number of index to draw
  28350. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28351. */
  28352. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  28353. /**
  28354. * Draw a list of unindexed primitives
  28355. * @param fillMode defines the primitive to use
  28356. * @param verticesStart defines the index of first vertex to draw
  28357. * @param verticesCount defines the count of vertices to draw
  28358. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28359. */
  28360. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28361. private _drawMode;
  28362. /** @hidden */
  28363. _releaseEffect(effect: Effect): void;
  28364. /** @hidden */
  28365. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  28366. /**
  28367. * Create a new effect (used to store vertex/fragment shaders)
  28368. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28369. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  28370. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  28371. * @param samplers defines an array of string used to represent textures
  28372. * @param defines defines the string containing the defines to use to compile the shaders
  28373. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28374. * @param onCompiled defines a function to call when the effect creation is successful
  28375. * @param onError defines a function to call when the effect creation has failed
  28376. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28377. * @returns the new Effect
  28378. */
  28379. 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;
  28380. private _compileShader;
  28381. private _compileRawShader;
  28382. /**
  28383. * Directly creates a webGL program
  28384. * @param pipelineContext defines the pipeline context to attach to
  28385. * @param vertexCode defines the vertex shader code to use
  28386. * @param fragmentCode defines the fragment shader code to use
  28387. * @param context defines the webGL context to use (if not set, the current one will be used)
  28388. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28389. * @returns the new webGL program
  28390. */
  28391. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28392. /**
  28393. * Creates a webGL program
  28394. * @param pipelineContext defines the pipeline context to attach to
  28395. * @param vertexCode defines the vertex shader code to use
  28396. * @param fragmentCode defines the fragment shader code to use
  28397. * @param defines defines the string containing the defines to use to compile the shaders
  28398. * @param context defines the webGL context to use (if not set, the current one will be used)
  28399. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28400. * @returns the new webGL program
  28401. */
  28402. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28403. /**
  28404. * Creates a new pipeline context
  28405. * @returns the new pipeline
  28406. */
  28407. createPipelineContext(): WebGLPipelineContext;
  28408. private _createShaderProgram;
  28409. private _finalizePipelineContext;
  28410. /** @hidden */
  28411. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  28412. /** @hidden */
  28413. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  28414. /** @hidden */
  28415. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  28416. /**
  28417. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28418. * @param pipelineContext defines the pipeline context to use
  28419. * @param uniformsNames defines the list of uniform names
  28420. * @returns an array of webGL uniform locations
  28421. */
  28422. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28423. /**
  28424. * Gets the lsit of active attributes for a given webGL program
  28425. * @param pipelineContext defines the pipeline context to use
  28426. * @param attributesNames defines the list of attribute names to get
  28427. * @returns an array of indices indicating the offset of each attribute
  28428. */
  28429. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  28430. /**
  28431. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28432. * @param effect defines the effect to activate
  28433. */
  28434. enableEffect(effect: Nullable<Effect>): void;
  28435. /**
  28436. * Set the value of an uniform to an array of int32
  28437. * @param uniform defines the webGL uniform location where to store the value
  28438. * @param array defines the array of int32 to store
  28439. */
  28440. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28441. /**
  28442. * Set the value of an uniform to an array of int32 (stored as vec2)
  28443. * @param uniform defines the webGL uniform location where to store the value
  28444. * @param array defines the array of int32 to store
  28445. */
  28446. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28447. /**
  28448. * Set the value of an uniform to an array of int32 (stored as vec3)
  28449. * @param uniform defines the webGL uniform location where to store the value
  28450. * @param array defines the array of int32 to store
  28451. */
  28452. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28453. /**
  28454. * Set the value of an uniform to an array of int32 (stored as vec4)
  28455. * @param uniform defines the webGL uniform location where to store the value
  28456. * @param array defines the array of int32 to store
  28457. */
  28458. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28459. /**
  28460. * Set the value of an uniform to an array of float32
  28461. * @param uniform defines the webGL uniform location where to store the value
  28462. * @param array defines the array of float32 to store
  28463. */
  28464. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28465. /**
  28466. * Set the value of an uniform to an array of float32 (stored as vec2)
  28467. * @param uniform defines the webGL uniform location where to store the value
  28468. * @param array defines the array of float32 to store
  28469. */
  28470. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28471. /**
  28472. * Set the value of an uniform to an array of float32 (stored as vec3)
  28473. * @param uniform defines the webGL uniform location where to store the value
  28474. * @param array defines the array of float32 to store
  28475. */
  28476. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28477. /**
  28478. * Set the value of an uniform to an array of float32 (stored as vec4)
  28479. * @param uniform defines the webGL uniform location where to store the value
  28480. * @param array defines the array of float32 to store
  28481. */
  28482. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28483. /**
  28484. * Set the value of an uniform to an array of number
  28485. * @param uniform defines the webGL uniform location where to store the value
  28486. * @param array defines the array of number to store
  28487. */
  28488. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28489. /**
  28490. * Set the value of an uniform to an array of number (stored as vec2)
  28491. * @param uniform defines the webGL uniform location where to store the value
  28492. * @param array defines the array of number to store
  28493. */
  28494. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28495. /**
  28496. * Set the value of an uniform to an array of number (stored as vec3)
  28497. * @param uniform defines the webGL uniform location where to store the value
  28498. * @param array defines the array of number to store
  28499. */
  28500. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28501. /**
  28502. * Set the value of an uniform to an array of number (stored as vec4)
  28503. * @param uniform defines the webGL uniform location where to store the value
  28504. * @param array defines the array of number to store
  28505. */
  28506. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28507. /**
  28508. * Set the value of an uniform to an array of float32 (stored as matrices)
  28509. * @param uniform defines the webGL uniform location where to store the value
  28510. * @param matrices defines the array of float32 to store
  28511. */
  28512. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28513. /**
  28514. * Set the value of an uniform to a matrix
  28515. * @param uniform defines the webGL uniform location where to store the value
  28516. * @param matrix defines the matrix to store
  28517. */
  28518. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28519. /**
  28520. * Set the value of an uniform to a matrix (3x3)
  28521. * @param uniform defines the webGL uniform location where to store the value
  28522. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28523. */
  28524. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28525. /**
  28526. * Set the value of an uniform to a matrix (2x2)
  28527. * @param uniform defines the webGL uniform location where to store the value
  28528. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28529. */
  28530. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28531. /**
  28532. * Set the value of an uniform to a number (int)
  28533. * @param uniform defines the webGL uniform location where to store the value
  28534. * @param value defines the int number to store
  28535. */
  28536. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28537. /**
  28538. * Set the value of an uniform to a number (float)
  28539. * @param uniform defines the webGL uniform location where to store the value
  28540. * @param value defines the float number to store
  28541. */
  28542. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28543. /**
  28544. * Set the value of an uniform to a vec2
  28545. * @param uniform defines the webGL uniform location where to store the value
  28546. * @param x defines the 1st component of the value
  28547. * @param y defines the 2nd component of the value
  28548. */
  28549. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28550. /**
  28551. * Set the value of an uniform to a vec3
  28552. * @param uniform defines the webGL uniform location where to store the value
  28553. * @param x defines the 1st component of the value
  28554. * @param y defines the 2nd component of the value
  28555. * @param z defines the 3rd component of the value
  28556. */
  28557. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28558. /**
  28559. * Set the value of an uniform to a boolean
  28560. * @param uniform defines the webGL uniform location where to store the value
  28561. * @param bool defines the boolean to store
  28562. */
  28563. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28564. /**
  28565. * Set the value of an uniform to a vec4
  28566. * @param uniform defines the webGL uniform location where to store the value
  28567. * @param x defines the 1st component of the value
  28568. * @param y defines the 2nd component of the value
  28569. * @param z defines the 3rd component of the value
  28570. * @param w defines the 4th component of the value
  28571. */
  28572. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28573. /**
  28574. * Set the value of an uniform to a Color3
  28575. * @param uniform defines the webGL uniform location where to store the value
  28576. * @param color3 defines the color to store
  28577. */
  28578. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28579. /**
  28580. * Set the value of an uniform to a Color3 and an alpha value
  28581. * @param uniform defines the webGL uniform location where to store the value
  28582. * @param color3 defines the color to store
  28583. * @param alpha defines the alpha component to store
  28584. */
  28585. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28586. /**
  28587. * Sets a Color4 on a uniform variable
  28588. * @param uniform defines the uniform location
  28589. * @param color4 defines the value to be set
  28590. */
  28591. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28592. /**
  28593. * Set various states to the webGL context
  28594. * @param culling defines backface culling state
  28595. * @param zOffset defines the value to apply to zOffset (0 by default)
  28596. * @param force defines if states must be applied even if cache is up to date
  28597. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28598. */
  28599. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28600. /**
  28601. * Set the z offset to apply to current rendering
  28602. * @param value defines the offset to apply
  28603. */
  28604. setZOffset(value: number): void;
  28605. /**
  28606. * Gets the current value of the zOffset
  28607. * @returns the current zOffset state
  28608. */
  28609. getZOffset(): number;
  28610. /**
  28611. * Enable or disable depth buffering
  28612. * @param enable defines the state to set
  28613. */
  28614. setDepthBuffer(enable: boolean): void;
  28615. /**
  28616. * Gets a boolean indicating if depth writing is enabled
  28617. * @returns the current depth writing state
  28618. */
  28619. getDepthWrite(): boolean;
  28620. /**
  28621. * Enable or disable depth writing
  28622. * @param enable defines the state to set
  28623. */
  28624. setDepthWrite(enable: boolean): void;
  28625. /**
  28626. * Enable or disable color writing
  28627. * @param enable defines the state to set
  28628. */
  28629. setColorWrite(enable: boolean): void;
  28630. /**
  28631. * Gets a boolean indicating if color writing is enabled
  28632. * @returns the current color writing state
  28633. */
  28634. getColorWrite(): boolean;
  28635. /**
  28636. * Sets alpha constants used by some alpha blending modes
  28637. * @param r defines the red component
  28638. * @param g defines the green component
  28639. * @param b defines the blue component
  28640. * @param a defines the alpha component
  28641. */
  28642. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28643. /**
  28644. * Sets the current alpha mode
  28645. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28646. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28647. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28648. */
  28649. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28650. /**
  28651. * Gets the current alpha mode
  28652. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28653. * @returns the current alpha mode
  28654. */
  28655. getAlphaMode(): number;
  28656. /**
  28657. * Clears the list of texture accessible through engine.
  28658. * This can help preventing texture load conflict due to name collision.
  28659. */
  28660. clearInternalTexturesCache(): void;
  28661. /**
  28662. * Force the entire cache to be cleared
  28663. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28664. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28665. */
  28666. wipeCaches(bruteForce?: boolean): void;
  28667. /**
  28668. * Set the compressed texture format to use, based on the formats you have, and the formats
  28669. * supported by the hardware / browser.
  28670. *
  28671. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28672. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28673. * to API arguments needed to compressed textures. This puts the burden on the container
  28674. * generator to house the arcane code for determining these for current & future formats.
  28675. *
  28676. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28677. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28678. *
  28679. * Note: The result of this call is not taken into account when a texture is base64.
  28680. *
  28681. * @param formatsAvailable defines the list of those format families you have created
  28682. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28683. *
  28684. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28685. * @returns The extension selected.
  28686. */
  28687. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28688. /** @hidden */
  28689. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  28690. min: number;
  28691. mag: number;
  28692. };
  28693. /** @hidden */
  28694. _createTexture(): WebGLTexture;
  28695. /**
  28696. * Usually called from Texture.ts.
  28697. * Passed information to create a WebGLTexture
  28698. * @param urlArg defines a value which contains one of the following:
  28699. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  28700. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  28701. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  28702. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  28703. * @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)
  28704. * @param scene needed for loading to the correct scene
  28705. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  28706. * @param onLoad optional callback to be called upon successful completion
  28707. * @param onError optional callback to be called upon failure
  28708. * @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
  28709. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  28710. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  28711. * @param forcedExtension defines the extension to use to pick the right loader
  28712. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  28713. * @returns a InternalTexture for assignment back into BABYLON.Texture
  28714. */
  28715. 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 | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  28716. private _rescaleTexture;
  28717. private _unpackFlipYCached;
  28718. /**
  28719. * In case you are sharing the context with other applications, it might
  28720. * be interested to not cache the unpack flip y state to ensure a consistent
  28721. * value would be set.
  28722. */
  28723. enableUnpackFlipYCached: boolean;
  28724. /** @hidden */
  28725. _unpackFlipY(value: boolean): void;
  28726. /** @hidden */
  28727. _getUnpackAlignement(): number;
  28728. /**
  28729. * Creates a dynamic texture
  28730. * @param width defines the width of the texture
  28731. * @param height defines the height of the texture
  28732. * @param generateMipMaps defines if the engine should generate the mip levels
  28733. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28734. * @returns the dynamic texture inside an InternalTexture
  28735. */
  28736. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  28737. /**
  28738. * Update the sampling mode of a given texture
  28739. * @param samplingMode defines the required sampling mode
  28740. * @param texture defines the texture to update
  28741. */
  28742. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  28743. /**
  28744. * Update the content of a dynamic texture
  28745. * @param texture defines the texture to update
  28746. * @param canvas defines the canvas containing the source
  28747. * @param invertY defines if data must be stored with Y axis inverted
  28748. * @param premulAlpha defines if alpha is stored as premultiplied
  28749. * @param format defines the format of the data
  28750. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  28751. */
  28752. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  28753. /**
  28754. * Update a video texture
  28755. * @param texture defines the texture to update
  28756. * @param video defines the video element to use
  28757. * @param invertY defines if data must be stored with Y axis inverted
  28758. */
  28759. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28760. /**
  28761. * Updates a depth texture Comparison Mode and Function.
  28762. * If the comparison Function is equal to 0, the mode will be set to none.
  28763. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  28764. * @param texture The texture to set the comparison function for
  28765. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  28766. */
  28767. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  28768. /** @hidden */
  28769. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  28770. width: number;
  28771. height: number;
  28772. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  28773. /**
  28774. * Creates a depth stencil texture.
  28775. * This is only available in WebGL 2 or with the depth texture extension available.
  28776. * @param size The size of face edge in the texture.
  28777. * @param options The options defining the texture.
  28778. * @returns The texture
  28779. */
  28780. createDepthStencilTexture(size: number | {
  28781. width: number;
  28782. height: number;
  28783. }, options: DepthTextureCreationOptions): InternalTexture;
  28784. /**
  28785. * Creates a depth stencil texture.
  28786. * This is only available in WebGL 2 or with the depth texture extension available.
  28787. * @param size The size of face edge in the texture.
  28788. * @param options The options defining the texture.
  28789. * @returns The texture
  28790. */
  28791. private _createDepthStencilTexture;
  28792. /**
  28793. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  28794. * @param renderTarget The render target to set the frame buffer for
  28795. */
  28796. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  28797. /**
  28798. * Creates a new render target texture
  28799. * @param size defines the size of the texture
  28800. * @param options defines the options used to create the texture
  28801. * @returns a new render target texture stored in an InternalTexture
  28802. */
  28803. createRenderTargetTexture(size: number | {
  28804. width: number;
  28805. height: number;
  28806. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  28807. /** @hidden */
  28808. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  28809. /**
  28810. * Updates the sample count of a render target texture
  28811. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28812. * @param texture defines the texture to update
  28813. * @param samples defines the sample count to set
  28814. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28815. */
  28816. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  28817. /** @hidden */
  28818. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28819. /** @hidden */
  28820. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28821. /** @hidden */
  28822. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28823. /** @hidden */
  28824. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  28825. /**
  28826. * @hidden
  28827. */
  28828. _setCubeMapTextureParams(loadMipmap: boolean): void;
  28829. private _prepareWebGLTextureContinuation;
  28830. private _prepareWebGLTexture;
  28831. /** @hidden */
  28832. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  28833. /** @hidden */
  28834. _releaseFramebufferObjects(texture: InternalTexture): void;
  28835. /** @hidden */
  28836. _releaseTexture(texture: InternalTexture): void;
  28837. private setProgram;
  28838. private _boundUniforms;
  28839. /**
  28840. * Binds an effect to the webGL context
  28841. * @param effect defines the effect to bind
  28842. */
  28843. bindSamplers(effect: Effect): void;
  28844. private _activateCurrentTexture;
  28845. /** @hidden */
  28846. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  28847. /** @hidden */
  28848. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  28849. /**
  28850. * Sets a texture to the webGL context from a postprocess
  28851. * @param channel defines the channel to use
  28852. * @param postProcess defines the source postprocess
  28853. */
  28854. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  28855. /**
  28856. * Binds the output of the passed in post process to the texture channel specified
  28857. * @param channel The channel the texture should be bound to
  28858. * @param postProcess The post process which's output should be bound
  28859. */
  28860. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  28861. /**
  28862. * Unbind all textures from the webGL context
  28863. */
  28864. unbindAllTextures(): void;
  28865. /**
  28866. * Sets a texture to the according uniform.
  28867. * @param channel The texture channel
  28868. * @param uniform The uniform to set
  28869. * @param texture The texture to apply
  28870. */
  28871. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  28872. /**
  28873. * Sets a depth stencil texture from a render target to the according uniform.
  28874. * @param channel The texture channel
  28875. * @param uniform The uniform to set
  28876. * @param texture The render target texture containing the depth stencil texture to apply
  28877. */
  28878. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  28879. private _bindSamplerUniformToChannel;
  28880. private _getTextureWrapMode;
  28881. private _setTexture;
  28882. /**
  28883. * Sets an array of texture to the webGL context
  28884. * @param channel defines the channel where the texture array must be set
  28885. * @param uniform defines the associated uniform location
  28886. * @param textures defines the array of textures to bind
  28887. */
  28888. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  28889. /** @hidden */
  28890. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  28891. private _setTextureParameterFloat;
  28892. private _setTextureParameterInteger;
  28893. /**
  28894. * Reads pixels from the current frame buffer. Please note that this function can be slow
  28895. * @param x defines the x coordinate of the rectangle where pixels must be read
  28896. * @param y defines the y coordinate of the rectangle where pixels must be read
  28897. * @param width defines the width of the rectangle where pixels must be read
  28898. * @param height defines the height of the rectangle where pixels must be read
  28899. * @returns a Uint8Array containing RGBA colors
  28900. */
  28901. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  28902. /**
  28903. * Add an externaly attached data from its key.
  28904. * This method call will fail and return false, if such key already exists.
  28905. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  28906. * @param key the unique key that identifies the data
  28907. * @param data the data object to associate to the key for this Engine instance
  28908. * @return true if no such key were already present and the data was added successfully, false otherwise
  28909. */
  28910. addExternalData<T>(key: string, data: T): boolean;
  28911. /**
  28912. * Get an externaly attached data from its key
  28913. * @param key the unique key that identifies the data
  28914. * @return the associated data, if present (can be null), or undefined if not present
  28915. */
  28916. getExternalData<T>(key: string): T;
  28917. /**
  28918. * Get an externaly attached data from its key, create it using a factory if it's not already present
  28919. * @param key the unique key that identifies the data
  28920. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  28921. * @return the associated data, can be null if the factory returned null.
  28922. */
  28923. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  28924. /**
  28925. * Remove an externaly attached data from the Engine instance
  28926. * @param key the unique key that identifies the data
  28927. * @return true if the data was successfully removed, false if it doesn't exist
  28928. */
  28929. removeExternalData(key: string): boolean;
  28930. /**
  28931. * Unbind all vertex attributes from the webGL context
  28932. */
  28933. unbindAllAttributes(): void;
  28934. /**
  28935. * 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
  28936. */
  28937. releaseEffects(): void;
  28938. /**
  28939. * Dispose and release all associated resources
  28940. */
  28941. dispose(): void;
  28942. /**
  28943. * Display the loading screen
  28944. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28945. */
  28946. displayLoadingUI(): void;
  28947. /**
  28948. * Hide the loading screen
  28949. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28950. */
  28951. hideLoadingUI(): void;
  28952. /**
  28953. * Gets the current loading screen object
  28954. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28955. */
  28956. /**
  28957. * Sets the current loading screen object
  28958. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28959. */
  28960. loadingScreen: ILoadingScreen;
  28961. /**
  28962. * Sets the current loading screen text
  28963. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28964. */
  28965. loadingUIText: string;
  28966. /**
  28967. * Sets the current loading screen background color
  28968. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28969. */
  28970. loadingUIBackgroundColor: string;
  28971. /**
  28972. * Attach a new callback raised when context lost event is fired
  28973. * @param callback defines the callback to call
  28974. */
  28975. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28976. /**
  28977. * Attach a new callback raised when context restored event is fired
  28978. * @param callback defines the callback to call
  28979. */
  28980. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28981. /**
  28982. * Gets the source code of the vertex shader associated with a specific webGL program
  28983. * @param program defines the program to use
  28984. * @returns a string containing the source code of the vertex shader associated with the program
  28985. */
  28986. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  28987. /**
  28988. * Gets the source code of the fragment shader associated with a specific webGL program
  28989. * @param program defines the program to use
  28990. * @returns a string containing the source code of the fragment shader associated with the program
  28991. */
  28992. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  28993. /**
  28994. * Get the current error code of the webGL context
  28995. * @returns the error code
  28996. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  28997. */
  28998. getError(): number;
  28999. /**
  29000. * Gets the current framerate
  29001. * @returns a number representing the framerate
  29002. */
  29003. getFps(): number;
  29004. /**
  29005. * Gets the time spent between current and previous frame
  29006. * @returns a number representing the delta time in ms
  29007. */
  29008. getDeltaTime(): number;
  29009. private _measureFps;
  29010. /** @hidden */
  29011. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  29012. private _canRenderToFloatFramebuffer;
  29013. private _canRenderToHalfFloatFramebuffer;
  29014. private _canRenderToFramebuffer;
  29015. /** @hidden */
  29016. _getWebGLTextureType(type: number): number;
  29017. /** @hidden */
  29018. _getInternalFormat(format: number): number;
  29019. /** @hidden */
  29020. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  29021. /** @hidden */
  29022. _getRGBAMultiSampleBufferFormat(type: number): number;
  29023. /** @hidden */
  29024. _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;
  29025. /** @hidden */
  29026. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  29027. /**
  29028. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29029. * @returns true if the engine can be created
  29030. * @ignorenaming
  29031. */
  29032. static isSupported(): boolean;
  29033. }
  29034. }
  29035. declare module BABYLON {
  29036. /**
  29037. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  29038. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  29039. */
  29040. export class EffectFallbacks {
  29041. private _defines;
  29042. private _currentRank;
  29043. private _maxRank;
  29044. private _mesh;
  29045. /**
  29046. * Removes the fallback from the bound mesh.
  29047. */
  29048. unBindMesh(): void;
  29049. /**
  29050. * Adds a fallback on the specified property.
  29051. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29052. * @param define The name of the define in the shader
  29053. */
  29054. addFallback(rank: number, define: string): void;
  29055. /**
  29056. * Sets the mesh to use CPU skinning when needing to fallback.
  29057. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29058. * @param mesh The mesh to use the fallbacks.
  29059. */
  29060. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29061. /**
  29062. * Checks to see if more fallbacks are still availible.
  29063. */
  29064. readonly isMoreFallbacks: boolean;
  29065. /**
  29066. * Removes the defines that shoould be removed when falling back.
  29067. * @param currentDefines defines the current define statements for the shader.
  29068. * @param effect defines the current effect we try to compile
  29069. * @returns The resulting defines with defines of the current rank removed.
  29070. */
  29071. reduce(currentDefines: string, effect: Effect): string;
  29072. }
  29073. /**
  29074. * Options to be used when creating an effect.
  29075. */
  29076. export class EffectCreationOptions {
  29077. /**
  29078. * Atrributes that will be used in the shader.
  29079. */
  29080. attributes: string[];
  29081. /**
  29082. * Uniform varible names that will be set in the shader.
  29083. */
  29084. uniformsNames: string[];
  29085. /**
  29086. * Uniform buffer varible names that will be set in the shader.
  29087. */
  29088. uniformBuffersNames: string[];
  29089. /**
  29090. * Sampler texture variable names that will be set in the shader.
  29091. */
  29092. samplers: string[];
  29093. /**
  29094. * Define statements that will be set in the shader.
  29095. */
  29096. defines: any;
  29097. /**
  29098. * Possible fallbacks for this effect to improve performance when needed.
  29099. */
  29100. fallbacks: Nullable<EffectFallbacks>;
  29101. /**
  29102. * Callback that will be called when the shader is compiled.
  29103. */
  29104. onCompiled: Nullable<(effect: Effect) => void>;
  29105. /**
  29106. * Callback that will be called if an error occurs during shader compilation.
  29107. */
  29108. onError: Nullable<(effect: Effect, errors: string) => void>;
  29109. /**
  29110. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29111. */
  29112. indexParameters: any;
  29113. /**
  29114. * Max number of lights that can be used in the shader.
  29115. */
  29116. maxSimultaneousLights: number;
  29117. /**
  29118. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29119. */
  29120. transformFeedbackVaryings: Nullable<string[]>;
  29121. }
  29122. /**
  29123. * Effect containing vertex and fragment shader that can be executed on an object.
  29124. */
  29125. export class Effect implements IDisposable {
  29126. /**
  29127. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29128. */
  29129. static ShadersRepository: string;
  29130. /**
  29131. * Name of the effect.
  29132. */
  29133. name: any;
  29134. /**
  29135. * String container all the define statements that should be set on the shader.
  29136. */
  29137. defines: string;
  29138. /**
  29139. * Callback that will be called when the shader is compiled.
  29140. */
  29141. onCompiled: Nullable<(effect: Effect) => void>;
  29142. /**
  29143. * Callback that will be called if an error occurs during shader compilation.
  29144. */
  29145. onError: Nullable<(effect: Effect, errors: string) => void>;
  29146. /**
  29147. * Callback that will be called when effect is bound.
  29148. */
  29149. onBind: Nullable<(effect: Effect) => void>;
  29150. /**
  29151. * Unique ID of the effect.
  29152. */
  29153. uniqueId: number;
  29154. /**
  29155. * Observable that will be called when the shader is compiled.
  29156. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29157. */
  29158. onCompileObservable: Observable<Effect>;
  29159. /**
  29160. * Observable that will be called if an error occurs during shader compilation.
  29161. */
  29162. onErrorObservable: Observable<Effect>;
  29163. /** @hidden */
  29164. _onBindObservable: Nullable<Observable<Effect>>;
  29165. /**
  29166. * Observable that will be called when effect is bound.
  29167. */
  29168. readonly onBindObservable: Observable<Effect>;
  29169. /** @hidden */
  29170. _bonesComputationForcedToCPU: boolean;
  29171. private static _uniqueIdSeed;
  29172. private _engine;
  29173. private _uniformBuffersNames;
  29174. private _uniformsNames;
  29175. private _samplerList;
  29176. private _samplers;
  29177. private _isReady;
  29178. private _compilationError;
  29179. private _attributesNames;
  29180. private _attributes;
  29181. private _uniforms;
  29182. /**
  29183. * Key for the effect.
  29184. * @hidden
  29185. */
  29186. _key: string;
  29187. private _indexParameters;
  29188. private _fallbacks;
  29189. private _vertexSourceCode;
  29190. private _fragmentSourceCode;
  29191. private _vertexSourceCodeOverride;
  29192. private _fragmentSourceCodeOverride;
  29193. private _transformFeedbackVaryings;
  29194. /**
  29195. * Compiled shader to webGL program.
  29196. * @hidden
  29197. */
  29198. _pipelineContext: Nullable<IPipelineContext>;
  29199. private _valueCache;
  29200. private static _baseCache;
  29201. /**
  29202. * Instantiates an effect.
  29203. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29204. * @param baseName Name of the effect.
  29205. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29206. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29207. * @param samplers List of sampler variables that will be passed to the shader.
  29208. * @param engine Engine to be used to render the effect
  29209. * @param defines Define statements to be added to the shader.
  29210. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29211. * @param onCompiled Callback that will be called when the shader is compiled.
  29212. * @param onError Callback that will be called if an error occurs during shader compilation.
  29213. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29214. */
  29215. 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);
  29216. /**
  29217. * Unique key for this effect
  29218. */
  29219. readonly key: string;
  29220. /**
  29221. * If the effect has been compiled and prepared.
  29222. * @returns if the effect is compiled and prepared.
  29223. */
  29224. isReady(): boolean;
  29225. /**
  29226. * The engine the effect was initialized with.
  29227. * @returns the engine.
  29228. */
  29229. getEngine(): Engine;
  29230. /**
  29231. * The pipeline context for this effect
  29232. * @returns the associated pipeline context
  29233. */
  29234. getPipelineContext(): Nullable<IPipelineContext>;
  29235. /**
  29236. * The set of names of attribute variables for the shader.
  29237. * @returns An array of attribute names.
  29238. */
  29239. getAttributesNames(): string[];
  29240. /**
  29241. * Returns the attribute at the given index.
  29242. * @param index The index of the attribute.
  29243. * @returns The location of the attribute.
  29244. */
  29245. getAttributeLocation(index: number): number;
  29246. /**
  29247. * Returns the attribute based on the name of the variable.
  29248. * @param name of the attribute to look up.
  29249. * @returns the attribute location.
  29250. */
  29251. getAttributeLocationByName(name: string): number;
  29252. /**
  29253. * The number of attributes.
  29254. * @returns the numnber of attributes.
  29255. */
  29256. getAttributesCount(): number;
  29257. /**
  29258. * Gets the index of a uniform variable.
  29259. * @param uniformName of the uniform to look up.
  29260. * @returns the index.
  29261. */
  29262. getUniformIndex(uniformName: string): number;
  29263. /**
  29264. * Returns the attribute based on the name of the variable.
  29265. * @param uniformName of the uniform to look up.
  29266. * @returns the location of the uniform.
  29267. */
  29268. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29269. /**
  29270. * Returns an array of sampler variable names
  29271. * @returns The array of sampler variable neames.
  29272. */
  29273. getSamplers(): string[];
  29274. /**
  29275. * The error from the last compilation.
  29276. * @returns the error string.
  29277. */
  29278. getCompilationError(): string;
  29279. /**
  29280. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29281. * @param func The callback to be used.
  29282. */
  29283. executeWhenCompiled(func: (effect: Effect) => void): void;
  29284. private _checkIsReady;
  29285. /** @hidden */
  29286. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29287. /** @hidden */
  29288. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29289. /** @hidden */
  29290. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29291. private _processShaderConversion;
  29292. private _processIncludes;
  29293. private _processPrecision;
  29294. /**
  29295. * Recompiles the webGL program
  29296. * @param vertexSourceCode The source code for the vertex shader.
  29297. * @param fragmentSourceCode The source code for the fragment shader.
  29298. * @param onCompiled Callback called when completed.
  29299. * @param onError Callback called on error.
  29300. * @hidden
  29301. */
  29302. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29303. /**
  29304. * Prepares the effect
  29305. * @hidden
  29306. */
  29307. _prepareEffect(): void;
  29308. /**
  29309. * Checks if the effect is supported. (Must be called after compilation)
  29310. */
  29311. readonly isSupported: boolean;
  29312. /**
  29313. * Binds a texture to the engine to be used as output of the shader.
  29314. * @param channel Name of the output variable.
  29315. * @param texture Texture to bind.
  29316. * @hidden
  29317. */
  29318. _bindTexture(channel: string, texture: InternalTexture): void;
  29319. /**
  29320. * Sets a texture on the engine to be used in the shader.
  29321. * @param channel Name of the sampler variable.
  29322. * @param texture Texture to set.
  29323. */
  29324. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29325. /**
  29326. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29327. * @param channel Name of the sampler variable.
  29328. * @param texture Texture to set.
  29329. */
  29330. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29331. /**
  29332. * Sets an array of textures on the engine to be used in the shader.
  29333. * @param channel Name of the variable.
  29334. * @param textures Textures to set.
  29335. */
  29336. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29337. /**
  29338. * 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)
  29339. * @param channel Name of the sampler variable.
  29340. * @param postProcess Post process to get the input texture from.
  29341. */
  29342. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29343. /**
  29344. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29345. * 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)
  29346. * @param channel Name of the sampler variable.
  29347. * @param postProcess Post process to get the output texture from.
  29348. */
  29349. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29350. /** @hidden */
  29351. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29352. /** @hidden */
  29353. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29354. /** @hidden */
  29355. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29356. /** @hidden */
  29357. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29358. /**
  29359. * Binds a buffer to a uniform.
  29360. * @param buffer Buffer to bind.
  29361. * @param name Name of the uniform variable to bind to.
  29362. */
  29363. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29364. /**
  29365. * Binds block to a uniform.
  29366. * @param blockName Name of the block to bind.
  29367. * @param index Index to bind.
  29368. */
  29369. bindUniformBlock(blockName: string, index: number): void;
  29370. /**
  29371. * Sets an interger value on a uniform variable.
  29372. * @param uniformName Name of the variable.
  29373. * @param value Value to be set.
  29374. * @returns this effect.
  29375. */
  29376. setInt(uniformName: string, value: number): Effect;
  29377. /**
  29378. * Sets an int array on a uniform variable.
  29379. * @param uniformName Name of the variable.
  29380. * @param array array to be set.
  29381. * @returns this effect.
  29382. */
  29383. setIntArray(uniformName: string, array: Int32Array): Effect;
  29384. /**
  29385. * 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)
  29386. * @param uniformName Name of the variable.
  29387. * @param array array to be set.
  29388. * @returns this effect.
  29389. */
  29390. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29391. /**
  29392. * 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)
  29393. * @param uniformName Name of the variable.
  29394. * @param array array to be set.
  29395. * @returns this effect.
  29396. */
  29397. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29398. /**
  29399. * 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)
  29400. * @param uniformName Name of the variable.
  29401. * @param array array to be set.
  29402. * @returns this effect.
  29403. */
  29404. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29405. /**
  29406. * Sets an float array on a uniform variable.
  29407. * @param uniformName Name of the variable.
  29408. * @param array array to be set.
  29409. * @returns this effect.
  29410. */
  29411. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29412. /**
  29413. * 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)
  29414. * @param uniformName Name of the variable.
  29415. * @param array array to be set.
  29416. * @returns this effect.
  29417. */
  29418. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29419. /**
  29420. * 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)
  29421. * @param uniformName Name of the variable.
  29422. * @param array array to be set.
  29423. * @returns this effect.
  29424. */
  29425. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29426. /**
  29427. * 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)
  29428. * @param uniformName Name of the variable.
  29429. * @param array array to be set.
  29430. * @returns this effect.
  29431. */
  29432. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29433. /**
  29434. * Sets an array on a uniform variable.
  29435. * @param uniformName Name of the variable.
  29436. * @param array array to be set.
  29437. * @returns this effect.
  29438. */
  29439. setArray(uniformName: string, array: number[]): Effect;
  29440. /**
  29441. * 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)
  29442. * @param uniformName Name of the variable.
  29443. * @param array array to be set.
  29444. * @returns this effect.
  29445. */
  29446. setArray2(uniformName: string, array: number[]): Effect;
  29447. /**
  29448. * 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)
  29449. * @param uniformName Name of the variable.
  29450. * @param array array to be set.
  29451. * @returns this effect.
  29452. */
  29453. setArray3(uniformName: string, array: number[]): Effect;
  29454. /**
  29455. * 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)
  29456. * @param uniformName Name of the variable.
  29457. * @param array array to be set.
  29458. * @returns this effect.
  29459. */
  29460. setArray4(uniformName: string, array: number[]): Effect;
  29461. /**
  29462. * Sets matrices on a uniform variable.
  29463. * @param uniformName Name of the variable.
  29464. * @param matrices matrices to be set.
  29465. * @returns this effect.
  29466. */
  29467. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29468. /**
  29469. * Sets matrix on a uniform variable.
  29470. * @param uniformName Name of the variable.
  29471. * @param matrix matrix to be set.
  29472. * @returns this effect.
  29473. */
  29474. setMatrix(uniformName: string, matrix: Matrix): Effect;
  29475. /**
  29476. * 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)
  29477. * @param uniformName Name of the variable.
  29478. * @param matrix matrix to be set.
  29479. * @returns this effect.
  29480. */
  29481. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29482. /**
  29483. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29484. * @param uniformName Name of the variable.
  29485. * @param matrix matrix to be set.
  29486. * @returns this effect.
  29487. */
  29488. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29489. /**
  29490. * Sets a float on a uniform variable.
  29491. * @param uniformName Name of the variable.
  29492. * @param value value to be set.
  29493. * @returns this effect.
  29494. */
  29495. setFloat(uniformName: string, value: number): Effect;
  29496. /**
  29497. * Sets a boolean on a uniform variable.
  29498. * @param uniformName Name of the variable.
  29499. * @param bool value to be set.
  29500. * @returns this effect.
  29501. */
  29502. setBool(uniformName: string, bool: boolean): Effect;
  29503. /**
  29504. * Sets a Vector2 on a uniform variable.
  29505. * @param uniformName Name of the variable.
  29506. * @param vector2 vector2 to be set.
  29507. * @returns this effect.
  29508. */
  29509. setVector2(uniformName: string, vector2: Vector2): Effect;
  29510. /**
  29511. * Sets a float2 on a uniform variable.
  29512. * @param uniformName Name of the variable.
  29513. * @param x First float in float2.
  29514. * @param y Second float in float2.
  29515. * @returns this effect.
  29516. */
  29517. setFloat2(uniformName: string, x: number, y: number): Effect;
  29518. /**
  29519. * Sets a Vector3 on a uniform variable.
  29520. * @param uniformName Name of the variable.
  29521. * @param vector3 Value to be set.
  29522. * @returns this effect.
  29523. */
  29524. setVector3(uniformName: string, vector3: Vector3): Effect;
  29525. /**
  29526. * Sets a float3 on a uniform variable.
  29527. * @param uniformName Name of the variable.
  29528. * @param x First float in float3.
  29529. * @param y Second float in float3.
  29530. * @param z Third float in float3.
  29531. * @returns this effect.
  29532. */
  29533. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29534. /**
  29535. * Sets a Vector4 on a uniform variable.
  29536. * @param uniformName Name of the variable.
  29537. * @param vector4 Value to be set.
  29538. * @returns this effect.
  29539. */
  29540. setVector4(uniformName: string, vector4: Vector4): Effect;
  29541. /**
  29542. * Sets a float4 on a uniform variable.
  29543. * @param uniformName Name of the variable.
  29544. * @param x First float in float4.
  29545. * @param y Second float in float4.
  29546. * @param z Third float in float4.
  29547. * @param w Fourth float in float4.
  29548. * @returns this effect.
  29549. */
  29550. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29551. /**
  29552. * Sets a Color3 on a uniform variable.
  29553. * @param uniformName Name of the variable.
  29554. * @param color3 Value to be set.
  29555. * @returns this effect.
  29556. */
  29557. setColor3(uniformName: string, color3: Color3): Effect;
  29558. /**
  29559. * Sets a Color4 on a uniform variable.
  29560. * @param uniformName Name of the variable.
  29561. * @param color3 Value to be set.
  29562. * @param alpha Alpha value to be set.
  29563. * @returns this effect.
  29564. */
  29565. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  29566. /**
  29567. * Sets a Color4 on a uniform variable
  29568. * @param uniformName defines the name of the variable
  29569. * @param color4 defines the value to be set
  29570. * @returns this effect.
  29571. */
  29572. setDirectColor4(uniformName: string, color4: Color4): Effect;
  29573. /** Release all associated resources */
  29574. dispose(): void;
  29575. /**
  29576. * This function will add a new shader to the shader store
  29577. * @param name the name of the shader
  29578. * @param pixelShader optional pixel shader content
  29579. * @param vertexShader optional vertex shader content
  29580. */
  29581. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29582. /**
  29583. * Store of each shader (The can be looked up using effect.key)
  29584. */
  29585. static ShadersStore: {
  29586. [key: string]: string;
  29587. };
  29588. /**
  29589. * Store of each included file for a shader (The can be looked up using effect.key)
  29590. */
  29591. static IncludesShadersStore: {
  29592. [key: string]: string;
  29593. };
  29594. /**
  29595. * Resets the cache of effects.
  29596. */
  29597. static ResetCache(): void;
  29598. }
  29599. }
  29600. declare module BABYLON {
  29601. /**
  29602. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29603. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29604. * 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;
  29605. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29606. */
  29607. export class ColorCurves {
  29608. private _dirty;
  29609. private _tempColor;
  29610. private _globalCurve;
  29611. private _highlightsCurve;
  29612. private _midtonesCurve;
  29613. private _shadowsCurve;
  29614. private _positiveCurve;
  29615. private _negativeCurve;
  29616. private _globalHue;
  29617. private _globalDensity;
  29618. private _globalSaturation;
  29619. private _globalExposure;
  29620. /**
  29621. * Gets the global Hue value.
  29622. * 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).
  29623. */
  29624. /**
  29625. * Sets the global Hue value.
  29626. * 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).
  29627. */
  29628. globalHue: number;
  29629. /**
  29630. * Gets the global Density value.
  29631. * 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.
  29632. * Values less than zero provide a filter of opposite hue.
  29633. */
  29634. /**
  29635. * Sets the global Density value.
  29636. * 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.
  29637. * Values less than zero provide a filter of opposite hue.
  29638. */
  29639. globalDensity: number;
  29640. /**
  29641. * Gets the global Saturation value.
  29642. * 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.
  29643. */
  29644. /**
  29645. * Sets the global Saturation value.
  29646. * 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.
  29647. */
  29648. globalSaturation: number;
  29649. /**
  29650. * Gets the global Exposure value.
  29651. * 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.
  29652. */
  29653. /**
  29654. * Sets the global Exposure value.
  29655. * 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.
  29656. */
  29657. globalExposure: number;
  29658. private _highlightsHue;
  29659. private _highlightsDensity;
  29660. private _highlightsSaturation;
  29661. private _highlightsExposure;
  29662. /**
  29663. * Gets the highlights Hue value.
  29664. * 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).
  29665. */
  29666. /**
  29667. * Sets the highlights Hue value.
  29668. * 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).
  29669. */
  29670. highlightsHue: number;
  29671. /**
  29672. * Gets the highlights Density value.
  29673. * 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.
  29674. * Values less than zero provide a filter of opposite hue.
  29675. */
  29676. /**
  29677. * Sets the highlights Density value.
  29678. * 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.
  29679. * Values less than zero provide a filter of opposite hue.
  29680. */
  29681. highlightsDensity: number;
  29682. /**
  29683. * Gets the highlights Saturation value.
  29684. * 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.
  29685. */
  29686. /**
  29687. * Sets the highlights Saturation value.
  29688. * 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.
  29689. */
  29690. highlightsSaturation: number;
  29691. /**
  29692. * Gets the highlights Exposure value.
  29693. * 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.
  29694. */
  29695. /**
  29696. * Sets the highlights Exposure value.
  29697. * 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.
  29698. */
  29699. highlightsExposure: number;
  29700. private _midtonesHue;
  29701. private _midtonesDensity;
  29702. private _midtonesSaturation;
  29703. private _midtonesExposure;
  29704. /**
  29705. * Gets the midtones Hue value.
  29706. * 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).
  29707. */
  29708. /**
  29709. * Sets the midtones Hue value.
  29710. * 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).
  29711. */
  29712. midtonesHue: number;
  29713. /**
  29714. * Gets the midtones Density value.
  29715. * 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.
  29716. * Values less than zero provide a filter of opposite hue.
  29717. */
  29718. /**
  29719. * Sets the midtones Density value.
  29720. * 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.
  29721. * Values less than zero provide a filter of opposite hue.
  29722. */
  29723. midtonesDensity: number;
  29724. /**
  29725. * Gets the midtones Saturation value.
  29726. * 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.
  29727. */
  29728. /**
  29729. * Sets the midtones Saturation value.
  29730. * 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.
  29731. */
  29732. midtonesSaturation: number;
  29733. /**
  29734. * Gets the midtones Exposure value.
  29735. * 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.
  29736. */
  29737. /**
  29738. * Sets the midtones Exposure value.
  29739. * 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.
  29740. */
  29741. midtonesExposure: number;
  29742. private _shadowsHue;
  29743. private _shadowsDensity;
  29744. private _shadowsSaturation;
  29745. private _shadowsExposure;
  29746. /**
  29747. * Gets the shadows Hue value.
  29748. * 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).
  29749. */
  29750. /**
  29751. * Sets the shadows Hue value.
  29752. * 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).
  29753. */
  29754. shadowsHue: number;
  29755. /**
  29756. * Gets the shadows Density value.
  29757. * 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.
  29758. * Values less than zero provide a filter of opposite hue.
  29759. */
  29760. /**
  29761. * Sets the shadows Density value.
  29762. * 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.
  29763. * Values less than zero provide a filter of opposite hue.
  29764. */
  29765. shadowsDensity: number;
  29766. /**
  29767. * Gets the shadows Saturation value.
  29768. * 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.
  29769. */
  29770. /**
  29771. * Sets the shadows Saturation value.
  29772. * 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.
  29773. */
  29774. shadowsSaturation: number;
  29775. /**
  29776. * Gets the shadows Exposure value.
  29777. * 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.
  29778. */
  29779. /**
  29780. * Sets the shadows Exposure value.
  29781. * 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.
  29782. */
  29783. shadowsExposure: number;
  29784. /**
  29785. * Returns the class name
  29786. * @returns The class name
  29787. */
  29788. getClassName(): string;
  29789. /**
  29790. * Binds the color curves to the shader.
  29791. * @param colorCurves The color curve to bind
  29792. * @param effect The effect to bind to
  29793. * @param positiveUniform The positive uniform shader parameter
  29794. * @param neutralUniform The neutral uniform shader parameter
  29795. * @param negativeUniform The negative uniform shader parameter
  29796. */
  29797. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  29798. /**
  29799. * Prepare the list of uniforms associated with the ColorCurves effects.
  29800. * @param uniformsList The list of uniforms used in the effect
  29801. */
  29802. static PrepareUniforms(uniformsList: string[]): void;
  29803. /**
  29804. * Returns color grading data based on a hue, density, saturation and exposure value.
  29805. * @param filterHue The hue of the color filter.
  29806. * @param filterDensity The density of the color filter.
  29807. * @param saturation The saturation.
  29808. * @param exposure The exposure.
  29809. * @param result The result data container.
  29810. */
  29811. private getColorGradingDataToRef;
  29812. /**
  29813. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  29814. * @param value The input slider value in range [-100,100].
  29815. * @returns Adjusted value.
  29816. */
  29817. private static applyColorGradingSliderNonlinear;
  29818. /**
  29819. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  29820. * @param hue The hue (H) input.
  29821. * @param saturation The saturation (S) input.
  29822. * @param brightness The brightness (B) input.
  29823. * @result An RGBA color represented as Vector4.
  29824. */
  29825. private static fromHSBToRef;
  29826. /**
  29827. * Returns a value clamped between min and max
  29828. * @param value The value to clamp
  29829. * @param min The minimum of value
  29830. * @param max The maximum of value
  29831. * @returns The clamped value.
  29832. */
  29833. private static clamp;
  29834. /**
  29835. * Clones the current color curve instance.
  29836. * @return The cloned curves
  29837. */
  29838. clone(): ColorCurves;
  29839. /**
  29840. * Serializes the current color curve instance to a json representation.
  29841. * @return a JSON representation
  29842. */
  29843. serialize(): any;
  29844. /**
  29845. * Parses the color curve from a json representation.
  29846. * @param source the JSON source to parse
  29847. * @return The parsed curves
  29848. */
  29849. static Parse(source: any): ColorCurves;
  29850. }
  29851. }
  29852. declare module BABYLON {
  29853. /**
  29854. * Interface to follow in your material defines to integrate easily the
  29855. * Image proccessing functions.
  29856. * @hidden
  29857. */
  29858. export interface IImageProcessingConfigurationDefines {
  29859. IMAGEPROCESSING: boolean;
  29860. VIGNETTE: boolean;
  29861. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29862. VIGNETTEBLENDMODEOPAQUE: boolean;
  29863. TONEMAPPING: boolean;
  29864. TONEMAPPING_ACES: boolean;
  29865. CONTRAST: boolean;
  29866. EXPOSURE: boolean;
  29867. COLORCURVES: boolean;
  29868. COLORGRADING: boolean;
  29869. COLORGRADING3D: boolean;
  29870. SAMPLER3DGREENDEPTH: boolean;
  29871. SAMPLER3DBGRMAP: boolean;
  29872. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29873. }
  29874. /**
  29875. * @hidden
  29876. */
  29877. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29878. IMAGEPROCESSING: boolean;
  29879. VIGNETTE: boolean;
  29880. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29881. VIGNETTEBLENDMODEOPAQUE: boolean;
  29882. TONEMAPPING: boolean;
  29883. TONEMAPPING_ACES: boolean;
  29884. CONTRAST: boolean;
  29885. COLORCURVES: boolean;
  29886. COLORGRADING: boolean;
  29887. COLORGRADING3D: boolean;
  29888. SAMPLER3DGREENDEPTH: boolean;
  29889. SAMPLER3DBGRMAP: boolean;
  29890. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29891. EXPOSURE: boolean;
  29892. constructor();
  29893. }
  29894. /**
  29895. * This groups together the common properties used for image processing either in direct forward pass
  29896. * or through post processing effect depending on the use of the image processing pipeline in your scene
  29897. * or not.
  29898. */
  29899. export class ImageProcessingConfiguration {
  29900. /**
  29901. * Default tone mapping applied in BabylonJS.
  29902. */
  29903. static readonly TONEMAPPING_STANDARD: number;
  29904. /**
  29905. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  29906. * to other engines rendering to increase portability.
  29907. */
  29908. static readonly TONEMAPPING_ACES: number;
  29909. /**
  29910. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  29911. */
  29912. colorCurves: Nullable<ColorCurves>;
  29913. private _colorCurvesEnabled;
  29914. /**
  29915. * Gets wether the color curves effect is enabled.
  29916. */
  29917. /**
  29918. * Sets wether the color curves effect is enabled.
  29919. */
  29920. colorCurvesEnabled: boolean;
  29921. private _colorGradingTexture;
  29922. /**
  29923. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29924. */
  29925. /**
  29926. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29927. */
  29928. colorGradingTexture: Nullable<BaseTexture>;
  29929. private _colorGradingEnabled;
  29930. /**
  29931. * Gets wether the color grading effect is enabled.
  29932. */
  29933. /**
  29934. * Sets wether the color grading effect is enabled.
  29935. */
  29936. colorGradingEnabled: boolean;
  29937. private _colorGradingWithGreenDepth;
  29938. /**
  29939. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  29940. */
  29941. /**
  29942. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  29943. */
  29944. colorGradingWithGreenDepth: boolean;
  29945. private _colorGradingBGR;
  29946. /**
  29947. * Gets wether the color grading texture contains BGR values.
  29948. */
  29949. /**
  29950. * Sets wether the color grading texture contains BGR values.
  29951. */
  29952. colorGradingBGR: boolean;
  29953. /** @hidden */
  29954. _exposure: number;
  29955. /**
  29956. * Gets the Exposure used in the effect.
  29957. */
  29958. /**
  29959. * Sets the Exposure used in the effect.
  29960. */
  29961. exposure: number;
  29962. private _toneMappingEnabled;
  29963. /**
  29964. * Gets wether the tone mapping effect is enabled.
  29965. */
  29966. /**
  29967. * Sets wether the tone mapping effect is enabled.
  29968. */
  29969. toneMappingEnabled: boolean;
  29970. private _toneMappingType;
  29971. /**
  29972. * Gets the type of tone mapping effect.
  29973. */
  29974. /**
  29975. * Sets the type of tone mapping effect used in BabylonJS.
  29976. */
  29977. toneMappingType: number;
  29978. protected _contrast: number;
  29979. /**
  29980. * Gets the contrast used in the effect.
  29981. */
  29982. /**
  29983. * Sets the contrast used in the effect.
  29984. */
  29985. contrast: number;
  29986. /**
  29987. * Vignette stretch size.
  29988. */
  29989. vignetteStretch: number;
  29990. /**
  29991. * Vignette centre X Offset.
  29992. */
  29993. vignetteCentreX: number;
  29994. /**
  29995. * Vignette centre Y Offset.
  29996. */
  29997. vignetteCentreY: number;
  29998. /**
  29999. * Vignette weight or intensity of the vignette effect.
  30000. */
  30001. vignetteWeight: number;
  30002. /**
  30003. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  30004. * if vignetteEnabled is set to true.
  30005. */
  30006. vignetteColor: Color4;
  30007. /**
  30008. * Camera field of view used by the Vignette effect.
  30009. */
  30010. vignetteCameraFov: number;
  30011. private _vignetteBlendMode;
  30012. /**
  30013. * Gets the vignette blend mode allowing different kind of effect.
  30014. */
  30015. /**
  30016. * Sets the vignette blend mode allowing different kind of effect.
  30017. */
  30018. vignetteBlendMode: number;
  30019. private _vignetteEnabled;
  30020. /**
  30021. * Gets wether the vignette effect is enabled.
  30022. */
  30023. /**
  30024. * Sets wether the vignette effect is enabled.
  30025. */
  30026. vignetteEnabled: boolean;
  30027. private _applyByPostProcess;
  30028. /**
  30029. * Gets wether the image processing is applied through a post process or not.
  30030. */
  30031. /**
  30032. * Sets wether the image processing is applied through a post process or not.
  30033. */
  30034. applyByPostProcess: boolean;
  30035. private _isEnabled;
  30036. /**
  30037. * Gets wether the image processing is enabled or not.
  30038. */
  30039. /**
  30040. * Sets wether the image processing is enabled or not.
  30041. */
  30042. isEnabled: boolean;
  30043. /**
  30044. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  30045. */
  30046. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  30047. /**
  30048. * Method called each time the image processing information changes requires to recompile the effect.
  30049. */
  30050. protected _updateParameters(): void;
  30051. /**
  30052. * Gets the current class name.
  30053. * @return "ImageProcessingConfiguration"
  30054. */
  30055. getClassName(): string;
  30056. /**
  30057. * Prepare the list of uniforms associated with the Image Processing effects.
  30058. * @param uniforms The list of uniforms used in the effect
  30059. * @param defines the list of defines currently in use
  30060. */
  30061. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  30062. /**
  30063. * Prepare the list of samplers associated with the Image Processing effects.
  30064. * @param samplersList The list of uniforms used in the effect
  30065. * @param defines the list of defines currently in use
  30066. */
  30067. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  30068. /**
  30069. * Prepare the list of defines associated to the shader.
  30070. * @param defines the list of defines to complete
  30071. * @param forPostProcess Define if we are currently in post process mode or not
  30072. */
  30073. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  30074. /**
  30075. * Returns true if all the image processing information are ready.
  30076. * @returns True if ready, otherwise, false
  30077. */
  30078. isReady(): boolean;
  30079. /**
  30080. * Binds the image processing to the shader.
  30081. * @param effect The effect to bind to
  30082. * @param aspectRatio Define the current aspect ratio of the effect
  30083. */
  30084. bind(effect: Effect, aspectRatio?: number): void;
  30085. /**
  30086. * Clones the current image processing instance.
  30087. * @return The cloned image processing
  30088. */
  30089. clone(): ImageProcessingConfiguration;
  30090. /**
  30091. * Serializes the current image processing instance to a json representation.
  30092. * @return a JSON representation
  30093. */
  30094. serialize(): any;
  30095. /**
  30096. * Parses the image processing from a json representation.
  30097. * @param source the JSON source to parse
  30098. * @return The parsed image processing
  30099. */
  30100. static Parse(source: any): ImageProcessingConfiguration;
  30101. private static _VIGNETTEMODE_MULTIPLY;
  30102. private static _VIGNETTEMODE_OPAQUE;
  30103. /**
  30104. * Used to apply the vignette as a mix with the pixel color.
  30105. */
  30106. static readonly VIGNETTEMODE_MULTIPLY: number;
  30107. /**
  30108. * Used to apply the vignette as a replacement of the pixel color.
  30109. */
  30110. static readonly VIGNETTEMODE_OPAQUE: number;
  30111. }
  30112. }
  30113. declare module BABYLON {
  30114. /**
  30115. * This represents all the required information to add a fresnel effect on a material:
  30116. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30117. */
  30118. export class FresnelParameters {
  30119. private _isEnabled;
  30120. /**
  30121. * Define if the fresnel effect is enable or not.
  30122. */
  30123. isEnabled: boolean;
  30124. /**
  30125. * Define the color used on edges (grazing angle)
  30126. */
  30127. leftColor: Color3;
  30128. /**
  30129. * Define the color used on center
  30130. */
  30131. rightColor: Color3;
  30132. /**
  30133. * Define bias applied to computed fresnel term
  30134. */
  30135. bias: number;
  30136. /**
  30137. * Defined the power exponent applied to fresnel term
  30138. */
  30139. power: number;
  30140. /**
  30141. * Clones the current fresnel and its valuues
  30142. * @returns a clone fresnel configuration
  30143. */
  30144. clone(): FresnelParameters;
  30145. /**
  30146. * Serializes the current fresnel parameters to a JSON representation.
  30147. * @return the JSON serialization
  30148. */
  30149. serialize(): any;
  30150. /**
  30151. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30152. * @param parsedFresnelParameters Define the JSON representation
  30153. * @returns the parsed parameters
  30154. */
  30155. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30156. }
  30157. }
  30158. declare module BABYLON {
  30159. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30160. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30161. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30162. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30163. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30164. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30165. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30166. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30167. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30168. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30169. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30170. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30171. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30172. /**
  30173. * Decorator used to define property that can be serialized as reference to a camera
  30174. * @param sourceName defines the name of the property to decorate
  30175. */
  30176. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30177. /**
  30178. * Class used to help serialization objects
  30179. */
  30180. export class SerializationHelper {
  30181. /** hidden */
  30182. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  30183. /** hidden */
  30184. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  30185. /** hidden */
  30186. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  30187. /** hidden */
  30188. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  30189. /**
  30190. * Appends the serialized animations from the source animations
  30191. * @param source Source containing the animations
  30192. * @param destination Target to store the animations
  30193. */
  30194. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30195. /**
  30196. * Static function used to serialized a specific entity
  30197. * @param entity defines the entity to serialize
  30198. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30199. * @returns a JSON compatible object representing the serialization of the entity
  30200. */
  30201. static Serialize<T>(entity: T, serializationObject?: any): any;
  30202. /**
  30203. * Creates a new entity from a serialization data object
  30204. * @param creationFunction defines a function used to instanciated the new entity
  30205. * @param source defines the source serialization data
  30206. * @param scene defines the hosting scene
  30207. * @param rootUrl defines the root url for resources
  30208. * @returns a new entity
  30209. */
  30210. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30211. /**
  30212. * Clones an object
  30213. * @param creationFunction defines the function used to instanciate the new object
  30214. * @param source defines the source object
  30215. * @returns the cloned object
  30216. */
  30217. static Clone<T>(creationFunction: () => T, source: T): T;
  30218. /**
  30219. * Instanciates a new object based on a source one (some data will be shared between both object)
  30220. * @param creationFunction defines the function used to instanciate the new object
  30221. * @param source defines the source object
  30222. * @returns the new object
  30223. */
  30224. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30225. }
  30226. }
  30227. declare module BABYLON {
  30228. /**
  30229. * This is the base class of all the camera used in the application.
  30230. * @see http://doc.babylonjs.com/features/cameras
  30231. */
  30232. export class Camera extends Node {
  30233. /** @hidden */
  30234. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30235. /**
  30236. * This is the default projection mode used by the cameras.
  30237. * It helps recreating a feeling of perspective and better appreciate depth.
  30238. * This is the best way to simulate real life cameras.
  30239. */
  30240. static readonly PERSPECTIVE_CAMERA: number;
  30241. /**
  30242. * This helps creating camera with an orthographic mode.
  30243. * 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.
  30244. */
  30245. static readonly ORTHOGRAPHIC_CAMERA: number;
  30246. /**
  30247. * This is the default FOV mode for perspective cameras.
  30248. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30249. */
  30250. static readonly FOVMODE_VERTICAL_FIXED: number;
  30251. /**
  30252. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30253. */
  30254. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30255. /**
  30256. * This specifies ther is no need for a camera rig.
  30257. * Basically only one eye is rendered corresponding to the camera.
  30258. */
  30259. static readonly RIG_MODE_NONE: number;
  30260. /**
  30261. * Simulates a camera Rig with one blue eye and one red eye.
  30262. * This can be use with 3d blue and red glasses.
  30263. */
  30264. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30265. /**
  30266. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30267. */
  30268. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30269. /**
  30270. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30271. */
  30272. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30273. /**
  30274. * Defines that both eyes of the camera will be rendered over under each other.
  30275. */
  30276. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30277. /**
  30278. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30279. */
  30280. static readonly RIG_MODE_VR: number;
  30281. /**
  30282. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30283. */
  30284. static readonly RIG_MODE_WEBVR: number;
  30285. /**
  30286. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30287. */
  30288. static readonly RIG_MODE_CUSTOM: number;
  30289. /**
  30290. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30291. */
  30292. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30293. /**
  30294. * Define the input manager associated with the camera.
  30295. */
  30296. inputs: CameraInputsManager<Camera>;
  30297. /** @hidden */
  30298. _position: Vector3;
  30299. /**
  30300. * Define the current local position of the camera in the scene
  30301. */
  30302. position: Vector3;
  30303. /**
  30304. * The vector the camera should consider as up.
  30305. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30306. */
  30307. upVector: Vector3;
  30308. /**
  30309. * Define the current limit on the left side for an orthographic camera
  30310. * In scene unit
  30311. */
  30312. orthoLeft: Nullable<number>;
  30313. /**
  30314. * Define the current limit on the right side for an orthographic camera
  30315. * In scene unit
  30316. */
  30317. orthoRight: Nullable<number>;
  30318. /**
  30319. * Define the current limit on the bottom side for an orthographic camera
  30320. * In scene unit
  30321. */
  30322. orthoBottom: Nullable<number>;
  30323. /**
  30324. * Define the current limit on the top side for an orthographic camera
  30325. * In scene unit
  30326. */
  30327. orthoTop: Nullable<number>;
  30328. /**
  30329. * Field Of View is set in Radians. (default is 0.8)
  30330. */
  30331. fov: number;
  30332. /**
  30333. * Define the minimum distance the camera can see from.
  30334. * This is important to note that the depth buffer are not infinite and the closer it starts
  30335. * the more your scene might encounter depth fighting issue.
  30336. */
  30337. minZ: number;
  30338. /**
  30339. * Define the maximum distance the camera can see to.
  30340. * This is important to note that the depth buffer are not infinite and the further it end
  30341. * the more your scene might encounter depth fighting issue.
  30342. */
  30343. maxZ: number;
  30344. /**
  30345. * Define the default inertia of the camera.
  30346. * This helps giving a smooth feeling to the camera movement.
  30347. */
  30348. inertia: number;
  30349. /**
  30350. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  30351. */
  30352. mode: number;
  30353. /**
  30354. * Define wether the camera is intermediate.
  30355. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30356. */
  30357. isIntermediate: boolean;
  30358. /**
  30359. * Define the viewport of the camera.
  30360. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30361. */
  30362. viewport: Viewport;
  30363. /**
  30364. * Restricts the camera to viewing objects with the same layerMask.
  30365. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30366. */
  30367. layerMask: number;
  30368. /**
  30369. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30370. */
  30371. fovMode: number;
  30372. /**
  30373. * Rig mode of the camera.
  30374. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30375. * This is normally controlled byt the camera themselves as internal use.
  30376. */
  30377. cameraRigMode: number;
  30378. /**
  30379. * Defines the distance between both "eyes" in case of a RIG
  30380. */
  30381. interaxialDistance: number;
  30382. /**
  30383. * Defines if stereoscopic rendering is done side by side or over under.
  30384. */
  30385. isStereoscopicSideBySide: boolean;
  30386. /**
  30387. * 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
  30388. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30389. * else in the scene.
  30390. */
  30391. customRenderTargets: RenderTargetTexture[];
  30392. /**
  30393. * When set, the camera will render to this render target instead of the default canvas
  30394. */
  30395. outputRenderTarget: Nullable<RenderTargetTexture>;
  30396. /**
  30397. * Observable triggered when the camera view matrix has changed.
  30398. */
  30399. onViewMatrixChangedObservable: Observable<Camera>;
  30400. /**
  30401. * Observable triggered when the camera Projection matrix has changed.
  30402. */
  30403. onProjectionMatrixChangedObservable: Observable<Camera>;
  30404. /**
  30405. * Observable triggered when the inputs have been processed.
  30406. */
  30407. onAfterCheckInputsObservable: Observable<Camera>;
  30408. /**
  30409. * Observable triggered when reset has been called and applied to the camera.
  30410. */
  30411. onRestoreStateObservable: Observable<Camera>;
  30412. /** @hidden */
  30413. _cameraRigParams: any;
  30414. /** @hidden */
  30415. _rigCameras: Camera[];
  30416. /** @hidden */
  30417. _rigPostProcess: Nullable<PostProcess>;
  30418. protected _webvrViewMatrix: Matrix;
  30419. /** @hidden */
  30420. _skipRendering: boolean;
  30421. /** @hidden */
  30422. _projectionMatrix: Matrix;
  30423. /** @hidden */
  30424. _postProcesses: Nullable<PostProcess>[];
  30425. /** @hidden */
  30426. _activeMeshes: SmartArray<AbstractMesh>;
  30427. protected _globalPosition: Vector3;
  30428. /** hidden */
  30429. _computedViewMatrix: Matrix;
  30430. private _doNotComputeProjectionMatrix;
  30431. private _transformMatrix;
  30432. private _frustumPlanes;
  30433. private _refreshFrustumPlanes;
  30434. private _storedFov;
  30435. private _stateStored;
  30436. /**
  30437. * Instantiates a new camera object.
  30438. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30439. * @see http://doc.babylonjs.com/features/cameras
  30440. * @param name Defines the name of the camera in the scene
  30441. * @param position Defines the position of the camera
  30442. * @param scene Defines the scene the camera belongs too
  30443. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30444. */
  30445. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30446. /**
  30447. * Store current camera state (fov, position, etc..)
  30448. * @returns the camera
  30449. */
  30450. storeState(): Camera;
  30451. /**
  30452. * Restores the camera state values if it has been stored. You must call storeState() first
  30453. */
  30454. protected _restoreStateValues(): boolean;
  30455. /**
  30456. * Restored camera state. You must call storeState() first.
  30457. * @returns true if restored and false otherwise
  30458. */
  30459. restoreState(): boolean;
  30460. /**
  30461. * Gets the class name of the camera.
  30462. * @returns the class name
  30463. */
  30464. getClassName(): string;
  30465. /** @hidden */
  30466. readonly _isCamera: boolean;
  30467. /**
  30468. * Gets a string representation of the camera useful for debug purpose.
  30469. * @param fullDetails Defines that a more verboe level of logging is required
  30470. * @returns the string representation
  30471. */
  30472. toString(fullDetails?: boolean): string;
  30473. /**
  30474. * Gets the current world space position of the camera.
  30475. */
  30476. readonly globalPosition: Vector3;
  30477. /**
  30478. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30479. * @returns the active meshe list
  30480. */
  30481. getActiveMeshes(): SmartArray<AbstractMesh>;
  30482. /**
  30483. * Check wether a mesh is part of the current active mesh list of the camera
  30484. * @param mesh Defines the mesh to check
  30485. * @returns true if active, false otherwise
  30486. */
  30487. isActiveMesh(mesh: Mesh): boolean;
  30488. /**
  30489. * Is this camera ready to be used/rendered
  30490. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30491. * @return true if the camera is ready
  30492. */
  30493. isReady(completeCheck?: boolean): boolean;
  30494. /** @hidden */
  30495. _initCache(): void;
  30496. /** @hidden */
  30497. _updateCache(ignoreParentClass?: boolean): void;
  30498. /** @hidden */
  30499. _isSynchronized(): boolean;
  30500. /** @hidden */
  30501. _isSynchronizedViewMatrix(): boolean;
  30502. /** @hidden */
  30503. _isSynchronizedProjectionMatrix(): boolean;
  30504. /**
  30505. * Attach the input controls to a specific dom element to get the input from.
  30506. * @param element Defines the element the controls should be listened from
  30507. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30508. */
  30509. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30510. /**
  30511. * Detach the current controls from the specified dom element.
  30512. * @param element Defines the element to stop listening the inputs from
  30513. */
  30514. detachControl(element: HTMLElement): void;
  30515. /**
  30516. * Update the camera state according to the different inputs gathered during the frame.
  30517. */
  30518. update(): void;
  30519. /** @hidden */
  30520. _checkInputs(): void;
  30521. /** @hidden */
  30522. readonly rigCameras: Camera[];
  30523. /**
  30524. * Gets the post process used by the rig cameras
  30525. */
  30526. readonly rigPostProcess: Nullable<PostProcess>;
  30527. /**
  30528. * Internal, gets the first post proces.
  30529. * @returns the first post process to be run on this camera.
  30530. */
  30531. _getFirstPostProcess(): Nullable<PostProcess>;
  30532. private _cascadePostProcessesToRigCams;
  30533. /**
  30534. * Attach a post process to the camera.
  30535. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30536. * @param postProcess The post process to attach to the camera
  30537. * @param insertAt The position of the post process in case several of them are in use in the scene
  30538. * @returns the position the post process has been inserted at
  30539. */
  30540. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30541. /**
  30542. * Detach a post process to the camera.
  30543. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30544. * @param postProcess The post process to detach from the camera
  30545. */
  30546. detachPostProcess(postProcess: PostProcess): void;
  30547. /**
  30548. * Gets the current world matrix of the camera
  30549. */
  30550. getWorldMatrix(): Matrix;
  30551. /** @hidden */
  30552. _getViewMatrix(): Matrix;
  30553. /**
  30554. * Gets the current view matrix of the camera.
  30555. * @param force forces the camera to recompute the matrix without looking at the cached state
  30556. * @returns the view matrix
  30557. */
  30558. getViewMatrix(force?: boolean): Matrix;
  30559. /**
  30560. * Freeze the projection matrix.
  30561. * It will prevent the cache check of the camera projection compute and can speed up perf
  30562. * if no parameter of the camera are meant to change
  30563. * @param projection Defines manually a projection if necessary
  30564. */
  30565. freezeProjectionMatrix(projection?: Matrix): void;
  30566. /**
  30567. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30568. */
  30569. unfreezeProjectionMatrix(): void;
  30570. /**
  30571. * Gets the current projection matrix of the camera.
  30572. * @param force forces the camera to recompute the matrix without looking at the cached state
  30573. * @returns the projection matrix
  30574. */
  30575. getProjectionMatrix(force?: boolean): Matrix;
  30576. /**
  30577. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30578. * @returns a Matrix
  30579. */
  30580. getTransformationMatrix(): Matrix;
  30581. private _updateFrustumPlanes;
  30582. /**
  30583. * Checks if a cullable object (mesh...) is in the camera frustum
  30584. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30585. * @param target The object to check
  30586. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  30587. * @returns true if the object is in frustum otherwise false
  30588. */
  30589. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  30590. /**
  30591. * Checks if a cullable object (mesh...) is in the camera frustum
  30592. * Unlike isInFrustum this cheks the full bounding box
  30593. * @param target The object to check
  30594. * @returns true if the object is in frustum otherwise false
  30595. */
  30596. isCompletelyInFrustum(target: ICullable): boolean;
  30597. /**
  30598. * Gets a ray in the forward direction from the camera.
  30599. * @param length Defines the length of the ray to create
  30600. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30601. * @param origin Defines the start point of the ray which defaults to the camera position
  30602. * @returns the forward ray
  30603. */
  30604. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30605. /**
  30606. * Releases resources associated with this node.
  30607. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30608. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30609. */
  30610. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30611. /** @hidden */
  30612. _isLeftCamera: boolean;
  30613. /**
  30614. * Gets the left camera of a rig setup in case of Rigged Camera
  30615. */
  30616. readonly isLeftCamera: boolean;
  30617. /** @hidden */
  30618. _isRightCamera: boolean;
  30619. /**
  30620. * Gets the right camera of a rig setup in case of Rigged Camera
  30621. */
  30622. readonly isRightCamera: boolean;
  30623. /**
  30624. * Gets the left camera of a rig setup in case of Rigged Camera
  30625. */
  30626. readonly leftCamera: Nullable<FreeCamera>;
  30627. /**
  30628. * Gets the right camera of a rig setup in case of Rigged Camera
  30629. */
  30630. readonly rightCamera: Nullable<FreeCamera>;
  30631. /**
  30632. * Gets the left camera target of a rig setup in case of Rigged Camera
  30633. * @returns the target position
  30634. */
  30635. getLeftTarget(): Nullable<Vector3>;
  30636. /**
  30637. * Gets the right camera target of a rig setup in case of Rigged Camera
  30638. * @returns the target position
  30639. */
  30640. getRightTarget(): Nullable<Vector3>;
  30641. /**
  30642. * @hidden
  30643. */
  30644. setCameraRigMode(mode: number, rigParams: any): void;
  30645. /** @hidden */
  30646. static _setStereoscopicRigMode(camera: Camera): void;
  30647. /** @hidden */
  30648. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30649. /** @hidden */
  30650. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30651. /** @hidden */
  30652. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30653. /** @hidden */
  30654. _getVRProjectionMatrix(): Matrix;
  30655. protected _updateCameraRotationMatrix(): void;
  30656. protected _updateWebVRCameraRotationMatrix(): void;
  30657. /**
  30658. * This function MUST be overwritten by the different WebVR cameras available.
  30659. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30660. * @hidden
  30661. */
  30662. _getWebVRProjectionMatrix(): Matrix;
  30663. /**
  30664. * This function MUST be overwritten by the different WebVR cameras available.
  30665. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30666. * @hidden
  30667. */
  30668. _getWebVRViewMatrix(): Matrix;
  30669. /** @hidden */
  30670. setCameraRigParameter(name: string, value: any): void;
  30671. /**
  30672. * needs to be overridden by children so sub has required properties to be copied
  30673. * @hidden
  30674. */
  30675. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30676. /**
  30677. * May need to be overridden by children
  30678. * @hidden
  30679. */
  30680. _updateRigCameras(): void;
  30681. /** @hidden */
  30682. _setupInputs(): void;
  30683. /**
  30684. * Serialiaze the camera setup to a json represention
  30685. * @returns the JSON representation
  30686. */
  30687. serialize(): any;
  30688. /**
  30689. * Clones the current camera.
  30690. * @param name The cloned camera name
  30691. * @returns the cloned camera
  30692. */
  30693. clone(name: string): Camera;
  30694. /**
  30695. * Gets the direction of the camera relative to a given local axis.
  30696. * @param localAxis Defines the reference axis to provide a relative direction.
  30697. * @return the direction
  30698. */
  30699. getDirection(localAxis: Vector3): Vector3;
  30700. /**
  30701. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30702. * @param localAxis Defines the reference axis to provide a relative direction.
  30703. * @param result Defines the vector to store the result in
  30704. */
  30705. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30706. /**
  30707. * Gets a camera constructor for a given camera type
  30708. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30709. * @param name The name of the camera the result will be able to instantiate
  30710. * @param scene The scene the result will construct the camera in
  30711. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30712. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30713. * @returns a factory method to construc the camera
  30714. */
  30715. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30716. /**
  30717. * Compute the world matrix of the camera.
  30718. * @returns the camera workd matrix
  30719. */
  30720. computeWorldMatrix(): Matrix;
  30721. /**
  30722. * Parse a JSON and creates the camera from the parsed information
  30723. * @param parsedCamera The JSON to parse
  30724. * @param scene The scene to instantiate the camera in
  30725. * @returns the newly constructed camera
  30726. */
  30727. static Parse(parsedCamera: any, scene: Scene): Camera;
  30728. }
  30729. }
  30730. declare module BABYLON {
  30731. /**
  30732. * Interface for any object that can request an animation frame
  30733. */
  30734. export interface ICustomAnimationFrameRequester {
  30735. /**
  30736. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30737. */
  30738. renderFunction?: Function;
  30739. /**
  30740. * Called to request the next frame to render to
  30741. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30742. */
  30743. requestAnimationFrame: Function;
  30744. /**
  30745. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30746. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30747. */
  30748. requestID?: number;
  30749. }
  30750. /**
  30751. * Interface containing an array of animations
  30752. */
  30753. export interface IAnimatable {
  30754. /**
  30755. * Array of animations
  30756. */
  30757. animations: Nullable<Array<Animation>>;
  30758. }
  30759. /** Interface used by value gradients (color, factor, ...) */
  30760. export interface IValueGradient {
  30761. /**
  30762. * Gets or sets the gradient value (between 0 and 1)
  30763. */
  30764. gradient: number;
  30765. }
  30766. /** Class used to store color4 gradient */
  30767. export class ColorGradient implements IValueGradient {
  30768. /**
  30769. * Gets or sets the gradient value (between 0 and 1)
  30770. */
  30771. gradient: number;
  30772. /**
  30773. * Gets or sets first associated color
  30774. */
  30775. color1: Color4;
  30776. /**
  30777. * Gets or sets second associated color
  30778. */
  30779. color2?: Color4;
  30780. /**
  30781. * Will get a color picked randomly between color1 and color2.
  30782. * If color2 is undefined then color1 will be used
  30783. * @param result defines the target Color4 to store the result in
  30784. */
  30785. getColorToRef(result: Color4): void;
  30786. }
  30787. /** Class used to store color 3 gradient */
  30788. export class Color3Gradient implements IValueGradient {
  30789. /**
  30790. * Gets or sets the gradient value (between 0 and 1)
  30791. */
  30792. gradient: number;
  30793. /**
  30794. * Gets or sets the associated color
  30795. */
  30796. color: Color3;
  30797. }
  30798. /** Class used to store factor gradient */
  30799. export class FactorGradient implements IValueGradient {
  30800. /**
  30801. * Gets or sets the gradient value (between 0 and 1)
  30802. */
  30803. gradient: number;
  30804. /**
  30805. * Gets or sets first associated factor
  30806. */
  30807. factor1: number;
  30808. /**
  30809. * Gets or sets second associated factor
  30810. */
  30811. factor2?: number;
  30812. /**
  30813. * Will get a number picked randomly between factor1 and factor2.
  30814. * If factor2 is undefined then factor1 will be used
  30815. * @returns the picked number
  30816. */
  30817. getFactor(): number;
  30818. }
  30819. /**
  30820. * @ignore
  30821. * Application error to support additional information when loading a file
  30822. */
  30823. export class LoadFileError extends Error {
  30824. /** defines the optional web request */
  30825. request?: WebRequest | undefined;
  30826. private static _setPrototypeOf;
  30827. /**
  30828. * Creates a new LoadFileError
  30829. * @param message defines the message of the error
  30830. * @param request defines the optional web request
  30831. */
  30832. constructor(message: string,
  30833. /** defines the optional web request */
  30834. request?: WebRequest | undefined);
  30835. }
  30836. /**
  30837. * Class used to define a retry strategy when error happens while loading assets
  30838. */
  30839. export class RetryStrategy {
  30840. /**
  30841. * Function used to defines an exponential back off strategy
  30842. * @param maxRetries defines the maximum number of retries (3 by default)
  30843. * @param baseInterval defines the interval between retries
  30844. * @returns the strategy function to use
  30845. */
  30846. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  30847. }
  30848. /**
  30849. * File request interface
  30850. */
  30851. export interface IFileRequest {
  30852. /**
  30853. * Raised when the request is complete (success or error).
  30854. */
  30855. onCompleteObservable: Observable<IFileRequest>;
  30856. /**
  30857. * Aborts the request for a file.
  30858. */
  30859. abort: () => void;
  30860. }
  30861. /**
  30862. * Class containing a set of static utilities functions
  30863. */
  30864. export class Tools {
  30865. /**
  30866. * Gets or sets the base URL to use to load assets
  30867. */
  30868. static BaseUrl: string;
  30869. /**
  30870. * Enable/Disable Custom HTTP Request Headers globally.
  30871. * default = false
  30872. * @see CustomRequestHeaders
  30873. */
  30874. static UseCustomRequestHeaders: boolean;
  30875. /**
  30876. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  30877. * i.e. when loading files, where the server/service expects an Authorization header
  30878. */
  30879. static CustomRequestHeaders: {
  30880. [key: string]: string;
  30881. };
  30882. /**
  30883. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  30884. */
  30885. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  30886. /**
  30887. * Default behaviour for cors in the application.
  30888. * It can be a string if the expected behavior is identical in the entire app.
  30889. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  30890. */
  30891. static CorsBehavior: string | ((url: string | string[]) => string);
  30892. /**
  30893. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  30894. * @ignorenaming
  30895. */
  30896. static UseFallbackTexture: boolean;
  30897. /**
  30898. * Use this object to register external classes like custom textures or material
  30899. * to allow the laoders to instantiate them
  30900. */
  30901. static RegisteredExternalClasses: {
  30902. [key: string]: Object;
  30903. };
  30904. /**
  30905. * Texture content used if a texture cannot loaded
  30906. * @ignorenaming
  30907. */
  30908. static fallbackTexture: string;
  30909. /**
  30910. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  30911. * @param u defines the coordinate on X axis
  30912. * @param v defines the coordinate on Y axis
  30913. * @param width defines the width of the source data
  30914. * @param height defines the height of the source data
  30915. * @param pixels defines the source byte array
  30916. * @param color defines the output color
  30917. */
  30918. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  30919. /**
  30920. * Interpolates between a and b via alpha
  30921. * @param a The lower value (returned when alpha = 0)
  30922. * @param b The upper value (returned when alpha = 1)
  30923. * @param alpha The interpolation-factor
  30924. * @return The mixed value
  30925. */
  30926. static Mix(a: number, b: number, alpha: number): number;
  30927. /**
  30928. * Tries to instantiate a new object from a given class name
  30929. * @param className defines the class name to instantiate
  30930. * @returns the new object or null if the system was not able to do the instantiation
  30931. */
  30932. static Instantiate(className: string): any;
  30933. /**
  30934. * Provides a slice function that will work even on IE
  30935. * @param data defines the array to slice
  30936. * @param start defines the start of the data (optional)
  30937. * @param end defines the end of the data (optional)
  30938. * @returns the new sliced array
  30939. */
  30940. static Slice<T>(data: T, start?: number, end?: number): T;
  30941. /**
  30942. * Polyfill for setImmediate
  30943. * @param action defines the action to execute after the current execution block
  30944. */
  30945. static SetImmediate(action: () => void): void;
  30946. /**
  30947. * Function indicating if a number is an exponent of 2
  30948. * @param value defines the value to test
  30949. * @returns true if the value is an exponent of 2
  30950. */
  30951. static IsExponentOfTwo(value: number): boolean;
  30952. private static _tmpFloatArray;
  30953. /**
  30954. * Returns the nearest 32-bit single precision float representation of a Number
  30955. * @param value A Number. If the parameter is of a different type, it will get converted
  30956. * to a number or to NaN if it cannot be converted
  30957. * @returns number
  30958. */
  30959. static FloatRound(value: number): number;
  30960. /**
  30961. * Find the next highest power of two.
  30962. * @param x Number to start search from.
  30963. * @return Next highest power of two.
  30964. */
  30965. static CeilingPOT(x: number): number;
  30966. /**
  30967. * Find the next lowest power of two.
  30968. * @param x Number to start search from.
  30969. * @return Next lowest power of two.
  30970. */
  30971. static FloorPOT(x: number): number;
  30972. /**
  30973. * Find the nearest power of two.
  30974. * @param x Number to start search from.
  30975. * @return Next nearest power of two.
  30976. */
  30977. static NearestPOT(x: number): number;
  30978. /**
  30979. * Get the closest exponent of two
  30980. * @param value defines the value to approximate
  30981. * @param max defines the maximum value to return
  30982. * @param mode defines how to define the closest value
  30983. * @returns closest exponent of two of the given value
  30984. */
  30985. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30986. /**
  30987. * Extracts the filename from a path
  30988. * @param path defines the path to use
  30989. * @returns the filename
  30990. */
  30991. static GetFilename(path: string): string;
  30992. /**
  30993. * Extracts the "folder" part of a path (everything before the filename).
  30994. * @param uri The URI to extract the info from
  30995. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  30996. * @returns The "folder" part of the path
  30997. */
  30998. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  30999. /**
  31000. * Extracts text content from a DOM element hierarchy
  31001. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31002. */
  31003. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31004. /**
  31005. * Convert an angle in radians to degrees
  31006. * @param angle defines the angle to convert
  31007. * @returns the angle in degrees
  31008. */
  31009. static ToDegrees(angle: number): number;
  31010. /**
  31011. * Convert an angle in degrees to radians
  31012. * @param angle defines the angle to convert
  31013. * @returns the angle in radians
  31014. */
  31015. static ToRadians(angle: number): number;
  31016. /**
  31017. * Encode a buffer to a base64 string
  31018. * @param buffer defines the buffer to encode
  31019. * @returns the encoded string
  31020. */
  31021. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31022. /**
  31023. * Extracts minimum and maximum values from a list of indexed positions
  31024. * @param positions defines the positions to use
  31025. * @param indices defines the indices to the positions
  31026. * @param indexStart defines the start index
  31027. * @param indexCount defines the end index
  31028. * @param bias defines bias value to add to the result
  31029. * @return minimum and maximum values
  31030. */
  31031. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  31032. minimum: Vector3;
  31033. maximum: Vector3;
  31034. };
  31035. /**
  31036. * Extracts minimum and maximum values from a list of positions
  31037. * @param positions defines the positions to use
  31038. * @param start defines the start index in the positions array
  31039. * @param count defines the number of positions to handle
  31040. * @param bias defines bias value to add to the result
  31041. * @param stride defines the stride size to use (distance between two positions in the positions array)
  31042. * @return minimum and maximum values
  31043. */
  31044. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  31045. minimum: Vector3;
  31046. maximum: Vector3;
  31047. };
  31048. /**
  31049. * Returns an array if obj is not an array
  31050. * @param obj defines the object to evaluate as an array
  31051. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31052. * @returns either obj directly if obj is an array or a new array containing obj
  31053. */
  31054. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31055. /**
  31056. * Gets the pointer prefix to use
  31057. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31058. */
  31059. static GetPointerPrefix(): string;
  31060. /**
  31061. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31062. * @param func - the function to be called
  31063. * @param requester - the object that will request the next frame. Falls back to window.
  31064. * @returns frame number
  31065. */
  31066. static QueueNewFrame(func: () => void, requester?: any): number;
  31067. /**
  31068. * Ask the browser to promote the current element to fullscreen rendering mode
  31069. * @param element defines the DOM element to promote
  31070. */
  31071. static RequestFullscreen(element: HTMLElement): void;
  31072. /**
  31073. * Asks the browser to exit fullscreen mode
  31074. */
  31075. static ExitFullscreen(): void;
  31076. /**
  31077. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31078. * @param url define the url we are trying
  31079. * @param element define the dom element where to configure the cors policy
  31080. */
  31081. static SetCorsBehavior(url: string | string[], element: {
  31082. crossOrigin: string | null;
  31083. }): void;
  31084. /**
  31085. * Removes unwanted characters from an url
  31086. * @param url defines the url to clean
  31087. * @returns the cleaned url
  31088. */
  31089. static CleanUrl(url: string): string;
  31090. /**
  31091. * Gets or sets a function used to pre-process url before using them to load assets
  31092. */
  31093. static PreprocessUrl: (url: string) => string;
  31094. /**
  31095. * Loads an image as an HTMLImageElement.
  31096. * @param input url string, ArrayBuffer, or Blob to load
  31097. * @param onLoad callback called when the image successfully loads
  31098. * @param onError callback called when the image fails to load
  31099. * @param offlineProvider offline provider for caching
  31100. * @returns the HTMLImageElement of the loaded image
  31101. */
  31102. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31103. /**
  31104. * Loads a file
  31105. * @param url url string, ArrayBuffer, or Blob to load
  31106. * @param onSuccess callback called when the file successfully loads
  31107. * @param onProgress callback called while file is loading (if the server supports this mode)
  31108. * @param offlineProvider defines the offline provider for caching
  31109. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31110. * @param onError callback called when the file fails to load
  31111. * @returns a file request object
  31112. */
  31113. 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;
  31114. /**
  31115. * Load a script (identified by an url). When the url returns, the
  31116. * content of this file is added into a new script element, attached to the DOM (body element)
  31117. * @param scriptUrl defines the url of the script to laod
  31118. * @param onSuccess defines the callback called when the script is loaded
  31119. * @param onError defines the callback to call if an error occurs
  31120. * @param scriptId defines the id of the script element
  31121. */
  31122. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31123. /**
  31124. * Load an asynchronous script (identified by an url). When the url returns, the
  31125. * content of this file is added into a new script element, attached to the DOM (body element)
  31126. * @param scriptUrl defines the url of the script to laod
  31127. * @param scriptId defines the id of the script element
  31128. * @returns a promise request object
  31129. */
  31130. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  31131. /**
  31132. * Loads a file from a blob
  31133. * @param fileToLoad defines the blob to use
  31134. * @param callback defines the callback to call when data is loaded
  31135. * @param progressCallback defines the callback to call during loading process
  31136. * @returns a file request object
  31137. */
  31138. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31139. /**
  31140. * Loads a file
  31141. * @param fileToLoad defines the file to load
  31142. * @param callback defines the callback to call when data is loaded
  31143. * @param progressCallBack defines the callback to call during loading process
  31144. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31145. * @returns a file request object
  31146. */
  31147. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31148. /**
  31149. * Creates a data url from a given string content
  31150. * @param content defines the content to convert
  31151. * @returns the new data url link
  31152. */
  31153. static FileAsURL(content: string): string;
  31154. /**
  31155. * Format the given number to a specific decimal format
  31156. * @param value defines the number to format
  31157. * @param decimals defines the number of decimals to use
  31158. * @returns the formatted string
  31159. */
  31160. static Format(value: number, decimals?: number): string;
  31161. /**
  31162. * Checks if a given vector is inside a specific range
  31163. * @param v defines the vector to test
  31164. * @param min defines the minimum range
  31165. * @param max defines the maximum range
  31166. */
  31167. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31168. /**
  31169. * Tries to copy an object by duplicating every property
  31170. * @param source defines the source object
  31171. * @param destination defines the target object
  31172. * @param doNotCopyList defines a list of properties to avoid
  31173. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31174. */
  31175. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31176. /**
  31177. * Gets a boolean indicating if the given object has no own property
  31178. * @param obj defines the object to test
  31179. * @returns true if object has no own property
  31180. */
  31181. static IsEmpty(obj: any): boolean;
  31182. /**
  31183. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  31184. * @param str Source string
  31185. * @param suffix Suffix to search for in the source string
  31186. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  31187. */
  31188. static EndsWith(str: string, suffix: string): boolean;
  31189. /**
  31190. * Function used to register events at window level
  31191. * @param events defines the events to register
  31192. */
  31193. static RegisterTopRootEvents(events: {
  31194. name: string;
  31195. handler: Nullable<(e: FocusEvent) => any>;
  31196. }[]): void;
  31197. /**
  31198. * Function used to unregister events from window level
  31199. * @param events defines the events to unregister
  31200. */
  31201. static UnregisterTopRootEvents(events: {
  31202. name: string;
  31203. handler: Nullable<(e: FocusEvent) => any>;
  31204. }[]): void;
  31205. /**
  31206. * @ignore
  31207. */
  31208. static _ScreenshotCanvas: HTMLCanvasElement;
  31209. /**
  31210. * Dumps the current bound framebuffer
  31211. * @param width defines the rendering width
  31212. * @param height defines the rendering height
  31213. * @param engine defines the hosting engine
  31214. * @param successCallback defines the callback triggered once the data are available
  31215. * @param mimeType defines the mime type of the result
  31216. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31217. */
  31218. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31219. /**
  31220. * Converts the canvas data to blob.
  31221. * This acts as a polyfill for browsers not supporting the to blob function.
  31222. * @param canvas Defines the canvas to extract the data from
  31223. * @param successCallback Defines the callback triggered once the data are available
  31224. * @param mimeType Defines the mime type of the result
  31225. */
  31226. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31227. /**
  31228. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31229. * @param successCallback defines the callback triggered once the data are available
  31230. * @param mimeType defines the mime type of the result
  31231. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31232. */
  31233. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31234. /**
  31235. * Downloads a blob in the browser
  31236. * @param blob defines the blob to download
  31237. * @param fileName defines the name of the downloaded file
  31238. */
  31239. static Download(blob: Blob, fileName: string): void;
  31240. /**
  31241. * Captures a screenshot of the current rendering
  31242. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31243. * @param engine defines the rendering engine
  31244. * @param camera defines the source camera
  31245. * @param size This parameter can be set to a single number or to an object with the
  31246. * following (optional) properties: precision, width, height. If a single number is passed,
  31247. * it will be used for both width and height. If an object is passed, the screenshot size
  31248. * will be derived from the parameters. The precision property is a multiplier allowing
  31249. * rendering at a higher or lower resolution
  31250. * @param successCallback defines the callback receives a single parameter which contains the
  31251. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31252. * src parameter of an <img> to display it
  31253. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31254. * Check your browser for supported MIME types
  31255. */
  31256. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31257. /**
  31258. * Generates an image screenshot from the specified camera.
  31259. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31260. * @param engine The engine to use for rendering
  31261. * @param camera The camera to use for rendering
  31262. * @param size This parameter can be set to a single number or to an object with the
  31263. * following (optional) properties: precision, width, height. If a single number is passed,
  31264. * it will be used for both width and height. If an object is passed, the screenshot size
  31265. * will be derived from the parameters. The precision property is a multiplier allowing
  31266. * rendering at a higher or lower resolution
  31267. * @param successCallback The callback receives a single parameter which contains the
  31268. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31269. * src parameter of an <img> to display it
  31270. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31271. * Check your browser for supported MIME types
  31272. * @param samples Texture samples (default: 1)
  31273. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31274. * @param fileName A name for for the downloaded file.
  31275. */
  31276. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31277. /**
  31278. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31279. * Be aware Math.random() could cause collisions, but:
  31280. * "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"
  31281. * @returns a pseudo random id
  31282. */
  31283. static RandomId(): string;
  31284. /**
  31285. * Test if the given uri is a base64 string
  31286. * @param uri The uri to test
  31287. * @return True if the uri is a base64 string or false otherwise
  31288. */
  31289. static IsBase64(uri: string): boolean;
  31290. /**
  31291. * Decode the given base64 uri.
  31292. * @param uri The uri to decode
  31293. * @return The decoded base64 data.
  31294. */
  31295. static DecodeBase64(uri: string): ArrayBuffer;
  31296. /**
  31297. * Gets the absolute url.
  31298. * @param url the input url
  31299. * @return the absolute url
  31300. */
  31301. static GetAbsoluteUrl(url: string): string;
  31302. /**
  31303. * No log
  31304. */
  31305. static readonly NoneLogLevel: number;
  31306. /**
  31307. * Only message logs
  31308. */
  31309. static readonly MessageLogLevel: number;
  31310. /**
  31311. * Only warning logs
  31312. */
  31313. static readonly WarningLogLevel: number;
  31314. /**
  31315. * Only error logs
  31316. */
  31317. static readonly ErrorLogLevel: number;
  31318. /**
  31319. * All logs
  31320. */
  31321. static readonly AllLogLevel: number;
  31322. /**
  31323. * Gets a value indicating the number of loading errors
  31324. * @ignorenaming
  31325. */
  31326. static readonly errorsCount: number;
  31327. /**
  31328. * Callback called when a new log is added
  31329. */
  31330. static OnNewCacheEntry: (entry: string) => void;
  31331. /**
  31332. * Log a message to the console
  31333. * @param message defines the message to log
  31334. */
  31335. static Log(message: string): void;
  31336. /**
  31337. * Write a warning message to the console
  31338. * @param message defines the message to log
  31339. */
  31340. static Warn(message: string): void;
  31341. /**
  31342. * Write an error message to the console
  31343. * @param message defines the message to log
  31344. */
  31345. static Error(message: string): void;
  31346. /**
  31347. * Gets current log cache (list of logs)
  31348. */
  31349. static readonly LogCache: string;
  31350. /**
  31351. * Clears the log cache
  31352. */
  31353. static ClearLogCache(): void;
  31354. /**
  31355. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31356. */
  31357. static LogLevels: number;
  31358. /**
  31359. * Checks if the loaded document was accessed via `file:`-Protocol.
  31360. * @returns boolean
  31361. */
  31362. static IsFileURL(): boolean;
  31363. /**
  31364. * Checks if the window object exists
  31365. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31366. */
  31367. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31368. /**
  31369. * No performance log
  31370. */
  31371. static readonly PerformanceNoneLogLevel: number;
  31372. /**
  31373. * Use user marks to log performance
  31374. */
  31375. static readonly PerformanceUserMarkLogLevel: number;
  31376. /**
  31377. * Log performance to the console
  31378. */
  31379. static readonly PerformanceConsoleLogLevel: number;
  31380. private static _performance;
  31381. /**
  31382. * Sets the current performance log level
  31383. */
  31384. static PerformanceLogLevel: number;
  31385. private static _StartPerformanceCounterDisabled;
  31386. private static _EndPerformanceCounterDisabled;
  31387. private static _StartUserMark;
  31388. private static _EndUserMark;
  31389. private static _StartPerformanceConsole;
  31390. private static _EndPerformanceConsole;
  31391. /**
  31392. * Starts a performance counter
  31393. */
  31394. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31395. /**
  31396. * Ends a specific performance coutner
  31397. */
  31398. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31399. /**
  31400. * Gets either window.performance.now() if supported or Date.now() else
  31401. */
  31402. static readonly Now: number;
  31403. /**
  31404. * This method will return the name of the class used to create the instance of the given object.
  31405. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31406. * @param object the object to get the class name from
  31407. * @param isType defines if the object is actually a type
  31408. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31409. */
  31410. static GetClassName(object: any, isType?: boolean): string;
  31411. /**
  31412. * Gets the first element of an array satisfying a given predicate
  31413. * @param array defines the array to browse
  31414. * @param predicate defines the predicate to use
  31415. * @returns null if not found or the element
  31416. */
  31417. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31418. /**
  31419. * This method will return the name of the full name of the class, including its owning module (if any).
  31420. * 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).
  31421. * @param object the object to get the class name from
  31422. * @param isType defines if the object is actually a type
  31423. * @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.
  31424. * @ignorenaming
  31425. */
  31426. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31427. /**
  31428. * Returns a promise that resolves after the given amount of time.
  31429. * @param delay Number of milliseconds to delay
  31430. * @returns Promise that resolves after the given amount of time
  31431. */
  31432. static DelayAsync(delay: number): Promise<void>;
  31433. /**
  31434. * Gets the current gradient from an array of IValueGradient
  31435. * @param ratio defines the current ratio to get
  31436. * @param gradients defines the array of IValueGradient
  31437. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31438. */
  31439. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31440. }
  31441. /**
  31442. * This class is used to track a performance counter which is number based.
  31443. * The user has access to many properties which give statistics of different nature.
  31444. *
  31445. * The implementer can track two kinds of Performance Counter: time and count.
  31446. * 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.
  31447. * 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.
  31448. */
  31449. export class PerfCounter {
  31450. /**
  31451. * Gets or sets a global boolean to turn on and off all the counters
  31452. */
  31453. static Enabled: boolean;
  31454. /**
  31455. * Returns the smallest value ever
  31456. */
  31457. readonly min: number;
  31458. /**
  31459. * Returns the biggest value ever
  31460. */
  31461. readonly max: number;
  31462. /**
  31463. * Returns the average value since the performance counter is running
  31464. */
  31465. readonly average: number;
  31466. /**
  31467. * Returns the average value of the last second the counter was monitored
  31468. */
  31469. readonly lastSecAverage: number;
  31470. /**
  31471. * Returns the current value
  31472. */
  31473. readonly current: number;
  31474. /**
  31475. * Gets the accumulated total
  31476. */
  31477. readonly total: number;
  31478. /**
  31479. * Gets the total value count
  31480. */
  31481. readonly count: number;
  31482. /**
  31483. * Creates a new counter
  31484. */
  31485. constructor();
  31486. /**
  31487. * Call this method to start monitoring a new frame.
  31488. * 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.
  31489. */
  31490. fetchNewFrame(): void;
  31491. /**
  31492. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31493. * @param newCount the count value to add to the monitored count
  31494. * @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.
  31495. */
  31496. addCount(newCount: number, fetchResult: boolean): void;
  31497. /**
  31498. * Start monitoring this performance counter
  31499. */
  31500. beginMonitoring(): void;
  31501. /**
  31502. * Compute the time lapsed since the previous beginMonitoring() call.
  31503. * @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
  31504. */
  31505. endMonitoring(newFrame?: boolean): void;
  31506. private _fetchResult;
  31507. private _startMonitoringTime;
  31508. private _min;
  31509. private _max;
  31510. private _average;
  31511. private _current;
  31512. private _totalValueCount;
  31513. private _totalAccumulated;
  31514. private _lastSecAverage;
  31515. private _lastSecAccumulated;
  31516. private _lastSecTime;
  31517. private _lastSecValueCount;
  31518. }
  31519. /**
  31520. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31521. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31522. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31523. * @param name The name of the class, case should be preserved
  31524. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31525. */
  31526. export function className(name: string, module?: string): (target: Object) => void;
  31527. /**
  31528. * An implementation of a loop for asynchronous functions.
  31529. */
  31530. export class AsyncLoop {
  31531. /**
  31532. * Defines the number of iterations for the loop
  31533. */
  31534. iterations: number;
  31535. /**
  31536. * Defines the current index of the loop.
  31537. */
  31538. index: number;
  31539. private _done;
  31540. private _fn;
  31541. private _successCallback;
  31542. /**
  31543. * Constructor.
  31544. * @param iterations the number of iterations.
  31545. * @param func the function to run each iteration
  31546. * @param successCallback the callback that will be called upon succesful execution
  31547. * @param offset starting offset.
  31548. */
  31549. constructor(
  31550. /**
  31551. * Defines the number of iterations for the loop
  31552. */
  31553. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31554. /**
  31555. * Execute the next iteration. Must be called after the last iteration was finished.
  31556. */
  31557. executeNext(): void;
  31558. /**
  31559. * Break the loop and run the success callback.
  31560. */
  31561. breakLoop(): void;
  31562. /**
  31563. * Create and run an async loop.
  31564. * @param iterations the number of iterations.
  31565. * @param fn the function to run each iteration
  31566. * @param successCallback the callback that will be called upon succesful execution
  31567. * @param offset starting offset.
  31568. * @returns the created async loop object
  31569. */
  31570. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31571. /**
  31572. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31573. * @param iterations total number of iterations
  31574. * @param syncedIterations number of synchronous iterations in each async iteration.
  31575. * @param fn the function to call each iteration.
  31576. * @param callback a success call back that will be called when iterating stops.
  31577. * @param breakFunction a break condition (optional)
  31578. * @param timeout timeout settings for the setTimeout function. default - 0.
  31579. * @returns the created async loop object
  31580. */
  31581. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31582. }
  31583. }
  31584. declare module BABYLON {
  31585. /** @hidden */
  31586. export interface ICollisionCoordinator {
  31587. createCollider(): Collider;
  31588. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31589. init(scene: Scene): void;
  31590. }
  31591. /** @hidden */
  31592. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31593. private _scene;
  31594. private _scaledPosition;
  31595. private _scaledVelocity;
  31596. private _finalPosition;
  31597. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31598. createCollider(): Collider;
  31599. init(scene: Scene): void;
  31600. private _collideWithWorld;
  31601. }
  31602. }
  31603. declare module BABYLON {
  31604. /**
  31605. * Class used to manage all inputs for the scene.
  31606. */
  31607. export class InputManager {
  31608. /** The distance in pixel that you have to move to prevent some events */
  31609. static DragMovementThreshold: number;
  31610. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  31611. static LongPressDelay: number;
  31612. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  31613. static DoubleClickDelay: number;
  31614. /** If you need to check double click without raising a single click at first click, enable this flag */
  31615. static ExclusiveDoubleClickMode: boolean;
  31616. private _wheelEventName;
  31617. private _onPointerMove;
  31618. private _onPointerDown;
  31619. private _onPointerUp;
  31620. private _initClickEvent;
  31621. private _initActionManager;
  31622. private _delayedSimpleClick;
  31623. private _delayedSimpleClickTimeout;
  31624. private _previousDelayedSimpleClickTimeout;
  31625. private _meshPickProceed;
  31626. private _previousButtonPressed;
  31627. private _currentPickResult;
  31628. private _previousPickResult;
  31629. private _totalPointersPressed;
  31630. private _doubleClickOccured;
  31631. private _pointerOverMesh;
  31632. private _pickedDownMesh;
  31633. private _pickedUpMesh;
  31634. private _pointerX;
  31635. private _pointerY;
  31636. private _unTranslatedPointerX;
  31637. private _unTranslatedPointerY;
  31638. private _startingPointerPosition;
  31639. private _previousStartingPointerPosition;
  31640. private _startingPointerTime;
  31641. private _previousStartingPointerTime;
  31642. private _pointerCaptures;
  31643. private _onKeyDown;
  31644. private _onKeyUp;
  31645. private _onCanvasFocusObserver;
  31646. private _onCanvasBlurObserver;
  31647. private _scene;
  31648. /**
  31649. * Creates a new InputManager
  31650. * @param scene defines the hosting scene
  31651. */
  31652. constructor(scene: Scene);
  31653. /**
  31654. * Gets the mesh that is currently under the pointer
  31655. */
  31656. readonly meshUnderPointer: Nullable<AbstractMesh>;
  31657. /**
  31658. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  31659. */
  31660. readonly unTranslatedPointer: Vector2;
  31661. /**
  31662. * Gets or sets the current on-screen X position of the pointer
  31663. */
  31664. pointerX: number;
  31665. /**
  31666. * Gets or sets the current on-screen Y position of the pointer
  31667. */
  31668. pointerY: number;
  31669. private _updatePointerPosition;
  31670. private _processPointerMove;
  31671. private _setRayOnPointerInfo;
  31672. private _checkPrePointerObservable;
  31673. /**
  31674. * Use this method to simulate a pointer move on a mesh
  31675. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31676. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31677. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31678. */
  31679. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  31680. /**
  31681. * Use this method to simulate a pointer down on a mesh
  31682. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31683. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31684. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31685. */
  31686. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  31687. private _processPointerDown;
  31688. /** @hidden */
  31689. _isPointerSwiping(): boolean;
  31690. /**
  31691. * Use this method to simulate a pointer up on a mesh
  31692. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31693. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31694. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31695. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  31696. */
  31697. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  31698. private _processPointerUp;
  31699. /**
  31700. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  31701. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  31702. * @returns true if the pointer was captured
  31703. */
  31704. isPointerCaptured(pointerId?: number): boolean;
  31705. /**
  31706. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  31707. * @param attachUp defines if you want to attach events to pointerup
  31708. * @param attachDown defines if you want to attach events to pointerdown
  31709. * @param attachMove defines if you want to attach events to pointermove
  31710. */
  31711. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  31712. /**
  31713. * Detaches all event handlers
  31714. */
  31715. detachControl(): void;
  31716. /**
  31717. * Force the value of meshUnderPointer
  31718. * @param mesh defines the mesh to use
  31719. */
  31720. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  31721. /**
  31722. * Gets the mesh under the pointer
  31723. * @returns a Mesh or null if no mesh is under the pointer
  31724. */
  31725. getPointerOverMesh(): Nullable<AbstractMesh>;
  31726. }
  31727. }
  31728. declare module BABYLON {
  31729. /**
  31730. * This class defines the direct association between an animation and a target
  31731. */
  31732. export class TargetedAnimation {
  31733. /**
  31734. * Animation to perform
  31735. */
  31736. animation: Animation;
  31737. /**
  31738. * Target to animate
  31739. */
  31740. target: any;
  31741. /**
  31742. * Serialize the object
  31743. * @returns the JSON object representing the current entity
  31744. */
  31745. serialize(): any;
  31746. }
  31747. /**
  31748. * Use this class to create coordinated animations on multiple targets
  31749. */
  31750. export class AnimationGroup implements IDisposable {
  31751. /** The name of the animation group */
  31752. name: string;
  31753. private _scene;
  31754. private _targetedAnimations;
  31755. private _animatables;
  31756. private _from;
  31757. private _to;
  31758. private _isStarted;
  31759. private _isPaused;
  31760. private _speedRatio;
  31761. private _loopAnimation;
  31762. /**
  31763. * Gets or sets the unique id of the node
  31764. */
  31765. uniqueId: number;
  31766. /**
  31767. * This observable will notify when one animation have ended
  31768. */
  31769. onAnimationEndObservable: Observable<TargetedAnimation>;
  31770. /**
  31771. * Observer raised when one animation loops
  31772. */
  31773. onAnimationLoopObservable: Observable<TargetedAnimation>;
  31774. /**
  31775. * This observable will notify when all animations have ended.
  31776. */
  31777. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  31778. /**
  31779. * This observable will notify when all animations have paused.
  31780. */
  31781. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  31782. /**
  31783. * This observable will notify when all animations are playing.
  31784. */
  31785. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  31786. /**
  31787. * Gets the first frame
  31788. */
  31789. readonly from: number;
  31790. /**
  31791. * Gets the last frame
  31792. */
  31793. readonly to: number;
  31794. /**
  31795. * Define if the animations are started
  31796. */
  31797. readonly isStarted: boolean;
  31798. /**
  31799. * Gets a value indicating that the current group is playing
  31800. */
  31801. readonly isPlaying: boolean;
  31802. /**
  31803. * Gets or sets the speed ratio to use for all animations
  31804. */
  31805. /**
  31806. * Gets or sets the speed ratio to use for all animations
  31807. */
  31808. speedRatio: number;
  31809. /**
  31810. * Gets or sets if all animations should loop or not
  31811. */
  31812. loopAnimation: boolean;
  31813. /**
  31814. * Gets the targeted animations for this animation group
  31815. */
  31816. readonly targetedAnimations: Array<TargetedAnimation>;
  31817. /**
  31818. * returning the list of animatables controlled by this animation group.
  31819. */
  31820. readonly animatables: Array<Animatable>;
  31821. /**
  31822. * Instantiates a new Animation Group.
  31823. * This helps managing several animations at once.
  31824. * @see http://doc.babylonjs.com/how_to/group
  31825. * @param name Defines the name of the group
  31826. * @param scene Defines the scene the group belongs to
  31827. */
  31828. constructor(
  31829. /** The name of the animation group */
  31830. name: string, scene?: Nullable<Scene>);
  31831. /**
  31832. * Add an animation (with its target) in the group
  31833. * @param animation defines the animation we want to add
  31834. * @param target defines the target of the animation
  31835. * @returns the TargetedAnimation object
  31836. */
  31837. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  31838. /**
  31839. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  31840. * It can add constant keys at begin or end
  31841. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  31842. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  31843. * @returns the animation group
  31844. */
  31845. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  31846. /**
  31847. * Start all animations on given targets
  31848. * @param loop defines if animations must loop
  31849. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  31850. * @param from defines the from key (optional)
  31851. * @param to defines the to key (optional)
  31852. * @returns the current animation group
  31853. */
  31854. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  31855. /**
  31856. * Pause all animations
  31857. * @returns the animation group
  31858. */
  31859. pause(): AnimationGroup;
  31860. /**
  31861. * Play all animations to initial state
  31862. * This function will start() the animations if they were not started or will restart() them if they were paused
  31863. * @param loop defines if animations must loop
  31864. * @returns the animation group
  31865. */
  31866. play(loop?: boolean): AnimationGroup;
  31867. /**
  31868. * Reset all animations to initial state
  31869. * @returns the animation group
  31870. */
  31871. reset(): AnimationGroup;
  31872. /**
  31873. * Restart animations from key 0
  31874. * @returns the animation group
  31875. */
  31876. restart(): AnimationGroup;
  31877. /**
  31878. * Stop all animations
  31879. * @returns the animation group
  31880. */
  31881. stop(): AnimationGroup;
  31882. /**
  31883. * Set animation weight for all animatables
  31884. * @param weight defines the weight to use
  31885. * @return the animationGroup
  31886. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31887. */
  31888. setWeightForAllAnimatables(weight: number): AnimationGroup;
  31889. /**
  31890. * Synchronize and normalize all animatables with a source animatable
  31891. * @param root defines the root animatable to synchronize with
  31892. * @return the animationGroup
  31893. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31894. */
  31895. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  31896. /**
  31897. * Goes to a specific frame in this animation group
  31898. * @param frame the frame number to go to
  31899. * @return the animationGroup
  31900. */
  31901. goToFrame(frame: number): AnimationGroup;
  31902. /**
  31903. * Dispose all associated resources
  31904. */
  31905. dispose(): void;
  31906. private _checkAnimationGroupEnded;
  31907. /**
  31908. * Clone the current animation group and returns a copy
  31909. * @param newName defines the name of the new group
  31910. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  31911. * @returns the new aniamtion group
  31912. */
  31913. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  31914. /**
  31915. * Serializes the animationGroup to an object
  31916. * @returns Serialized object
  31917. */
  31918. serialize(): any;
  31919. /**
  31920. * Returns a new AnimationGroup object parsed from the source provided.
  31921. * @param parsedAnimationGroup defines the source
  31922. * @param scene defines the scene that will receive the animationGroup
  31923. * @returns a new AnimationGroup
  31924. */
  31925. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  31926. /**
  31927. * Returns the string "AnimationGroup"
  31928. * @returns "AnimationGroup"
  31929. */
  31930. getClassName(): string;
  31931. /**
  31932. * Creates a detailled string about the object
  31933. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  31934. * @returns a string representing the object
  31935. */
  31936. toString(fullDetails?: boolean): string;
  31937. }
  31938. }
  31939. declare module BABYLON {
  31940. /**
  31941. * Define an interface for all classes that will hold resources
  31942. */
  31943. export interface IDisposable {
  31944. /**
  31945. * Releases all held resources
  31946. */
  31947. dispose(): void;
  31948. }
  31949. /** Interface defining initialization parameters for Scene class */
  31950. export interface SceneOptions {
  31951. /**
  31952. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  31953. * It will improve performance when the number of geometries becomes important.
  31954. */
  31955. useGeometryUniqueIdsMap?: boolean;
  31956. /**
  31957. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  31958. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31959. */
  31960. useMaterialMeshMap?: boolean;
  31961. /**
  31962. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  31963. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31964. */
  31965. useClonedMeshhMap?: boolean;
  31966. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  31967. virtual?: boolean;
  31968. }
  31969. /**
  31970. * Represents a scene to be rendered by the engine.
  31971. * @see http://doc.babylonjs.com/features/scene
  31972. */
  31973. export class Scene extends AbstractScene implements IAnimatable {
  31974. private static _uniqueIdCounter;
  31975. /** The fog is deactivated */
  31976. static readonly FOGMODE_NONE: number;
  31977. /** The fog density is following an exponential function */
  31978. static readonly FOGMODE_EXP: number;
  31979. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  31980. static readonly FOGMODE_EXP2: number;
  31981. /** The fog density is following a linear function. */
  31982. static readonly FOGMODE_LINEAR: number;
  31983. /**
  31984. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  31985. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31986. */
  31987. static MinDeltaTime: number;
  31988. /**
  31989. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  31990. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31991. */
  31992. static MaxDeltaTime: number;
  31993. /**
  31994. * Factory used to create the default material.
  31995. * @param name The name of the material to create
  31996. * @param scene The scene to create the material for
  31997. * @returns The default material
  31998. */
  31999. static DefaultMaterialFactory(scene: Scene): Material;
  32000. /**
  32001. * Factory used to create the a collision coordinator.
  32002. * @returns The collision coordinator
  32003. */
  32004. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32005. /** @hidden */
  32006. _inputManager: InputManager;
  32007. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32008. cameraToUseForPointers: Nullable<Camera>;
  32009. /** @hidden */
  32010. readonly _isScene: boolean;
  32011. /**
  32012. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32013. */
  32014. autoClear: boolean;
  32015. /**
  32016. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32017. */
  32018. autoClearDepthAndStencil: boolean;
  32019. /**
  32020. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32021. */
  32022. clearColor: Color4;
  32023. /**
  32024. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32025. */
  32026. ambientColor: Color3;
  32027. /**
  32028. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32029. * It should only be one of the following (if not the default embedded one):
  32030. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32031. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32032. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32033. * The material properties need to be setup according to the type of texture in use.
  32034. */
  32035. environmentBRDFTexture: BaseTexture;
  32036. /** @hidden */
  32037. protected _environmentTexture: Nullable<BaseTexture>;
  32038. /**
  32039. * Texture used in all pbr material as the reflection texture.
  32040. * As in the majority of the scene they are the same (exception for multi room and so on),
  32041. * this is easier to reference from here than from all the materials.
  32042. */
  32043. /**
  32044. * Texture used in all pbr material as the reflection texture.
  32045. * As in the majority of the scene they are the same (exception for multi room and so on),
  32046. * this is easier to set here than in all the materials.
  32047. */
  32048. environmentTexture: Nullable<BaseTexture>;
  32049. /** @hidden */
  32050. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32051. /**
  32052. * Default image processing configuration used either in the rendering
  32053. * Forward main pass or through the imageProcessingPostProcess if present.
  32054. * As in the majority of the scene they are the same (exception for multi camera),
  32055. * this is easier to reference from here than from all the materials and post process.
  32056. *
  32057. * No setter as we it is a shared configuration, you can set the values instead.
  32058. */
  32059. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32060. private _forceWireframe;
  32061. /**
  32062. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32063. */
  32064. forceWireframe: boolean;
  32065. private _forcePointsCloud;
  32066. /**
  32067. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32068. */
  32069. forcePointsCloud: boolean;
  32070. /**
  32071. * Gets or sets the active clipplane 1
  32072. */
  32073. clipPlane: Nullable<Plane>;
  32074. /**
  32075. * Gets or sets the active clipplane 2
  32076. */
  32077. clipPlane2: Nullable<Plane>;
  32078. /**
  32079. * Gets or sets the active clipplane 3
  32080. */
  32081. clipPlane3: Nullable<Plane>;
  32082. /**
  32083. * Gets or sets the active clipplane 4
  32084. */
  32085. clipPlane4: Nullable<Plane>;
  32086. /**
  32087. * Gets or sets a boolean indicating if animations are enabled
  32088. */
  32089. animationsEnabled: boolean;
  32090. private _animationPropertiesOverride;
  32091. /**
  32092. * Gets or sets the animation properties override
  32093. */
  32094. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32095. /**
  32096. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32097. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32098. */
  32099. useConstantAnimationDeltaTime: boolean;
  32100. /**
  32101. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32102. * Please note that it requires to run a ray cast through the scene on every frame
  32103. */
  32104. constantlyUpdateMeshUnderPointer: boolean;
  32105. /**
  32106. * Defines the HTML cursor to use when hovering over interactive elements
  32107. */
  32108. hoverCursor: string;
  32109. /**
  32110. * Defines the HTML default cursor to use (empty by default)
  32111. */
  32112. defaultCursor: string;
  32113. /**
  32114. * This is used to call preventDefault() on pointer down
  32115. * in order to block unwanted artifacts like system double clicks
  32116. */
  32117. preventDefaultOnPointerDown: boolean;
  32118. /**
  32119. * This is used to call preventDefault() on pointer up
  32120. * in order to block unwanted artifacts like system double clicks
  32121. */
  32122. preventDefaultOnPointerUp: boolean;
  32123. /**
  32124. * Gets or sets user defined metadata
  32125. */
  32126. metadata: any;
  32127. /**
  32128. * For internal use only. Please do not use.
  32129. */
  32130. reservedDataStore: any;
  32131. /**
  32132. * Gets the name of the plugin used to load this scene (null by default)
  32133. */
  32134. loadingPluginName: string;
  32135. /**
  32136. * Use this array to add regular expressions used to disable offline support for specific urls
  32137. */
  32138. disableOfflineSupportExceptionRules: RegExp[];
  32139. /**
  32140. * An event triggered when the scene is disposed.
  32141. */
  32142. onDisposeObservable: Observable<Scene>;
  32143. private _onDisposeObserver;
  32144. /** Sets a function to be executed when this scene is disposed. */
  32145. onDispose: () => void;
  32146. /**
  32147. * An event triggered before rendering the scene (right after animations and physics)
  32148. */
  32149. onBeforeRenderObservable: Observable<Scene>;
  32150. private _onBeforeRenderObserver;
  32151. /** Sets a function to be executed before rendering this scene */
  32152. beforeRender: Nullable<() => void>;
  32153. /**
  32154. * An event triggered after rendering the scene
  32155. */
  32156. onAfterRenderObservable: Observable<Scene>;
  32157. private _onAfterRenderObserver;
  32158. /** Sets a function to be executed after rendering this scene */
  32159. afterRender: Nullable<() => void>;
  32160. /**
  32161. * An event triggered before animating the scene
  32162. */
  32163. onBeforeAnimationsObservable: Observable<Scene>;
  32164. /**
  32165. * An event triggered after animations processing
  32166. */
  32167. onAfterAnimationsObservable: Observable<Scene>;
  32168. /**
  32169. * An event triggered before draw calls are ready to be sent
  32170. */
  32171. onBeforeDrawPhaseObservable: Observable<Scene>;
  32172. /**
  32173. * An event triggered after draw calls have been sent
  32174. */
  32175. onAfterDrawPhaseObservable: Observable<Scene>;
  32176. /**
  32177. * An event triggered when the scene is ready
  32178. */
  32179. onReadyObservable: Observable<Scene>;
  32180. /**
  32181. * An event triggered before rendering a camera
  32182. */
  32183. onBeforeCameraRenderObservable: Observable<Camera>;
  32184. private _onBeforeCameraRenderObserver;
  32185. /** Sets a function to be executed before rendering a camera*/
  32186. beforeCameraRender: () => void;
  32187. /**
  32188. * An event triggered after rendering a camera
  32189. */
  32190. onAfterCameraRenderObservable: Observable<Camera>;
  32191. private _onAfterCameraRenderObserver;
  32192. /** Sets a function to be executed after rendering a camera*/
  32193. afterCameraRender: () => void;
  32194. /**
  32195. * An event triggered when active meshes evaluation is about to start
  32196. */
  32197. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32198. /**
  32199. * An event triggered when active meshes evaluation is done
  32200. */
  32201. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32202. /**
  32203. * An event triggered when particles rendering is about to start
  32204. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32205. */
  32206. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32207. /**
  32208. * An event triggered when particles rendering is done
  32209. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32210. */
  32211. onAfterParticlesRenderingObservable: Observable<Scene>;
  32212. /**
  32213. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32214. */
  32215. onDataLoadedObservable: Observable<Scene>;
  32216. /**
  32217. * An event triggered when a camera is created
  32218. */
  32219. onNewCameraAddedObservable: Observable<Camera>;
  32220. /**
  32221. * An event triggered when a camera is removed
  32222. */
  32223. onCameraRemovedObservable: Observable<Camera>;
  32224. /**
  32225. * An event triggered when a light is created
  32226. */
  32227. onNewLightAddedObservable: Observable<Light>;
  32228. /**
  32229. * An event triggered when a light is removed
  32230. */
  32231. onLightRemovedObservable: Observable<Light>;
  32232. /**
  32233. * An event triggered when a geometry is created
  32234. */
  32235. onNewGeometryAddedObservable: Observable<Geometry>;
  32236. /**
  32237. * An event triggered when a geometry is removed
  32238. */
  32239. onGeometryRemovedObservable: Observable<Geometry>;
  32240. /**
  32241. * An event triggered when a transform node is created
  32242. */
  32243. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32244. /**
  32245. * An event triggered when a transform node is removed
  32246. */
  32247. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32248. /**
  32249. * An event triggered when a mesh is created
  32250. */
  32251. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32252. /**
  32253. * An event triggered when a mesh is removed
  32254. */
  32255. onMeshRemovedObservable: Observable<AbstractMesh>;
  32256. /**
  32257. * An event triggered when a skeleton is created
  32258. */
  32259. onNewSkeletonAddedObservable: Observable<Skeleton>;
  32260. /**
  32261. * An event triggered when a skeleton is removed
  32262. */
  32263. onSkeletonRemovedObservable: Observable<Skeleton>;
  32264. /**
  32265. * An event triggered when a material is created
  32266. */
  32267. onNewMaterialAddedObservable: Observable<Material>;
  32268. /**
  32269. * An event triggered when a material is removed
  32270. */
  32271. onMaterialRemovedObservable: Observable<Material>;
  32272. /**
  32273. * An event triggered when a texture is created
  32274. */
  32275. onNewTextureAddedObservable: Observable<BaseTexture>;
  32276. /**
  32277. * An event triggered when a texture is removed
  32278. */
  32279. onTextureRemovedObservable: Observable<BaseTexture>;
  32280. /**
  32281. * An event triggered when render targets are about to be rendered
  32282. * Can happen multiple times per frame.
  32283. */
  32284. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32285. /**
  32286. * An event triggered when render targets were rendered.
  32287. * Can happen multiple times per frame.
  32288. */
  32289. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32290. /**
  32291. * An event triggered before calculating deterministic simulation step
  32292. */
  32293. onBeforeStepObservable: Observable<Scene>;
  32294. /**
  32295. * An event triggered after calculating deterministic simulation step
  32296. */
  32297. onAfterStepObservable: Observable<Scene>;
  32298. /**
  32299. * An event triggered when the activeCamera property is updated
  32300. */
  32301. onActiveCameraChanged: Observable<Scene>;
  32302. /**
  32303. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32304. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32305. * 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)
  32306. */
  32307. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32308. /**
  32309. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32310. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32311. * 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)
  32312. */
  32313. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32314. /**
  32315. * This Observable will when a mesh has been imported into the scene.
  32316. */
  32317. onMeshImportedObservable: Observable<AbstractMesh>;
  32318. /**
  32319. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32320. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32321. */
  32322. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32323. /** @hidden */
  32324. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32325. /**
  32326. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32327. */
  32328. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32329. /**
  32330. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32331. */
  32332. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32333. /**
  32334. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32335. */
  32336. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32337. /** Callback called when a pointer move is detected */
  32338. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32339. /** Callback called when a pointer down is detected */
  32340. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32341. /** Callback called when a pointer up is detected */
  32342. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32343. /** Callback called when a pointer pick is detected */
  32344. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32345. /**
  32346. * 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).
  32347. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32348. */
  32349. onPrePointerObservable: Observable<PointerInfoPre>;
  32350. /**
  32351. * Observable event triggered each time an input event is received from the rendering canvas
  32352. */
  32353. onPointerObservable: Observable<PointerInfo>;
  32354. /**
  32355. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32356. */
  32357. readonly unTranslatedPointer: Vector2;
  32358. /**
  32359. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  32360. */
  32361. static DragMovementThreshold: number;
  32362. /**
  32363. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  32364. */
  32365. static LongPressDelay: number;
  32366. /**
  32367. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  32368. */
  32369. static DoubleClickDelay: number;
  32370. /** If you need to check double click without raising a single click at first click, enable this flag */
  32371. static ExclusiveDoubleClickMode: boolean;
  32372. /** @hidden */
  32373. _mirroredCameraPosition: Nullable<Vector3>;
  32374. /**
  32375. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32376. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32377. */
  32378. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32379. /**
  32380. * Observable event triggered each time an keyboard event is received from the hosting window
  32381. */
  32382. onKeyboardObservable: Observable<KeyboardInfo>;
  32383. private _useRightHandedSystem;
  32384. /**
  32385. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32386. */
  32387. useRightHandedSystem: boolean;
  32388. private _timeAccumulator;
  32389. private _currentStepId;
  32390. private _currentInternalStep;
  32391. /**
  32392. * Sets the step Id used by deterministic lock step
  32393. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32394. * @param newStepId defines the step Id
  32395. */
  32396. setStepId(newStepId: number): void;
  32397. /**
  32398. * Gets the step Id used by deterministic lock step
  32399. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32400. * @returns the step Id
  32401. */
  32402. getStepId(): number;
  32403. /**
  32404. * Gets the internal step used by deterministic lock step
  32405. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32406. * @returns the internal step
  32407. */
  32408. getInternalStep(): number;
  32409. private _fogEnabled;
  32410. /**
  32411. * Gets or sets a boolean indicating if fog is enabled on this scene
  32412. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32413. * (Default is true)
  32414. */
  32415. fogEnabled: boolean;
  32416. private _fogMode;
  32417. /**
  32418. * Gets or sets the fog mode to use
  32419. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32420. * | mode | value |
  32421. * | --- | --- |
  32422. * | FOGMODE_NONE | 0 |
  32423. * | FOGMODE_EXP | 1 |
  32424. * | FOGMODE_EXP2 | 2 |
  32425. * | FOGMODE_LINEAR | 3 |
  32426. */
  32427. fogMode: number;
  32428. /**
  32429. * Gets or sets the fog color to use
  32430. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32431. * (Default is Color3(0.2, 0.2, 0.3))
  32432. */
  32433. fogColor: Color3;
  32434. /**
  32435. * Gets or sets the fog density to use
  32436. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32437. * (Default is 0.1)
  32438. */
  32439. fogDensity: number;
  32440. /**
  32441. * Gets or sets the fog start distance to use
  32442. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32443. * (Default is 0)
  32444. */
  32445. fogStart: number;
  32446. /**
  32447. * Gets or sets the fog end distance to use
  32448. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32449. * (Default is 1000)
  32450. */
  32451. fogEnd: number;
  32452. private _shadowsEnabled;
  32453. /**
  32454. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32455. */
  32456. shadowsEnabled: boolean;
  32457. private _lightsEnabled;
  32458. /**
  32459. * Gets or sets a boolean indicating if lights are enabled on this scene
  32460. */
  32461. lightsEnabled: boolean;
  32462. /** All of the active cameras added to this scene. */
  32463. activeCameras: Camera[];
  32464. /** @hidden */
  32465. _activeCamera: Nullable<Camera>;
  32466. /** Gets or sets the current active camera */
  32467. activeCamera: Nullable<Camera>;
  32468. private _defaultMaterial;
  32469. /** The default material used on meshes when no material is affected */
  32470. /** The default material used on meshes when no material is affected */
  32471. defaultMaterial: Material;
  32472. private _texturesEnabled;
  32473. /**
  32474. * Gets or sets a boolean indicating if textures are enabled on this scene
  32475. */
  32476. texturesEnabled: boolean;
  32477. /**
  32478. * Gets or sets a boolean indicating if particles are enabled on this scene
  32479. */
  32480. particlesEnabled: boolean;
  32481. /**
  32482. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32483. */
  32484. spritesEnabled: boolean;
  32485. private _skeletonsEnabled;
  32486. /**
  32487. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32488. */
  32489. skeletonsEnabled: boolean;
  32490. /**
  32491. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32492. */
  32493. lensFlaresEnabled: boolean;
  32494. /**
  32495. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32496. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32497. */
  32498. collisionsEnabled: boolean;
  32499. private _collisionCoordinator;
  32500. /** @hidden */
  32501. readonly collisionCoordinator: ICollisionCoordinator;
  32502. /**
  32503. * Defines the gravity applied to this scene (used only for collisions)
  32504. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32505. */
  32506. gravity: Vector3;
  32507. /**
  32508. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32509. */
  32510. postProcessesEnabled: boolean;
  32511. /**
  32512. * The list of postprocesses added to the scene
  32513. */
  32514. postProcesses: PostProcess[];
  32515. /**
  32516. * Gets the current postprocess manager
  32517. */
  32518. postProcessManager: PostProcessManager;
  32519. /**
  32520. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32521. */
  32522. renderTargetsEnabled: boolean;
  32523. /**
  32524. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32525. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32526. */
  32527. dumpNextRenderTargets: boolean;
  32528. /**
  32529. * The list of user defined render targets added to the scene
  32530. */
  32531. customRenderTargets: RenderTargetTexture[];
  32532. /**
  32533. * Defines if texture loading must be delayed
  32534. * If true, textures will only be loaded when they need to be rendered
  32535. */
  32536. useDelayedTextureLoading: boolean;
  32537. /**
  32538. * Gets the list of meshes imported to the scene through SceneLoader
  32539. */
  32540. importedMeshesFiles: String[];
  32541. /**
  32542. * Gets or sets a boolean indicating if probes are enabled on this scene
  32543. */
  32544. probesEnabled: boolean;
  32545. /**
  32546. * Gets or sets the current offline provider to use to store scene data
  32547. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32548. */
  32549. offlineProvider: IOfflineProvider;
  32550. /**
  32551. * Gets or sets the action manager associated with the scene
  32552. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32553. */
  32554. actionManager: AbstractActionManager;
  32555. private _meshesForIntersections;
  32556. /**
  32557. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32558. */
  32559. proceduralTexturesEnabled: boolean;
  32560. private _engine;
  32561. private _totalVertices;
  32562. /** @hidden */
  32563. _activeIndices: PerfCounter;
  32564. /** @hidden */
  32565. _activeParticles: PerfCounter;
  32566. /** @hidden */
  32567. _activeBones: PerfCounter;
  32568. private _animationRatio;
  32569. /** @hidden */
  32570. _animationTimeLast: number;
  32571. /** @hidden */
  32572. _animationTime: number;
  32573. /**
  32574. * Gets or sets a general scale for animation speed
  32575. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32576. */
  32577. animationTimeScale: number;
  32578. /** @hidden */
  32579. _cachedMaterial: Nullable<Material>;
  32580. /** @hidden */
  32581. _cachedEffect: Nullable<Effect>;
  32582. /** @hidden */
  32583. _cachedVisibility: Nullable<number>;
  32584. private _renderId;
  32585. private _frameId;
  32586. private _executeWhenReadyTimeoutId;
  32587. private _intermediateRendering;
  32588. private _viewUpdateFlag;
  32589. private _projectionUpdateFlag;
  32590. /** @hidden */
  32591. _toBeDisposed: Nullable<IDisposable>[];
  32592. private _activeRequests;
  32593. /** @hidden */
  32594. _pendingData: any[];
  32595. private _isDisposed;
  32596. /**
  32597. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32598. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32599. */
  32600. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32601. private _activeMeshes;
  32602. private _processedMaterials;
  32603. private _renderTargets;
  32604. /** @hidden */
  32605. _activeParticleSystems: SmartArray<IParticleSystem>;
  32606. private _activeSkeletons;
  32607. private _softwareSkinnedMeshes;
  32608. private _renderingManager;
  32609. /** @hidden */
  32610. _activeAnimatables: Animatable[];
  32611. private _transformMatrix;
  32612. private _sceneUbo;
  32613. /** @hidden */
  32614. _viewMatrix: Matrix;
  32615. private _projectionMatrix;
  32616. /** @hidden */
  32617. _forcedViewPosition: Nullable<Vector3>;
  32618. /** @hidden */
  32619. _frustumPlanes: Plane[];
  32620. /**
  32621. * Gets the list of frustum planes (built from the active camera)
  32622. */
  32623. readonly frustumPlanes: Plane[];
  32624. /**
  32625. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32626. * This is useful if there are more lights that the maximum simulteanous authorized
  32627. */
  32628. requireLightSorting: boolean;
  32629. /** @hidden */
  32630. readonly useMaterialMeshMap: boolean;
  32631. /** @hidden */
  32632. readonly useClonedMeshhMap: boolean;
  32633. private _externalData;
  32634. private _uid;
  32635. /**
  32636. * @hidden
  32637. * Backing store of defined scene components.
  32638. */
  32639. _components: ISceneComponent[];
  32640. /**
  32641. * @hidden
  32642. * Backing store of defined scene components.
  32643. */
  32644. _serializableComponents: ISceneSerializableComponent[];
  32645. /**
  32646. * List of components to register on the next registration step.
  32647. */
  32648. private _transientComponents;
  32649. /**
  32650. * Registers the transient components if needed.
  32651. */
  32652. private _registerTransientComponents;
  32653. /**
  32654. * @hidden
  32655. * Add a component to the scene.
  32656. * Note that the ccomponent could be registered on th next frame if this is called after
  32657. * the register component stage.
  32658. * @param component Defines the component to add to the scene
  32659. */
  32660. _addComponent(component: ISceneComponent): void;
  32661. /**
  32662. * @hidden
  32663. * Gets a component from the scene.
  32664. * @param name defines the name of the component to retrieve
  32665. * @returns the component or null if not present
  32666. */
  32667. _getComponent(name: string): Nullable<ISceneComponent>;
  32668. /**
  32669. * @hidden
  32670. * Defines the actions happening before camera updates.
  32671. */
  32672. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32673. /**
  32674. * @hidden
  32675. * Defines the actions happening before clear the canvas.
  32676. */
  32677. _beforeClearStage: Stage<SimpleStageAction>;
  32678. /**
  32679. * @hidden
  32680. * Defines the actions when collecting render targets for the frame.
  32681. */
  32682. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32683. /**
  32684. * @hidden
  32685. * Defines the actions happening for one camera in the frame.
  32686. */
  32687. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32688. /**
  32689. * @hidden
  32690. * Defines the actions happening during the per mesh ready checks.
  32691. */
  32692. _isReadyForMeshStage: Stage<MeshStageAction>;
  32693. /**
  32694. * @hidden
  32695. * Defines the actions happening before evaluate active mesh checks.
  32696. */
  32697. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  32698. /**
  32699. * @hidden
  32700. * Defines the actions happening during the evaluate sub mesh checks.
  32701. */
  32702. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  32703. /**
  32704. * @hidden
  32705. * Defines the actions happening during the active mesh stage.
  32706. */
  32707. _activeMeshStage: Stage<ActiveMeshStageAction>;
  32708. /**
  32709. * @hidden
  32710. * Defines the actions happening during the per camera render target step.
  32711. */
  32712. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  32713. /**
  32714. * @hidden
  32715. * Defines the actions happening just before the active camera is drawing.
  32716. */
  32717. _beforeCameraDrawStage: Stage<CameraStageAction>;
  32718. /**
  32719. * @hidden
  32720. * Defines the actions happening just before a render target is drawing.
  32721. */
  32722. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32723. /**
  32724. * @hidden
  32725. * Defines the actions happening just before a rendering group is drawing.
  32726. */
  32727. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32728. /**
  32729. * @hidden
  32730. * Defines the actions happening just before a mesh is drawing.
  32731. */
  32732. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32733. /**
  32734. * @hidden
  32735. * Defines the actions happening just after a mesh has been drawn.
  32736. */
  32737. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32738. /**
  32739. * @hidden
  32740. * Defines the actions happening just after a rendering group has been drawn.
  32741. */
  32742. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32743. /**
  32744. * @hidden
  32745. * Defines the actions happening just after the active camera has been drawn.
  32746. */
  32747. _afterCameraDrawStage: Stage<CameraStageAction>;
  32748. /**
  32749. * @hidden
  32750. * Defines the actions happening just after a render target has been drawn.
  32751. */
  32752. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32753. /**
  32754. * @hidden
  32755. * Defines the actions happening just after rendering all cameras and computing intersections.
  32756. */
  32757. _afterRenderStage: Stage<SimpleStageAction>;
  32758. /**
  32759. * @hidden
  32760. * Defines the actions happening when a pointer move event happens.
  32761. */
  32762. _pointerMoveStage: Stage<PointerMoveStageAction>;
  32763. /**
  32764. * @hidden
  32765. * Defines the actions happening when a pointer down event happens.
  32766. */
  32767. _pointerDownStage: Stage<PointerUpDownStageAction>;
  32768. /**
  32769. * @hidden
  32770. * Defines the actions happening when a pointer up event happens.
  32771. */
  32772. _pointerUpStage: Stage<PointerUpDownStageAction>;
  32773. /**
  32774. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  32775. */
  32776. private geometriesByUniqueId;
  32777. /**
  32778. * Creates a new Scene
  32779. * @param engine defines the engine to use to render this scene
  32780. * @param options defines the scene options
  32781. */
  32782. constructor(engine: Engine, options?: SceneOptions);
  32783. /**
  32784. * Gets a string idenfifying the name of the class
  32785. * @returns "Scene" string
  32786. */
  32787. getClassName(): string;
  32788. private _defaultMeshCandidates;
  32789. /**
  32790. * @hidden
  32791. */
  32792. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  32793. private _defaultSubMeshCandidates;
  32794. /**
  32795. * @hidden
  32796. */
  32797. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  32798. /**
  32799. * Sets the default candidate providers for the scene.
  32800. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  32801. * and getCollidingSubMeshCandidates to their default function
  32802. */
  32803. setDefaultCandidateProviders(): void;
  32804. /**
  32805. * Gets the mesh that is currently under the pointer
  32806. */
  32807. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32808. /**
  32809. * Gets or sets the current on-screen X position of the pointer
  32810. */
  32811. pointerX: number;
  32812. /**
  32813. * Gets or sets the current on-screen Y position of the pointer
  32814. */
  32815. pointerY: number;
  32816. /**
  32817. * Gets the cached material (ie. the latest rendered one)
  32818. * @returns the cached material
  32819. */
  32820. getCachedMaterial(): Nullable<Material>;
  32821. /**
  32822. * Gets the cached effect (ie. the latest rendered one)
  32823. * @returns the cached effect
  32824. */
  32825. getCachedEffect(): Nullable<Effect>;
  32826. /**
  32827. * Gets the cached visibility state (ie. the latest rendered one)
  32828. * @returns the cached visibility state
  32829. */
  32830. getCachedVisibility(): Nullable<number>;
  32831. /**
  32832. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  32833. * @param material defines the current material
  32834. * @param effect defines the current effect
  32835. * @param visibility defines the current visibility state
  32836. * @returns true if one parameter is not cached
  32837. */
  32838. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  32839. /**
  32840. * Gets the engine associated with the scene
  32841. * @returns an Engine
  32842. */
  32843. getEngine(): Engine;
  32844. /**
  32845. * Gets the total number of vertices rendered per frame
  32846. * @returns the total number of vertices rendered per frame
  32847. */
  32848. getTotalVertices(): number;
  32849. /**
  32850. * Gets the performance counter for total vertices
  32851. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32852. */
  32853. readonly totalVerticesPerfCounter: PerfCounter;
  32854. /**
  32855. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  32856. * @returns the total number of active indices rendered per frame
  32857. */
  32858. getActiveIndices(): number;
  32859. /**
  32860. * Gets the performance counter for active indices
  32861. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32862. */
  32863. readonly totalActiveIndicesPerfCounter: PerfCounter;
  32864. /**
  32865. * Gets the total number of active particles rendered per frame
  32866. * @returns the total number of active particles rendered per frame
  32867. */
  32868. getActiveParticles(): number;
  32869. /**
  32870. * Gets the performance counter for active particles
  32871. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32872. */
  32873. readonly activeParticlesPerfCounter: PerfCounter;
  32874. /**
  32875. * Gets the total number of active bones rendered per frame
  32876. * @returns the total number of active bones rendered per frame
  32877. */
  32878. getActiveBones(): number;
  32879. /**
  32880. * Gets the performance counter for active bones
  32881. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32882. */
  32883. readonly activeBonesPerfCounter: PerfCounter;
  32884. /**
  32885. * Gets the array of active meshes
  32886. * @returns an array of AbstractMesh
  32887. */
  32888. getActiveMeshes(): SmartArray<AbstractMesh>;
  32889. /**
  32890. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  32891. * @returns a number
  32892. */
  32893. getAnimationRatio(): number;
  32894. /**
  32895. * Gets an unique Id for the current render phase
  32896. * @returns a number
  32897. */
  32898. getRenderId(): number;
  32899. /**
  32900. * Gets an unique Id for the current frame
  32901. * @returns a number
  32902. */
  32903. getFrameId(): number;
  32904. /** Call this function if you want to manually increment the render Id*/
  32905. incrementRenderId(): void;
  32906. private _createUbo;
  32907. /**
  32908. * Use this method to simulate a pointer move on a mesh
  32909. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32910. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32911. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32912. * @returns the current scene
  32913. */
  32914. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32915. /**
  32916. * Use this method to simulate a pointer down on a mesh
  32917. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32918. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32919. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32920. * @returns the current scene
  32921. */
  32922. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32923. /**
  32924. * Use this method to simulate a pointer up on a mesh
  32925. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32926. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32927. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32928. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32929. * @returns the current scene
  32930. */
  32931. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  32932. /**
  32933. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32934. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32935. * @returns true if the pointer was captured
  32936. */
  32937. isPointerCaptured(pointerId?: number): boolean;
  32938. /**
  32939. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32940. * @param attachUp defines if you want to attach events to pointerup
  32941. * @param attachDown defines if you want to attach events to pointerdown
  32942. * @param attachMove defines if you want to attach events to pointermove
  32943. */
  32944. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32945. /** Detaches all event handlers*/
  32946. detachControl(): void;
  32947. /**
  32948. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  32949. * Delay loaded resources are not taking in account
  32950. * @return true if all required resources are ready
  32951. */
  32952. isReady(): boolean;
  32953. /** Resets all cached information relative to material (including effect and visibility) */
  32954. resetCachedMaterial(): void;
  32955. /**
  32956. * Registers a function to be called before every frame render
  32957. * @param func defines the function to register
  32958. */
  32959. registerBeforeRender(func: () => void): void;
  32960. /**
  32961. * Unregisters a function called before every frame render
  32962. * @param func defines the function to unregister
  32963. */
  32964. unregisterBeforeRender(func: () => void): void;
  32965. /**
  32966. * Registers a function to be called after every frame render
  32967. * @param func defines the function to register
  32968. */
  32969. registerAfterRender(func: () => void): void;
  32970. /**
  32971. * Unregisters a function called after every frame render
  32972. * @param func defines the function to unregister
  32973. */
  32974. unregisterAfterRender(func: () => void): void;
  32975. private _executeOnceBeforeRender;
  32976. /**
  32977. * The provided function will run before render once and will be disposed afterwards.
  32978. * A timeout delay can be provided so that the function will be executed in N ms.
  32979. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  32980. * @param func The function to be executed.
  32981. * @param timeout optional delay in ms
  32982. */
  32983. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  32984. /** @hidden */
  32985. _addPendingData(data: any): void;
  32986. /** @hidden */
  32987. _removePendingData(data: any): void;
  32988. /**
  32989. * Returns the number of items waiting to be loaded
  32990. * @returns the number of items waiting to be loaded
  32991. */
  32992. getWaitingItemsCount(): number;
  32993. /**
  32994. * Returns a boolean indicating if the scene is still loading data
  32995. */
  32996. readonly isLoading: boolean;
  32997. /**
  32998. * Registers a function to be executed when the scene is ready
  32999. * @param {Function} func - the function to be executed
  33000. */
  33001. executeWhenReady(func: () => void): void;
  33002. /**
  33003. * Returns a promise that resolves when the scene is ready
  33004. * @returns A promise that resolves when the scene is ready
  33005. */
  33006. whenReadyAsync(): Promise<void>;
  33007. /** @hidden */
  33008. _checkIsReady(): void;
  33009. /**
  33010. * Gets all animatable attached to the scene
  33011. */
  33012. readonly animatables: Animatable[];
  33013. /**
  33014. * Resets the last animation time frame.
  33015. * Useful to override when animations start running when loading a scene for the first time.
  33016. */
  33017. resetLastAnimationTimeFrame(): void;
  33018. /**
  33019. * Gets the current view matrix
  33020. * @returns a Matrix
  33021. */
  33022. getViewMatrix(): Matrix;
  33023. /**
  33024. * Gets the current projection matrix
  33025. * @returns a Matrix
  33026. */
  33027. getProjectionMatrix(): Matrix;
  33028. /**
  33029. * Gets the current transform matrix
  33030. * @returns a Matrix made of View * Projection
  33031. */
  33032. getTransformMatrix(): Matrix;
  33033. /**
  33034. * Sets the current transform matrix
  33035. * @param viewL defines the View matrix to use
  33036. * @param projectionL defines the Projection matrix to use
  33037. * @param viewR defines the right View matrix to use (if provided)
  33038. * @param projectionR defines the right Projection matrix to use (if provided)
  33039. */
  33040. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33041. /**
  33042. * Gets the uniform buffer used to store scene data
  33043. * @returns a UniformBuffer
  33044. */
  33045. getSceneUniformBuffer(): UniformBuffer;
  33046. /**
  33047. * Gets an unique (relatively to the current scene) Id
  33048. * @returns an unique number for the scene
  33049. */
  33050. getUniqueId(): number;
  33051. /**
  33052. * Add a mesh to the list of scene's meshes
  33053. * @param newMesh defines the mesh to add
  33054. * @param recursive if all child meshes should also be added to the scene
  33055. */
  33056. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33057. /**
  33058. * Remove a mesh for the list of scene's meshes
  33059. * @param toRemove defines the mesh to remove
  33060. * @param recursive if all child meshes should also be removed from the scene
  33061. * @returns the index where the mesh was in the mesh list
  33062. */
  33063. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33064. /**
  33065. * Add a transform node to the list of scene's transform nodes
  33066. * @param newTransformNode defines the transform node to add
  33067. */
  33068. addTransformNode(newTransformNode: TransformNode): void;
  33069. /**
  33070. * Remove a transform node for the list of scene's transform nodes
  33071. * @param toRemove defines the transform node to remove
  33072. * @returns the index where the transform node was in the transform node list
  33073. */
  33074. removeTransformNode(toRemove: TransformNode): number;
  33075. /**
  33076. * Remove a skeleton for the list of scene's skeletons
  33077. * @param toRemove defines the skeleton to remove
  33078. * @returns the index where the skeleton was in the skeleton list
  33079. */
  33080. removeSkeleton(toRemove: Skeleton): number;
  33081. /**
  33082. * Remove a morph target for the list of scene's morph targets
  33083. * @param toRemove defines the morph target to remove
  33084. * @returns the index where the morph target was in the morph target list
  33085. */
  33086. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33087. /**
  33088. * Remove a light for the list of scene's lights
  33089. * @param toRemove defines the light to remove
  33090. * @returns the index where the light was in the light list
  33091. */
  33092. removeLight(toRemove: Light): number;
  33093. /**
  33094. * Remove a camera for the list of scene's cameras
  33095. * @param toRemove defines the camera to remove
  33096. * @returns the index where the camera was in the camera list
  33097. */
  33098. removeCamera(toRemove: Camera): number;
  33099. /**
  33100. * Remove a particle system for the list of scene's particle systems
  33101. * @param toRemove defines the particle system to remove
  33102. * @returns the index where the particle system was in the particle system list
  33103. */
  33104. removeParticleSystem(toRemove: IParticleSystem): number;
  33105. /**
  33106. * Remove a animation for the list of scene's animations
  33107. * @param toRemove defines the animation to remove
  33108. * @returns the index where the animation was in the animation list
  33109. */
  33110. removeAnimation(toRemove: Animation): number;
  33111. /**
  33112. * Will stop the animation of the given target
  33113. * @param target - the target
  33114. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  33115. * @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)
  33116. */
  33117. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  33118. /**
  33119. * Removes the given animation group from this scene.
  33120. * @param toRemove The animation group to remove
  33121. * @returns The index of the removed animation group
  33122. */
  33123. removeAnimationGroup(toRemove: AnimationGroup): number;
  33124. /**
  33125. * Removes the given multi-material from this scene.
  33126. * @param toRemove The multi-material to remove
  33127. * @returns The index of the removed multi-material
  33128. */
  33129. removeMultiMaterial(toRemove: MultiMaterial): number;
  33130. /**
  33131. * Removes the given material from this scene.
  33132. * @param toRemove The material to remove
  33133. * @returns The index of the removed material
  33134. */
  33135. removeMaterial(toRemove: Material): number;
  33136. /**
  33137. * Removes the given action manager from this scene.
  33138. * @param toRemove The action manager to remove
  33139. * @returns The index of the removed action manager
  33140. */
  33141. removeActionManager(toRemove: AbstractActionManager): number;
  33142. /**
  33143. * Removes the given texture from this scene.
  33144. * @param toRemove The texture to remove
  33145. * @returns The index of the removed texture
  33146. */
  33147. removeTexture(toRemove: BaseTexture): number;
  33148. /**
  33149. * Adds the given light to this scene
  33150. * @param newLight The light to add
  33151. */
  33152. addLight(newLight: Light): void;
  33153. /**
  33154. * Sorts the list list based on light priorities
  33155. */
  33156. sortLightsByPriority(): void;
  33157. /**
  33158. * Adds the given camera to this scene
  33159. * @param newCamera The camera to add
  33160. */
  33161. addCamera(newCamera: Camera): void;
  33162. /**
  33163. * Adds the given skeleton to this scene
  33164. * @param newSkeleton The skeleton to add
  33165. */
  33166. addSkeleton(newSkeleton: Skeleton): void;
  33167. /**
  33168. * Adds the given particle system to this scene
  33169. * @param newParticleSystem The particle system to add
  33170. */
  33171. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33172. /**
  33173. * Adds the given animation to this scene
  33174. * @param newAnimation The animation to add
  33175. */
  33176. addAnimation(newAnimation: Animation): void;
  33177. /**
  33178. * Adds the given animation group to this scene.
  33179. * @param newAnimationGroup The animation group to add
  33180. */
  33181. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33182. /**
  33183. * Adds the given multi-material to this scene
  33184. * @param newMultiMaterial The multi-material to add
  33185. */
  33186. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33187. /**
  33188. * Adds the given material to this scene
  33189. * @param newMaterial The material to add
  33190. */
  33191. addMaterial(newMaterial: Material): void;
  33192. /**
  33193. * Adds the given morph target to this scene
  33194. * @param newMorphTargetManager The morph target to add
  33195. */
  33196. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33197. /**
  33198. * Adds the given geometry to this scene
  33199. * @param newGeometry The geometry to add
  33200. */
  33201. addGeometry(newGeometry: Geometry): void;
  33202. /**
  33203. * Adds the given action manager to this scene
  33204. * @param newActionManager The action manager to add
  33205. */
  33206. addActionManager(newActionManager: AbstractActionManager): void;
  33207. /**
  33208. * Adds the given texture to this scene.
  33209. * @param newTexture The texture to add
  33210. */
  33211. addTexture(newTexture: BaseTexture): void;
  33212. /**
  33213. * Switch active camera
  33214. * @param newCamera defines the new active camera
  33215. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33216. */
  33217. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33218. /**
  33219. * sets the active camera of the scene using its ID
  33220. * @param id defines the camera's ID
  33221. * @return the new active camera or null if none found.
  33222. */
  33223. setActiveCameraByID(id: string): Nullable<Camera>;
  33224. /**
  33225. * sets the active camera of the scene using its name
  33226. * @param name defines the camera's name
  33227. * @returns the new active camera or null if none found.
  33228. */
  33229. setActiveCameraByName(name: string): Nullable<Camera>;
  33230. /**
  33231. * get an animation group using its name
  33232. * @param name defines the material's name
  33233. * @return the animation group or null if none found.
  33234. */
  33235. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33236. /**
  33237. * Get a material using its unique id
  33238. * @param uniqueId defines the material's unique id
  33239. * @return the material or null if none found.
  33240. */
  33241. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  33242. /**
  33243. * get a material using its id
  33244. * @param id defines the material's ID
  33245. * @return the material or null if none found.
  33246. */
  33247. getMaterialByID(id: string): Nullable<Material>;
  33248. /**
  33249. * Gets a material using its name
  33250. * @param name defines the material's name
  33251. * @return the material or null if none found.
  33252. */
  33253. getMaterialByName(name: string): Nullable<Material>;
  33254. /**
  33255. * Gets a camera using its id
  33256. * @param id defines the id to look for
  33257. * @returns the camera or null if not found
  33258. */
  33259. getCameraByID(id: string): Nullable<Camera>;
  33260. /**
  33261. * Gets a camera using its unique id
  33262. * @param uniqueId defines the unique id to look for
  33263. * @returns the camera or null if not found
  33264. */
  33265. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33266. /**
  33267. * Gets a camera using its name
  33268. * @param name defines the camera's name
  33269. * @return the camera or null if none found.
  33270. */
  33271. getCameraByName(name: string): Nullable<Camera>;
  33272. /**
  33273. * Gets a bone using its id
  33274. * @param id defines the bone's id
  33275. * @return the bone or null if not found
  33276. */
  33277. getBoneByID(id: string): Nullable<Bone>;
  33278. /**
  33279. * Gets a bone using its id
  33280. * @param name defines the bone's name
  33281. * @return the bone or null if not found
  33282. */
  33283. getBoneByName(name: string): Nullable<Bone>;
  33284. /**
  33285. * Gets a light node using its name
  33286. * @param name defines the the light's name
  33287. * @return the light or null if none found.
  33288. */
  33289. getLightByName(name: string): Nullable<Light>;
  33290. /**
  33291. * Gets a light node using its id
  33292. * @param id defines the light's id
  33293. * @return the light or null if none found.
  33294. */
  33295. getLightByID(id: string): Nullable<Light>;
  33296. /**
  33297. * Gets a light node using its scene-generated unique ID
  33298. * @param uniqueId defines the light's unique id
  33299. * @return the light or null if none found.
  33300. */
  33301. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33302. /**
  33303. * Gets a particle system by id
  33304. * @param id defines the particle system id
  33305. * @return the corresponding system or null if none found
  33306. */
  33307. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33308. /**
  33309. * Gets a geometry using its ID
  33310. * @param id defines the geometry's id
  33311. * @return the geometry or null if none found.
  33312. */
  33313. getGeometryByID(id: string): Nullable<Geometry>;
  33314. private _getGeometryByUniqueID;
  33315. /**
  33316. * Add a new geometry to this scene
  33317. * @param geometry defines the geometry to be added to the scene.
  33318. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33319. * @return a boolean defining if the geometry was added or not
  33320. */
  33321. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33322. /**
  33323. * Removes an existing geometry
  33324. * @param geometry defines the geometry to be removed from the scene
  33325. * @return a boolean defining if the geometry was removed or not
  33326. */
  33327. removeGeometry(geometry: Geometry): boolean;
  33328. /**
  33329. * Gets the list of geometries attached to the scene
  33330. * @returns an array of Geometry
  33331. */
  33332. getGeometries(): Geometry[];
  33333. /**
  33334. * Gets the first added mesh found of a given ID
  33335. * @param id defines the id to search for
  33336. * @return the mesh found or null if not found at all
  33337. */
  33338. getMeshByID(id: string): Nullable<AbstractMesh>;
  33339. /**
  33340. * Gets a list of meshes using their id
  33341. * @param id defines the id to search for
  33342. * @returns a list of meshes
  33343. */
  33344. getMeshesByID(id: string): Array<AbstractMesh>;
  33345. /**
  33346. * Gets the first added transform node found of a given ID
  33347. * @param id defines the id to search for
  33348. * @return the found transform node or null if not found at all.
  33349. */
  33350. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33351. /**
  33352. * Gets a transform node with its auto-generated unique id
  33353. * @param uniqueId efines the unique id to search for
  33354. * @return the found transform node or null if not found at all.
  33355. */
  33356. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  33357. /**
  33358. * Gets a list of transform nodes using their id
  33359. * @param id defines the id to search for
  33360. * @returns a list of transform nodes
  33361. */
  33362. getTransformNodesByID(id: string): Array<TransformNode>;
  33363. /**
  33364. * Gets a mesh with its auto-generated unique id
  33365. * @param uniqueId defines the unique id to search for
  33366. * @return the found mesh or null if not found at all.
  33367. */
  33368. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33369. /**
  33370. * Gets a the last added mesh using a given id
  33371. * @param id defines the id to search for
  33372. * @return the found mesh or null if not found at all.
  33373. */
  33374. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33375. /**
  33376. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33377. * @param id defines the id to search for
  33378. * @return the found node or null if not found at all
  33379. */
  33380. getLastEntryByID(id: string): Nullable<Node>;
  33381. /**
  33382. * Gets a node (Mesh, Camera, Light) using a given id
  33383. * @param id defines the id to search for
  33384. * @return the found node or null if not found at all
  33385. */
  33386. getNodeByID(id: string): Nullable<Node>;
  33387. /**
  33388. * Gets a node (Mesh, Camera, Light) using a given name
  33389. * @param name defines the name to search for
  33390. * @return the found node or null if not found at all.
  33391. */
  33392. getNodeByName(name: string): Nullable<Node>;
  33393. /**
  33394. * Gets a mesh using a given name
  33395. * @param name defines the name to search for
  33396. * @return the found mesh or null if not found at all.
  33397. */
  33398. getMeshByName(name: string): Nullable<AbstractMesh>;
  33399. /**
  33400. * Gets a transform node using a given name
  33401. * @param name defines the name to search for
  33402. * @return the found transform node or null if not found at all.
  33403. */
  33404. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33405. /**
  33406. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33407. * @param id defines the id to search for
  33408. * @return the found skeleton or null if not found at all.
  33409. */
  33410. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33411. /**
  33412. * Gets a skeleton using a given auto generated unique id
  33413. * @param uniqueId defines the unique id to search for
  33414. * @return the found skeleton or null if not found at all.
  33415. */
  33416. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  33417. /**
  33418. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33419. * @param id defines the id to search for
  33420. * @return the found skeleton or null if not found at all.
  33421. */
  33422. getSkeletonById(id: string): Nullable<Skeleton>;
  33423. /**
  33424. * Gets a skeleton using a given name
  33425. * @param name defines the name to search for
  33426. * @return the found skeleton or null if not found at all.
  33427. */
  33428. getSkeletonByName(name: string): Nullable<Skeleton>;
  33429. /**
  33430. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33431. * @param id defines the id to search for
  33432. * @return the found morph target manager or null if not found at all.
  33433. */
  33434. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33435. /**
  33436. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33437. * @param id defines the id to search for
  33438. * @return the found morph target or null if not found at all.
  33439. */
  33440. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33441. /**
  33442. * Gets a boolean indicating if the given mesh is active
  33443. * @param mesh defines the mesh to look for
  33444. * @returns true if the mesh is in the active list
  33445. */
  33446. isActiveMesh(mesh: AbstractMesh): boolean;
  33447. /**
  33448. * Return a unique id as a string which can serve as an identifier for the scene
  33449. */
  33450. readonly uid: string;
  33451. /**
  33452. * Add an externaly attached data from its key.
  33453. * This method call will fail and return false, if such key already exists.
  33454. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33455. * @param key the unique key that identifies the data
  33456. * @param data the data object to associate to the key for this Engine instance
  33457. * @return true if no such key were already present and the data was added successfully, false otherwise
  33458. */
  33459. addExternalData<T>(key: string, data: T): boolean;
  33460. /**
  33461. * Get an externaly attached data from its key
  33462. * @param key the unique key that identifies the data
  33463. * @return the associated data, if present (can be null), or undefined if not present
  33464. */
  33465. getExternalData<T>(key: string): Nullable<T>;
  33466. /**
  33467. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33468. * @param key the unique key that identifies the data
  33469. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33470. * @return the associated data, can be null if the factory returned null.
  33471. */
  33472. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33473. /**
  33474. * Remove an externaly attached data from the Engine instance
  33475. * @param key the unique key that identifies the data
  33476. * @return true if the data was successfully removed, false if it doesn't exist
  33477. */
  33478. removeExternalData(key: string): boolean;
  33479. private _evaluateSubMesh;
  33480. /**
  33481. * Clear the processed materials smart array preventing retention point in material dispose.
  33482. */
  33483. freeProcessedMaterials(): void;
  33484. private _preventFreeActiveMeshesAndRenderingGroups;
  33485. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33486. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33487. * when disposing several meshes in a row or a hierarchy of meshes.
  33488. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33489. */
  33490. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33491. /**
  33492. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33493. */
  33494. freeActiveMeshes(): void;
  33495. /**
  33496. * Clear the info related to rendering groups preventing retention points during dispose.
  33497. */
  33498. freeRenderingGroups(): void;
  33499. /** @hidden */
  33500. _isInIntermediateRendering(): boolean;
  33501. /**
  33502. * Lambda returning the list of potentially active meshes.
  33503. */
  33504. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33505. /**
  33506. * Lambda returning the list of potentially active sub meshes.
  33507. */
  33508. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33509. /**
  33510. * Lambda returning the list of potentially intersecting sub meshes.
  33511. */
  33512. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33513. /**
  33514. * Lambda returning the list of potentially colliding sub meshes.
  33515. */
  33516. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33517. private _activeMeshesFrozen;
  33518. /**
  33519. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33520. * @returns the current scene
  33521. */
  33522. freezeActiveMeshes(): Scene;
  33523. /**
  33524. * Use this function to restart evaluating active meshes on every frame
  33525. * @returns the current scene
  33526. */
  33527. unfreezeActiveMeshes(): Scene;
  33528. private _evaluateActiveMeshes;
  33529. private _activeMesh;
  33530. /**
  33531. * Update the transform matrix to update from the current active camera
  33532. * @param force defines a boolean used to force the update even if cache is up to date
  33533. */
  33534. updateTransformMatrix(force?: boolean): void;
  33535. private _bindFrameBuffer;
  33536. /** @hidden */
  33537. _allowPostProcessClearColor: boolean;
  33538. /** @hidden */
  33539. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  33540. private _processSubCameras;
  33541. private _checkIntersections;
  33542. /** @hidden */
  33543. _advancePhysicsEngineStep(step: number): void;
  33544. /**
  33545. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33546. */
  33547. getDeterministicFrameTime: () => number;
  33548. /** @hidden */
  33549. _animate(): void;
  33550. /** Execute all animations (for a frame) */
  33551. animate(): void;
  33552. /**
  33553. * Render the scene
  33554. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33555. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  33556. */
  33557. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  33558. /**
  33559. * Freeze all materials
  33560. * A frozen material will not be updatable but should be faster to render
  33561. */
  33562. freezeMaterials(): void;
  33563. /**
  33564. * Unfreeze all materials
  33565. * A frozen material will not be updatable but should be faster to render
  33566. */
  33567. unfreezeMaterials(): void;
  33568. /**
  33569. * Releases all held ressources
  33570. */
  33571. dispose(): void;
  33572. /**
  33573. * Gets if the scene is already disposed
  33574. */
  33575. readonly isDisposed: boolean;
  33576. /**
  33577. * Call this function to reduce memory footprint of the scene.
  33578. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33579. */
  33580. clearCachedVertexData(): void;
  33581. /**
  33582. * This function will remove the local cached buffer data from texture.
  33583. * It will save memory but will prevent the texture from being rebuilt
  33584. */
  33585. cleanCachedTextureBuffer(): void;
  33586. /**
  33587. * Get the world extend vectors with an optional filter
  33588. *
  33589. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33590. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33591. */
  33592. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33593. min: Vector3;
  33594. max: Vector3;
  33595. };
  33596. /**
  33597. * Creates a ray that can be used to pick in the scene
  33598. * @param x defines the x coordinate of the origin (on-screen)
  33599. * @param y defines the y coordinate of the origin (on-screen)
  33600. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33601. * @param camera defines the camera to use for the picking
  33602. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33603. * @returns a Ray
  33604. */
  33605. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33606. /**
  33607. * Creates a ray that can be used to pick in the scene
  33608. * @param x defines the x coordinate of the origin (on-screen)
  33609. * @param y defines the y coordinate of the origin (on-screen)
  33610. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33611. * @param result defines the ray where to store the picking ray
  33612. * @param camera defines the camera to use for the picking
  33613. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33614. * @returns the current scene
  33615. */
  33616. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33617. /**
  33618. * Creates a ray that can be used to pick in the scene
  33619. * @param x defines the x coordinate of the origin (on-screen)
  33620. * @param y defines the y coordinate of the origin (on-screen)
  33621. * @param camera defines the camera to use for the picking
  33622. * @returns a Ray
  33623. */
  33624. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33625. /**
  33626. * Creates a ray that can be used to pick in the scene
  33627. * @param x defines the x coordinate of the origin (on-screen)
  33628. * @param y defines the y coordinate of the origin (on-screen)
  33629. * @param result defines the ray where to store the picking ray
  33630. * @param camera defines the camera to use for the picking
  33631. * @returns the current scene
  33632. */
  33633. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33634. /** Launch a ray to try to pick a mesh in the scene
  33635. * @param x position on screen
  33636. * @param y position on screen
  33637. * @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
  33638. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33639. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33640. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33641. * @returns a PickingInfo
  33642. */
  33643. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  33644. /** Use the given ray to pick a mesh in the scene
  33645. * @param ray The ray to use to pick meshes
  33646. * @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
  33647. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33648. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33649. * @returns a PickingInfo
  33650. */
  33651. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33652. /**
  33653. * Launch a ray to try to pick a mesh in the scene
  33654. * @param x X position on screen
  33655. * @param y Y position on screen
  33656. * @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
  33657. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33658. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33659. * @returns an array of PickingInfo
  33660. */
  33661. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33662. /**
  33663. * Launch a ray to try to pick a mesh in the scene
  33664. * @param ray Ray to use
  33665. * @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
  33666. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33667. * @returns an array of PickingInfo
  33668. */
  33669. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33670. /**
  33671. * Force the value of meshUnderPointer
  33672. * @param mesh defines the mesh to use
  33673. */
  33674. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33675. /**
  33676. * Gets the mesh under the pointer
  33677. * @returns a Mesh or null if no mesh is under the pointer
  33678. */
  33679. getPointerOverMesh(): Nullable<AbstractMesh>;
  33680. /** @hidden */
  33681. _rebuildGeometries(): void;
  33682. /** @hidden */
  33683. _rebuildTextures(): void;
  33684. private _getByTags;
  33685. /**
  33686. * Get a list of meshes by tags
  33687. * @param tagsQuery defines the tags query to use
  33688. * @param forEach defines a predicate used to filter results
  33689. * @returns an array of Mesh
  33690. */
  33691. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  33692. /**
  33693. * Get a list of cameras by tags
  33694. * @param tagsQuery defines the tags query to use
  33695. * @param forEach defines a predicate used to filter results
  33696. * @returns an array of Camera
  33697. */
  33698. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  33699. /**
  33700. * Get a list of lights by tags
  33701. * @param tagsQuery defines the tags query to use
  33702. * @param forEach defines a predicate used to filter results
  33703. * @returns an array of Light
  33704. */
  33705. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  33706. /**
  33707. * Get a list of materials by tags
  33708. * @param tagsQuery defines the tags query to use
  33709. * @param forEach defines a predicate used to filter results
  33710. * @returns an array of Material
  33711. */
  33712. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  33713. /**
  33714. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33715. * This allowed control for front to back rendering or reversly depending of the special needs.
  33716. *
  33717. * @param renderingGroupId The rendering group id corresponding to its index
  33718. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33719. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33720. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33721. */
  33722. 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;
  33723. /**
  33724. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33725. *
  33726. * @param renderingGroupId The rendering group id corresponding to its index
  33727. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33728. * @param depth Automatically clears depth between groups if true and autoClear is true.
  33729. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  33730. */
  33731. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  33732. /**
  33733. * Gets the current auto clear configuration for one rendering group of the rendering
  33734. * manager.
  33735. * @param index the rendering group index to get the information for
  33736. * @returns The auto clear setup for the requested rendering group
  33737. */
  33738. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  33739. private _blockMaterialDirtyMechanism;
  33740. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  33741. blockMaterialDirtyMechanism: boolean;
  33742. /**
  33743. * Will flag all materials as dirty to trigger new shader compilation
  33744. * @param flag defines the flag used to specify which material part must be marked as dirty
  33745. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  33746. */
  33747. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33748. /** @hidden */
  33749. _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;
  33750. /** @hidden */
  33751. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33752. }
  33753. }
  33754. declare module BABYLON {
  33755. /**
  33756. * Set of assets to keep when moving a scene into an asset container.
  33757. */
  33758. export class KeepAssets extends AbstractScene {
  33759. }
  33760. /**
  33761. * Container with a set of assets that can be added or removed from a scene.
  33762. */
  33763. export class AssetContainer extends AbstractScene {
  33764. /**
  33765. * The scene the AssetContainer belongs to.
  33766. */
  33767. scene: Scene;
  33768. /**
  33769. * Instantiates an AssetContainer.
  33770. * @param scene The scene the AssetContainer belongs to.
  33771. */
  33772. constructor(scene: Scene);
  33773. /**
  33774. * Adds all the assets from the container to the scene.
  33775. */
  33776. addAllToScene(): void;
  33777. /**
  33778. * Removes all the assets in the container from the scene
  33779. */
  33780. removeAllFromScene(): void;
  33781. /**
  33782. * Disposes all the assets in the container
  33783. */
  33784. dispose(): void;
  33785. private _moveAssets;
  33786. /**
  33787. * Removes all the assets contained in the scene and adds them to the container.
  33788. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  33789. */
  33790. moveAllFromScene(keepAssets?: KeepAssets): void;
  33791. /**
  33792. * 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.
  33793. * @returns the root mesh
  33794. */
  33795. createRootMesh(): Mesh;
  33796. }
  33797. }
  33798. declare module BABYLON {
  33799. /**
  33800. * Defines how the parser contract is defined.
  33801. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  33802. */
  33803. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  33804. /**
  33805. * Defines how the individual parser contract is defined.
  33806. * These parser can parse an individual asset
  33807. */
  33808. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  33809. /**
  33810. * Base class of the scene acting as a container for the different elements composing a scene.
  33811. * This class is dynamically extended by the different components of the scene increasing
  33812. * flexibility and reducing coupling
  33813. */
  33814. export abstract class AbstractScene {
  33815. /**
  33816. * Stores the list of available parsers in the application.
  33817. */
  33818. private static _BabylonFileParsers;
  33819. /**
  33820. * Stores the list of available individual parsers in the application.
  33821. */
  33822. private static _IndividualBabylonFileParsers;
  33823. /**
  33824. * Adds a parser in the list of available ones
  33825. * @param name Defines the name of the parser
  33826. * @param parser Defines the parser to add
  33827. */
  33828. static AddParser(name: string, parser: BabylonFileParser): void;
  33829. /**
  33830. * Gets a general parser from the list of avaialble ones
  33831. * @param name Defines the name of the parser
  33832. * @returns the requested parser or null
  33833. */
  33834. static GetParser(name: string): Nullable<BabylonFileParser>;
  33835. /**
  33836. * Adds n individual parser in the list of available ones
  33837. * @param name Defines the name of the parser
  33838. * @param parser Defines the parser to add
  33839. */
  33840. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  33841. /**
  33842. * Gets an individual parser from the list of avaialble ones
  33843. * @param name Defines the name of the parser
  33844. * @returns the requested parser or null
  33845. */
  33846. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  33847. /**
  33848. * Parser json data and populate both a scene and its associated container object
  33849. * @param jsonData Defines the data to parse
  33850. * @param scene Defines the scene to parse the data for
  33851. * @param container Defines the container attached to the parsing sequence
  33852. * @param rootUrl Defines the root url of the data
  33853. */
  33854. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  33855. /**
  33856. * Gets the list of root nodes (ie. nodes with no parent)
  33857. */
  33858. rootNodes: Node[];
  33859. /** All of the cameras added to this scene
  33860. * @see http://doc.babylonjs.com/babylon101/cameras
  33861. */
  33862. cameras: Camera[];
  33863. /**
  33864. * All of the lights added to this scene
  33865. * @see http://doc.babylonjs.com/babylon101/lights
  33866. */
  33867. lights: Light[];
  33868. /**
  33869. * All of the (abstract) meshes added to this scene
  33870. */
  33871. meshes: AbstractMesh[];
  33872. /**
  33873. * The list of skeletons added to the scene
  33874. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33875. */
  33876. skeletons: Skeleton[];
  33877. /**
  33878. * All of the particle systems added to this scene
  33879. * @see http://doc.babylonjs.com/babylon101/particles
  33880. */
  33881. particleSystems: IParticleSystem[];
  33882. /**
  33883. * Gets a list of Animations associated with the scene
  33884. */
  33885. animations: Animation[];
  33886. /**
  33887. * All of the animation groups added to this scene
  33888. * @see http://doc.babylonjs.com/how_to/group
  33889. */
  33890. animationGroups: AnimationGroup[];
  33891. /**
  33892. * All of the multi-materials added to this scene
  33893. * @see http://doc.babylonjs.com/how_to/multi_materials
  33894. */
  33895. multiMaterials: MultiMaterial[];
  33896. /**
  33897. * All of the materials added to this scene
  33898. * In the context of a Scene, it is not supposed to be modified manually.
  33899. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  33900. * Note also that the order of the Material wihin the array is not significant and might change.
  33901. * @see http://doc.babylonjs.com/babylon101/materials
  33902. */
  33903. materials: Material[];
  33904. /**
  33905. * The list of morph target managers added to the scene
  33906. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  33907. */
  33908. morphTargetManagers: MorphTargetManager[];
  33909. /**
  33910. * The list of geometries used in the scene.
  33911. */
  33912. geometries: Geometry[];
  33913. /**
  33914. * All of the tranform nodes added to this scene
  33915. * In the context of a Scene, it is not supposed to be modified manually.
  33916. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  33917. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  33918. * @see http://doc.babylonjs.com/how_to/transformnode
  33919. */
  33920. transformNodes: TransformNode[];
  33921. /**
  33922. * ActionManagers available on the scene.
  33923. */
  33924. actionManagers: AbstractActionManager[];
  33925. /**
  33926. * Textures to keep.
  33927. */
  33928. textures: BaseTexture[];
  33929. /**
  33930. * Environment texture for the scene
  33931. */
  33932. environmentTexture: Nullable<BaseTexture>;
  33933. }
  33934. }
  33935. declare module BABYLON {
  33936. /**
  33937. * Defines a sound that can be played in the application.
  33938. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  33939. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33940. */
  33941. export class Sound {
  33942. /**
  33943. * The name of the sound in the scene.
  33944. */
  33945. name: string;
  33946. /**
  33947. * Does the sound autoplay once loaded.
  33948. */
  33949. autoplay: boolean;
  33950. /**
  33951. * Does the sound loop after it finishes playing once.
  33952. */
  33953. loop: boolean;
  33954. /**
  33955. * Does the sound use a custom attenuation curve to simulate the falloff
  33956. * happening when the source gets further away from the camera.
  33957. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33958. */
  33959. useCustomAttenuation: boolean;
  33960. /**
  33961. * The sound track id this sound belongs to.
  33962. */
  33963. soundTrackId: number;
  33964. /**
  33965. * Is this sound currently played.
  33966. */
  33967. isPlaying: boolean;
  33968. /**
  33969. * Is this sound currently paused.
  33970. */
  33971. isPaused: boolean;
  33972. /**
  33973. * Does this sound enables spatial sound.
  33974. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33975. */
  33976. spatialSound: boolean;
  33977. /**
  33978. * Define the reference distance the sound should be heard perfectly.
  33979. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33980. */
  33981. refDistance: number;
  33982. /**
  33983. * Define the roll off factor of spatial sounds.
  33984. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33985. */
  33986. rolloffFactor: number;
  33987. /**
  33988. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  33989. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33990. */
  33991. maxDistance: number;
  33992. /**
  33993. * Define the distance attenuation model the sound will follow.
  33994. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33995. */
  33996. distanceModel: string;
  33997. /**
  33998. * @hidden
  33999. * Back Compat
  34000. **/
  34001. onended: () => any;
  34002. /**
  34003. * Observable event when the current playing sound finishes.
  34004. */
  34005. onEndedObservable: Observable<Sound>;
  34006. private _panningModel;
  34007. private _playbackRate;
  34008. private _streaming;
  34009. private _startTime;
  34010. private _startOffset;
  34011. private _position;
  34012. /** @hidden */
  34013. _positionInEmitterSpace: boolean;
  34014. private _localDirection;
  34015. private _volume;
  34016. private _isReadyToPlay;
  34017. private _isDirectional;
  34018. private _readyToPlayCallback;
  34019. private _audioBuffer;
  34020. private _soundSource;
  34021. private _streamingSource;
  34022. private _soundPanner;
  34023. private _soundGain;
  34024. private _inputAudioNode;
  34025. private _outputAudioNode;
  34026. private _coneInnerAngle;
  34027. private _coneOuterAngle;
  34028. private _coneOuterGain;
  34029. private _scene;
  34030. private _connectedTransformNode;
  34031. private _customAttenuationFunction;
  34032. private _registerFunc;
  34033. private _isOutputConnected;
  34034. private _htmlAudioElement;
  34035. private _urlType;
  34036. /** @hidden */
  34037. static _SceneComponentInitialization: (scene: Scene) => void;
  34038. /**
  34039. * Create a sound and attach it to a scene
  34040. * @param name Name of your sound
  34041. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34042. * @param scene defines the scene the sound belongs to
  34043. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34044. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34045. */
  34046. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  34047. /**
  34048. * Release the sound and its associated resources
  34049. */
  34050. dispose(): void;
  34051. /**
  34052. * Gets if the sounds is ready to be played or not.
  34053. * @returns true if ready, otherwise false
  34054. */
  34055. isReady(): boolean;
  34056. private _soundLoaded;
  34057. /**
  34058. * Sets the data of the sound from an audiobuffer
  34059. * @param audioBuffer The audioBuffer containing the data
  34060. */
  34061. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34062. /**
  34063. * Updates the current sounds options such as maxdistance, loop...
  34064. * @param options A JSON object containing values named as the object properties
  34065. */
  34066. updateOptions(options: any): void;
  34067. private _createSpatialParameters;
  34068. private _updateSpatialParameters;
  34069. /**
  34070. * Switch the panning model to HRTF:
  34071. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34072. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34073. */
  34074. switchPanningModelToHRTF(): void;
  34075. /**
  34076. * Switch the panning model to Equal Power:
  34077. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34078. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34079. */
  34080. switchPanningModelToEqualPower(): void;
  34081. private _switchPanningModel;
  34082. /**
  34083. * Connect this sound to a sound track audio node like gain...
  34084. * @param soundTrackAudioNode the sound track audio node to connect to
  34085. */
  34086. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34087. /**
  34088. * Transform this sound into a directional source
  34089. * @param coneInnerAngle Size of the inner cone in degree
  34090. * @param coneOuterAngle Size of the outer cone in degree
  34091. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34092. */
  34093. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34094. /**
  34095. * Gets or sets the inner angle for the directional cone.
  34096. */
  34097. /**
  34098. * Gets or sets the inner angle for the directional cone.
  34099. */
  34100. directionalConeInnerAngle: number;
  34101. /**
  34102. * Gets or sets the outer angle for the directional cone.
  34103. */
  34104. /**
  34105. * Gets or sets the outer angle for the directional cone.
  34106. */
  34107. directionalConeOuterAngle: number;
  34108. /**
  34109. * Sets the position of the emitter if spatial sound is enabled
  34110. * @param newPosition Defines the new posisiton
  34111. */
  34112. setPosition(newPosition: Vector3): void;
  34113. /**
  34114. * Sets the local direction of the emitter if spatial sound is enabled
  34115. * @param newLocalDirection Defines the new local direction
  34116. */
  34117. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34118. private _updateDirection;
  34119. /** @hidden */
  34120. updateDistanceFromListener(): void;
  34121. /**
  34122. * Sets a new custom attenuation function for the sound.
  34123. * @param callback Defines the function used for the attenuation
  34124. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34125. */
  34126. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34127. /**
  34128. * Play the sound
  34129. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34130. * @param offset (optional) Start the sound setting it at a specific time
  34131. */
  34132. play(time?: number, offset?: number): void;
  34133. private _onended;
  34134. /**
  34135. * Stop the sound
  34136. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34137. */
  34138. stop(time?: number): void;
  34139. /**
  34140. * Put the sound in pause
  34141. */
  34142. pause(): void;
  34143. /**
  34144. * Sets a dedicated volume for this sounds
  34145. * @param newVolume Define the new volume of the sound
  34146. * @param time Define in how long the sound should be at this value
  34147. */
  34148. setVolume(newVolume: number, time?: number): void;
  34149. /**
  34150. * Set the sound play back rate
  34151. * @param newPlaybackRate Define the playback rate the sound should be played at
  34152. */
  34153. setPlaybackRate(newPlaybackRate: number): void;
  34154. /**
  34155. * Gets the volume of the sound.
  34156. * @returns the volume of the sound
  34157. */
  34158. getVolume(): number;
  34159. /**
  34160. * Attach the sound to a dedicated mesh
  34161. * @param transformNode The transform node to connect the sound with
  34162. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34163. */
  34164. attachToMesh(transformNode: TransformNode): void;
  34165. /**
  34166. * Detach the sound from the previously attached mesh
  34167. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34168. */
  34169. detachFromMesh(): void;
  34170. private _onRegisterAfterWorldMatrixUpdate;
  34171. /**
  34172. * Clone the current sound in the scene.
  34173. * @returns the new sound clone
  34174. */
  34175. clone(): Nullable<Sound>;
  34176. /**
  34177. * Gets the current underlying audio buffer containing the data
  34178. * @returns the audio buffer
  34179. */
  34180. getAudioBuffer(): Nullable<AudioBuffer>;
  34181. /**
  34182. * Serializes the Sound in a JSON representation
  34183. * @returns the JSON representation of the sound
  34184. */
  34185. serialize(): any;
  34186. /**
  34187. * Parse a JSON representation of a sound to innstantiate in a given scene
  34188. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34189. * @param scene Define the scene the new parsed sound should be created in
  34190. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34191. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34192. * @returns the newly parsed sound
  34193. */
  34194. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34195. }
  34196. }
  34197. declare module BABYLON {
  34198. /**
  34199. * This defines an action helpful to play a defined sound on a triggered action.
  34200. */
  34201. export class PlaySoundAction extends Action {
  34202. private _sound;
  34203. /**
  34204. * Instantiate the action
  34205. * @param triggerOptions defines the trigger options
  34206. * @param sound defines the sound to play
  34207. * @param condition defines the trigger related conditions
  34208. */
  34209. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34210. /** @hidden */
  34211. _prepare(): void;
  34212. /**
  34213. * Execute the action and play the sound.
  34214. */
  34215. execute(): void;
  34216. /**
  34217. * Serializes the actions and its related information.
  34218. * @param parent defines the object to serialize in
  34219. * @returns the serialized object
  34220. */
  34221. serialize(parent: any): any;
  34222. }
  34223. /**
  34224. * This defines an action helpful to stop a defined sound on a triggered action.
  34225. */
  34226. export class StopSoundAction extends Action {
  34227. private _sound;
  34228. /**
  34229. * Instantiate the action
  34230. * @param triggerOptions defines the trigger options
  34231. * @param sound defines the sound to stop
  34232. * @param condition defines the trigger related conditions
  34233. */
  34234. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34235. /** @hidden */
  34236. _prepare(): void;
  34237. /**
  34238. * Execute the action and stop the sound.
  34239. */
  34240. execute(): void;
  34241. /**
  34242. * Serializes the actions and its related information.
  34243. * @param parent defines the object to serialize in
  34244. * @returns the serialized object
  34245. */
  34246. serialize(parent: any): any;
  34247. }
  34248. }
  34249. declare module BABYLON {
  34250. /**
  34251. * This defines an action responsible to change the value of a property
  34252. * by interpolating between its current value and the newly set one once triggered.
  34253. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34254. */
  34255. export class InterpolateValueAction extends Action {
  34256. /**
  34257. * Defines the path of the property where the value should be interpolated
  34258. */
  34259. propertyPath: string;
  34260. /**
  34261. * Defines the target value at the end of the interpolation.
  34262. */
  34263. value: any;
  34264. /**
  34265. * Defines the time it will take for the property to interpolate to the value.
  34266. */
  34267. duration: number;
  34268. /**
  34269. * Defines if the other scene animations should be stopped when the action has been triggered
  34270. */
  34271. stopOtherAnimations?: boolean;
  34272. /**
  34273. * Defines a callback raised once the interpolation animation has been done.
  34274. */
  34275. onInterpolationDone?: () => void;
  34276. /**
  34277. * Observable triggered once the interpolation animation has been done.
  34278. */
  34279. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34280. private _target;
  34281. private _effectiveTarget;
  34282. private _property;
  34283. /**
  34284. * Instantiate the action
  34285. * @param triggerOptions defines the trigger options
  34286. * @param target defines the object containing the value to interpolate
  34287. * @param propertyPath defines the path to the property in the target object
  34288. * @param value defines the target value at the end of the interpolation
  34289. * @param duration deines the time it will take for the property to interpolate to the value.
  34290. * @param condition defines the trigger related conditions
  34291. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34292. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34293. */
  34294. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34295. /** @hidden */
  34296. _prepare(): void;
  34297. /**
  34298. * Execute the action starts the value interpolation.
  34299. */
  34300. execute(): void;
  34301. /**
  34302. * Serializes the actions and its related information.
  34303. * @param parent defines the object to serialize in
  34304. * @returns the serialized object
  34305. */
  34306. serialize(parent: any): any;
  34307. }
  34308. }
  34309. declare module BABYLON {
  34310. /**
  34311. * Options allowed during the creation of a sound track.
  34312. */
  34313. export interface ISoundTrackOptions {
  34314. /**
  34315. * The volume the sound track should take during creation
  34316. */
  34317. volume?: number;
  34318. /**
  34319. * Define if the sound track is the main sound track of the scene
  34320. */
  34321. mainTrack?: boolean;
  34322. }
  34323. /**
  34324. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34325. * It will be also used in a future release to apply effects on a specific track.
  34326. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34327. */
  34328. export class SoundTrack {
  34329. /**
  34330. * The unique identifier of the sound track in the scene.
  34331. */
  34332. id: number;
  34333. /**
  34334. * The list of sounds included in the sound track.
  34335. */
  34336. soundCollection: Array<Sound>;
  34337. private _outputAudioNode;
  34338. private _scene;
  34339. private _isMainTrack;
  34340. private _connectedAnalyser;
  34341. private _options;
  34342. private _isInitialized;
  34343. /**
  34344. * Creates a new sound track.
  34345. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34346. * @param scene Define the scene the sound track belongs to
  34347. * @param options
  34348. */
  34349. constructor(scene: Scene, options?: ISoundTrackOptions);
  34350. private _initializeSoundTrackAudioGraph;
  34351. /**
  34352. * Release the sound track and its associated resources
  34353. */
  34354. dispose(): void;
  34355. /**
  34356. * Adds a sound to this sound track
  34357. * @param sound define the cound to add
  34358. * @ignoreNaming
  34359. */
  34360. AddSound(sound: Sound): void;
  34361. /**
  34362. * Removes a sound to this sound track
  34363. * @param sound define the cound to remove
  34364. * @ignoreNaming
  34365. */
  34366. RemoveSound(sound: Sound): void;
  34367. /**
  34368. * Set a global volume for the full sound track.
  34369. * @param newVolume Define the new volume of the sound track
  34370. */
  34371. setVolume(newVolume: number): void;
  34372. /**
  34373. * Switch the panning model to HRTF:
  34374. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34375. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34376. */
  34377. switchPanningModelToHRTF(): void;
  34378. /**
  34379. * Switch the panning model to Equal Power:
  34380. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34381. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34382. */
  34383. switchPanningModelToEqualPower(): void;
  34384. /**
  34385. * Connect the sound track to an audio analyser allowing some amazing
  34386. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34387. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34388. * @param analyser The analyser to connect to the engine
  34389. */
  34390. connectToAnalyser(analyser: Analyser): void;
  34391. }
  34392. }
  34393. declare module BABYLON {
  34394. interface AbstractScene {
  34395. /**
  34396. * The list of sounds used in the scene.
  34397. */
  34398. sounds: Nullable<Array<Sound>>;
  34399. }
  34400. interface Scene {
  34401. /**
  34402. * @hidden
  34403. * Backing field
  34404. */
  34405. _mainSoundTrack: SoundTrack;
  34406. /**
  34407. * The main sound track played by the scene.
  34408. * It cotains your primary collection of sounds.
  34409. */
  34410. mainSoundTrack: SoundTrack;
  34411. /**
  34412. * The list of sound tracks added to the scene
  34413. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34414. */
  34415. soundTracks: Nullable<Array<SoundTrack>>;
  34416. /**
  34417. * Gets a sound using a given name
  34418. * @param name defines the name to search for
  34419. * @return the found sound or null if not found at all.
  34420. */
  34421. getSoundByName(name: string): Nullable<Sound>;
  34422. /**
  34423. * Gets or sets if audio support is enabled
  34424. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34425. */
  34426. audioEnabled: boolean;
  34427. /**
  34428. * Gets or sets if audio will be output to headphones
  34429. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34430. */
  34431. headphone: boolean;
  34432. }
  34433. /**
  34434. * Defines the sound scene component responsible to manage any sounds
  34435. * in a given scene.
  34436. */
  34437. export class AudioSceneComponent implements ISceneSerializableComponent {
  34438. /**
  34439. * The component name helpfull to identify the component in the list of scene components.
  34440. */
  34441. readonly name: string;
  34442. /**
  34443. * The scene the component belongs to.
  34444. */
  34445. scene: Scene;
  34446. private _audioEnabled;
  34447. /**
  34448. * Gets whether audio is enabled or not.
  34449. * Please use related enable/disable method to switch state.
  34450. */
  34451. readonly audioEnabled: boolean;
  34452. private _headphone;
  34453. /**
  34454. * Gets whether audio is outputing to headphone or not.
  34455. * Please use the according Switch methods to change output.
  34456. */
  34457. readonly headphone: boolean;
  34458. /**
  34459. * Creates a new instance of the component for the given scene
  34460. * @param scene Defines the scene to register the component in
  34461. */
  34462. constructor(scene: Scene);
  34463. /**
  34464. * Registers the component in a given scene
  34465. */
  34466. register(): void;
  34467. /**
  34468. * Rebuilds the elements related to this component in case of
  34469. * context lost for instance.
  34470. */
  34471. rebuild(): void;
  34472. /**
  34473. * Serializes the component data to the specified json object
  34474. * @param serializationObject The object to serialize to
  34475. */
  34476. serialize(serializationObject: any): void;
  34477. /**
  34478. * Adds all the elements from the container to the scene
  34479. * @param container the container holding the elements
  34480. */
  34481. addFromContainer(container: AbstractScene): void;
  34482. /**
  34483. * Removes all the elements in the container from the scene
  34484. * @param container contains the elements to remove
  34485. * @param dispose if the removed element should be disposed (default: false)
  34486. */
  34487. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  34488. /**
  34489. * Disposes the component and the associated ressources.
  34490. */
  34491. dispose(): void;
  34492. /**
  34493. * Disables audio in the associated scene.
  34494. */
  34495. disableAudio(): void;
  34496. /**
  34497. * Enables audio in the associated scene.
  34498. */
  34499. enableAudio(): void;
  34500. /**
  34501. * Switch audio to headphone output.
  34502. */
  34503. switchAudioModeForHeadphones(): void;
  34504. /**
  34505. * Switch audio to normal speakers.
  34506. */
  34507. switchAudioModeForNormalSpeakers(): void;
  34508. private _afterRender;
  34509. }
  34510. }
  34511. declare module BABYLON {
  34512. /**
  34513. * Wraps one or more Sound objects and selects one with random weight for playback.
  34514. */
  34515. export class WeightedSound {
  34516. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34517. loop: boolean;
  34518. private _coneInnerAngle;
  34519. private _coneOuterAngle;
  34520. private _volume;
  34521. /** A Sound is currently playing. */
  34522. isPlaying: boolean;
  34523. /** A Sound is currently paused. */
  34524. isPaused: boolean;
  34525. private _sounds;
  34526. private _weights;
  34527. private _currentIndex?;
  34528. /**
  34529. * Creates a new WeightedSound from the list of sounds given.
  34530. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34531. * @param sounds Array of Sounds that will be selected from.
  34532. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34533. */
  34534. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34535. /**
  34536. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34537. */
  34538. /**
  34539. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34540. */
  34541. directionalConeInnerAngle: number;
  34542. /**
  34543. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34544. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34545. */
  34546. /**
  34547. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34548. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34549. */
  34550. directionalConeOuterAngle: number;
  34551. /**
  34552. * Playback volume.
  34553. */
  34554. /**
  34555. * Playback volume.
  34556. */
  34557. volume: number;
  34558. private _onended;
  34559. /**
  34560. * Suspend playback
  34561. */
  34562. pause(): void;
  34563. /**
  34564. * Stop playback
  34565. */
  34566. stop(): void;
  34567. /**
  34568. * Start playback.
  34569. * @param startOffset Position the clip head at a specific time in seconds.
  34570. */
  34571. play(startOffset?: number): void;
  34572. }
  34573. }
  34574. declare module BABYLON {
  34575. /**
  34576. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34577. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34578. */
  34579. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34580. /**
  34581. * Gets the name of the behavior.
  34582. */
  34583. readonly name: string;
  34584. /**
  34585. * The easing function used by animations
  34586. */
  34587. static EasingFunction: BackEase;
  34588. /**
  34589. * The easing mode used by animations
  34590. */
  34591. static EasingMode: number;
  34592. /**
  34593. * The duration of the animation, in milliseconds
  34594. */
  34595. transitionDuration: number;
  34596. /**
  34597. * Length of the distance animated by the transition when lower radius is reached
  34598. */
  34599. lowerRadiusTransitionRange: number;
  34600. /**
  34601. * Length of the distance animated by the transition when upper radius is reached
  34602. */
  34603. upperRadiusTransitionRange: number;
  34604. private _autoTransitionRange;
  34605. /**
  34606. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34607. */
  34608. /**
  34609. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34610. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  34611. */
  34612. autoTransitionRange: boolean;
  34613. private _attachedCamera;
  34614. private _onAfterCheckInputsObserver;
  34615. private _onMeshTargetChangedObserver;
  34616. /**
  34617. * Initializes the behavior.
  34618. */
  34619. init(): void;
  34620. /**
  34621. * Attaches the behavior to its arc rotate camera.
  34622. * @param camera Defines the camera to attach the behavior to
  34623. */
  34624. attach(camera: ArcRotateCamera): void;
  34625. /**
  34626. * Detaches the behavior from its current arc rotate camera.
  34627. */
  34628. detach(): void;
  34629. private _radiusIsAnimating;
  34630. private _radiusBounceTransition;
  34631. private _animatables;
  34632. private _cachedWheelPrecision;
  34633. /**
  34634. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  34635. * @param radiusLimit The limit to check against.
  34636. * @return Bool to indicate if at limit.
  34637. */
  34638. private _isRadiusAtLimit;
  34639. /**
  34640. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  34641. * @param radiusDelta The delta by which to animate to. Can be negative.
  34642. */
  34643. private _applyBoundRadiusAnimation;
  34644. /**
  34645. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  34646. */
  34647. protected _clearAnimationLocks(): void;
  34648. /**
  34649. * Stops and removes all animations that have been applied to the camera
  34650. */
  34651. stopAllAnimations(): void;
  34652. }
  34653. }
  34654. declare module BABYLON {
  34655. /**
  34656. * 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.
  34657. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34658. */
  34659. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  34660. /**
  34661. * Gets the name of the behavior.
  34662. */
  34663. readonly name: string;
  34664. private _mode;
  34665. private _radiusScale;
  34666. private _positionScale;
  34667. private _defaultElevation;
  34668. private _elevationReturnTime;
  34669. private _elevationReturnWaitTime;
  34670. private _zoomStopsAnimation;
  34671. private _framingTime;
  34672. /**
  34673. * The easing function used by animations
  34674. */
  34675. static EasingFunction: ExponentialEase;
  34676. /**
  34677. * The easing mode used by animations
  34678. */
  34679. static EasingMode: number;
  34680. /**
  34681. * Sets the current mode used by the behavior
  34682. */
  34683. /**
  34684. * Gets current mode used by the behavior.
  34685. */
  34686. mode: number;
  34687. /**
  34688. * Sets the scale applied to the radius (1 by default)
  34689. */
  34690. /**
  34691. * Gets the scale applied to the radius
  34692. */
  34693. radiusScale: number;
  34694. /**
  34695. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34696. */
  34697. /**
  34698. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34699. */
  34700. positionScale: number;
  34701. /**
  34702. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34703. * behaviour is triggered, in radians.
  34704. */
  34705. /**
  34706. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34707. * behaviour is triggered, in radians.
  34708. */
  34709. defaultElevation: number;
  34710. /**
  34711. * Sets the time (in milliseconds) taken to return to the default beta position.
  34712. * Negative value indicates camera should not return to default.
  34713. */
  34714. /**
  34715. * Gets the time (in milliseconds) taken to return to the default beta position.
  34716. * Negative value indicates camera should not return to default.
  34717. */
  34718. elevationReturnTime: number;
  34719. /**
  34720. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34721. */
  34722. /**
  34723. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34724. */
  34725. elevationReturnWaitTime: number;
  34726. /**
  34727. * Sets the flag that indicates if user zooming should stop animation.
  34728. */
  34729. /**
  34730. * Gets the flag that indicates if user zooming should stop animation.
  34731. */
  34732. zoomStopsAnimation: boolean;
  34733. /**
  34734. * Sets the transition time when framing the mesh, in milliseconds
  34735. */
  34736. /**
  34737. * Gets the transition time when framing the mesh, in milliseconds
  34738. */
  34739. framingTime: number;
  34740. /**
  34741. * Define if the behavior should automatically change the configured
  34742. * camera limits and sensibilities.
  34743. */
  34744. autoCorrectCameraLimitsAndSensibility: boolean;
  34745. private _onPrePointerObservableObserver;
  34746. private _onAfterCheckInputsObserver;
  34747. private _onMeshTargetChangedObserver;
  34748. private _attachedCamera;
  34749. private _isPointerDown;
  34750. private _lastInteractionTime;
  34751. /**
  34752. * Initializes the behavior.
  34753. */
  34754. init(): void;
  34755. /**
  34756. * Attaches the behavior to its arc rotate camera.
  34757. * @param camera Defines the camera to attach the behavior to
  34758. */
  34759. attach(camera: ArcRotateCamera): void;
  34760. /**
  34761. * Detaches the behavior from its current arc rotate camera.
  34762. */
  34763. detach(): void;
  34764. private _animatables;
  34765. private _betaIsAnimating;
  34766. private _betaTransition;
  34767. private _radiusTransition;
  34768. private _vectorTransition;
  34769. /**
  34770. * Targets the given mesh and updates zoom level accordingly.
  34771. * @param mesh The mesh to target.
  34772. * @param radius Optional. If a cached radius position already exists, overrides default.
  34773. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34774. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34775. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34776. */
  34777. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34778. /**
  34779. * Targets the given mesh with its children and updates zoom level accordingly.
  34780. * @param mesh The mesh to target.
  34781. * @param radius Optional. If a cached radius position already exists, overrides default.
  34782. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34783. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34784. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34785. */
  34786. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34787. /**
  34788. * Targets the given meshes with their children and updates zoom level accordingly.
  34789. * @param meshes The mesh to target.
  34790. * @param radius Optional. If a cached radius position already exists, overrides default.
  34791. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34792. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34793. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34794. */
  34795. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34796. /**
  34797. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  34798. * @param minimumWorld Determines the smaller position of the bounding box extend
  34799. * @param maximumWorld Determines the bigger position of the bounding box extend
  34800. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34801. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34802. */
  34803. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34804. /**
  34805. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  34806. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  34807. * frustum width.
  34808. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  34809. * to fully enclose the mesh in the viewing frustum.
  34810. */
  34811. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  34812. /**
  34813. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  34814. * is automatically returned to its default position (expected to be above ground plane).
  34815. */
  34816. private _maintainCameraAboveGround;
  34817. /**
  34818. * Returns the frustum slope based on the canvas ratio and camera FOV
  34819. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  34820. */
  34821. private _getFrustumSlope;
  34822. /**
  34823. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  34824. */
  34825. private _clearAnimationLocks;
  34826. /**
  34827. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34828. */
  34829. private _applyUserInteraction;
  34830. /**
  34831. * Stops and removes all animations that have been applied to the camera
  34832. */
  34833. stopAllAnimations(): void;
  34834. /**
  34835. * Gets a value indicating if the user is moving the camera
  34836. */
  34837. readonly isUserIsMoving: boolean;
  34838. /**
  34839. * The camera can move all the way towards the mesh.
  34840. */
  34841. static IgnoreBoundsSizeMode: number;
  34842. /**
  34843. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  34844. */
  34845. static FitFrustumSidesMode: number;
  34846. }
  34847. }
  34848. declare module BABYLON {
  34849. /**
  34850. * Base class for Camera Pointer Inputs.
  34851. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  34852. * for example usage.
  34853. */
  34854. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  34855. /**
  34856. * Defines the camera the input is attached to.
  34857. */
  34858. abstract camera: Camera;
  34859. /**
  34860. * Whether keyboard modifier keys are pressed at time of last mouse event.
  34861. */
  34862. protected _altKey: boolean;
  34863. protected _ctrlKey: boolean;
  34864. protected _metaKey: boolean;
  34865. protected _shiftKey: boolean;
  34866. /**
  34867. * Which mouse buttons were pressed at time of last mouse event.
  34868. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  34869. */
  34870. protected _buttonsPressed: number;
  34871. /**
  34872. * Defines the buttons associated with the input to handle camera move.
  34873. */
  34874. buttons: number[];
  34875. /**
  34876. * Attach the input controls to a specific dom element to get the input from.
  34877. * @param element Defines the element the controls should be listened from
  34878. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34879. */
  34880. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34881. /**
  34882. * Detach the current controls from the specified dom element.
  34883. * @param element Defines the element to stop listening the inputs from
  34884. */
  34885. detachControl(element: Nullable<HTMLElement>): void;
  34886. /**
  34887. * Gets the class name of the current input.
  34888. * @returns the class name
  34889. */
  34890. getClassName(): string;
  34891. /**
  34892. * Get the friendly name associated with the input class.
  34893. * @returns the input friendly name
  34894. */
  34895. getSimpleName(): string;
  34896. /**
  34897. * Called on pointer POINTERDOUBLETAP event.
  34898. * Override this method to provide functionality on POINTERDOUBLETAP event.
  34899. */
  34900. protected onDoubleTap(type: string): void;
  34901. /**
  34902. * Called on pointer POINTERMOVE event if only a single touch is active.
  34903. * Override this method to provide functionality.
  34904. */
  34905. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34906. /**
  34907. * Called on pointer POINTERMOVE event if multiple touches are active.
  34908. * Override this method to provide functionality.
  34909. */
  34910. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34911. /**
  34912. * Called on JS contextmenu event.
  34913. * Override this method to provide functionality.
  34914. */
  34915. protected onContextMenu(evt: PointerEvent): void;
  34916. /**
  34917. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34918. * press.
  34919. * Override this method to provide functionality.
  34920. */
  34921. protected onButtonDown(evt: PointerEvent): void;
  34922. /**
  34923. * Called each time a new POINTERUP event occurs. Ie, for each button
  34924. * release.
  34925. * Override this method to provide functionality.
  34926. */
  34927. protected onButtonUp(evt: PointerEvent): void;
  34928. /**
  34929. * Called when window becomes inactive.
  34930. * Override this method to provide functionality.
  34931. */
  34932. protected onLostFocus(): void;
  34933. private _pointerInput;
  34934. private _observer;
  34935. private _onLostFocus;
  34936. private pointA;
  34937. private pointB;
  34938. }
  34939. }
  34940. declare module BABYLON {
  34941. /**
  34942. * Manage the pointers inputs to control an arc rotate camera.
  34943. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34944. */
  34945. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  34946. /**
  34947. * Defines the camera the input is attached to.
  34948. */
  34949. camera: ArcRotateCamera;
  34950. /**
  34951. * Gets the class name of the current input.
  34952. * @returns the class name
  34953. */
  34954. getClassName(): string;
  34955. /**
  34956. * Defines the buttons associated with the input to handle camera move.
  34957. */
  34958. buttons: number[];
  34959. /**
  34960. * Defines the pointer angular sensibility along the X axis or how fast is
  34961. * the camera rotating.
  34962. */
  34963. angularSensibilityX: number;
  34964. /**
  34965. * Defines the pointer angular sensibility along the Y axis or how fast is
  34966. * the camera rotating.
  34967. */
  34968. angularSensibilityY: number;
  34969. /**
  34970. * Defines the pointer pinch precision or how fast is the camera zooming.
  34971. */
  34972. pinchPrecision: number;
  34973. /**
  34974. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  34975. * from 0.
  34976. * It defines the percentage of current camera.radius to use as delta when
  34977. * pinch zoom is used.
  34978. */
  34979. pinchDeltaPercentage: number;
  34980. /**
  34981. * Defines the pointer panning sensibility or how fast is the camera moving.
  34982. */
  34983. panningSensibility: number;
  34984. /**
  34985. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  34986. */
  34987. multiTouchPanning: boolean;
  34988. /**
  34989. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  34990. * zoom (pinch) through multitouch.
  34991. */
  34992. multiTouchPanAndZoom: boolean;
  34993. /**
  34994. * Revers pinch action direction.
  34995. */
  34996. pinchInwards: boolean;
  34997. private _isPanClick;
  34998. private _twoFingerActivityCount;
  34999. private _isPinching;
  35000. /**
  35001. * Called on pointer POINTERMOVE event if only a single touch is active.
  35002. */
  35003. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35004. /**
  35005. * Called on pointer POINTERDOUBLETAP event.
  35006. */
  35007. protected onDoubleTap(type: string): void;
  35008. /**
  35009. * Called on pointer POINTERMOVE event if multiple touches are active.
  35010. */
  35011. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35012. /**
  35013. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35014. * press.
  35015. */
  35016. protected onButtonDown(evt: PointerEvent): void;
  35017. /**
  35018. * Called each time a new POINTERUP event occurs. Ie, for each button
  35019. * release.
  35020. */
  35021. protected onButtonUp(evt: PointerEvent): void;
  35022. /**
  35023. * Called when window becomes inactive.
  35024. */
  35025. protected onLostFocus(): void;
  35026. }
  35027. }
  35028. declare module BABYLON {
  35029. /**
  35030. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35031. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35032. */
  35033. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35034. /**
  35035. * Defines the camera the input is attached to.
  35036. */
  35037. camera: ArcRotateCamera;
  35038. /**
  35039. * Defines the list of key codes associated with the up action (increase alpha)
  35040. */
  35041. keysUp: number[];
  35042. /**
  35043. * Defines the list of key codes associated with the down action (decrease alpha)
  35044. */
  35045. keysDown: number[];
  35046. /**
  35047. * Defines the list of key codes associated with the left action (increase beta)
  35048. */
  35049. keysLeft: number[];
  35050. /**
  35051. * Defines the list of key codes associated with the right action (decrease beta)
  35052. */
  35053. keysRight: number[];
  35054. /**
  35055. * Defines the list of key codes associated with the reset action.
  35056. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35057. */
  35058. keysReset: number[];
  35059. /**
  35060. * Defines the panning sensibility of the inputs.
  35061. * (How fast is the camera paning)
  35062. */
  35063. panningSensibility: number;
  35064. /**
  35065. * Defines the zooming sensibility of the inputs.
  35066. * (How fast is the camera zooming)
  35067. */
  35068. zoomingSensibility: number;
  35069. /**
  35070. * Defines wether maintaining the alt key down switch the movement mode from
  35071. * orientation to zoom.
  35072. */
  35073. useAltToZoom: boolean;
  35074. /**
  35075. * Rotation speed of the camera
  35076. */
  35077. angularSpeed: number;
  35078. private _keys;
  35079. private _ctrlPressed;
  35080. private _altPressed;
  35081. private _onCanvasBlurObserver;
  35082. private _onKeyboardObserver;
  35083. private _engine;
  35084. private _scene;
  35085. /**
  35086. * Attach the input controls to a specific dom element to get the input from.
  35087. * @param element Defines the element the controls should be listened from
  35088. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35089. */
  35090. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35091. /**
  35092. * Detach the current controls from the specified dom element.
  35093. * @param element Defines the element to stop listening the inputs from
  35094. */
  35095. detachControl(element: Nullable<HTMLElement>): void;
  35096. /**
  35097. * Update the current camera state depending on the inputs that have been used this frame.
  35098. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35099. */
  35100. checkInputs(): void;
  35101. /**
  35102. * Gets the class name of the current intput.
  35103. * @returns the class name
  35104. */
  35105. getClassName(): string;
  35106. /**
  35107. * Get the friendly name associated with the input class.
  35108. * @returns the input friendly name
  35109. */
  35110. getSimpleName(): string;
  35111. }
  35112. }
  35113. declare module BABYLON {
  35114. /**
  35115. * Manage the mouse wheel inputs to control an arc rotate camera.
  35116. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35117. */
  35118. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35119. /**
  35120. * Defines the camera the input is attached to.
  35121. */
  35122. camera: ArcRotateCamera;
  35123. /**
  35124. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35125. */
  35126. wheelPrecision: number;
  35127. /**
  35128. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35129. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35130. */
  35131. wheelDeltaPercentage: number;
  35132. private _wheel;
  35133. private _observer;
  35134. private computeDeltaFromMouseWheelLegacyEvent;
  35135. /**
  35136. * Attach the input controls to a specific dom element to get the input from.
  35137. * @param element Defines the element the controls should be listened from
  35138. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35139. */
  35140. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35141. /**
  35142. * Detach the current controls from the specified dom element.
  35143. * @param element Defines the element to stop listening the inputs from
  35144. */
  35145. detachControl(element: Nullable<HTMLElement>): void;
  35146. /**
  35147. * Gets the class name of the current intput.
  35148. * @returns the class name
  35149. */
  35150. getClassName(): string;
  35151. /**
  35152. * Get the friendly name associated with the input class.
  35153. * @returns the input friendly name
  35154. */
  35155. getSimpleName(): string;
  35156. }
  35157. }
  35158. declare module BABYLON {
  35159. /**
  35160. * Default Inputs manager for the ArcRotateCamera.
  35161. * It groups all the default supported inputs for ease of use.
  35162. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35163. */
  35164. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35165. /**
  35166. * Instantiates a new ArcRotateCameraInputsManager.
  35167. * @param camera Defines the camera the inputs belong to
  35168. */
  35169. constructor(camera: ArcRotateCamera);
  35170. /**
  35171. * Add mouse wheel input support to the input manager.
  35172. * @returns the current input manager
  35173. */
  35174. addMouseWheel(): ArcRotateCameraInputsManager;
  35175. /**
  35176. * Add pointers input support to the input manager.
  35177. * @returns the current input manager
  35178. */
  35179. addPointers(): ArcRotateCameraInputsManager;
  35180. /**
  35181. * Add keyboard input support to the input manager.
  35182. * @returns the current input manager
  35183. */
  35184. addKeyboard(): ArcRotateCameraInputsManager;
  35185. }
  35186. }
  35187. declare module BABYLON {
  35188. /**
  35189. * This represents an orbital type of camera.
  35190. *
  35191. * 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.
  35192. * 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.
  35193. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35194. */
  35195. export class ArcRotateCamera extends TargetCamera {
  35196. /**
  35197. * Defines the rotation angle of the camera along the longitudinal axis.
  35198. */
  35199. alpha: number;
  35200. /**
  35201. * Defines the rotation angle of the camera along the latitudinal axis.
  35202. */
  35203. beta: number;
  35204. /**
  35205. * Defines the radius of the camera from it s target point.
  35206. */
  35207. radius: number;
  35208. protected _target: Vector3;
  35209. protected _targetHost: Nullable<AbstractMesh>;
  35210. /**
  35211. * Defines the target point of the camera.
  35212. * The camera looks towards it form the radius distance.
  35213. */
  35214. target: Vector3;
  35215. /**
  35216. * Define the current local position of the camera in the scene
  35217. */
  35218. position: Vector3;
  35219. protected _upVector: Vector3;
  35220. protected _upToYMatrix: Matrix;
  35221. protected _YToUpMatrix: Matrix;
  35222. /**
  35223. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  35224. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  35225. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  35226. */
  35227. upVector: Vector3;
  35228. /**
  35229. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  35230. */
  35231. setMatUp(): void;
  35232. /**
  35233. * Current inertia value on the longitudinal axis.
  35234. * The bigger this number the longer it will take for the camera to stop.
  35235. */
  35236. inertialAlphaOffset: number;
  35237. /**
  35238. * Current inertia value on the latitudinal axis.
  35239. * The bigger this number the longer it will take for the camera to stop.
  35240. */
  35241. inertialBetaOffset: number;
  35242. /**
  35243. * Current inertia value on the radius axis.
  35244. * The bigger this number the longer it will take for the camera to stop.
  35245. */
  35246. inertialRadiusOffset: number;
  35247. /**
  35248. * Minimum allowed angle on the longitudinal axis.
  35249. * This can help limiting how the Camera is able to move in the scene.
  35250. */
  35251. lowerAlphaLimit: Nullable<number>;
  35252. /**
  35253. * Maximum allowed angle on the longitudinal axis.
  35254. * This can help limiting how the Camera is able to move in the scene.
  35255. */
  35256. upperAlphaLimit: Nullable<number>;
  35257. /**
  35258. * Minimum allowed angle on the latitudinal axis.
  35259. * This can help limiting how the Camera is able to move in the scene.
  35260. */
  35261. lowerBetaLimit: number;
  35262. /**
  35263. * Maximum allowed angle on the latitudinal axis.
  35264. * This can help limiting how the Camera is able to move in the scene.
  35265. */
  35266. upperBetaLimit: number;
  35267. /**
  35268. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35269. * This can help limiting how the Camera is able to move in the scene.
  35270. */
  35271. lowerRadiusLimit: Nullable<number>;
  35272. /**
  35273. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35274. * This can help limiting how the Camera is able to move in the scene.
  35275. */
  35276. upperRadiusLimit: Nullable<number>;
  35277. /**
  35278. * Defines the current inertia value used during panning of the camera along the X axis.
  35279. */
  35280. inertialPanningX: number;
  35281. /**
  35282. * Defines the current inertia value used during panning of the camera along the Y axis.
  35283. */
  35284. inertialPanningY: number;
  35285. /**
  35286. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35287. * Basically if your fingers moves away from more than this distance you will be considered
  35288. * in pinch mode.
  35289. */
  35290. pinchToPanMaxDistance: number;
  35291. /**
  35292. * Defines the maximum distance the camera can pan.
  35293. * This could help keeping the cammera always in your scene.
  35294. */
  35295. panningDistanceLimit: Nullable<number>;
  35296. /**
  35297. * Defines the target of the camera before paning.
  35298. */
  35299. panningOriginTarget: Vector3;
  35300. /**
  35301. * Defines the value of the inertia used during panning.
  35302. * 0 would mean stop inertia and one would mean no decelleration at all.
  35303. */
  35304. panningInertia: number;
  35305. /**
  35306. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35307. */
  35308. angularSensibilityX: number;
  35309. /**
  35310. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35311. */
  35312. angularSensibilityY: number;
  35313. /**
  35314. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35315. */
  35316. pinchPrecision: number;
  35317. /**
  35318. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35319. * It will be used instead of pinchDeltaPrecision if different from 0.
  35320. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35321. */
  35322. pinchDeltaPercentage: number;
  35323. /**
  35324. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35325. */
  35326. panningSensibility: number;
  35327. /**
  35328. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35329. */
  35330. keysUp: number[];
  35331. /**
  35332. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35333. */
  35334. keysDown: number[];
  35335. /**
  35336. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35337. */
  35338. keysLeft: number[];
  35339. /**
  35340. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35341. */
  35342. keysRight: number[];
  35343. /**
  35344. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35345. */
  35346. wheelPrecision: number;
  35347. /**
  35348. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35349. * It will be used instead of pinchDeltaPrecision if different from 0.
  35350. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35351. */
  35352. wheelDeltaPercentage: number;
  35353. /**
  35354. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35355. */
  35356. zoomOnFactor: number;
  35357. /**
  35358. * Defines a screen offset for the camera position.
  35359. */
  35360. targetScreenOffset: Vector2;
  35361. /**
  35362. * Allows the camera to be completely reversed.
  35363. * If false the camera can not arrive upside down.
  35364. */
  35365. allowUpsideDown: boolean;
  35366. /**
  35367. * Define if double tap/click is used to restore the previously saved state of the camera.
  35368. */
  35369. useInputToRestoreState: boolean;
  35370. /** @hidden */
  35371. _viewMatrix: Matrix;
  35372. /** @hidden */
  35373. _useCtrlForPanning: boolean;
  35374. /** @hidden */
  35375. _panningMouseButton: number;
  35376. /**
  35377. * Defines the input associated to the camera.
  35378. */
  35379. inputs: ArcRotateCameraInputsManager;
  35380. /** @hidden */
  35381. _reset: () => void;
  35382. /**
  35383. * Defines the allowed panning axis.
  35384. */
  35385. panningAxis: Vector3;
  35386. protected _localDirection: Vector3;
  35387. protected _transformedDirection: Vector3;
  35388. private _bouncingBehavior;
  35389. /**
  35390. * Gets the bouncing behavior of the camera if it has been enabled.
  35391. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35392. */
  35393. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35394. /**
  35395. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35396. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35397. */
  35398. useBouncingBehavior: boolean;
  35399. private _framingBehavior;
  35400. /**
  35401. * Gets the framing behavior of the camera if it has been enabled.
  35402. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35403. */
  35404. readonly framingBehavior: Nullable<FramingBehavior>;
  35405. /**
  35406. * Defines if the framing behavior of the camera is enabled on the camera.
  35407. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35408. */
  35409. useFramingBehavior: boolean;
  35410. private _autoRotationBehavior;
  35411. /**
  35412. * Gets the auto rotation behavior of the camera if it has been enabled.
  35413. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35414. */
  35415. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35416. /**
  35417. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35418. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35419. */
  35420. useAutoRotationBehavior: boolean;
  35421. /**
  35422. * Observable triggered when the mesh target has been changed on the camera.
  35423. */
  35424. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35425. /**
  35426. * Event raised when the camera is colliding with a mesh.
  35427. */
  35428. onCollide: (collidedMesh: AbstractMesh) => void;
  35429. /**
  35430. * Defines whether the camera should check collision with the objects oh the scene.
  35431. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35432. */
  35433. checkCollisions: boolean;
  35434. /**
  35435. * Defines the collision radius of the camera.
  35436. * This simulates a sphere around the camera.
  35437. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35438. */
  35439. collisionRadius: Vector3;
  35440. protected _collider: Collider;
  35441. protected _previousPosition: Vector3;
  35442. protected _collisionVelocity: Vector3;
  35443. protected _newPosition: Vector3;
  35444. protected _previousAlpha: number;
  35445. protected _previousBeta: number;
  35446. protected _previousRadius: number;
  35447. protected _collisionTriggered: boolean;
  35448. protected _targetBoundingCenter: Nullable<Vector3>;
  35449. private _computationVector;
  35450. /**
  35451. * Instantiates a new ArcRotateCamera in a given scene
  35452. * @param name Defines the name of the camera
  35453. * @param alpha Defines the camera rotation along the logitudinal axis
  35454. * @param beta Defines the camera rotation along the latitudinal axis
  35455. * @param radius Defines the camera distance from its target
  35456. * @param target Defines the camera target
  35457. * @param scene Defines the scene the camera belongs to
  35458. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35459. */
  35460. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35461. /** @hidden */
  35462. _initCache(): void;
  35463. /** @hidden */
  35464. _updateCache(ignoreParentClass?: boolean): void;
  35465. protected _getTargetPosition(): Vector3;
  35466. private _storedAlpha;
  35467. private _storedBeta;
  35468. private _storedRadius;
  35469. private _storedTarget;
  35470. /**
  35471. * Stores the current state of the camera (alpha, beta, radius and target)
  35472. * @returns the camera itself
  35473. */
  35474. storeState(): Camera;
  35475. /**
  35476. * @hidden
  35477. * Restored camera state. You must call storeState() first
  35478. */
  35479. _restoreStateValues(): boolean;
  35480. /** @hidden */
  35481. _isSynchronizedViewMatrix(): boolean;
  35482. /**
  35483. * Attached controls to the current camera.
  35484. * @param element Defines the element the controls should be listened from
  35485. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35486. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35487. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35488. */
  35489. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35490. /**
  35491. * Detach the current controls from the camera.
  35492. * The camera will stop reacting to inputs.
  35493. * @param element Defines the element to stop listening the inputs from
  35494. */
  35495. detachControl(element: HTMLElement): void;
  35496. /** @hidden */
  35497. _checkInputs(): void;
  35498. protected _checkLimits(): void;
  35499. /**
  35500. * Rebuilds angles (alpha, beta) and radius from the give position and target
  35501. */
  35502. rebuildAnglesAndRadius(): void;
  35503. /**
  35504. * Use a position to define the current camera related information like aplha, beta and radius
  35505. * @param position Defines the position to set the camera at
  35506. */
  35507. setPosition(position: Vector3): void;
  35508. /**
  35509. * Defines the target the camera should look at.
  35510. * This will automatically adapt alpha beta and radius to fit within the new target.
  35511. * @param target Defines the new target as a Vector or a mesh
  35512. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35513. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35514. */
  35515. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35516. /** @hidden */
  35517. _getViewMatrix(): Matrix;
  35518. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35519. /**
  35520. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35521. * @param meshes Defines the mesh to zoom on
  35522. * @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)
  35523. */
  35524. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35525. /**
  35526. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35527. * The target will be changed but the radius
  35528. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35529. * @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)
  35530. */
  35531. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35532. min: Vector3;
  35533. max: Vector3;
  35534. distance: number;
  35535. }, doNotUpdateMaxZ?: boolean): void;
  35536. /**
  35537. * @override
  35538. * Override Camera.createRigCamera
  35539. */
  35540. createRigCamera(name: string, cameraIndex: number): Camera;
  35541. /**
  35542. * @hidden
  35543. * @override
  35544. * Override Camera._updateRigCameras
  35545. */
  35546. _updateRigCameras(): void;
  35547. /**
  35548. * Destroy the camera and release the current resources hold by it.
  35549. */
  35550. dispose(): void;
  35551. /**
  35552. * Gets the current object class name.
  35553. * @return the class name
  35554. */
  35555. getClassName(): string;
  35556. }
  35557. }
  35558. declare module BABYLON {
  35559. /**
  35560. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35561. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35562. */
  35563. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35564. /**
  35565. * Gets the name of the behavior.
  35566. */
  35567. readonly name: string;
  35568. private _zoomStopsAnimation;
  35569. private _idleRotationSpeed;
  35570. private _idleRotationWaitTime;
  35571. private _idleRotationSpinupTime;
  35572. /**
  35573. * Sets the flag that indicates if user zooming should stop animation.
  35574. */
  35575. /**
  35576. * Gets the flag that indicates if user zooming should stop animation.
  35577. */
  35578. zoomStopsAnimation: boolean;
  35579. /**
  35580. * Sets the default speed at which the camera rotates around the model.
  35581. */
  35582. /**
  35583. * Gets the default speed at which the camera rotates around the model.
  35584. */
  35585. idleRotationSpeed: number;
  35586. /**
  35587. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35588. */
  35589. /**
  35590. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35591. */
  35592. idleRotationWaitTime: number;
  35593. /**
  35594. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35595. */
  35596. /**
  35597. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35598. */
  35599. idleRotationSpinupTime: number;
  35600. /**
  35601. * Gets a value indicating if the camera is currently rotating because of this behavior
  35602. */
  35603. readonly rotationInProgress: boolean;
  35604. private _onPrePointerObservableObserver;
  35605. private _onAfterCheckInputsObserver;
  35606. private _attachedCamera;
  35607. private _isPointerDown;
  35608. private _lastFrameTime;
  35609. private _lastInteractionTime;
  35610. private _cameraRotationSpeed;
  35611. /**
  35612. * Initializes the behavior.
  35613. */
  35614. init(): void;
  35615. /**
  35616. * Attaches the behavior to its arc rotate camera.
  35617. * @param camera Defines the camera to attach the behavior to
  35618. */
  35619. attach(camera: ArcRotateCamera): void;
  35620. /**
  35621. * Detaches the behavior from its current arc rotate camera.
  35622. */
  35623. detach(): void;
  35624. /**
  35625. * Returns true if user is scrolling.
  35626. * @return true if user is scrolling.
  35627. */
  35628. private _userIsZooming;
  35629. private _lastFrameRadius;
  35630. private _shouldAnimationStopForInteraction;
  35631. /**
  35632. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35633. */
  35634. private _applyUserInteraction;
  35635. private _userIsMoving;
  35636. }
  35637. }
  35638. declare module BABYLON {
  35639. /**
  35640. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  35641. */
  35642. export class AttachToBoxBehavior implements Behavior<Mesh> {
  35643. private ui;
  35644. /**
  35645. * The name of the behavior
  35646. */
  35647. name: string;
  35648. /**
  35649. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  35650. */
  35651. distanceAwayFromFace: number;
  35652. /**
  35653. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  35654. */
  35655. distanceAwayFromBottomOfFace: number;
  35656. private _faceVectors;
  35657. private _target;
  35658. private _scene;
  35659. private _onRenderObserver;
  35660. private _tmpMatrix;
  35661. private _tmpVector;
  35662. /**
  35663. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  35664. * @param ui The transform node that should be attched to the mesh
  35665. */
  35666. constructor(ui: TransformNode);
  35667. /**
  35668. * Initializes the behavior
  35669. */
  35670. init(): void;
  35671. private _closestFace;
  35672. private _zeroVector;
  35673. private _lookAtTmpMatrix;
  35674. private _lookAtToRef;
  35675. /**
  35676. * Attaches the AttachToBoxBehavior to the passed in mesh
  35677. * @param target The mesh that the specified node will be attached to
  35678. */
  35679. attach(target: Mesh): void;
  35680. /**
  35681. * Detaches the behavior from the mesh
  35682. */
  35683. detach(): void;
  35684. }
  35685. }
  35686. declare module BABYLON {
  35687. /**
  35688. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  35689. */
  35690. export class FadeInOutBehavior implements Behavior<Mesh> {
  35691. /**
  35692. * Time in milliseconds to delay before fading in (Default: 0)
  35693. */
  35694. delay: number;
  35695. /**
  35696. * Time in milliseconds for the mesh to fade in (Default: 300)
  35697. */
  35698. fadeInTime: number;
  35699. private _millisecondsPerFrame;
  35700. private _hovered;
  35701. private _hoverValue;
  35702. private _ownerNode;
  35703. /**
  35704. * Instatiates the FadeInOutBehavior
  35705. */
  35706. constructor();
  35707. /**
  35708. * The name of the behavior
  35709. */
  35710. readonly name: string;
  35711. /**
  35712. * Initializes the behavior
  35713. */
  35714. init(): void;
  35715. /**
  35716. * Attaches the fade behavior on the passed in mesh
  35717. * @param ownerNode The mesh that will be faded in/out once attached
  35718. */
  35719. attach(ownerNode: Mesh): void;
  35720. /**
  35721. * Detaches the behavior from the mesh
  35722. */
  35723. detach(): void;
  35724. /**
  35725. * Triggers the mesh to begin fading in or out
  35726. * @param value if the object should fade in or out (true to fade in)
  35727. */
  35728. fadeIn(value: boolean): void;
  35729. private _update;
  35730. private _setAllVisibility;
  35731. }
  35732. }
  35733. declare module BABYLON {
  35734. /**
  35735. * Class containing a set of static utilities functions for managing Pivots
  35736. * @hidden
  35737. */
  35738. export class PivotTools {
  35739. private static _PivotCached;
  35740. private static _OldPivotPoint;
  35741. private static _PivotTranslation;
  35742. private static _PivotTmpVector;
  35743. /** @hidden */
  35744. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  35745. /** @hidden */
  35746. static _RestorePivotPoint(mesh: AbstractMesh): void;
  35747. }
  35748. }
  35749. declare module BABYLON {
  35750. /**
  35751. * Class containing static functions to help procedurally build meshes
  35752. */
  35753. export class PlaneBuilder {
  35754. /**
  35755. * Creates a plane mesh
  35756. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  35757. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  35758. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  35759. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35760. * * 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
  35761. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35762. * @param name defines the name of the mesh
  35763. * @param options defines the options used to create the mesh
  35764. * @param scene defines the hosting scene
  35765. * @returns the plane mesh
  35766. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  35767. */
  35768. static CreatePlane(name: string, options: {
  35769. size?: number;
  35770. width?: number;
  35771. height?: number;
  35772. sideOrientation?: number;
  35773. frontUVs?: Vector4;
  35774. backUVs?: Vector4;
  35775. updatable?: boolean;
  35776. sourcePlane?: Plane;
  35777. }, scene?: Nullable<Scene>): Mesh;
  35778. }
  35779. }
  35780. declare module BABYLON {
  35781. /**
  35782. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  35783. */
  35784. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  35785. private static _AnyMouseID;
  35786. /**
  35787. * Abstract mesh the behavior is set on
  35788. */
  35789. attachedNode: AbstractMesh;
  35790. private _dragPlane;
  35791. private _scene;
  35792. private _pointerObserver;
  35793. private _beforeRenderObserver;
  35794. private static _planeScene;
  35795. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  35796. /**
  35797. * 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)
  35798. */
  35799. maxDragAngle: number;
  35800. /**
  35801. * @hidden
  35802. */
  35803. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  35804. /**
  35805. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35806. */
  35807. currentDraggingPointerID: number;
  35808. /**
  35809. * The last position where the pointer hit the drag plane in world space
  35810. */
  35811. lastDragPosition: Vector3;
  35812. /**
  35813. * If the behavior is currently in a dragging state
  35814. */
  35815. dragging: boolean;
  35816. /**
  35817. * 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)
  35818. */
  35819. dragDeltaRatio: number;
  35820. /**
  35821. * If the drag plane orientation should be updated during the dragging (Default: true)
  35822. */
  35823. updateDragPlane: boolean;
  35824. private _debugMode;
  35825. private _moving;
  35826. /**
  35827. * Fires each time the attached mesh is dragged with the pointer
  35828. * * delta between last drag position and current drag position in world space
  35829. * * dragDistance along the drag axis
  35830. * * dragPlaneNormal normal of the current drag plane used during the drag
  35831. * * dragPlanePoint in world space where the drag intersects the drag plane
  35832. */
  35833. onDragObservable: Observable<{
  35834. delta: Vector3;
  35835. dragPlanePoint: Vector3;
  35836. dragPlaneNormal: Vector3;
  35837. dragDistance: number;
  35838. pointerId: number;
  35839. }>;
  35840. /**
  35841. * Fires each time a drag begins (eg. mouse down on mesh)
  35842. */
  35843. onDragStartObservable: Observable<{
  35844. dragPlanePoint: Vector3;
  35845. pointerId: number;
  35846. }>;
  35847. /**
  35848. * Fires each time a drag ends (eg. mouse release after drag)
  35849. */
  35850. onDragEndObservable: Observable<{
  35851. dragPlanePoint: Vector3;
  35852. pointerId: number;
  35853. }>;
  35854. /**
  35855. * If the attached mesh should be moved when dragged
  35856. */
  35857. moveAttached: boolean;
  35858. /**
  35859. * If the drag behavior will react to drag events (Default: true)
  35860. */
  35861. enabled: boolean;
  35862. /**
  35863. * If camera controls should be detached during the drag
  35864. */
  35865. detachCameraControls: boolean;
  35866. /**
  35867. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  35868. */
  35869. useObjectOrienationForDragging: boolean;
  35870. private _options;
  35871. /**
  35872. * Creates a pointer drag behavior that can be attached to a mesh
  35873. * @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)
  35874. */
  35875. constructor(options?: {
  35876. dragAxis?: Vector3;
  35877. dragPlaneNormal?: Vector3;
  35878. });
  35879. /**
  35880. * Predicate to determine if it is valid to move the object to a new position when it is moved
  35881. */
  35882. validateDrag: (targetPosition: Vector3) => boolean;
  35883. /**
  35884. * The name of the behavior
  35885. */
  35886. readonly name: string;
  35887. /**
  35888. * Initializes the behavior
  35889. */
  35890. init(): void;
  35891. private _tmpVector;
  35892. private _alternatePickedPoint;
  35893. private _worldDragAxis;
  35894. private _targetPosition;
  35895. private _attachedElement;
  35896. /**
  35897. * Attaches the drag behavior the passed in mesh
  35898. * @param ownerNode The mesh that will be dragged around once attached
  35899. */
  35900. attach(ownerNode: AbstractMesh): void;
  35901. /**
  35902. * Force relase the drag action by code.
  35903. */
  35904. releaseDrag(): void;
  35905. private _startDragRay;
  35906. private _lastPointerRay;
  35907. /**
  35908. * Simulates the start of a pointer drag event on the behavior
  35909. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  35910. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  35911. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  35912. */
  35913. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  35914. private _startDrag;
  35915. private _dragDelta;
  35916. private _moveDrag;
  35917. private _pickWithRayOnDragPlane;
  35918. private _pointA;
  35919. private _pointB;
  35920. private _pointC;
  35921. private _lineA;
  35922. private _lineB;
  35923. private _localAxis;
  35924. private _lookAt;
  35925. private _updateDragPlanePosition;
  35926. /**
  35927. * Detaches the behavior from the mesh
  35928. */
  35929. detach(): void;
  35930. }
  35931. }
  35932. declare module BABYLON {
  35933. /**
  35934. * A behavior that when attached to a mesh will allow the mesh to be scaled
  35935. */
  35936. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  35937. private _dragBehaviorA;
  35938. private _dragBehaviorB;
  35939. private _startDistance;
  35940. private _initialScale;
  35941. private _targetScale;
  35942. private _ownerNode;
  35943. private _sceneRenderObserver;
  35944. /**
  35945. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  35946. */
  35947. constructor();
  35948. /**
  35949. * The name of the behavior
  35950. */
  35951. readonly name: string;
  35952. /**
  35953. * Initializes the behavior
  35954. */
  35955. init(): void;
  35956. private _getCurrentDistance;
  35957. /**
  35958. * Attaches the scale behavior the passed in mesh
  35959. * @param ownerNode The mesh that will be scaled around once attached
  35960. */
  35961. attach(ownerNode: Mesh): void;
  35962. /**
  35963. * Detaches the behavior from the mesh
  35964. */
  35965. detach(): void;
  35966. }
  35967. }
  35968. declare module BABYLON {
  35969. /**
  35970. * 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
  35971. */
  35972. export class SixDofDragBehavior implements Behavior<Mesh> {
  35973. private static _virtualScene;
  35974. private _ownerNode;
  35975. private _sceneRenderObserver;
  35976. private _scene;
  35977. private _targetPosition;
  35978. private _virtualOriginMesh;
  35979. private _virtualDragMesh;
  35980. private _pointerObserver;
  35981. private _moving;
  35982. private _startingOrientation;
  35983. /**
  35984. * 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)
  35985. */
  35986. private zDragFactor;
  35987. /**
  35988. * If the object should rotate to face the drag origin
  35989. */
  35990. rotateDraggedObject: boolean;
  35991. /**
  35992. * If the behavior is currently in a dragging state
  35993. */
  35994. dragging: boolean;
  35995. /**
  35996. * 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)
  35997. */
  35998. dragDeltaRatio: number;
  35999. /**
  36000. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36001. */
  36002. currentDraggingPointerID: number;
  36003. /**
  36004. * If camera controls should be detached during the drag
  36005. */
  36006. detachCameraControls: boolean;
  36007. /**
  36008. * Fires each time a drag starts
  36009. */
  36010. onDragStartObservable: Observable<{}>;
  36011. /**
  36012. * Fires each time a drag ends (eg. mouse release after drag)
  36013. */
  36014. onDragEndObservable: Observable<{}>;
  36015. /**
  36016. * 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
  36017. */
  36018. constructor();
  36019. /**
  36020. * The name of the behavior
  36021. */
  36022. readonly name: string;
  36023. /**
  36024. * Initializes the behavior
  36025. */
  36026. init(): void;
  36027. /**
  36028. * Attaches the scale behavior the passed in mesh
  36029. * @param ownerNode The mesh that will be scaled around once attached
  36030. */
  36031. attach(ownerNode: Mesh): void;
  36032. /**
  36033. * Detaches the behavior from the mesh
  36034. */
  36035. detach(): void;
  36036. }
  36037. }
  36038. declare module BABYLON {
  36039. /**
  36040. * Class used to apply inverse kinematics to bones
  36041. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36042. */
  36043. export class BoneIKController {
  36044. private static _tmpVecs;
  36045. private static _tmpQuat;
  36046. private static _tmpMats;
  36047. /**
  36048. * Gets or sets the target mesh
  36049. */
  36050. targetMesh: AbstractMesh;
  36051. /** Gets or sets the mesh used as pole */
  36052. poleTargetMesh: AbstractMesh;
  36053. /**
  36054. * Gets or sets the bone used as pole
  36055. */
  36056. poleTargetBone: Nullable<Bone>;
  36057. /**
  36058. * Gets or sets the target position
  36059. */
  36060. targetPosition: Vector3;
  36061. /**
  36062. * Gets or sets the pole target position
  36063. */
  36064. poleTargetPosition: Vector3;
  36065. /**
  36066. * Gets or sets the pole target local offset
  36067. */
  36068. poleTargetLocalOffset: Vector3;
  36069. /**
  36070. * Gets or sets the pole angle
  36071. */
  36072. poleAngle: number;
  36073. /**
  36074. * Gets or sets the mesh associated with the controller
  36075. */
  36076. mesh: AbstractMesh;
  36077. /**
  36078. * 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)
  36079. */
  36080. slerpAmount: number;
  36081. private _bone1Quat;
  36082. private _bone1Mat;
  36083. private _bone2Ang;
  36084. private _bone1;
  36085. private _bone2;
  36086. private _bone1Length;
  36087. private _bone2Length;
  36088. private _maxAngle;
  36089. private _maxReach;
  36090. private _rightHandedSystem;
  36091. private _bendAxis;
  36092. private _slerping;
  36093. private _adjustRoll;
  36094. /**
  36095. * Gets or sets maximum allowed angle
  36096. */
  36097. maxAngle: number;
  36098. /**
  36099. * Creates a new BoneIKController
  36100. * @param mesh defines the mesh to control
  36101. * @param bone defines the bone to control
  36102. * @param options defines options to set up the controller
  36103. */
  36104. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36105. targetMesh?: AbstractMesh;
  36106. poleTargetMesh?: AbstractMesh;
  36107. poleTargetBone?: Bone;
  36108. poleTargetLocalOffset?: Vector3;
  36109. poleAngle?: number;
  36110. bendAxis?: Vector3;
  36111. maxAngle?: number;
  36112. slerpAmount?: number;
  36113. });
  36114. private _setMaxAngle;
  36115. /**
  36116. * Force the controller to update the bones
  36117. */
  36118. update(): void;
  36119. }
  36120. }
  36121. declare module BABYLON {
  36122. /**
  36123. * Class used to make a bone look toward a point in space
  36124. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36125. */
  36126. export class BoneLookController {
  36127. private static _tmpVecs;
  36128. private static _tmpQuat;
  36129. private static _tmpMats;
  36130. /**
  36131. * The target Vector3 that the bone will look at
  36132. */
  36133. target: Vector3;
  36134. /**
  36135. * The mesh that the bone is attached to
  36136. */
  36137. mesh: AbstractMesh;
  36138. /**
  36139. * The bone that will be looking to the target
  36140. */
  36141. bone: Bone;
  36142. /**
  36143. * The up axis of the coordinate system that is used when the bone is rotated
  36144. */
  36145. upAxis: Vector3;
  36146. /**
  36147. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36148. */
  36149. upAxisSpace: Space;
  36150. /**
  36151. * Used to make an adjustment to the yaw of the bone
  36152. */
  36153. adjustYaw: number;
  36154. /**
  36155. * Used to make an adjustment to the pitch of the bone
  36156. */
  36157. adjustPitch: number;
  36158. /**
  36159. * Used to make an adjustment to the roll of the bone
  36160. */
  36161. adjustRoll: number;
  36162. /**
  36163. * 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)
  36164. */
  36165. slerpAmount: number;
  36166. private _minYaw;
  36167. private _maxYaw;
  36168. private _minPitch;
  36169. private _maxPitch;
  36170. private _minYawSin;
  36171. private _minYawCos;
  36172. private _maxYawSin;
  36173. private _maxYawCos;
  36174. private _midYawConstraint;
  36175. private _minPitchTan;
  36176. private _maxPitchTan;
  36177. private _boneQuat;
  36178. private _slerping;
  36179. private _transformYawPitch;
  36180. private _transformYawPitchInv;
  36181. private _firstFrameSkipped;
  36182. private _yawRange;
  36183. private _fowardAxis;
  36184. /**
  36185. * Gets or sets the minimum yaw angle that the bone can look to
  36186. */
  36187. minYaw: number;
  36188. /**
  36189. * Gets or sets the maximum yaw angle that the bone can look to
  36190. */
  36191. maxYaw: number;
  36192. /**
  36193. * Gets or sets the minimum pitch angle that the bone can look to
  36194. */
  36195. minPitch: number;
  36196. /**
  36197. * Gets or sets the maximum pitch angle that the bone can look to
  36198. */
  36199. maxPitch: number;
  36200. /**
  36201. * Create a BoneLookController
  36202. * @param mesh the mesh that the bone belongs to
  36203. * @param bone the bone that will be looking to the target
  36204. * @param target the target Vector3 to look at
  36205. * @param options optional settings:
  36206. * * maxYaw: the maximum angle the bone will yaw to
  36207. * * minYaw: the minimum angle the bone will yaw to
  36208. * * maxPitch: the maximum angle the bone will pitch to
  36209. * * minPitch: the minimum angle the bone will yaw to
  36210. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36211. * * upAxis: the up axis of the coordinate system
  36212. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36213. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36214. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36215. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36216. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36217. * * adjustRoll: used to make an adjustment to the roll of the bone
  36218. **/
  36219. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36220. maxYaw?: number;
  36221. minYaw?: number;
  36222. maxPitch?: number;
  36223. minPitch?: number;
  36224. slerpAmount?: number;
  36225. upAxis?: Vector3;
  36226. upAxisSpace?: Space;
  36227. yawAxis?: Vector3;
  36228. pitchAxis?: Vector3;
  36229. adjustYaw?: number;
  36230. adjustPitch?: number;
  36231. adjustRoll?: number;
  36232. });
  36233. /**
  36234. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36235. */
  36236. update(): void;
  36237. private _getAngleDiff;
  36238. private _getAngleBetween;
  36239. private _isAngleBetween;
  36240. }
  36241. }
  36242. declare module BABYLON {
  36243. /**
  36244. * Manage the gamepad inputs to control an arc rotate camera.
  36245. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36246. */
  36247. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36248. /**
  36249. * Defines the camera the input is attached to.
  36250. */
  36251. camera: ArcRotateCamera;
  36252. /**
  36253. * Defines the gamepad the input is gathering event from.
  36254. */
  36255. gamepad: Nullable<Gamepad>;
  36256. /**
  36257. * Defines the gamepad rotation sensiblity.
  36258. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36259. */
  36260. gamepadRotationSensibility: number;
  36261. /**
  36262. * Defines the gamepad move sensiblity.
  36263. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36264. */
  36265. gamepadMoveSensibility: number;
  36266. private _onGamepadConnectedObserver;
  36267. private _onGamepadDisconnectedObserver;
  36268. /**
  36269. * Attach the input controls to a specific dom element to get the input from.
  36270. * @param element Defines the element the controls should be listened from
  36271. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36272. */
  36273. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36274. /**
  36275. * Detach the current controls from the specified dom element.
  36276. * @param element Defines the element to stop listening the inputs from
  36277. */
  36278. detachControl(element: Nullable<HTMLElement>): void;
  36279. /**
  36280. * Update the current camera state depending on the inputs that have been used this frame.
  36281. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36282. */
  36283. checkInputs(): void;
  36284. /**
  36285. * Gets the class name of the current intput.
  36286. * @returns the class name
  36287. */
  36288. getClassName(): string;
  36289. /**
  36290. * Get the friendly name associated with the input class.
  36291. * @returns the input friendly name
  36292. */
  36293. getSimpleName(): string;
  36294. }
  36295. }
  36296. declare module BABYLON {
  36297. interface ArcRotateCameraInputsManager {
  36298. /**
  36299. * Add orientation input support to the input manager.
  36300. * @returns the current input manager
  36301. */
  36302. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36303. }
  36304. /**
  36305. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36306. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36307. */
  36308. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36309. /**
  36310. * Defines the camera the input is attached to.
  36311. */
  36312. camera: ArcRotateCamera;
  36313. /**
  36314. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36315. */
  36316. alphaCorrection: number;
  36317. /**
  36318. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36319. */
  36320. gammaCorrection: number;
  36321. private _alpha;
  36322. private _gamma;
  36323. private _dirty;
  36324. private _deviceOrientationHandler;
  36325. /**
  36326. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36327. */
  36328. constructor();
  36329. /**
  36330. * Attach the input controls to a specific dom element to get the input from.
  36331. * @param element Defines the element the controls should be listened from
  36332. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36333. */
  36334. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36335. /** @hidden */
  36336. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36337. /**
  36338. * Update the current camera state depending on the inputs that have been used this frame.
  36339. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36340. */
  36341. checkInputs(): void;
  36342. /**
  36343. * Detach the current controls from the specified dom element.
  36344. * @param element Defines the element to stop listening the inputs from
  36345. */
  36346. detachControl(element: Nullable<HTMLElement>): void;
  36347. /**
  36348. * Gets the class name of the current intput.
  36349. * @returns the class name
  36350. */
  36351. getClassName(): string;
  36352. /**
  36353. * Get the friendly name associated with the input class.
  36354. * @returns the input friendly name
  36355. */
  36356. getSimpleName(): string;
  36357. }
  36358. }
  36359. declare module BABYLON {
  36360. /**
  36361. * Listen to mouse events to control the camera.
  36362. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36363. */
  36364. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36365. /**
  36366. * Defines the camera the input is attached to.
  36367. */
  36368. camera: FlyCamera;
  36369. /**
  36370. * Defines if touch is enabled. (Default is true.)
  36371. */
  36372. touchEnabled: boolean;
  36373. /**
  36374. * Defines the buttons associated with the input to handle camera rotation.
  36375. */
  36376. buttons: number[];
  36377. /**
  36378. * Assign buttons for Yaw control.
  36379. */
  36380. buttonsYaw: number[];
  36381. /**
  36382. * Assign buttons for Pitch control.
  36383. */
  36384. buttonsPitch: number[];
  36385. /**
  36386. * Assign buttons for Roll control.
  36387. */
  36388. buttonsRoll: number[];
  36389. /**
  36390. * Detect if any button is being pressed while mouse is moved.
  36391. * -1 = Mouse locked.
  36392. * 0 = Left button.
  36393. * 1 = Middle Button.
  36394. * 2 = Right Button.
  36395. */
  36396. activeButton: number;
  36397. /**
  36398. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36399. * Higher values reduce its sensitivity.
  36400. */
  36401. angularSensibility: number;
  36402. private _mousemoveCallback;
  36403. private _observer;
  36404. private _rollObserver;
  36405. private previousPosition;
  36406. private noPreventDefault;
  36407. private element;
  36408. /**
  36409. * Listen to mouse events to control the camera.
  36410. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36411. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36412. */
  36413. constructor(touchEnabled?: boolean);
  36414. /**
  36415. * Attach the mouse control to the HTML DOM element.
  36416. * @param element Defines the element that listens to the input events.
  36417. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36418. */
  36419. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36420. /**
  36421. * Detach the current controls from the specified dom element.
  36422. * @param element Defines the element to stop listening the inputs from
  36423. */
  36424. detachControl(element: Nullable<HTMLElement>): void;
  36425. /**
  36426. * Gets the class name of the current input.
  36427. * @returns the class name.
  36428. */
  36429. getClassName(): string;
  36430. /**
  36431. * Get the friendly name associated with the input class.
  36432. * @returns the input's friendly name.
  36433. */
  36434. getSimpleName(): string;
  36435. private _pointerInput;
  36436. private _onMouseMove;
  36437. /**
  36438. * Rotate camera by mouse offset.
  36439. */
  36440. private rotateCamera;
  36441. }
  36442. }
  36443. declare module BABYLON {
  36444. /**
  36445. * Default Inputs manager for the FlyCamera.
  36446. * It groups all the default supported inputs for ease of use.
  36447. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36448. */
  36449. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36450. /**
  36451. * Instantiates a new FlyCameraInputsManager.
  36452. * @param camera Defines the camera the inputs belong to.
  36453. */
  36454. constructor(camera: FlyCamera);
  36455. /**
  36456. * Add keyboard input support to the input manager.
  36457. * @returns the new FlyCameraKeyboardMoveInput().
  36458. */
  36459. addKeyboard(): FlyCameraInputsManager;
  36460. /**
  36461. * Add mouse input support to the input manager.
  36462. * @param touchEnabled Enable touch screen support.
  36463. * @returns the new FlyCameraMouseInput().
  36464. */
  36465. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36466. }
  36467. }
  36468. declare module BABYLON {
  36469. /**
  36470. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36471. * such as in a 3D Space Shooter or a Flight Simulator.
  36472. */
  36473. export class FlyCamera extends TargetCamera {
  36474. /**
  36475. * Define the collision ellipsoid of the camera.
  36476. * This is helpful for simulating a camera body, like a player's body.
  36477. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36478. */
  36479. ellipsoid: Vector3;
  36480. /**
  36481. * Define an offset for the position of the ellipsoid around the camera.
  36482. * This can be helpful if the camera is attached away from the player's body center,
  36483. * such as at its head.
  36484. */
  36485. ellipsoidOffset: Vector3;
  36486. /**
  36487. * Enable or disable collisions of the camera with the rest of the scene objects.
  36488. */
  36489. checkCollisions: boolean;
  36490. /**
  36491. * Enable or disable gravity on the camera.
  36492. */
  36493. applyGravity: boolean;
  36494. /**
  36495. * Define the current direction the camera is moving to.
  36496. */
  36497. cameraDirection: Vector3;
  36498. /**
  36499. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36500. * This overrides and empties cameraRotation.
  36501. */
  36502. rotationQuaternion: Quaternion;
  36503. /**
  36504. * Track Roll to maintain the wanted Rolling when looking around.
  36505. */
  36506. _trackRoll: number;
  36507. /**
  36508. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36509. */
  36510. rollCorrect: number;
  36511. /**
  36512. * Mimic a banked turn, Rolling the camera when Yawing.
  36513. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36514. */
  36515. bankedTurn: boolean;
  36516. /**
  36517. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36518. */
  36519. bankedTurnLimit: number;
  36520. /**
  36521. * Value of 0 disables the banked Roll.
  36522. * Value of 1 is equal to the Yaw angle in radians.
  36523. */
  36524. bankedTurnMultiplier: number;
  36525. /**
  36526. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36527. */
  36528. inputs: FlyCameraInputsManager;
  36529. /**
  36530. * Gets the input sensibility for mouse input.
  36531. * Higher values reduce sensitivity.
  36532. */
  36533. /**
  36534. * Sets the input sensibility for a mouse input.
  36535. * Higher values reduce sensitivity.
  36536. */
  36537. angularSensibility: number;
  36538. /**
  36539. * Get the keys for camera movement forward.
  36540. */
  36541. /**
  36542. * Set the keys for camera movement forward.
  36543. */
  36544. keysForward: number[];
  36545. /**
  36546. * Get the keys for camera movement backward.
  36547. */
  36548. keysBackward: number[];
  36549. /**
  36550. * Get the keys for camera movement up.
  36551. */
  36552. /**
  36553. * Set the keys for camera movement up.
  36554. */
  36555. keysUp: number[];
  36556. /**
  36557. * Get the keys for camera movement down.
  36558. */
  36559. /**
  36560. * Set the keys for camera movement down.
  36561. */
  36562. keysDown: number[];
  36563. /**
  36564. * Get the keys for camera movement left.
  36565. */
  36566. /**
  36567. * Set the keys for camera movement left.
  36568. */
  36569. keysLeft: number[];
  36570. /**
  36571. * Set the keys for camera movement right.
  36572. */
  36573. /**
  36574. * Set the keys for camera movement right.
  36575. */
  36576. keysRight: number[];
  36577. /**
  36578. * Event raised when the camera collides with a mesh in the scene.
  36579. */
  36580. onCollide: (collidedMesh: AbstractMesh) => void;
  36581. private _collider;
  36582. private _needMoveForGravity;
  36583. private _oldPosition;
  36584. private _diffPosition;
  36585. private _newPosition;
  36586. /** @hidden */
  36587. _localDirection: Vector3;
  36588. /** @hidden */
  36589. _transformedDirection: Vector3;
  36590. /**
  36591. * Instantiates a FlyCamera.
  36592. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36593. * such as in a 3D Space Shooter or a Flight Simulator.
  36594. * @param name Define the name of the camera in the scene.
  36595. * @param position Define the starting position of the camera in the scene.
  36596. * @param scene Define the scene the camera belongs to.
  36597. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  36598. */
  36599. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36600. /**
  36601. * Attach a control to the HTML DOM element.
  36602. * @param element Defines the element that listens to the input events.
  36603. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  36604. */
  36605. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36606. /**
  36607. * Detach a control from the HTML DOM element.
  36608. * The camera will stop reacting to that input.
  36609. * @param element Defines the element that listens to the input events.
  36610. */
  36611. detachControl(element: HTMLElement): void;
  36612. private _collisionMask;
  36613. /**
  36614. * Get the mask that the camera ignores in collision events.
  36615. */
  36616. /**
  36617. * Set the mask that the camera ignores in collision events.
  36618. */
  36619. collisionMask: number;
  36620. /** @hidden */
  36621. _collideWithWorld(displacement: Vector3): void;
  36622. /** @hidden */
  36623. private _onCollisionPositionChange;
  36624. /** @hidden */
  36625. _checkInputs(): void;
  36626. /** @hidden */
  36627. _decideIfNeedsToMove(): boolean;
  36628. /** @hidden */
  36629. _updatePosition(): void;
  36630. /**
  36631. * Restore the Roll to its target value at the rate specified.
  36632. * @param rate - Higher means slower restoring.
  36633. * @hidden
  36634. */
  36635. restoreRoll(rate: number): void;
  36636. /**
  36637. * Destroy the camera and release the current resources held by it.
  36638. */
  36639. dispose(): void;
  36640. /**
  36641. * Get the current object class name.
  36642. * @returns the class name.
  36643. */
  36644. getClassName(): string;
  36645. }
  36646. }
  36647. declare module BABYLON {
  36648. /**
  36649. * Listen to keyboard events to control the camera.
  36650. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36651. */
  36652. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  36653. /**
  36654. * Defines the camera the input is attached to.
  36655. */
  36656. camera: FlyCamera;
  36657. /**
  36658. * The list of keyboard keys used to control the forward move of the camera.
  36659. */
  36660. keysForward: number[];
  36661. /**
  36662. * The list of keyboard keys used to control the backward move of the camera.
  36663. */
  36664. keysBackward: number[];
  36665. /**
  36666. * The list of keyboard keys used to control the forward move of the camera.
  36667. */
  36668. keysUp: number[];
  36669. /**
  36670. * The list of keyboard keys used to control the backward move of the camera.
  36671. */
  36672. keysDown: number[];
  36673. /**
  36674. * The list of keyboard keys used to control the right strafe move of the camera.
  36675. */
  36676. keysRight: number[];
  36677. /**
  36678. * The list of keyboard keys used to control the left strafe move of the camera.
  36679. */
  36680. keysLeft: number[];
  36681. private _keys;
  36682. private _onCanvasBlurObserver;
  36683. private _onKeyboardObserver;
  36684. private _engine;
  36685. private _scene;
  36686. /**
  36687. * Attach the input controls to a specific dom element to get the input from.
  36688. * @param element Defines the element the controls should be listened from
  36689. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36690. */
  36691. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36692. /**
  36693. * Detach the current controls from the specified dom element.
  36694. * @param element Defines the element to stop listening the inputs from
  36695. */
  36696. detachControl(element: Nullable<HTMLElement>): void;
  36697. /**
  36698. * Gets the class name of the current intput.
  36699. * @returns the class name
  36700. */
  36701. getClassName(): string;
  36702. /** @hidden */
  36703. _onLostFocus(e: FocusEvent): void;
  36704. /**
  36705. * Get the friendly name associated with the input class.
  36706. * @returns the input friendly name
  36707. */
  36708. getSimpleName(): string;
  36709. /**
  36710. * Update the current camera state depending on the inputs that have been used this frame.
  36711. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36712. */
  36713. checkInputs(): void;
  36714. }
  36715. }
  36716. declare module BABYLON {
  36717. /**
  36718. * Manage the mouse wheel inputs to control a follow camera.
  36719. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36720. */
  36721. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  36722. /**
  36723. * Defines the camera the input is attached to.
  36724. */
  36725. camera: FollowCamera;
  36726. /**
  36727. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  36728. */
  36729. axisControlRadius: boolean;
  36730. /**
  36731. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  36732. */
  36733. axisControlHeight: boolean;
  36734. /**
  36735. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  36736. */
  36737. axisControlRotation: boolean;
  36738. /**
  36739. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  36740. * relation to mouseWheel events.
  36741. */
  36742. wheelPrecision: number;
  36743. /**
  36744. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36745. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36746. */
  36747. wheelDeltaPercentage: number;
  36748. private _wheel;
  36749. private _observer;
  36750. /**
  36751. * Attach the input controls to a specific dom element to get the input from.
  36752. * @param element Defines the element the controls should be listened from
  36753. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36754. */
  36755. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36756. /**
  36757. * Detach the current controls from the specified dom element.
  36758. * @param element Defines the element to stop listening the inputs from
  36759. */
  36760. detachControl(element: Nullable<HTMLElement>): void;
  36761. /**
  36762. * Gets the class name of the current intput.
  36763. * @returns the class name
  36764. */
  36765. getClassName(): string;
  36766. /**
  36767. * Get the friendly name associated with the input class.
  36768. * @returns the input friendly name
  36769. */
  36770. getSimpleName(): string;
  36771. }
  36772. }
  36773. declare module BABYLON {
  36774. /**
  36775. * Manage the pointers inputs to control an follow camera.
  36776. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36777. */
  36778. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  36779. /**
  36780. * Defines the camera the input is attached to.
  36781. */
  36782. camera: FollowCamera;
  36783. /**
  36784. * Gets the class name of the current input.
  36785. * @returns the class name
  36786. */
  36787. getClassName(): string;
  36788. /**
  36789. * Defines the pointer angular sensibility along the X axis or how fast is
  36790. * the camera rotating.
  36791. * A negative number will reverse the axis direction.
  36792. */
  36793. angularSensibilityX: number;
  36794. /**
  36795. * Defines the pointer angular sensibility along the Y axis or how fast is
  36796. * the camera rotating.
  36797. * A negative number will reverse the axis direction.
  36798. */
  36799. angularSensibilityY: number;
  36800. /**
  36801. * Defines the pointer pinch precision or how fast is the camera zooming.
  36802. * A negative number will reverse the axis direction.
  36803. */
  36804. pinchPrecision: number;
  36805. /**
  36806. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36807. * from 0.
  36808. * It defines the percentage of current camera.radius to use as delta when
  36809. * pinch zoom is used.
  36810. */
  36811. pinchDeltaPercentage: number;
  36812. /**
  36813. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  36814. */
  36815. axisXControlRadius: boolean;
  36816. /**
  36817. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  36818. */
  36819. axisXControlHeight: boolean;
  36820. /**
  36821. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  36822. */
  36823. axisXControlRotation: boolean;
  36824. /**
  36825. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  36826. */
  36827. axisYControlRadius: boolean;
  36828. /**
  36829. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  36830. */
  36831. axisYControlHeight: boolean;
  36832. /**
  36833. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  36834. */
  36835. axisYControlRotation: boolean;
  36836. /**
  36837. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  36838. */
  36839. axisPinchControlRadius: boolean;
  36840. /**
  36841. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  36842. */
  36843. axisPinchControlHeight: boolean;
  36844. /**
  36845. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  36846. */
  36847. axisPinchControlRotation: boolean;
  36848. /**
  36849. * Log error messages if basic misconfiguration has occurred.
  36850. */
  36851. warningEnable: boolean;
  36852. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36853. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36854. private _warningCounter;
  36855. private _warning;
  36856. }
  36857. }
  36858. declare module BABYLON {
  36859. /**
  36860. * Default Inputs manager for the FollowCamera.
  36861. * It groups all the default supported inputs for ease of use.
  36862. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36863. */
  36864. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  36865. /**
  36866. * Instantiates a new FollowCameraInputsManager.
  36867. * @param camera Defines the camera the inputs belong to
  36868. */
  36869. constructor(camera: FollowCamera);
  36870. /**
  36871. * Add keyboard input support to the input manager.
  36872. * @returns the current input manager
  36873. */
  36874. addKeyboard(): FollowCameraInputsManager;
  36875. /**
  36876. * Add mouse wheel input support to the input manager.
  36877. * @returns the current input manager
  36878. */
  36879. addMouseWheel(): FollowCameraInputsManager;
  36880. /**
  36881. * Add pointers input support to the input manager.
  36882. * @returns the current input manager
  36883. */
  36884. addPointers(): FollowCameraInputsManager;
  36885. /**
  36886. * Add orientation input support to the input manager.
  36887. * @returns the current input manager
  36888. */
  36889. addVRDeviceOrientation(): FollowCameraInputsManager;
  36890. }
  36891. }
  36892. declare module BABYLON {
  36893. /**
  36894. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  36895. * an arc rotate version arcFollowCamera are available.
  36896. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36897. */
  36898. export class FollowCamera extends TargetCamera {
  36899. /**
  36900. * Distance the follow camera should follow an object at
  36901. */
  36902. radius: number;
  36903. /**
  36904. * Minimum allowed distance of the camera to the axis of rotation
  36905. * (The camera can not get closer).
  36906. * This can help limiting how the Camera is able to move in the scene.
  36907. */
  36908. lowerRadiusLimit: Nullable<number>;
  36909. /**
  36910. * Maximum allowed distance of the camera to the axis of rotation
  36911. * (The camera can not get further).
  36912. * This can help limiting how the Camera is able to move in the scene.
  36913. */
  36914. upperRadiusLimit: Nullable<number>;
  36915. /**
  36916. * Define a rotation offset between the camera and the object it follows
  36917. */
  36918. rotationOffset: number;
  36919. /**
  36920. * Minimum allowed angle to camera position relative to target object.
  36921. * This can help limiting how the Camera is able to move in the scene.
  36922. */
  36923. lowerRotationOffsetLimit: Nullable<number>;
  36924. /**
  36925. * Maximum allowed angle to camera position relative to target object.
  36926. * This can help limiting how the Camera is able to move in the scene.
  36927. */
  36928. upperRotationOffsetLimit: Nullable<number>;
  36929. /**
  36930. * Define a height offset between the camera and the object it follows.
  36931. * It can help following an object from the top (like a car chaing a plane)
  36932. */
  36933. heightOffset: number;
  36934. /**
  36935. * Minimum allowed height of camera position relative to target object.
  36936. * This can help limiting how the Camera is able to move in the scene.
  36937. */
  36938. lowerHeightOffsetLimit: Nullable<number>;
  36939. /**
  36940. * Maximum allowed height of camera position relative to target object.
  36941. * This can help limiting how the Camera is able to move in the scene.
  36942. */
  36943. upperHeightOffsetLimit: Nullable<number>;
  36944. /**
  36945. * Define how fast the camera can accelerate to follow it s target.
  36946. */
  36947. cameraAcceleration: number;
  36948. /**
  36949. * Define the speed limit of the camera following an object.
  36950. */
  36951. maxCameraSpeed: number;
  36952. /**
  36953. * Define the target of the camera.
  36954. */
  36955. lockedTarget: Nullable<AbstractMesh>;
  36956. /**
  36957. * Defines the input associated with the camera.
  36958. */
  36959. inputs: FollowCameraInputsManager;
  36960. /**
  36961. * Instantiates the follow camera.
  36962. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36963. * @param name Define the name of the camera in the scene
  36964. * @param position Define the position of the camera
  36965. * @param scene Define the scene the camera belong to
  36966. * @param lockedTarget Define the target of the camera
  36967. */
  36968. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  36969. private _follow;
  36970. /**
  36971. * Attached controls to the current camera.
  36972. * @param element Defines the element the controls should be listened from
  36973. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36974. */
  36975. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36976. /**
  36977. * Detach the current controls from the camera.
  36978. * The camera will stop reacting to inputs.
  36979. * @param element Defines the element to stop listening the inputs from
  36980. */
  36981. detachControl(element: HTMLElement): void;
  36982. /** @hidden */
  36983. _checkInputs(): void;
  36984. private _checkLimits;
  36985. /**
  36986. * Gets the camera class name.
  36987. * @returns the class name
  36988. */
  36989. getClassName(): string;
  36990. }
  36991. /**
  36992. * Arc Rotate version of the follow camera.
  36993. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  36994. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36995. */
  36996. export class ArcFollowCamera extends TargetCamera {
  36997. /** The longitudinal angle of the camera */
  36998. alpha: number;
  36999. /** The latitudinal angle of the camera */
  37000. beta: number;
  37001. /** The radius of the camera from its target */
  37002. radius: number;
  37003. /** Define the camera target (the messh it should follow) */
  37004. target: Nullable<AbstractMesh>;
  37005. private _cartesianCoordinates;
  37006. /**
  37007. * Instantiates a new ArcFollowCamera
  37008. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37009. * @param name Define the name of the camera
  37010. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37011. * @param beta Define the rotation angle of the camera around the elevation axis
  37012. * @param radius Define the radius of the camera from its target point
  37013. * @param target Define the target of the camera
  37014. * @param scene Define the scene the camera belongs to
  37015. */
  37016. constructor(name: string,
  37017. /** The longitudinal angle of the camera */
  37018. alpha: number,
  37019. /** The latitudinal angle of the camera */
  37020. beta: number,
  37021. /** The radius of the camera from its target */
  37022. radius: number,
  37023. /** Define the camera target (the messh it should follow) */
  37024. target: Nullable<AbstractMesh>, scene: Scene);
  37025. private _follow;
  37026. /** @hidden */
  37027. _checkInputs(): void;
  37028. /**
  37029. * Returns the class name of the object.
  37030. * It is mostly used internally for serialization purposes.
  37031. */
  37032. getClassName(): string;
  37033. }
  37034. }
  37035. declare module BABYLON {
  37036. /**
  37037. * Manage the keyboard inputs to control the movement of a follow camera.
  37038. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37039. */
  37040. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37041. /**
  37042. * Defines the camera the input is attached to.
  37043. */
  37044. camera: FollowCamera;
  37045. /**
  37046. * Defines the list of key codes associated with the up action (increase heightOffset)
  37047. */
  37048. keysHeightOffsetIncr: number[];
  37049. /**
  37050. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37051. */
  37052. keysHeightOffsetDecr: number[];
  37053. /**
  37054. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37055. */
  37056. keysHeightOffsetModifierAlt: boolean;
  37057. /**
  37058. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37059. */
  37060. keysHeightOffsetModifierCtrl: boolean;
  37061. /**
  37062. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37063. */
  37064. keysHeightOffsetModifierShift: boolean;
  37065. /**
  37066. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37067. */
  37068. keysRotationOffsetIncr: number[];
  37069. /**
  37070. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37071. */
  37072. keysRotationOffsetDecr: number[];
  37073. /**
  37074. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37075. */
  37076. keysRotationOffsetModifierAlt: boolean;
  37077. /**
  37078. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37079. */
  37080. keysRotationOffsetModifierCtrl: boolean;
  37081. /**
  37082. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37083. */
  37084. keysRotationOffsetModifierShift: boolean;
  37085. /**
  37086. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37087. */
  37088. keysRadiusIncr: number[];
  37089. /**
  37090. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37091. */
  37092. keysRadiusDecr: number[];
  37093. /**
  37094. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37095. */
  37096. keysRadiusModifierAlt: boolean;
  37097. /**
  37098. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37099. */
  37100. keysRadiusModifierCtrl: boolean;
  37101. /**
  37102. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37103. */
  37104. keysRadiusModifierShift: boolean;
  37105. /**
  37106. * Defines the rate of change of heightOffset.
  37107. */
  37108. heightSensibility: number;
  37109. /**
  37110. * Defines the rate of change of rotationOffset.
  37111. */
  37112. rotationSensibility: number;
  37113. /**
  37114. * Defines the rate of change of radius.
  37115. */
  37116. radiusSensibility: number;
  37117. private _keys;
  37118. private _ctrlPressed;
  37119. private _altPressed;
  37120. private _shiftPressed;
  37121. private _onCanvasBlurObserver;
  37122. private _onKeyboardObserver;
  37123. private _engine;
  37124. private _scene;
  37125. /**
  37126. * Attach the input controls to a specific dom element to get the input from.
  37127. * @param element Defines the element the controls should be listened from
  37128. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37129. */
  37130. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37131. /**
  37132. * Detach the current controls from the specified dom element.
  37133. * @param element Defines the element to stop listening the inputs from
  37134. */
  37135. detachControl(element: Nullable<HTMLElement>): void;
  37136. /**
  37137. * Update the current camera state depending on the inputs that have been used this frame.
  37138. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37139. */
  37140. checkInputs(): void;
  37141. /**
  37142. * Gets the class name of the current input.
  37143. * @returns the class name
  37144. */
  37145. getClassName(): string;
  37146. /**
  37147. * Get the friendly name associated with the input class.
  37148. * @returns the input friendly name
  37149. */
  37150. getSimpleName(): string;
  37151. /**
  37152. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37153. * allow modification of the heightOffset value.
  37154. */
  37155. private _modifierHeightOffset;
  37156. /**
  37157. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37158. * allow modification of the rotationOffset value.
  37159. */
  37160. private _modifierRotationOffset;
  37161. /**
  37162. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37163. * allow modification of the radius value.
  37164. */
  37165. private _modifierRadius;
  37166. }
  37167. }
  37168. declare module BABYLON {
  37169. interface FreeCameraInputsManager {
  37170. /**
  37171. * @hidden
  37172. */
  37173. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  37174. /**
  37175. * Add orientation input support to the input manager.
  37176. * @returns the current input manager
  37177. */
  37178. addDeviceOrientation(): FreeCameraInputsManager;
  37179. }
  37180. /**
  37181. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37182. * Screen rotation is taken into account.
  37183. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37184. */
  37185. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37186. private _camera;
  37187. private _screenOrientationAngle;
  37188. private _constantTranform;
  37189. private _screenQuaternion;
  37190. private _alpha;
  37191. private _beta;
  37192. private _gamma;
  37193. /**
  37194. * @hidden
  37195. */
  37196. _onDeviceOrientationChangedObservable: Observable<void>;
  37197. /**
  37198. * Instantiates a new input
  37199. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37200. */
  37201. constructor();
  37202. /**
  37203. * Define the camera controlled by the input.
  37204. */
  37205. camera: FreeCamera;
  37206. /**
  37207. * Attach the input controls to a specific dom element to get the input from.
  37208. * @param element Defines the element the controls should be listened from
  37209. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37210. */
  37211. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37212. private _orientationChanged;
  37213. private _deviceOrientation;
  37214. /**
  37215. * Detach the current controls from the specified dom element.
  37216. * @param element Defines the element to stop listening the inputs from
  37217. */
  37218. detachControl(element: Nullable<HTMLElement>): void;
  37219. /**
  37220. * Update the current camera state depending on the inputs that have been used this frame.
  37221. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37222. */
  37223. checkInputs(): void;
  37224. /**
  37225. * Gets the class name of the current intput.
  37226. * @returns the class name
  37227. */
  37228. getClassName(): string;
  37229. /**
  37230. * Get the friendly name associated with the input class.
  37231. * @returns the input friendly name
  37232. */
  37233. getSimpleName(): string;
  37234. }
  37235. }
  37236. declare module BABYLON {
  37237. /**
  37238. * Manage the gamepad inputs to control a free camera.
  37239. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37240. */
  37241. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37242. /**
  37243. * Define the camera the input is attached to.
  37244. */
  37245. camera: FreeCamera;
  37246. /**
  37247. * Define the Gamepad controlling the input
  37248. */
  37249. gamepad: Nullable<Gamepad>;
  37250. /**
  37251. * Defines the gamepad rotation sensiblity.
  37252. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37253. */
  37254. gamepadAngularSensibility: number;
  37255. /**
  37256. * Defines the gamepad move sensiblity.
  37257. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37258. */
  37259. gamepadMoveSensibility: number;
  37260. private _onGamepadConnectedObserver;
  37261. private _onGamepadDisconnectedObserver;
  37262. private _cameraTransform;
  37263. private _deltaTransform;
  37264. private _vector3;
  37265. private _vector2;
  37266. /**
  37267. * Attach the input controls to a specific dom element to get the input from.
  37268. * @param element Defines the element the controls should be listened from
  37269. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37270. */
  37271. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37272. /**
  37273. * Detach the current controls from the specified dom element.
  37274. * @param element Defines the element to stop listening the inputs from
  37275. */
  37276. detachControl(element: Nullable<HTMLElement>): void;
  37277. /**
  37278. * Update the current camera state depending on the inputs that have been used this frame.
  37279. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37280. */
  37281. checkInputs(): void;
  37282. /**
  37283. * Gets the class name of the current intput.
  37284. * @returns the class name
  37285. */
  37286. getClassName(): string;
  37287. /**
  37288. * Get the friendly name associated with the input class.
  37289. * @returns the input friendly name
  37290. */
  37291. getSimpleName(): string;
  37292. }
  37293. }
  37294. declare module BABYLON {
  37295. /**
  37296. * Defines the potential axis of a Joystick
  37297. */
  37298. export enum JoystickAxis {
  37299. /** X axis */
  37300. X = 0,
  37301. /** Y axis */
  37302. Y = 1,
  37303. /** Z axis */
  37304. Z = 2
  37305. }
  37306. /**
  37307. * Class used to define virtual joystick (used in touch mode)
  37308. */
  37309. export class VirtualJoystick {
  37310. /**
  37311. * Gets or sets a boolean indicating that left and right values must be inverted
  37312. */
  37313. reverseLeftRight: boolean;
  37314. /**
  37315. * Gets or sets a boolean indicating that up and down values must be inverted
  37316. */
  37317. reverseUpDown: boolean;
  37318. /**
  37319. * Gets the offset value for the position (ie. the change of the position value)
  37320. */
  37321. deltaPosition: Vector3;
  37322. /**
  37323. * Gets a boolean indicating if the virtual joystick was pressed
  37324. */
  37325. pressed: boolean;
  37326. /**
  37327. * Canvas the virtual joystick will render onto, default z-index of this is 5
  37328. */
  37329. static Canvas: Nullable<HTMLCanvasElement>;
  37330. private static _globalJoystickIndex;
  37331. private static vjCanvasContext;
  37332. private static vjCanvasWidth;
  37333. private static vjCanvasHeight;
  37334. private static halfWidth;
  37335. private _action;
  37336. private _axisTargetedByLeftAndRight;
  37337. private _axisTargetedByUpAndDown;
  37338. private _joystickSensibility;
  37339. private _inversedSensibility;
  37340. private _joystickPointerID;
  37341. private _joystickColor;
  37342. private _joystickPointerPos;
  37343. private _joystickPreviousPointerPos;
  37344. private _joystickPointerStartPos;
  37345. private _deltaJoystickVector;
  37346. private _leftJoystick;
  37347. private _touches;
  37348. private _onPointerDownHandlerRef;
  37349. private _onPointerMoveHandlerRef;
  37350. private _onPointerUpHandlerRef;
  37351. private _onResize;
  37352. /**
  37353. * Creates a new virtual joystick
  37354. * @param leftJoystick defines that the joystick is for left hand (false by default)
  37355. */
  37356. constructor(leftJoystick?: boolean);
  37357. /**
  37358. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  37359. * @param newJoystickSensibility defines the new sensibility
  37360. */
  37361. setJoystickSensibility(newJoystickSensibility: number): void;
  37362. private _onPointerDown;
  37363. private _onPointerMove;
  37364. private _onPointerUp;
  37365. /**
  37366. * Change the color of the virtual joystick
  37367. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  37368. */
  37369. setJoystickColor(newColor: string): void;
  37370. /**
  37371. * Defines a callback to call when the joystick is touched
  37372. * @param action defines the callback
  37373. */
  37374. setActionOnTouch(action: () => any): void;
  37375. /**
  37376. * Defines which axis you'd like to control for left & right
  37377. * @param axis defines the axis to use
  37378. */
  37379. setAxisForLeftRight(axis: JoystickAxis): void;
  37380. /**
  37381. * Defines which axis you'd like to control for up & down
  37382. * @param axis defines the axis to use
  37383. */
  37384. setAxisForUpDown(axis: JoystickAxis): void;
  37385. private _drawVirtualJoystick;
  37386. /**
  37387. * Release internal HTML canvas
  37388. */
  37389. releaseCanvas(): void;
  37390. }
  37391. }
  37392. declare module BABYLON {
  37393. interface FreeCameraInputsManager {
  37394. /**
  37395. * Add virtual joystick input support to the input manager.
  37396. * @returns the current input manager
  37397. */
  37398. addVirtualJoystick(): FreeCameraInputsManager;
  37399. }
  37400. /**
  37401. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  37402. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37403. */
  37404. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  37405. /**
  37406. * Defines the camera the input is attached to.
  37407. */
  37408. camera: FreeCamera;
  37409. private _leftjoystick;
  37410. private _rightjoystick;
  37411. /**
  37412. * Gets the left stick of the virtual joystick.
  37413. * @returns The virtual Joystick
  37414. */
  37415. getLeftJoystick(): VirtualJoystick;
  37416. /**
  37417. * Gets the right stick of the virtual joystick.
  37418. * @returns The virtual Joystick
  37419. */
  37420. getRightJoystick(): VirtualJoystick;
  37421. /**
  37422. * Update the current camera state depending on the inputs that have been used this frame.
  37423. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37424. */
  37425. checkInputs(): void;
  37426. /**
  37427. * Attach the input controls to a specific dom element to get the input from.
  37428. * @param element Defines the element the controls should be listened from
  37429. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37430. */
  37431. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37432. /**
  37433. * Detach the current controls from the specified dom element.
  37434. * @param element Defines the element to stop listening the inputs from
  37435. */
  37436. detachControl(element: Nullable<HTMLElement>): void;
  37437. /**
  37438. * Gets the class name of the current intput.
  37439. * @returns the class name
  37440. */
  37441. getClassName(): string;
  37442. /**
  37443. * Get the friendly name associated with the input class.
  37444. * @returns the input friendly name
  37445. */
  37446. getSimpleName(): string;
  37447. }
  37448. }
  37449. declare module BABYLON {
  37450. /**
  37451. * This represents a FPS type of camera controlled by touch.
  37452. * This is like a universal camera minus the Gamepad controls.
  37453. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37454. */
  37455. export class TouchCamera extends FreeCamera {
  37456. /**
  37457. * Defines the touch sensibility for rotation.
  37458. * The higher the faster.
  37459. */
  37460. touchAngularSensibility: number;
  37461. /**
  37462. * Defines the touch sensibility for move.
  37463. * The higher the faster.
  37464. */
  37465. touchMoveSensibility: number;
  37466. /**
  37467. * Instantiates a new touch camera.
  37468. * This represents a FPS type of camera controlled by touch.
  37469. * This is like a universal camera minus the Gamepad controls.
  37470. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37471. * @param name Define the name of the camera in the scene
  37472. * @param position Define the start position of the camera in the scene
  37473. * @param scene Define the scene the camera belongs to
  37474. */
  37475. constructor(name: string, position: Vector3, scene: Scene);
  37476. /**
  37477. * Gets the current object class name.
  37478. * @return the class name
  37479. */
  37480. getClassName(): string;
  37481. /** @hidden */
  37482. _setupInputs(): void;
  37483. }
  37484. }
  37485. declare module BABYLON {
  37486. /**
  37487. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  37488. * being tilted forward or back and left or right.
  37489. */
  37490. export class DeviceOrientationCamera extends FreeCamera {
  37491. private _initialQuaternion;
  37492. private _quaternionCache;
  37493. private _tmpDragQuaternion;
  37494. /**
  37495. * Creates a new device orientation camera
  37496. * @param name The name of the camera
  37497. * @param position The start position camera
  37498. * @param scene The scene the camera belongs to
  37499. */
  37500. constructor(name: string, position: Vector3, scene: Scene);
  37501. /**
  37502. * @hidden
  37503. * Disabled pointer input on first orientation sensor update (Default: true)
  37504. */
  37505. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  37506. private _dragFactor;
  37507. /**
  37508. * Enabled turning on the y axis when the orientation sensor is active
  37509. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  37510. */
  37511. enableHorizontalDragging(dragFactor?: number): void;
  37512. /**
  37513. * Gets the current instance class name ("DeviceOrientationCamera").
  37514. * This helps avoiding instanceof at run time.
  37515. * @returns the class name
  37516. */
  37517. getClassName(): string;
  37518. /**
  37519. * @hidden
  37520. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  37521. */
  37522. _checkInputs(): void;
  37523. /**
  37524. * Reset the camera to its default orientation on the specified axis only.
  37525. * @param axis The axis to reset
  37526. */
  37527. resetToCurrentRotation(axis?: Axis): void;
  37528. }
  37529. }
  37530. declare module BABYLON {
  37531. /**
  37532. * Defines supported buttons for XBox360 compatible gamepads
  37533. */
  37534. export enum Xbox360Button {
  37535. /** A */
  37536. A = 0,
  37537. /** B */
  37538. B = 1,
  37539. /** X */
  37540. X = 2,
  37541. /** Y */
  37542. Y = 3,
  37543. /** Start */
  37544. Start = 4,
  37545. /** Back */
  37546. Back = 5,
  37547. /** Left button */
  37548. LB = 6,
  37549. /** Right button */
  37550. RB = 7,
  37551. /** Left stick */
  37552. LeftStick = 8,
  37553. /** Right stick */
  37554. RightStick = 9
  37555. }
  37556. /** Defines values for XBox360 DPad */
  37557. export enum Xbox360Dpad {
  37558. /** Up */
  37559. Up = 0,
  37560. /** Down */
  37561. Down = 1,
  37562. /** Left */
  37563. Left = 2,
  37564. /** Right */
  37565. Right = 3
  37566. }
  37567. /**
  37568. * Defines a XBox360 gamepad
  37569. */
  37570. export class Xbox360Pad extends Gamepad {
  37571. private _leftTrigger;
  37572. private _rightTrigger;
  37573. private _onlefttriggerchanged;
  37574. private _onrighttriggerchanged;
  37575. private _onbuttondown;
  37576. private _onbuttonup;
  37577. private _ondpaddown;
  37578. private _ondpadup;
  37579. /** Observable raised when a button is pressed */
  37580. onButtonDownObservable: Observable<Xbox360Button>;
  37581. /** Observable raised when a button is released */
  37582. onButtonUpObservable: Observable<Xbox360Button>;
  37583. /** Observable raised when a pad is pressed */
  37584. onPadDownObservable: Observable<Xbox360Dpad>;
  37585. /** Observable raised when a pad is released */
  37586. onPadUpObservable: Observable<Xbox360Dpad>;
  37587. private _buttonA;
  37588. private _buttonB;
  37589. private _buttonX;
  37590. private _buttonY;
  37591. private _buttonBack;
  37592. private _buttonStart;
  37593. private _buttonLB;
  37594. private _buttonRB;
  37595. private _buttonLeftStick;
  37596. private _buttonRightStick;
  37597. private _dPadUp;
  37598. private _dPadDown;
  37599. private _dPadLeft;
  37600. private _dPadRight;
  37601. private _isXboxOnePad;
  37602. /**
  37603. * Creates a new XBox360 gamepad object
  37604. * @param id defines the id of this gamepad
  37605. * @param index defines its index
  37606. * @param gamepad defines the internal HTML gamepad object
  37607. * @param xboxOne defines if it is a XBox One gamepad
  37608. */
  37609. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  37610. /**
  37611. * Defines the callback to call when left trigger is pressed
  37612. * @param callback defines the callback to use
  37613. */
  37614. onlefttriggerchanged(callback: (value: number) => void): void;
  37615. /**
  37616. * Defines the callback to call when right trigger is pressed
  37617. * @param callback defines the callback to use
  37618. */
  37619. onrighttriggerchanged(callback: (value: number) => void): void;
  37620. /**
  37621. * Gets the left trigger value
  37622. */
  37623. /**
  37624. * Sets the left trigger value
  37625. */
  37626. leftTrigger: number;
  37627. /**
  37628. * Gets the right trigger value
  37629. */
  37630. /**
  37631. * Sets the right trigger value
  37632. */
  37633. rightTrigger: number;
  37634. /**
  37635. * Defines the callback to call when a button is pressed
  37636. * @param callback defines the callback to use
  37637. */
  37638. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  37639. /**
  37640. * Defines the callback to call when a button is released
  37641. * @param callback defines the callback to use
  37642. */
  37643. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  37644. /**
  37645. * Defines the callback to call when a pad is pressed
  37646. * @param callback defines the callback to use
  37647. */
  37648. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  37649. /**
  37650. * Defines the callback to call when a pad is released
  37651. * @param callback defines the callback to use
  37652. */
  37653. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  37654. private _setButtonValue;
  37655. private _setDPadValue;
  37656. /**
  37657. * Gets the value of the `A` button
  37658. */
  37659. /**
  37660. * Sets the value of the `A` button
  37661. */
  37662. buttonA: number;
  37663. /**
  37664. * Gets the value of the `B` button
  37665. */
  37666. /**
  37667. * Sets the value of the `B` button
  37668. */
  37669. buttonB: number;
  37670. /**
  37671. * Gets the value of the `X` button
  37672. */
  37673. /**
  37674. * Sets the value of the `X` button
  37675. */
  37676. buttonX: number;
  37677. /**
  37678. * Gets the value of the `Y` button
  37679. */
  37680. /**
  37681. * Sets the value of the `Y` button
  37682. */
  37683. buttonY: number;
  37684. /**
  37685. * Gets the value of the `Start` button
  37686. */
  37687. /**
  37688. * Sets the value of the `Start` button
  37689. */
  37690. buttonStart: number;
  37691. /**
  37692. * Gets the value of the `Back` button
  37693. */
  37694. /**
  37695. * Sets the value of the `Back` button
  37696. */
  37697. buttonBack: number;
  37698. /**
  37699. * Gets the value of the `Left` button
  37700. */
  37701. /**
  37702. * Sets the value of the `Left` button
  37703. */
  37704. buttonLB: number;
  37705. /**
  37706. * Gets the value of the `Right` button
  37707. */
  37708. /**
  37709. * Sets the value of the `Right` button
  37710. */
  37711. buttonRB: number;
  37712. /**
  37713. * Gets the value of the Left joystick
  37714. */
  37715. /**
  37716. * Sets the value of the Left joystick
  37717. */
  37718. buttonLeftStick: number;
  37719. /**
  37720. * Gets the value of the Right joystick
  37721. */
  37722. /**
  37723. * Sets the value of the Right joystick
  37724. */
  37725. buttonRightStick: number;
  37726. /**
  37727. * Gets the value of D-pad up
  37728. */
  37729. /**
  37730. * Sets the value of D-pad up
  37731. */
  37732. dPadUp: number;
  37733. /**
  37734. * Gets the value of D-pad down
  37735. */
  37736. /**
  37737. * Sets the value of D-pad down
  37738. */
  37739. dPadDown: number;
  37740. /**
  37741. * Gets the value of D-pad left
  37742. */
  37743. /**
  37744. * Sets the value of D-pad left
  37745. */
  37746. dPadLeft: number;
  37747. /**
  37748. * Gets the value of D-pad right
  37749. */
  37750. /**
  37751. * Sets the value of D-pad right
  37752. */
  37753. dPadRight: number;
  37754. /**
  37755. * Force the gamepad to synchronize with device values
  37756. */
  37757. update(): void;
  37758. /**
  37759. * Disposes the gamepad
  37760. */
  37761. dispose(): void;
  37762. }
  37763. }
  37764. declare module BABYLON {
  37765. /**
  37766. * Manager for handling gamepads
  37767. */
  37768. export class GamepadManager {
  37769. private _scene?;
  37770. private _babylonGamepads;
  37771. private _oneGamepadConnected;
  37772. /** @hidden */
  37773. _isMonitoring: boolean;
  37774. private _gamepadEventSupported;
  37775. private _gamepadSupport;
  37776. /**
  37777. * observable to be triggered when the gamepad controller has been connected
  37778. */
  37779. onGamepadConnectedObservable: Observable<Gamepad>;
  37780. /**
  37781. * observable to be triggered when the gamepad controller has been disconnected
  37782. */
  37783. onGamepadDisconnectedObservable: Observable<Gamepad>;
  37784. private _onGamepadConnectedEvent;
  37785. private _onGamepadDisconnectedEvent;
  37786. /**
  37787. * Initializes the gamepad manager
  37788. * @param _scene BabylonJS scene
  37789. */
  37790. constructor(_scene?: Scene | undefined);
  37791. /**
  37792. * The gamepads in the game pad manager
  37793. */
  37794. readonly gamepads: Gamepad[];
  37795. /**
  37796. * Get the gamepad controllers based on type
  37797. * @param type The type of gamepad controller
  37798. * @returns Nullable gamepad
  37799. */
  37800. getGamepadByType(type?: number): Nullable<Gamepad>;
  37801. /**
  37802. * Disposes the gamepad manager
  37803. */
  37804. dispose(): void;
  37805. private _addNewGamepad;
  37806. private _startMonitoringGamepads;
  37807. private _stopMonitoringGamepads;
  37808. /** @hidden */
  37809. _checkGamepadsStatus(): void;
  37810. private _updateGamepadObjects;
  37811. }
  37812. }
  37813. declare module BABYLON {
  37814. interface Scene {
  37815. /** @hidden */
  37816. _gamepadManager: Nullable<GamepadManager>;
  37817. /**
  37818. * Gets the gamepad manager associated with the scene
  37819. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  37820. */
  37821. gamepadManager: GamepadManager;
  37822. }
  37823. /**
  37824. * Interface representing a free camera inputs manager
  37825. */
  37826. interface FreeCameraInputsManager {
  37827. /**
  37828. * Adds gamepad input support to the FreeCameraInputsManager.
  37829. * @returns the FreeCameraInputsManager
  37830. */
  37831. addGamepad(): FreeCameraInputsManager;
  37832. }
  37833. /**
  37834. * Interface representing an arc rotate camera inputs manager
  37835. */
  37836. interface ArcRotateCameraInputsManager {
  37837. /**
  37838. * Adds gamepad input support to the ArcRotateCamera InputManager.
  37839. * @returns the camera inputs manager
  37840. */
  37841. addGamepad(): ArcRotateCameraInputsManager;
  37842. }
  37843. /**
  37844. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  37845. */
  37846. export class GamepadSystemSceneComponent implements ISceneComponent {
  37847. /**
  37848. * The component name helpfull to identify the component in the list of scene components.
  37849. */
  37850. readonly name: string;
  37851. /**
  37852. * The scene the component belongs to.
  37853. */
  37854. scene: Scene;
  37855. /**
  37856. * Creates a new instance of the component for the given scene
  37857. * @param scene Defines the scene to register the component in
  37858. */
  37859. constructor(scene: Scene);
  37860. /**
  37861. * Registers the component in a given scene
  37862. */
  37863. register(): void;
  37864. /**
  37865. * Rebuilds the elements related to this component in case of
  37866. * context lost for instance.
  37867. */
  37868. rebuild(): void;
  37869. /**
  37870. * Disposes the component and the associated ressources
  37871. */
  37872. dispose(): void;
  37873. private _beforeCameraUpdate;
  37874. }
  37875. }
  37876. declare module BABYLON {
  37877. /**
  37878. * 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,
  37879. * which still works and will still be found in many Playgrounds.
  37880. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37881. */
  37882. export class UniversalCamera extends TouchCamera {
  37883. /**
  37884. * Defines the gamepad rotation sensiblity.
  37885. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37886. */
  37887. gamepadAngularSensibility: number;
  37888. /**
  37889. * Defines the gamepad move sensiblity.
  37890. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37891. */
  37892. gamepadMoveSensibility: number;
  37893. /**
  37894. * 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,
  37895. * which still works and will still be found in many Playgrounds.
  37896. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37897. * @param name Define the name of the camera in the scene
  37898. * @param position Define the start position of the camera in the scene
  37899. * @param scene Define the scene the camera belongs to
  37900. */
  37901. constructor(name: string, position: Vector3, scene: Scene);
  37902. /**
  37903. * Gets the current object class name.
  37904. * @return the class name
  37905. */
  37906. getClassName(): string;
  37907. }
  37908. }
  37909. declare module BABYLON {
  37910. /**
  37911. * This represents a FPS type of camera. This is only here for back compat purpose.
  37912. * Please use the UniversalCamera instead as both are identical.
  37913. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37914. */
  37915. export class GamepadCamera extends UniversalCamera {
  37916. /**
  37917. * Instantiates a new Gamepad Camera
  37918. * This represents a FPS type of camera. This is only here for back compat purpose.
  37919. * Please use the UniversalCamera instead as both are identical.
  37920. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37921. * @param name Define the name of the camera in the scene
  37922. * @param position Define the start position of the camera in the scene
  37923. * @param scene Define the scene the camera belongs to
  37924. */
  37925. constructor(name: string, position: Vector3, scene: Scene);
  37926. /**
  37927. * Gets the current object class name.
  37928. * @return the class name
  37929. */
  37930. getClassName(): string;
  37931. }
  37932. }
  37933. declare module BABYLON {
  37934. /** @hidden */
  37935. export var passPixelShader: {
  37936. name: string;
  37937. shader: string;
  37938. };
  37939. }
  37940. declare module BABYLON {
  37941. /** @hidden */
  37942. export var passCubePixelShader: {
  37943. name: string;
  37944. shader: string;
  37945. };
  37946. }
  37947. declare module BABYLON {
  37948. /**
  37949. * PassPostProcess which produces an output the same as it's input
  37950. */
  37951. export class PassPostProcess extends PostProcess {
  37952. /**
  37953. * Creates the PassPostProcess
  37954. * @param name The name of the effect.
  37955. * @param options The required width/height ratio to downsize to before computing the render pass.
  37956. * @param camera The camera to apply the render pass to.
  37957. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37958. * @param engine The engine which the post process will be applied. (default: current engine)
  37959. * @param reusable If the post process can be reused on the same frame. (default: false)
  37960. * @param textureType The type of texture to be used when performing the post processing.
  37961. * @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)
  37962. */
  37963. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37964. }
  37965. /**
  37966. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  37967. */
  37968. export class PassCubePostProcess extends PostProcess {
  37969. private _face;
  37970. /**
  37971. * Gets or sets the cube face to display.
  37972. * * 0 is +X
  37973. * * 1 is -X
  37974. * * 2 is +Y
  37975. * * 3 is -Y
  37976. * * 4 is +Z
  37977. * * 5 is -Z
  37978. */
  37979. face: number;
  37980. /**
  37981. * Creates the PassCubePostProcess
  37982. * @param name The name of the effect.
  37983. * @param options The required width/height ratio to downsize to before computing the render pass.
  37984. * @param camera The camera to apply the render pass to.
  37985. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37986. * @param engine The engine which the post process will be applied. (default: current engine)
  37987. * @param reusable If the post process can be reused on the same frame. (default: false)
  37988. * @param textureType The type of texture to be used when performing the post processing.
  37989. * @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)
  37990. */
  37991. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37992. }
  37993. }
  37994. declare module BABYLON {
  37995. /** @hidden */
  37996. export var anaglyphPixelShader: {
  37997. name: string;
  37998. shader: string;
  37999. };
  38000. }
  38001. declare module BABYLON {
  38002. /**
  38003. * Postprocess used to generate anaglyphic rendering
  38004. */
  38005. export class AnaglyphPostProcess extends PostProcess {
  38006. private _passedProcess;
  38007. /**
  38008. * Creates a new AnaglyphPostProcess
  38009. * @param name defines postprocess name
  38010. * @param options defines creation options or target ratio scale
  38011. * @param rigCameras defines cameras using this postprocess
  38012. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  38013. * @param engine defines hosting engine
  38014. * @param reusable defines if the postprocess will be reused multiple times per frame
  38015. */
  38016. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  38017. }
  38018. }
  38019. declare module BABYLON {
  38020. /**
  38021. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  38022. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38023. */
  38024. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  38025. /**
  38026. * Creates a new AnaglyphArcRotateCamera
  38027. * @param name defines camera name
  38028. * @param alpha defines alpha angle (in radians)
  38029. * @param beta defines beta angle (in radians)
  38030. * @param radius defines radius
  38031. * @param target defines camera target
  38032. * @param interaxialDistance defines distance between each color axis
  38033. * @param scene defines the hosting scene
  38034. */
  38035. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  38036. /**
  38037. * Gets camera class name
  38038. * @returns AnaglyphArcRotateCamera
  38039. */
  38040. getClassName(): string;
  38041. }
  38042. }
  38043. declare module BABYLON {
  38044. /**
  38045. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  38046. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38047. */
  38048. export class AnaglyphFreeCamera extends FreeCamera {
  38049. /**
  38050. * Creates a new AnaglyphFreeCamera
  38051. * @param name defines camera name
  38052. * @param position defines initial position
  38053. * @param interaxialDistance defines distance between each color axis
  38054. * @param scene defines the hosting scene
  38055. */
  38056. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38057. /**
  38058. * Gets camera class name
  38059. * @returns AnaglyphFreeCamera
  38060. */
  38061. getClassName(): string;
  38062. }
  38063. }
  38064. declare module BABYLON {
  38065. /**
  38066. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  38067. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38068. */
  38069. export class AnaglyphGamepadCamera extends GamepadCamera {
  38070. /**
  38071. * Creates a new AnaglyphGamepadCamera
  38072. * @param name defines camera name
  38073. * @param position defines initial position
  38074. * @param interaxialDistance defines distance between each color axis
  38075. * @param scene defines the hosting scene
  38076. */
  38077. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38078. /**
  38079. * Gets camera class name
  38080. * @returns AnaglyphGamepadCamera
  38081. */
  38082. getClassName(): string;
  38083. }
  38084. }
  38085. declare module BABYLON {
  38086. /**
  38087. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  38088. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38089. */
  38090. export class AnaglyphUniversalCamera extends UniversalCamera {
  38091. /**
  38092. * Creates a new AnaglyphUniversalCamera
  38093. * @param name defines camera name
  38094. * @param position defines initial position
  38095. * @param interaxialDistance defines distance between each color axis
  38096. * @param scene defines the hosting scene
  38097. */
  38098. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38099. /**
  38100. * Gets camera class name
  38101. * @returns AnaglyphUniversalCamera
  38102. */
  38103. getClassName(): string;
  38104. }
  38105. }
  38106. declare module BABYLON {
  38107. /** @hidden */
  38108. export var stereoscopicInterlacePixelShader: {
  38109. name: string;
  38110. shader: string;
  38111. };
  38112. }
  38113. declare module BABYLON {
  38114. /**
  38115. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  38116. */
  38117. export class StereoscopicInterlacePostProcess extends PostProcess {
  38118. private _stepSize;
  38119. private _passedProcess;
  38120. /**
  38121. * Initializes a StereoscopicInterlacePostProcess
  38122. * @param name The name of the effect.
  38123. * @param rigCameras The rig cameras to be appled to the post process
  38124. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  38125. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38126. * @param engine The engine which the post process will be applied. (default: current engine)
  38127. * @param reusable If the post process can be reused on the same frame. (default: false)
  38128. */
  38129. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  38130. }
  38131. }
  38132. declare module BABYLON {
  38133. /**
  38134. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  38135. * @see http://doc.babylonjs.com/features/cameras
  38136. */
  38137. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  38138. /**
  38139. * Creates a new StereoscopicArcRotateCamera
  38140. * @param name defines camera name
  38141. * @param alpha defines alpha angle (in radians)
  38142. * @param beta defines beta angle (in radians)
  38143. * @param radius defines radius
  38144. * @param target defines camera target
  38145. * @param interaxialDistance defines distance between each color axis
  38146. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38147. * @param scene defines the hosting scene
  38148. */
  38149. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38150. /**
  38151. * Gets camera class name
  38152. * @returns StereoscopicArcRotateCamera
  38153. */
  38154. getClassName(): string;
  38155. }
  38156. }
  38157. declare module BABYLON {
  38158. /**
  38159. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  38160. * @see http://doc.babylonjs.com/features/cameras
  38161. */
  38162. export class StereoscopicFreeCamera extends FreeCamera {
  38163. /**
  38164. * Creates a new StereoscopicFreeCamera
  38165. * @param name defines camera name
  38166. * @param position defines initial position
  38167. * @param interaxialDistance defines distance between each color axis
  38168. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38169. * @param scene defines the hosting scene
  38170. */
  38171. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38172. /**
  38173. * Gets camera class name
  38174. * @returns StereoscopicFreeCamera
  38175. */
  38176. getClassName(): string;
  38177. }
  38178. }
  38179. declare module BABYLON {
  38180. /**
  38181. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  38182. * @see http://doc.babylonjs.com/features/cameras
  38183. */
  38184. export class StereoscopicGamepadCamera extends GamepadCamera {
  38185. /**
  38186. * Creates a new StereoscopicGamepadCamera
  38187. * @param name defines camera name
  38188. * @param position defines initial position
  38189. * @param interaxialDistance defines distance between each color axis
  38190. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38191. * @param scene defines the hosting scene
  38192. */
  38193. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38194. /**
  38195. * Gets camera class name
  38196. * @returns StereoscopicGamepadCamera
  38197. */
  38198. getClassName(): string;
  38199. }
  38200. }
  38201. declare module BABYLON {
  38202. /**
  38203. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  38204. * @see http://doc.babylonjs.com/features/cameras
  38205. */
  38206. export class StereoscopicUniversalCamera extends UniversalCamera {
  38207. /**
  38208. * Creates a new StereoscopicUniversalCamera
  38209. * @param name defines camera name
  38210. * @param position defines initial position
  38211. * @param interaxialDistance defines distance between each color axis
  38212. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38213. * @param scene defines the hosting scene
  38214. */
  38215. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38216. /**
  38217. * Gets camera class name
  38218. * @returns StereoscopicUniversalCamera
  38219. */
  38220. getClassName(): string;
  38221. }
  38222. }
  38223. declare module BABYLON {
  38224. /**
  38225. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38226. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38227. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38228. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38229. */
  38230. export class VirtualJoysticksCamera extends FreeCamera {
  38231. /**
  38232. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38233. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38234. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38235. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38236. * @param name Define the name of the camera in the scene
  38237. * @param position Define the start position of the camera in the scene
  38238. * @param scene Define the scene the camera belongs to
  38239. */
  38240. constructor(name: string, position: Vector3, scene: Scene);
  38241. /**
  38242. * Gets the current object class name.
  38243. * @return the class name
  38244. */
  38245. getClassName(): string;
  38246. }
  38247. }
  38248. declare module BABYLON {
  38249. /**
  38250. * This represents all the required metrics to create a VR camera.
  38251. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  38252. */
  38253. export class VRCameraMetrics {
  38254. /**
  38255. * Define the horizontal resolution off the screen.
  38256. */
  38257. hResolution: number;
  38258. /**
  38259. * Define the vertical resolution off the screen.
  38260. */
  38261. vResolution: number;
  38262. /**
  38263. * Define the horizontal screen size.
  38264. */
  38265. hScreenSize: number;
  38266. /**
  38267. * Define the vertical screen size.
  38268. */
  38269. vScreenSize: number;
  38270. /**
  38271. * Define the vertical screen center position.
  38272. */
  38273. vScreenCenter: number;
  38274. /**
  38275. * Define the distance of the eyes to the screen.
  38276. */
  38277. eyeToScreenDistance: number;
  38278. /**
  38279. * Define the distance between both lenses
  38280. */
  38281. lensSeparationDistance: number;
  38282. /**
  38283. * Define the distance between both viewer's eyes.
  38284. */
  38285. interpupillaryDistance: number;
  38286. /**
  38287. * Define the distortion factor of the VR postprocess.
  38288. * Please, touch with care.
  38289. */
  38290. distortionK: number[];
  38291. /**
  38292. * Define the chromatic aberration correction factors for the VR post process.
  38293. */
  38294. chromaAbCorrection: number[];
  38295. /**
  38296. * Define the scale factor of the post process.
  38297. * The smaller the better but the slower.
  38298. */
  38299. postProcessScaleFactor: number;
  38300. /**
  38301. * Define an offset for the lens center.
  38302. */
  38303. lensCenterOffset: number;
  38304. /**
  38305. * Define if the current vr camera should compensate the distortion of the lense or not.
  38306. */
  38307. compensateDistortion: boolean;
  38308. /**
  38309. * Defines if multiview should be enabled when rendering (Default: false)
  38310. */
  38311. multiviewEnabled: boolean;
  38312. /**
  38313. * Gets the rendering aspect ratio based on the provided resolutions.
  38314. */
  38315. readonly aspectRatio: number;
  38316. /**
  38317. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  38318. */
  38319. readonly aspectRatioFov: number;
  38320. /**
  38321. * @hidden
  38322. */
  38323. readonly leftHMatrix: Matrix;
  38324. /**
  38325. * @hidden
  38326. */
  38327. readonly rightHMatrix: Matrix;
  38328. /**
  38329. * @hidden
  38330. */
  38331. readonly leftPreViewMatrix: Matrix;
  38332. /**
  38333. * @hidden
  38334. */
  38335. readonly rightPreViewMatrix: Matrix;
  38336. /**
  38337. * Get the default VRMetrics based on the most generic setup.
  38338. * @returns the default vr metrics
  38339. */
  38340. static GetDefault(): VRCameraMetrics;
  38341. }
  38342. }
  38343. declare module BABYLON {
  38344. /** @hidden */
  38345. export var vrDistortionCorrectionPixelShader: {
  38346. name: string;
  38347. shader: string;
  38348. };
  38349. }
  38350. declare module BABYLON {
  38351. /**
  38352. * VRDistortionCorrectionPostProcess used for mobile VR
  38353. */
  38354. export class VRDistortionCorrectionPostProcess extends PostProcess {
  38355. private _isRightEye;
  38356. private _distortionFactors;
  38357. private _postProcessScaleFactor;
  38358. private _lensCenterOffset;
  38359. private _scaleIn;
  38360. private _scaleFactor;
  38361. private _lensCenter;
  38362. /**
  38363. * Initializes the VRDistortionCorrectionPostProcess
  38364. * @param name The name of the effect.
  38365. * @param camera The camera to apply the render pass to.
  38366. * @param isRightEye If this is for the right eye distortion
  38367. * @param vrMetrics All the required metrics for the VR camera
  38368. */
  38369. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  38370. }
  38371. }
  38372. declare module BABYLON {
  38373. /**
  38374. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  38375. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38376. */
  38377. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  38378. /**
  38379. * Creates a new VRDeviceOrientationArcRotateCamera
  38380. * @param name defines camera name
  38381. * @param alpha defines the camera rotation along the logitudinal axis
  38382. * @param beta defines the camera rotation along the latitudinal axis
  38383. * @param radius defines the camera distance from its target
  38384. * @param target defines the camera target
  38385. * @param scene defines the scene the camera belongs to
  38386. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38387. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38388. */
  38389. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38390. /**
  38391. * Gets camera class name
  38392. * @returns VRDeviceOrientationArcRotateCamera
  38393. */
  38394. getClassName(): string;
  38395. }
  38396. }
  38397. declare module BABYLON {
  38398. /**
  38399. * Camera used to simulate VR rendering (based on FreeCamera)
  38400. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38401. */
  38402. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  38403. /**
  38404. * Creates a new VRDeviceOrientationFreeCamera
  38405. * @param name defines camera name
  38406. * @param position defines the start position of the camera
  38407. * @param scene defines the scene the camera belongs to
  38408. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38409. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38410. */
  38411. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38412. /**
  38413. * Gets camera class name
  38414. * @returns VRDeviceOrientationFreeCamera
  38415. */
  38416. getClassName(): string;
  38417. }
  38418. }
  38419. declare module BABYLON {
  38420. /**
  38421. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  38422. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38423. */
  38424. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  38425. /**
  38426. * Creates a new VRDeviceOrientationGamepadCamera
  38427. * @param name defines camera name
  38428. * @param position defines the start position of the camera
  38429. * @param scene defines the scene the camera belongs to
  38430. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38431. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38432. */
  38433. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38434. /**
  38435. * Gets camera class name
  38436. * @returns VRDeviceOrientationGamepadCamera
  38437. */
  38438. getClassName(): string;
  38439. }
  38440. }
  38441. declare module BABYLON {
  38442. /**
  38443. * Base class of materials working in push mode in babylon JS
  38444. * @hidden
  38445. */
  38446. export class PushMaterial extends Material {
  38447. protected _activeEffect: Effect;
  38448. protected _normalMatrix: Matrix;
  38449. /**
  38450. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  38451. * This means that the material can keep using a previous shader while a new one is being compiled.
  38452. * This is mostly used when shader parallel compilation is supported (true by default)
  38453. */
  38454. allowShaderHotSwapping: boolean;
  38455. constructor(name: string, scene: Scene);
  38456. getEffect(): Effect;
  38457. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  38458. /**
  38459. * Binds the given world matrix to the active effect
  38460. *
  38461. * @param world the matrix to bind
  38462. */
  38463. bindOnlyWorldMatrix(world: Matrix): void;
  38464. /**
  38465. * Binds the given normal matrix to the active effect
  38466. *
  38467. * @param normalMatrix the matrix to bind
  38468. */
  38469. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  38470. bind(world: Matrix, mesh?: Mesh): void;
  38471. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  38472. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  38473. }
  38474. }
  38475. declare module BABYLON {
  38476. /**
  38477. * This groups all the flags used to control the materials channel.
  38478. */
  38479. export class MaterialFlags {
  38480. private static _DiffuseTextureEnabled;
  38481. /**
  38482. * Are diffuse textures enabled in the application.
  38483. */
  38484. static DiffuseTextureEnabled: boolean;
  38485. private static _AmbientTextureEnabled;
  38486. /**
  38487. * Are ambient textures enabled in the application.
  38488. */
  38489. static AmbientTextureEnabled: boolean;
  38490. private static _OpacityTextureEnabled;
  38491. /**
  38492. * Are opacity textures enabled in the application.
  38493. */
  38494. static OpacityTextureEnabled: boolean;
  38495. private static _ReflectionTextureEnabled;
  38496. /**
  38497. * Are reflection textures enabled in the application.
  38498. */
  38499. static ReflectionTextureEnabled: boolean;
  38500. private static _EmissiveTextureEnabled;
  38501. /**
  38502. * Are emissive textures enabled in the application.
  38503. */
  38504. static EmissiveTextureEnabled: boolean;
  38505. private static _SpecularTextureEnabled;
  38506. /**
  38507. * Are specular textures enabled in the application.
  38508. */
  38509. static SpecularTextureEnabled: boolean;
  38510. private static _BumpTextureEnabled;
  38511. /**
  38512. * Are bump textures enabled in the application.
  38513. */
  38514. static BumpTextureEnabled: boolean;
  38515. private static _LightmapTextureEnabled;
  38516. /**
  38517. * Are lightmap textures enabled in the application.
  38518. */
  38519. static LightmapTextureEnabled: boolean;
  38520. private static _RefractionTextureEnabled;
  38521. /**
  38522. * Are refraction textures enabled in the application.
  38523. */
  38524. static RefractionTextureEnabled: boolean;
  38525. private static _ColorGradingTextureEnabled;
  38526. /**
  38527. * Are color grading textures enabled in the application.
  38528. */
  38529. static ColorGradingTextureEnabled: boolean;
  38530. private static _FresnelEnabled;
  38531. /**
  38532. * Are fresnels enabled in the application.
  38533. */
  38534. static FresnelEnabled: boolean;
  38535. private static _ClearCoatTextureEnabled;
  38536. /**
  38537. * Are clear coat textures enabled in the application.
  38538. */
  38539. static ClearCoatTextureEnabled: boolean;
  38540. private static _ClearCoatBumpTextureEnabled;
  38541. /**
  38542. * Are clear coat bump textures enabled in the application.
  38543. */
  38544. static ClearCoatBumpTextureEnabled: boolean;
  38545. private static _ClearCoatTintTextureEnabled;
  38546. /**
  38547. * Are clear coat tint textures enabled in the application.
  38548. */
  38549. static ClearCoatTintTextureEnabled: boolean;
  38550. private static _SheenTextureEnabled;
  38551. /**
  38552. * Are sheen textures enabled in the application.
  38553. */
  38554. static SheenTextureEnabled: boolean;
  38555. private static _AnisotropicTextureEnabled;
  38556. /**
  38557. * Are anisotropic textures enabled in the application.
  38558. */
  38559. static AnisotropicTextureEnabled: boolean;
  38560. private static _ThicknessTextureEnabled;
  38561. /**
  38562. * Are thickness textures enabled in the application.
  38563. */
  38564. static ThicknessTextureEnabled: boolean;
  38565. }
  38566. }
  38567. declare module BABYLON {
  38568. /** @hidden */
  38569. export var defaultFragmentDeclaration: {
  38570. name: string;
  38571. shader: string;
  38572. };
  38573. }
  38574. declare module BABYLON {
  38575. /** @hidden */
  38576. export var defaultUboDeclaration: {
  38577. name: string;
  38578. shader: string;
  38579. };
  38580. }
  38581. declare module BABYLON {
  38582. /** @hidden */
  38583. export var lightFragmentDeclaration: {
  38584. name: string;
  38585. shader: string;
  38586. };
  38587. }
  38588. declare module BABYLON {
  38589. /** @hidden */
  38590. export var lightUboDeclaration: {
  38591. name: string;
  38592. shader: string;
  38593. };
  38594. }
  38595. declare module BABYLON {
  38596. /** @hidden */
  38597. export var lightsFragmentFunctions: {
  38598. name: string;
  38599. shader: string;
  38600. };
  38601. }
  38602. declare module BABYLON {
  38603. /** @hidden */
  38604. export var shadowsFragmentFunctions: {
  38605. name: string;
  38606. shader: string;
  38607. };
  38608. }
  38609. declare module BABYLON {
  38610. /** @hidden */
  38611. export var fresnelFunction: {
  38612. name: string;
  38613. shader: string;
  38614. };
  38615. }
  38616. declare module BABYLON {
  38617. /** @hidden */
  38618. export var reflectionFunction: {
  38619. name: string;
  38620. shader: string;
  38621. };
  38622. }
  38623. declare module BABYLON {
  38624. /** @hidden */
  38625. export var bumpFragmentFunctions: {
  38626. name: string;
  38627. shader: string;
  38628. };
  38629. }
  38630. declare module BABYLON {
  38631. /** @hidden */
  38632. export var logDepthDeclaration: {
  38633. name: string;
  38634. shader: string;
  38635. };
  38636. }
  38637. declare module BABYLON {
  38638. /** @hidden */
  38639. export var bumpFragment: {
  38640. name: string;
  38641. shader: string;
  38642. };
  38643. }
  38644. declare module BABYLON {
  38645. /** @hidden */
  38646. export var depthPrePass: {
  38647. name: string;
  38648. shader: string;
  38649. };
  38650. }
  38651. declare module BABYLON {
  38652. /** @hidden */
  38653. export var lightFragment: {
  38654. name: string;
  38655. shader: string;
  38656. };
  38657. }
  38658. declare module BABYLON {
  38659. /** @hidden */
  38660. export var logDepthFragment: {
  38661. name: string;
  38662. shader: string;
  38663. };
  38664. }
  38665. declare module BABYLON {
  38666. /** @hidden */
  38667. export var defaultPixelShader: {
  38668. name: string;
  38669. shader: string;
  38670. };
  38671. }
  38672. declare module BABYLON {
  38673. /** @hidden */
  38674. export var defaultVertexDeclaration: {
  38675. name: string;
  38676. shader: string;
  38677. };
  38678. }
  38679. declare module BABYLON {
  38680. /** @hidden */
  38681. export var bumpVertexDeclaration: {
  38682. name: string;
  38683. shader: string;
  38684. };
  38685. }
  38686. declare module BABYLON {
  38687. /** @hidden */
  38688. export var bumpVertex: {
  38689. name: string;
  38690. shader: string;
  38691. };
  38692. }
  38693. declare module BABYLON {
  38694. /** @hidden */
  38695. export var fogVertex: {
  38696. name: string;
  38697. shader: string;
  38698. };
  38699. }
  38700. declare module BABYLON {
  38701. /** @hidden */
  38702. export var shadowsVertex: {
  38703. name: string;
  38704. shader: string;
  38705. };
  38706. }
  38707. declare module BABYLON {
  38708. /** @hidden */
  38709. export var pointCloudVertex: {
  38710. name: string;
  38711. shader: string;
  38712. };
  38713. }
  38714. declare module BABYLON {
  38715. /** @hidden */
  38716. export var logDepthVertex: {
  38717. name: string;
  38718. shader: string;
  38719. };
  38720. }
  38721. declare module BABYLON {
  38722. /** @hidden */
  38723. export var defaultVertexShader: {
  38724. name: string;
  38725. shader: string;
  38726. };
  38727. }
  38728. declare module BABYLON {
  38729. /** @hidden */
  38730. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  38731. MAINUV1: boolean;
  38732. MAINUV2: boolean;
  38733. DIFFUSE: boolean;
  38734. DIFFUSEDIRECTUV: number;
  38735. AMBIENT: boolean;
  38736. AMBIENTDIRECTUV: number;
  38737. OPACITY: boolean;
  38738. OPACITYDIRECTUV: number;
  38739. OPACITYRGB: boolean;
  38740. REFLECTION: boolean;
  38741. EMISSIVE: boolean;
  38742. EMISSIVEDIRECTUV: number;
  38743. SPECULAR: boolean;
  38744. SPECULARDIRECTUV: number;
  38745. BUMP: boolean;
  38746. BUMPDIRECTUV: number;
  38747. PARALLAX: boolean;
  38748. PARALLAXOCCLUSION: boolean;
  38749. SPECULAROVERALPHA: boolean;
  38750. CLIPPLANE: boolean;
  38751. CLIPPLANE2: boolean;
  38752. CLIPPLANE3: boolean;
  38753. CLIPPLANE4: boolean;
  38754. ALPHATEST: boolean;
  38755. DEPTHPREPASS: boolean;
  38756. ALPHAFROMDIFFUSE: boolean;
  38757. POINTSIZE: boolean;
  38758. FOG: boolean;
  38759. SPECULARTERM: boolean;
  38760. DIFFUSEFRESNEL: boolean;
  38761. OPACITYFRESNEL: boolean;
  38762. REFLECTIONFRESNEL: boolean;
  38763. REFRACTIONFRESNEL: boolean;
  38764. EMISSIVEFRESNEL: boolean;
  38765. FRESNEL: boolean;
  38766. NORMAL: boolean;
  38767. UV1: boolean;
  38768. UV2: boolean;
  38769. VERTEXCOLOR: boolean;
  38770. VERTEXALPHA: boolean;
  38771. NUM_BONE_INFLUENCERS: number;
  38772. BonesPerMesh: number;
  38773. BONETEXTURE: boolean;
  38774. INSTANCES: boolean;
  38775. GLOSSINESS: boolean;
  38776. ROUGHNESS: boolean;
  38777. EMISSIVEASILLUMINATION: boolean;
  38778. LINKEMISSIVEWITHDIFFUSE: boolean;
  38779. REFLECTIONFRESNELFROMSPECULAR: boolean;
  38780. LIGHTMAP: boolean;
  38781. LIGHTMAPDIRECTUV: number;
  38782. OBJECTSPACE_NORMALMAP: boolean;
  38783. USELIGHTMAPASSHADOWMAP: boolean;
  38784. REFLECTIONMAP_3D: boolean;
  38785. REFLECTIONMAP_SPHERICAL: boolean;
  38786. REFLECTIONMAP_PLANAR: boolean;
  38787. REFLECTIONMAP_CUBIC: boolean;
  38788. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  38789. REFLECTIONMAP_PROJECTION: boolean;
  38790. REFLECTIONMAP_SKYBOX: boolean;
  38791. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  38792. REFLECTIONMAP_EXPLICIT: boolean;
  38793. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  38794. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  38795. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  38796. INVERTCUBICMAP: boolean;
  38797. LOGARITHMICDEPTH: boolean;
  38798. REFRACTION: boolean;
  38799. REFRACTIONMAP_3D: boolean;
  38800. REFLECTIONOVERALPHA: boolean;
  38801. TWOSIDEDLIGHTING: boolean;
  38802. SHADOWFLOAT: boolean;
  38803. MORPHTARGETS: boolean;
  38804. MORPHTARGETS_NORMAL: boolean;
  38805. MORPHTARGETS_TANGENT: boolean;
  38806. NUM_MORPH_INFLUENCERS: number;
  38807. NONUNIFORMSCALING: boolean;
  38808. PREMULTIPLYALPHA: boolean;
  38809. IMAGEPROCESSING: boolean;
  38810. VIGNETTE: boolean;
  38811. VIGNETTEBLENDMODEMULTIPLY: boolean;
  38812. VIGNETTEBLENDMODEOPAQUE: boolean;
  38813. TONEMAPPING: boolean;
  38814. TONEMAPPING_ACES: boolean;
  38815. CONTRAST: boolean;
  38816. COLORCURVES: boolean;
  38817. COLORGRADING: boolean;
  38818. COLORGRADING3D: boolean;
  38819. SAMPLER3DGREENDEPTH: boolean;
  38820. SAMPLER3DBGRMAP: boolean;
  38821. IMAGEPROCESSINGPOSTPROCESS: boolean;
  38822. MULTIVIEW: boolean;
  38823. /**
  38824. * If the reflection texture on this material is in linear color space
  38825. * @hidden
  38826. */
  38827. IS_REFLECTION_LINEAR: boolean;
  38828. /**
  38829. * If the refraction texture on this material is in linear color space
  38830. * @hidden
  38831. */
  38832. IS_REFRACTION_LINEAR: boolean;
  38833. EXPOSURE: boolean;
  38834. constructor();
  38835. setReflectionMode(modeToEnable: string): void;
  38836. }
  38837. /**
  38838. * This is the default material used in Babylon. It is the best trade off between quality
  38839. * and performances.
  38840. * @see http://doc.babylonjs.com/babylon101/materials
  38841. */
  38842. export class StandardMaterial extends PushMaterial {
  38843. private _diffuseTexture;
  38844. /**
  38845. * The basic texture of the material as viewed under a light.
  38846. */
  38847. diffuseTexture: Nullable<BaseTexture>;
  38848. private _ambientTexture;
  38849. /**
  38850. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  38851. */
  38852. ambientTexture: Nullable<BaseTexture>;
  38853. private _opacityTexture;
  38854. /**
  38855. * Define the transparency of the material from a texture.
  38856. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  38857. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  38858. */
  38859. opacityTexture: Nullable<BaseTexture>;
  38860. private _reflectionTexture;
  38861. /**
  38862. * Define the texture used to display the reflection.
  38863. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38864. */
  38865. reflectionTexture: Nullable<BaseTexture>;
  38866. private _emissiveTexture;
  38867. /**
  38868. * Define texture of the material as if self lit.
  38869. * This will be mixed in the final result even in the absence of light.
  38870. */
  38871. emissiveTexture: Nullable<BaseTexture>;
  38872. private _specularTexture;
  38873. /**
  38874. * Define how the color and intensity of the highlight given by the light in the material.
  38875. */
  38876. specularTexture: Nullable<BaseTexture>;
  38877. private _bumpTexture;
  38878. /**
  38879. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  38880. * 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.
  38881. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  38882. */
  38883. bumpTexture: Nullable<BaseTexture>;
  38884. private _lightmapTexture;
  38885. /**
  38886. * Complex lighting can be computationally expensive to compute at runtime.
  38887. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  38888. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  38889. */
  38890. lightmapTexture: Nullable<BaseTexture>;
  38891. private _refractionTexture;
  38892. /**
  38893. * Define the texture used to display the refraction.
  38894. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38895. */
  38896. refractionTexture: Nullable<BaseTexture>;
  38897. /**
  38898. * The color of the material lit by the environmental background lighting.
  38899. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  38900. */
  38901. ambientColor: Color3;
  38902. /**
  38903. * The basic color of the material as viewed under a light.
  38904. */
  38905. diffuseColor: Color3;
  38906. /**
  38907. * Define how the color and intensity of the highlight given by the light in the material.
  38908. */
  38909. specularColor: Color3;
  38910. /**
  38911. * Define the color of the material as if self lit.
  38912. * This will be mixed in the final result even in the absence of light.
  38913. */
  38914. emissiveColor: Color3;
  38915. /**
  38916. * Defines how sharp are the highlights in the material.
  38917. * The bigger the value the sharper giving a more glossy feeling to the result.
  38918. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  38919. */
  38920. specularPower: number;
  38921. private _useAlphaFromDiffuseTexture;
  38922. /**
  38923. * Does the transparency come from the diffuse texture alpha channel.
  38924. */
  38925. useAlphaFromDiffuseTexture: boolean;
  38926. private _useEmissiveAsIllumination;
  38927. /**
  38928. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  38929. */
  38930. useEmissiveAsIllumination: boolean;
  38931. private _linkEmissiveWithDiffuse;
  38932. /**
  38933. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  38934. * the emissive level when the final color is close to one.
  38935. */
  38936. linkEmissiveWithDiffuse: boolean;
  38937. private _useSpecularOverAlpha;
  38938. /**
  38939. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  38940. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  38941. */
  38942. useSpecularOverAlpha: boolean;
  38943. private _useReflectionOverAlpha;
  38944. /**
  38945. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  38946. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  38947. */
  38948. useReflectionOverAlpha: boolean;
  38949. private _disableLighting;
  38950. /**
  38951. * Does lights from the scene impacts this material.
  38952. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  38953. */
  38954. disableLighting: boolean;
  38955. private _useObjectSpaceNormalMap;
  38956. /**
  38957. * Allows using an object space normal map (instead of tangent space).
  38958. */
  38959. useObjectSpaceNormalMap: boolean;
  38960. private _useParallax;
  38961. /**
  38962. * Is parallax enabled or not.
  38963. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38964. */
  38965. useParallax: boolean;
  38966. private _useParallaxOcclusion;
  38967. /**
  38968. * Is parallax occlusion enabled or not.
  38969. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  38970. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38971. */
  38972. useParallaxOcclusion: boolean;
  38973. /**
  38974. * 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.
  38975. */
  38976. parallaxScaleBias: number;
  38977. private _roughness;
  38978. /**
  38979. * Helps to define how blurry the reflections should appears in the material.
  38980. */
  38981. roughness: number;
  38982. /**
  38983. * In case of refraction, define the value of the indice of refraction.
  38984. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38985. */
  38986. indexOfRefraction: number;
  38987. /**
  38988. * Invert the refraction texture alongside the y axis.
  38989. * It can be useful with procedural textures or probe for instance.
  38990. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38991. */
  38992. invertRefractionY: boolean;
  38993. /**
  38994. * Defines the alpha limits in alpha test mode.
  38995. */
  38996. alphaCutOff: number;
  38997. private _useLightmapAsShadowmap;
  38998. /**
  38999. * In case of light mapping, define whether the map contains light or shadow informations.
  39000. */
  39001. useLightmapAsShadowmap: boolean;
  39002. private _diffuseFresnelParameters;
  39003. /**
  39004. * Define the diffuse fresnel parameters of the material.
  39005. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39006. */
  39007. diffuseFresnelParameters: FresnelParameters;
  39008. private _opacityFresnelParameters;
  39009. /**
  39010. * Define the opacity fresnel parameters of the material.
  39011. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39012. */
  39013. opacityFresnelParameters: FresnelParameters;
  39014. private _reflectionFresnelParameters;
  39015. /**
  39016. * Define the reflection fresnel parameters of the material.
  39017. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39018. */
  39019. reflectionFresnelParameters: FresnelParameters;
  39020. private _refractionFresnelParameters;
  39021. /**
  39022. * Define the refraction fresnel parameters of the material.
  39023. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39024. */
  39025. refractionFresnelParameters: FresnelParameters;
  39026. private _emissiveFresnelParameters;
  39027. /**
  39028. * Define the emissive fresnel parameters of the material.
  39029. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39030. */
  39031. emissiveFresnelParameters: FresnelParameters;
  39032. private _useReflectionFresnelFromSpecular;
  39033. /**
  39034. * If true automatically deducts the fresnels values from the material specularity.
  39035. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39036. */
  39037. useReflectionFresnelFromSpecular: boolean;
  39038. private _useGlossinessFromSpecularMapAlpha;
  39039. /**
  39040. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39041. */
  39042. useGlossinessFromSpecularMapAlpha: boolean;
  39043. private _maxSimultaneousLights;
  39044. /**
  39045. * Defines the maximum number of lights that can be used in the material
  39046. */
  39047. maxSimultaneousLights: number;
  39048. private _invertNormalMapX;
  39049. /**
  39050. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39051. */
  39052. invertNormalMapX: boolean;
  39053. private _invertNormalMapY;
  39054. /**
  39055. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39056. */
  39057. invertNormalMapY: boolean;
  39058. private _twoSidedLighting;
  39059. /**
  39060. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39061. */
  39062. twoSidedLighting: boolean;
  39063. /**
  39064. * Default configuration related to image processing available in the standard Material.
  39065. */
  39066. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39067. /**
  39068. * Gets the image processing configuration used either in this material.
  39069. */
  39070. /**
  39071. * Sets the Default image processing configuration used either in the this material.
  39072. *
  39073. * If sets to null, the scene one is in use.
  39074. */
  39075. imageProcessingConfiguration: ImageProcessingConfiguration;
  39076. /**
  39077. * Keep track of the image processing observer to allow dispose and replace.
  39078. */
  39079. private _imageProcessingObserver;
  39080. /**
  39081. * Attaches a new image processing configuration to the Standard Material.
  39082. * @param configuration
  39083. */
  39084. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39085. /**
  39086. * Gets wether the color curves effect is enabled.
  39087. */
  39088. /**
  39089. * Sets wether the color curves effect is enabled.
  39090. */
  39091. cameraColorCurvesEnabled: boolean;
  39092. /**
  39093. * Gets wether the color grading effect is enabled.
  39094. */
  39095. /**
  39096. * Gets wether the color grading effect is enabled.
  39097. */
  39098. cameraColorGradingEnabled: boolean;
  39099. /**
  39100. * Gets wether tonemapping is enabled or not.
  39101. */
  39102. /**
  39103. * Sets wether tonemapping is enabled or not
  39104. */
  39105. cameraToneMappingEnabled: boolean;
  39106. /**
  39107. * The camera exposure used on this material.
  39108. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39109. * This corresponds to a photographic exposure.
  39110. */
  39111. /**
  39112. * The camera exposure used on this material.
  39113. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39114. * This corresponds to a photographic exposure.
  39115. */
  39116. cameraExposure: number;
  39117. /**
  39118. * Gets The camera contrast used on this material.
  39119. */
  39120. /**
  39121. * Sets The camera contrast used on this material.
  39122. */
  39123. cameraContrast: number;
  39124. /**
  39125. * Gets the Color Grading 2D Lookup Texture.
  39126. */
  39127. /**
  39128. * Sets the Color Grading 2D Lookup Texture.
  39129. */
  39130. cameraColorGradingTexture: Nullable<BaseTexture>;
  39131. /**
  39132. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39133. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39134. * 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;
  39135. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39136. */
  39137. /**
  39138. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39139. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39140. * 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;
  39141. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39142. */
  39143. cameraColorCurves: Nullable<ColorCurves>;
  39144. /**
  39145. * Custom callback helping to override the default shader used in the material.
  39146. */
  39147. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39148. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39149. protected _worldViewProjectionMatrix: Matrix;
  39150. protected _globalAmbientColor: Color3;
  39151. protected _useLogarithmicDepth: boolean;
  39152. /**
  39153. * Instantiates a new standard material.
  39154. * This is the default material used in Babylon. It is the best trade off between quality
  39155. * and performances.
  39156. * @see http://doc.babylonjs.com/babylon101/materials
  39157. * @param name Define the name of the material in the scene
  39158. * @param scene Define the scene the material belong to
  39159. */
  39160. constructor(name: string, scene: Scene);
  39161. /**
  39162. * Gets a boolean indicating that current material needs to register RTT
  39163. */
  39164. readonly hasRenderTargetTextures: boolean;
  39165. /**
  39166. * Gets the current class name of the material e.g. "StandardMaterial"
  39167. * Mainly use in serialization.
  39168. * @returns the class name
  39169. */
  39170. getClassName(): string;
  39171. /**
  39172. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39173. * You can try switching to logarithmic depth.
  39174. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  39175. */
  39176. useLogarithmicDepth: boolean;
  39177. /**
  39178. * Specifies if the material will require alpha blending
  39179. * @returns a boolean specifying if alpha blending is needed
  39180. */
  39181. needAlphaBlending(): boolean;
  39182. /**
  39183. * Specifies if this material should be rendered in alpha test mode
  39184. * @returns a boolean specifying if an alpha test is needed.
  39185. */
  39186. needAlphaTesting(): boolean;
  39187. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  39188. /**
  39189. * Get the texture used for alpha test purpose.
  39190. * @returns the diffuse texture in case of the standard material.
  39191. */
  39192. getAlphaTestTexture(): Nullable<BaseTexture>;
  39193. /**
  39194. * Get if the submesh is ready to be used and all its information available.
  39195. * Child classes can use it to update shaders
  39196. * @param mesh defines the mesh to check
  39197. * @param subMesh defines which submesh to check
  39198. * @param useInstances specifies that instances should be used
  39199. * @returns a boolean indicating that the submesh is ready or not
  39200. */
  39201. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39202. /**
  39203. * Builds the material UBO layouts.
  39204. * Used internally during the effect preparation.
  39205. */
  39206. buildUniformLayout(): void;
  39207. /**
  39208. * Unbinds the material from the mesh
  39209. */
  39210. unbind(): void;
  39211. /**
  39212. * Binds the submesh to this material by preparing the effect and shader to draw
  39213. * @param world defines the world transformation matrix
  39214. * @param mesh defines the mesh containing the submesh
  39215. * @param subMesh defines the submesh to bind the material to
  39216. */
  39217. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  39218. /**
  39219. * Get the list of animatables in the material.
  39220. * @returns the list of animatables object used in the material
  39221. */
  39222. getAnimatables(): IAnimatable[];
  39223. /**
  39224. * Gets the active textures from the material
  39225. * @returns an array of textures
  39226. */
  39227. getActiveTextures(): BaseTexture[];
  39228. /**
  39229. * Specifies if the material uses a texture
  39230. * @param texture defines the texture to check against the material
  39231. * @returns a boolean specifying if the material uses the texture
  39232. */
  39233. hasTexture(texture: BaseTexture): boolean;
  39234. /**
  39235. * Disposes the material
  39236. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  39237. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  39238. */
  39239. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  39240. /**
  39241. * Makes a duplicate of the material, and gives it a new name
  39242. * @param name defines the new name for the duplicated material
  39243. * @returns the cloned material
  39244. */
  39245. clone(name: string): StandardMaterial;
  39246. /**
  39247. * Serializes this material in a JSON representation
  39248. * @returns the serialized material object
  39249. */
  39250. serialize(): any;
  39251. /**
  39252. * Creates a standard material from parsed material data
  39253. * @param source defines the JSON representation of the material
  39254. * @param scene defines the hosting scene
  39255. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  39256. * @returns a new standard material
  39257. */
  39258. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  39259. /**
  39260. * Are diffuse textures enabled in the application.
  39261. */
  39262. static DiffuseTextureEnabled: boolean;
  39263. /**
  39264. * Are ambient textures enabled in the application.
  39265. */
  39266. static AmbientTextureEnabled: boolean;
  39267. /**
  39268. * Are opacity textures enabled in the application.
  39269. */
  39270. static OpacityTextureEnabled: boolean;
  39271. /**
  39272. * Are reflection textures enabled in the application.
  39273. */
  39274. static ReflectionTextureEnabled: boolean;
  39275. /**
  39276. * Are emissive textures enabled in the application.
  39277. */
  39278. static EmissiveTextureEnabled: boolean;
  39279. /**
  39280. * Are specular textures enabled in the application.
  39281. */
  39282. static SpecularTextureEnabled: boolean;
  39283. /**
  39284. * Are bump textures enabled in the application.
  39285. */
  39286. static BumpTextureEnabled: boolean;
  39287. /**
  39288. * Are lightmap textures enabled in the application.
  39289. */
  39290. static LightmapTextureEnabled: boolean;
  39291. /**
  39292. * Are refraction textures enabled in the application.
  39293. */
  39294. static RefractionTextureEnabled: boolean;
  39295. /**
  39296. * Are color grading textures enabled in the application.
  39297. */
  39298. static ColorGradingTextureEnabled: boolean;
  39299. /**
  39300. * Are fresnels enabled in the application.
  39301. */
  39302. static FresnelEnabled: boolean;
  39303. }
  39304. }
  39305. declare module BABYLON {
  39306. /**
  39307. * A class extending Texture allowing drawing on a texture
  39308. * @see http://doc.babylonjs.com/how_to/dynamictexture
  39309. */
  39310. export class DynamicTexture extends Texture {
  39311. private _generateMipMaps;
  39312. private _canvas;
  39313. private _context;
  39314. private _engine;
  39315. /**
  39316. * Creates a DynamicTexture
  39317. * @param name defines the name of the texture
  39318. * @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
  39319. * @param scene defines the scene where you want the texture
  39320. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  39321. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  39322. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  39323. */
  39324. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  39325. /**
  39326. * Get the current class name of the texture useful for serialization or dynamic coding.
  39327. * @returns "DynamicTexture"
  39328. */
  39329. getClassName(): string;
  39330. /**
  39331. * Gets the current state of canRescale
  39332. */
  39333. readonly canRescale: boolean;
  39334. private _recreate;
  39335. /**
  39336. * Scales the texture
  39337. * @param ratio the scale factor to apply to both width and height
  39338. */
  39339. scale(ratio: number): void;
  39340. /**
  39341. * Resizes the texture
  39342. * @param width the new width
  39343. * @param height the new height
  39344. */
  39345. scaleTo(width: number, height: number): void;
  39346. /**
  39347. * Gets the context of the canvas used by the texture
  39348. * @returns the canvas context of the dynamic texture
  39349. */
  39350. getContext(): CanvasRenderingContext2D;
  39351. /**
  39352. * Clears the texture
  39353. */
  39354. clear(): void;
  39355. /**
  39356. * Updates the texture
  39357. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39358. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  39359. */
  39360. update(invertY?: boolean, premulAlpha?: boolean): void;
  39361. /**
  39362. * Draws text onto the texture
  39363. * @param text defines the text to be drawn
  39364. * @param x defines the placement of the text from the left
  39365. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  39366. * @param font defines the font to be used with font-style, font-size, font-name
  39367. * @param color defines the color used for the text
  39368. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  39369. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39370. * @param update defines whether texture is immediately update (default is true)
  39371. */
  39372. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  39373. /**
  39374. * Clones the texture
  39375. * @returns the clone of the texture.
  39376. */
  39377. clone(): DynamicTexture;
  39378. /**
  39379. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  39380. * @returns a serialized dynamic texture object
  39381. */
  39382. serialize(): any;
  39383. /** @hidden */
  39384. _rebuild(): void;
  39385. }
  39386. }
  39387. declare module BABYLON {
  39388. /** @hidden */
  39389. export var imageProcessingPixelShader: {
  39390. name: string;
  39391. shader: string;
  39392. };
  39393. }
  39394. declare module BABYLON {
  39395. /**
  39396. * ImageProcessingPostProcess
  39397. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  39398. */
  39399. export class ImageProcessingPostProcess extends PostProcess {
  39400. /**
  39401. * Default configuration related to image processing available in the PBR Material.
  39402. */
  39403. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39404. /**
  39405. * Gets the image processing configuration used either in this material.
  39406. */
  39407. /**
  39408. * Sets the Default image processing configuration used either in the this material.
  39409. *
  39410. * If sets to null, the scene one is in use.
  39411. */
  39412. imageProcessingConfiguration: ImageProcessingConfiguration;
  39413. /**
  39414. * Keep track of the image processing observer to allow dispose and replace.
  39415. */
  39416. private _imageProcessingObserver;
  39417. /**
  39418. * Attaches a new image processing configuration to the PBR Material.
  39419. * @param configuration
  39420. */
  39421. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  39422. /**
  39423. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39424. */
  39425. /**
  39426. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39427. */
  39428. colorCurves: Nullable<ColorCurves>;
  39429. /**
  39430. * Gets wether the color curves effect is enabled.
  39431. */
  39432. /**
  39433. * Sets wether the color curves effect is enabled.
  39434. */
  39435. colorCurvesEnabled: boolean;
  39436. /**
  39437. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39438. */
  39439. /**
  39440. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39441. */
  39442. colorGradingTexture: Nullable<BaseTexture>;
  39443. /**
  39444. * Gets wether the color grading effect is enabled.
  39445. */
  39446. /**
  39447. * Gets wether the color grading effect is enabled.
  39448. */
  39449. colorGradingEnabled: boolean;
  39450. /**
  39451. * Gets exposure used in the effect.
  39452. */
  39453. /**
  39454. * Sets exposure used in the effect.
  39455. */
  39456. exposure: number;
  39457. /**
  39458. * Gets wether tonemapping is enabled or not.
  39459. */
  39460. /**
  39461. * Sets wether tonemapping is enabled or not
  39462. */
  39463. toneMappingEnabled: boolean;
  39464. /**
  39465. * Gets the type of tone mapping effect.
  39466. */
  39467. /**
  39468. * Sets the type of tone mapping effect.
  39469. */
  39470. toneMappingType: number;
  39471. /**
  39472. * Gets contrast used in the effect.
  39473. */
  39474. /**
  39475. * Sets contrast used in the effect.
  39476. */
  39477. contrast: number;
  39478. /**
  39479. * Gets Vignette stretch size.
  39480. */
  39481. /**
  39482. * Sets Vignette stretch size.
  39483. */
  39484. vignetteStretch: number;
  39485. /**
  39486. * Gets Vignette centre X Offset.
  39487. */
  39488. /**
  39489. * Sets Vignette centre X Offset.
  39490. */
  39491. vignetteCentreX: number;
  39492. /**
  39493. * Gets Vignette centre Y Offset.
  39494. */
  39495. /**
  39496. * Sets Vignette centre Y Offset.
  39497. */
  39498. vignetteCentreY: number;
  39499. /**
  39500. * Gets Vignette weight or intensity of the vignette effect.
  39501. */
  39502. /**
  39503. * Sets Vignette weight or intensity of the vignette effect.
  39504. */
  39505. vignetteWeight: number;
  39506. /**
  39507. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39508. * if vignetteEnabled is set to true.
  39509. */
  39510. /**
  39511. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39512. * if vignetteEnabled is set to true.
  39513. */
  39514. vignetteColor: Color4;
  39515. /**
  39516. * Gets Camera field of view used by the Vignette effect.
  39517. */
  39518. /**
  39519. * Sets Camera field of view used by the Vignette effect.
  39520. */
  39521. vignetteCameraFov: number;
  39522. /**
  39523. * Gets the vignette blend mode allowing different kind of effect.
  39524. */
  39525. /**
  39526. * Sets the vignette blend mode allowing different kind of effect.
  39527. */
  39528. vignetteBlendMode: number;
  39529. /**
  39530. * Gets wether the vignette effect is enabled.
  39531. */
  39532. /**
  39533. * Sets wether the vignette effect is enabled.
  39534. */
  39535. vignetteEnabled: boolean;
  39536. private _fromLinearSpace;
  39537. /**
  39538. * Gets wether the input of the processing is in Gamma or Linear Space.
  39539. */
  39540. /**
  39541. * Sets wether the input of the processing is in Gamma or Linear Space.
  39542. */
  39543. fromLinearSpace: boolean;
  39544. /**
  39545. * Defines cache preventing GC.
  39546. */
  39547. private _defines;
  39548. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  39549. /**
  39550. * "ImageProcessingPostProcess"
  39551. * @returns "ImageProcessingPostProcess"
  39552. */
  39553. getClassName(): string;
  39554. protected _updateParameters(): void;
  39555. dispose(camera?: Camera): void;
  39556. }
  39557. }
  39558. declare module BABYLON {
  39559. /**
  39560. * Class containing static functions to help procedurally build meshes
  39561. */
  39562. export class GroundBuilder {
  39563. /**
  39564. * Creates a ground mesh
  39565. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  39566. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  39567. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39568. * @param name defines the name of the mesh
  39569. * @param options defines the options used to create the mesh
  39570. * @param scene defines the hosting scene
  39571. * @returns the ground mesh
  39572. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  39573. */
  39574. static CreateGround(name: string, options: {
  39575. width?: number;
  39576. height?: number;
  39577. subdivisions?: number;
  39578. subdivisionsX?: number;
  39579. subdivisionsY?: number;
  39580. updatable?: boolean;
  39581. }, scene: any): Mesh;
  39582. /**
  39583. * Creates a tiled ground mesh
  39584. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  39585. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  39586. * * 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
  39587. * * 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
  39588. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39589. * @param name defines the name of the mesh
  39590. * @param options defines the options used to create the mesh
  39591. * @param scene defines the hosting scene
  39592. * @returns the tiled ground mesh
  39593. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  39594. */
  39595. static CreateTiledGround(name: string, options: {
  39596. xmin: number;
  39597. zmin: number;
  39598. xmax: number;
  39599. zmax: number;
  39600. subdivisions?: {
  39601. w: number;
  39602. h: number;
  39603. };
  39604. precision?: {
  39605. w: number;
  39606. h: number;
  39607. };
  39608. updatable?: boolean;
  39609. }, scene?: Nullable<Scene>): Mesh;
  39610. /**
  39611. * Creates a ground mesh from a height map
  39612. * * The parameter `url` sets the URL of the height map image resource.
  39613. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  39614. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  39615. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  39616. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  39617. * * 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.
  39618. * * 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).
  39619. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  39620. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39621. * @param name defines the name of the mesh
  39622. * @param url defines the url to the height map
  39623. * @param options defines the options used to create the mesh
  39624. * @param scene defines the hosting scene
  39625. * @returns the ground mesh
  39626. * @see https://doc.babylonjs.com/babylon101/height_map
  39627. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  39628. */
  39629. static CreateGroundFromHeightMap(name: string, url: string, options: {
  39630. width?: number;
  39631. height?: number;
  39632. subdivisions?: number;
  39633. minHeight?: number;
  39634. maxHeight?: number;
  39635. colorFilter?: Color3;
  39636. alphaFilter?: number;
  39637. updatable?: boolean;
  39638. onReady?: (mesh: GroundMesh) => void;
  39639. }, scene?: Nullable<Scene>): GroundMesh;
  39640. }
  39641. }
  39642. declare module BABYLON {
  39643. /**
  39644. * Class containing static functions to help procedurally build meshes
  39645. */
  39646. export class TorusBuilder {
  39647. /**
  39648. * Creates a torus mesh
  39649. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  39650. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  39651. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  39652. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39653. * * 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
  39654. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39655. * @param name defines the name of the mesh
  39656. * @param options defines the options used to create the mesh
  39657. * @param scene defines the hosting scene
  39658. * @returns the torus mesh
  39659. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  39660. */
  39661. static CreateTorus(name: string, options: {
  39662. diameter?: number;
  39663. thickness?: number;
  39664. tessellation?: number;
  39665. updatable?: boolean;
  39666. sideOrientation?: number;
  39667. frontUVs?: Vector4;
  39668. backUVs?: Vector4;
  39669. }, scene: any): Mesh;
  39670. }
  39671. }
  39672. declare module BABYLON {
  39673. /**
  39674. * Class containing static functions to help procedurally build meshes
  39675. */
  39676. export class CylinderBuilder {
  39677. /**
  39678. * Creates a cylinder or a cone mesh
  39679. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  39680. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  39681. * * 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.
  39682. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  39683. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  39684. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  39685. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  39686. * * 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).
  39687. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  39688. * * 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).
  39689. * * 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
  39690. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  39691. * * 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
  39692. * * 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.
  39693. * * If `enclose` is false, a ring surface is one element.
  39694. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  39695. * * 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
  39696. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39697. * * 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
  39698. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39699. * @param name defines the name of the mesh
  39700. * @param options defines the options used to create the mesh
  39701. * @param scene defines the hosting scene
  39702. * @returns the cylinder mesh
  39703. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  39704. */
  39705. static CreateCylinder(name: string, options: {
  39706. height?: number;
  39707. diameterTop?: number;
  39708. diameterBottom?: number;
  39709. diameter?: number;
  39710. tessellation?: number;
  39711. subdivisions?: number;
  39712. arc?: number;
  39713. faceColors?: Color4[];
  39714. faceUV?: Vector4[];
  39715. updatable?: boolean;
  39716. hasRings?: boolean;
  39717. enclose?: boolean;
  39718. cap?: number;
  39719. sideOrientation?: number;
  39720. frontUVs?: Vector4;
  39721. backUVs?: Vector4;
  39722. }, scene: any): Mesh;
  39723. }
  39724. }
  39725. declare module BABYLON {
  39726. /**
  39727. * Options to modify the vr teleportation behavior.
  39728. */
  39729. export interface VRTeleportationOptions {
  39730. /**
  39731. * The name of the mesh which should be used as the teleportation floor. (default: null)
  39732. */
  39733. floorMeshName?: string;
  39734. /**
  39735. * A list of meshes to be used as the teleportation floor. (default: empty)
  39736. */
  39737. floorMeshes?: Mesh[];
  39738. }
  39739. /**
  39740. * Options to modify the vr experience helper's behavior.
  39741. */
  39742. export interface VRExperienceHelperOptions extends WebVROptions {
  39743. /**
  39744. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  39745. */
  39746. createDeviceOrientationCamera?: boolean;
  39747. /**
  39748. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  39749. */
  39750. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  39751. /**
  39752. * Uses the main button on the controller to toggle the laser casted. (default: true)
  39753. */
  39754. laserToggle?: boolean;
  39755. /**
  39756. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  39757. */
  39758. floorMeshes?: Mesh[];
  39759. /**
  39760. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  39761. */
  39762. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  39763. }
  39764. /**
  39765. * Event containing information after VR has been entered
  39766. */
  39767. export class OnAfterEnteringVRObservableEvent {
  39768. /**
  39769. * If entering vr was successful
  39770. */
  39771. success: boolean;
  39772. }
  39773. /**
  39774. * Helps to quickly add VR support to an existing scene.
  39775. * See http://doc.babylonjs.com/how_to/webvr_helper
  39776. */
  39777. export class VRExperienceHelper {
  39778. /** Options to modify the vr experience helper's behavior. */
  39779. webVROptions: VRExperienceHelperOptions;
  39780. private _scene;
  39781. private _position;
  39782. private _btnVR;
  39783. private _btnVRDisplayed;
  39784. private _webVRsupported;
  39785. private _webVRready;
  39786. private _webVRrequesting;
  39787. private _webVRpresenting;
  39788. private _hasEnteredVR;
  39789. private _fullscreenVRpresenting;
  39790. private _canvas;
  39791. private _webVRCamera;
  39792. private _vrDeviceOrientationCamera;
  39793. private _deviceOrientationCamera;
  39794. private _existingCamera;
  39795. private _onKeyDown;
  39796. private _onVrDisplayPresentChange;
  39797. private _onVRDisplayChanged;
  39798. private _onVRRequestPresentStart;
  39799. private _onVRRequestPresentComplete;
  39800. /**
  39801. * Observable raised right before entering VR.
  39802. */
  39803. onEnteringVRObservable: Observable<VRExperienceHelper>;
  39804. /**
  39805. * Observable raised when entering VR has completed.
  39806. */
  39807. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  39808. /**
  39809. * Observable raised when exiting VR.
  39810. */
  39811. onExitingVRObservable: Observable<VRExperienceHelper>;
  39812. /**
  39813. * Observable raised when controller mesh is loaded.
  39814. */
  39815. onControllerMeshLoadedObservable: Observable<WebVRController>;
  39816. /** Return this.onEnteringVRObservable
  39817. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  39818. */
  39819. readonly onEnteringVR: Observable<VRExperienceHelper>;
  39820. /** Return this.onExitingVRObservable
  39821. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  39822. */
  39823. readonly onExitingVR: Observable<VRExperienceHelper>;
  39824. /** Return this.onControllerMeshLoadedObservable
  39825. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  39826. */
  39827. readonly onControllerMeshLoaded: Observable<WebVRController>;
  39828. private _rayLength;
  39829. private _useCustomVRButton;
  39830. private _teleportationRequested;
  39831. private _teleportActive;
  39832. private _floorMeshName;
  39833. private _floorMeshesCollection;
  39834. private _rotationAllowed;
  39835. private _teleportBackwardsVector;
  39836. private _teleportationTarget;
  39837. private _isDefaultTeleportationTarget;
  39838. private _postProcessMove;
  39839. private _teleportationFillColor;
  39840. private _teleportationBorderColor;
  39841. private _rotationAngle;
  39842. private _haloCenter;
  39843. private _cameraGazer;
  39844. private _padSensibilityUp;
  39845. private _padSensibilityDown;
  39846. private _leftController;
  39847. private _rightController;
  39848. /**
  39849. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  39850. */
  39851. onNewMeshSelected: Observable<AbstractMesh>;
  39852. /**
  39853. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  39854. */
  39855. onNewMeshPicked: Observable<PickingInfo>;
  39856. private _circleEase;
  39857. /**
  39858. * Observable raised before camera teleportation
  39859. */
  39860. onBeforeCameraTeleport: Observable<Vector3>;
  39861. /**
  39862. * Observable raised after camera teleportation
  39863. */
  39864. onAfterCameraTeleport: Observable<Vector3>;
  39865. /**
  39866. * Observable raised when current selected mesh gets unselected
  39867. */
  39868. onSelectedMeshUnselected: Observable<AbstractMesh>;
  39869. private _raySelectionPredicate;
  39870. /**
  39871. * To be optionaly changed by user to define custom ray selection
  39872. */
  39873. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  39874. /**
  39875. * To be optionaly changed by user to define custom selection logic (after ray selection)
  39876. */
  39877. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  39878. /**
  39879. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  39880. */
  39881. teleportationEnabled: boolean;
  39882. private _defaultHeight;
  39883. private _teleportationInitialized;
  39884. private _interactionsEnabled;
  39885. private _interactionsRequested;
  39886. private _displayGaze;
  39887. private _displayLaserPointer;
  39888. /**
  39889. * The mesh used to display where the user is going to teleport.
  39890. */
  39891. /**
  39892. * Sets the mesh to be used to display where the user is going to teleport.
  39893. */
  39894. teleportationTarget: Mesh;
  39895. /**
  39896. * 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
  39897. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  39898. * See http://doc.babylonjs.com/resources/baking_transformations
  39899. */
  39900. gazeTrackerMesh: Mesh;
  39901. /**
  39902. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  39903. */
  39904. updateGazeTrackerScale: boolean;
  39905. /**
  39906. * If the gaze trackers color should be updated when selecting meshes
  39907. */
  39908. updateGazeTrackerColor: boolean;
  39909. /**
  39910. * The gaze tracking mesh corresponding to the left controller
  39911. */
  39912. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  39913. /**
  39914. * The gaze tracking mesh corresponding to the right controller
  39915. */
  39916. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  39917. /**
  39918. * If the ray of the gaze should be displayed.
  39919. */
  39920. /**
  39921. * Sets if the ray of the gaze should be displayed.
  39922. */
  39923. displayGaze: boolean;
  39924. /**
  39925. * If the ray of the LaserPointer should be displayed.
  39926. */
  39927. /**
  39928. * Sets if the ray of the LaserPointer should be displayed.
  39929. */
  39930. displayLaserPointer: boolean;
  39931. /**
  39932. * The deviceOrientationCamera used as the camera when not in VR.
  39933. */
  39934. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  39935. /**
  39936. * Based on the current WebVR support, returns the current VR camera used.
  39937. */
  39938. readonly currentVRCamera: Nullable<Camera>;
  39939. /**
  39940. * The webVRCamera which is used when in VR.
  39941. */
  39942. readonly webVRCamera: WebVRFreeCamera;
  39943. /**
  39944. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  39945. */
  39946. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  39947. private readonly _teleportationRequestInitiated;
  39948. /**
  39949. * Defines wether or not Pointer lock should be requested when switching to
  39950. * full screen.
  39951. */
  39952. requestPointerLockOnFullScreen: boolean;
  39953. /**
  39954. * Instantiates a VRExperienceHelper.
  39955. * Helps to quickly add VR support to an existing scene.
  39956. * @param scene The scene the VRExperienceHelper belongs to.
  39957. * @param webVROptions Options to modify the vr experience helper's behavior.
  39958. */
  39959. constructor(scene: Scene,
  39960. /** Options to modify the vr experience helper's behavior. */
  39961. webVROptions?: VRExperienceHelperOptions);
  39962. private _onDefaultMeshLoaded;
  39963. private _onResize;
  39964. private _onFullscreenChange;
  39965. /**
  39966. * Gets a value indicating if we are currently in VR mode.
  39967. */
  39968. readonly isInVRMode: boolean;
  39969. private onVrDisplayPresentChange;
  39970. private onVRDisplayChanged;
  39971. private moveButtonToBottomRight;
  39972. private displayVRButton;
  39973. private updateButtonVisibility;
  39974. private _cachedAngularSensibility;
  39975. /**
  39976. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  39977. * Otherwise, will use the fullscreen API.
  39978. */
  39979. enterVR(): void;
  39980. /**
  39981. * Attempt to exit VR, or fullscreen.
  39982. */
  39983. exitVR(): void;
  39984. /**
  39985. * The position of the vr experience helper.
  39986. */
  39987. /**
  39988. * Sets the position of the vr experience helper.
  39989. */
  39990. position: Vector3;
  39991. /**
  39992. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  39993. */
  39994. enableInteractions(): void;
  39995. private readonly _noControllerIsActive;
  39996. private beforeRender;
  39997. private _isTeleportationFloor;
  39998. /**
  39999. * Adds a floor mesh to be used for teleportation.
  40000. * @param floorMesh the mesh to be used for teleportation.
  40001. */
  40002. addFloorMesh(floorMesh: Mesh): void;
  40003. /**
  40004. * Removes a floor mesh from being used for teleportation.
  40005. * @param floorMesh the mesh to be removed.
  40006. */
  40007. removeFloorMesh(floorMesh: Mesh): void;
  40008. /**
  40009. * Enables interactions and teleportation using the VR controllers and gaze.
  40010. * @param vrTeleportationOptions options to modify teleportation behavior.
  40011. */
  40012. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40013. private _onNewGamepadConnected;
  40014. private _tryEnableInteractionOnController;
  40015. private _onNewGamepadDisconnected;
  40016. private _enableInteractionOnController;
  40017. private _checkTeleportWithRay;
  40018. private _checkRotate;
  40019. private _checkTeleportBackwards;
  40020. private _enableTeleportationOnController;
  40021. private _createTeleportationCircles;
  40022. private _displayTeleportationTarget;
  40023. private _hideTeleportationTarget;
  40024. private _rotateCamera;
  40025. private _moveTeleportationSelectorTo;
  40026. private _workingVector;
  40027. private _workingQuaternion;
  40028. private _workingMatrix;
  40029. /**
  40030. * Teleports the users feet to the desired location
  40031. * @param location The location where the user's feet should be placed
  40032. */
  40033. teleportCamera(location: Vector3): void;
  40034. private _convertNormalToDirectionOfRay;
  40035. private _castRayAndSelectObject;
  40036. private _notifySelectedMeshUnselected;
  40037. /**
  40038. * Sets the color of the laser ray from the vr controllers.
  40039. * @param color new color for the ray.
  40040. */
  40041. changeLaserColor(color: Color3): void;
  40042. /**
  40043. * Sets the color of the ray from the vr headsets gaze.
  40044. * @param color new color for the ray.
  40045. */
  40046. changeGazeColor(color: Color3): void;
  40047. /**
  40048. * Exits VR and disposes of the vr experience helper
  40049. */
  40050. dispose(): void;
  40051. /**
  40052. * Gets the name of the VRExperienceHelper class
  40053. * @returns "VRExperienceHelper"
  40054. */
  40055. getClassName(): string;
  40056. }
  40057. }
  40058. declare module BABYLON {
  40059. /**
  40060. * Manages an XRSession
  40061. * @see https://doc.babylonjs.com/how_to/webxr
  40062. */
  40063. export class WebXRSessionManager implements IDisposable {
  40064. private scene;
  40065. /**
  40066. * Fires every time a new xrFrame arrives which can be used to update the camera
  40067. */
  40068. onXRFrameObservable: Observable<any>;
  40069. /**
  40070. * Fires when the xr session is ended either by the device or manually done
  40071. */
  40072. onXRSessionEnded: Observable<any>;
  40073. /** @hidden */
  40074. _xrSession: XRSession;
  40075. /** @hidden */
  40076. _frameOfReference: XRFrameOfReference;
  40077. /** @hidden */
  40078. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  40079. /** @hidden */
  40080. _currentXRFrame: Nullable<XRFrame>;
  40081. private _xrNavigator;
  40082. private _xrDevice;
  40083. private _tmpMatrix;
  40084. /**
  40085. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  40086. * @param scene The scene which the session should be created for
  40087. */
  40088. constructor(scene: Scene);
  40089. /**
  40090. * Initializes the manager
  40091. * After initialization enterXR can be called to start an XR session
  40092. * @returns Promise which resolves after it is initialized
  40093. */
  40094. initializeAsync(): Promise<void>;
  40095. /**
  40096. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  40097. * @param sessionCreationOptions xr options to create the session with
  40098. * @param frameOfReferenceType option to configure how the xr pose is expressed
  40099. * @returns Promise which resolves after it enters XR
  40100. */
  40101. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  40102. /**
  40103. * Stops the xrSession and restores the renderloop
  40104. * @returns Promise which resolves after it exits XR
  40105. */
  40106. exitXRAsync(): Promise<void>;
  40107. /**
  40108. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40109. * @param ray ray to cast into the environment
  40110. * @returns Promise which resolves with a collision point in the environment if it exists
  40111. */
  40112. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40113. /**
  40114. * Checks if a session would be supported for the creation options specified
  40115. * @param options creation options to check if they are supported
  40116. * @returns true if supported
  40117. */
  40118. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40119. /**
  40120. * @hidden
  40121. * Converts the render layer of xrSession to a render target
  40122. * @param session session to create render target for
  40123. * @param scene scene the new render target should be created for
  40124. */
  40125. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  40126. /**
  40127. * Disposes of the session manager
  40128. */
  40129. dispose(): void;
  40130. }
  40131. }
  40132. declare module BABYLON {
  40133. /**
  40134. * WebXR Camera which holds the views for the xrSession
  40135. * @see https://doc.babylonjs.com/how_to/webxr
  40136. */
  40137. export class WebXRCamera extends FreeCamera {
  40138. private static _TmpMatrix;
  40139. /**
  40140. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  40141. * @param name the name of the camera
  40142. * @param scene the scene to add the camera to
  40143. */
  40144. constructor(name: string, scene: Scene);
  40145. private _updateNumberOfRigCameras;
  40146. /** @hidden */
  40147. _updateForDualEyeDebugging(pupilDistance?: number): void;
  40148. /**
  40149. * Updates the cameras position from the current pose information of the XR session
  40150. * @param xrSessionManager the session containing pose information
  40151. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  40152. */
  40153. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  40154. }
  40155. }
  40156. declare module BABYLON {
  40157. /**
  40158. * States of the webXR experience
  40159. */
  40160. export enum WebXRState {
  40161. /**
  40162. * Transitioning to being in XR mode
  40163. */
  40164. ENTERING_XR = 0,
  40165. /**
  40166. * Transitioning to non XR mode
  40167. */
  40168. EXITING_XR = 1,
  40169. /**
  40170. * In XR mode and presenting
  40171. */
  40172. IN_XR = 2,
  40173. /**
  40174. * Not entered XR mode
  40175. */
  40176. NOT_IN_XR = 3
  40177. }
  40178. /**
  40179. * Helper class used to enable XR
  40180. * @see https://doc.babylonjs.com/how_to/webxr
  40181. */
  40182. export class WebXRExperienceHelper implements IDisposable {
  40183. private scene;
  40184. /**
  40185. * 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
  40186. */
  40187. container: AbstractMesh;
  40188. /**
  40189. * Camera used to render xr content
  40190. */
  40191. camera: WebXRCamera;
  40192. /**
  40193. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  40194. */
  40195. state: WebXRState;
  40196. private _setState;
  40197. private static _TmpVector;
  40198. /**
  40199. * Fires when the state of the experience helper has changed
  40200. */
  40201. onStateChangedObservable: Observable<WebXRState>;
  40202. /** @hidden */
  40203. _sessionManager: WebXRSessionManager;
  40204. private _nonVRCamera;
  40205. private _originalSceneAutoClear;
  40206. private _supported;
  40207. /**
  40208. * Creates the experience helper
  40209. * @param scene the scene to attach the experience helper to
  40210. * @returns a promise for the experience helper
  40211. */
  40212. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  40213. /**
  40214. * Creates a WebXRExperienceHelper
  40215. * @param scene The scene the helper should be created in
  40216. */
  40217. private constructor();
  40218. /**
  40219. * Exits XR mode and returns the scene to its original state
  40220. * @returns promise that resolves after xr mode has exited
  40221. */
  40222. exitXRAsync(): Promise<void>;
  40223. /**
  40224. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  40225. * @param sessionCreationOptions options for the XR session
  40226. * @param frameOfReference frame of reference of the XR session
  40227. * @returns promise that resolves after xr mode has entered
  40228. */
  40229. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  40230. /**
  40231. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40232. * @param ray ray to cast into the environment
  40233. * @returns Promise which resolves with a collision point in the environment if it exists
  40234. */
  40235. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40236. /**
  40237. * Updates the global position of the camera by moving the camera's container
  40238. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  40239. * @param position The desired global position of the camera
  40240. */
  40241. setPositionOfCameraUsingContainer(position: Vector3): void;
  40242. /**
  40243. * Rotates the xr camera by rotating the camera's container around the camera's position
  40244. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  40245. * @param rotation the desired quaternion rotation to apply to the camera
  40246. */
  40247. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  40248. /**
  40249. * Checks if the creation options are supported by the xr session
  40250. * @param options creation options
  40251. * @returns true if supported
  40252. */
  40253. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40254. /**
  40255. * Disposes of the experience helper
  40256. */
  40257. dispose(): void;
  40258. }
  40259. }
  40260. declare module BABYLON {
  40261. /**
  40262. * Button which can be used to enter a different mode of XR
  40263. */
  40264. export class WebXREnterExitUIButton {
  40265. /** button element */
  40266. element: HTMLElement;
  40267. /** XR initialization options for the button */
  40268. initializationOptions: XRSessionCreationOptions;
  40269. /**
  40270. * Creates a WebXREnterExitUIButton
  40271. * @param element button element
  40272. * @param initializationOptions XR initialization options for the button
  40273. */
  40274. constructor(
  40275. /** button element */
  40276. element: HTMLElement,
  40277. /** XR initialization options for the button */
  40278. initializationOptions: XRSessionCreationOptions);
  40279. /**
  40280. * Overwritable function which can be used to update the button's visuals when the state changes
  40281. * @param activeButton the current active button in the UI
  40282. */
  40283. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  40284. }
  40285. /**
  40286. * Options to create the webXR UI
  40287. */
  40288. export class WebXREnterExitUIOptions {
  40289. /**
  40290. * Context to enter xr with
  40291. */
  40292. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  40293. /**
  40294. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  40295. */
  40296. customButtons?: Array<WebXREnterExitUIButton>;
  40297. }
  40298. /**
  40299. * UI to allow the user to enter/exit XR mode
  40300. */
  40301. export class WebXREnterExitUI implements IDisposable {
  40302. private scene;
  40303. private _overlay;
  40304. private _buttons;
  40305. private _activeButton;
  40306. /**
  40307. * Fired every time the active button is changed.
  40308. *
  40309. * When xr is entered via a button that launches xr that button will be the callback parameter
  40310. *
  40311. * When exiting xr the callback parameter will be null)
  40312. */
  40313. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  40314. /**
  40315. * Creates UI to allow the user to enter/exit XR mode
  40316. * @param scene the scene to add the ui to
  40317. * @param helper the xr experience helper to enter/exit xr with
  40318. * @param options options to configure the UI
  40319. * @returns the created ui
  40320. */
  40321. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  40322. private constructor();
  40323. private _updateButtons;
  40324. /**
  40325. * Disposes of the object
  40326. */
  40327. dispose(): void;
  40328. }
  40329. }
  40330. declare module BABYLON {
  40331. /**
  40332. * Represents an XR input
  40333. */
  40334. export class WebXRController {
  40335. /**
  40336. * 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
  40337. */
  40338. grip?: AbstractMesh;
  40339. /**
  40340. * Pointer which can be used to select objects or attach a visible laser to
  40341. */
  40342. pointer: AbstractMesh;
  40343. /**
  40344. * Creates the controller
  40345. * @see https://doc.babylonjs.com/how_to/webxr
  40346. * @param scene the scene which the controller should be associated to
  40347. */
  40348. constructor(scene: Scene);
  40349. /**
  40350. * Disposes of the object
  40351. */
  40352. dispose(): void;
  40353. }
  40354. /**
  40355. * XR input used to track XR inputs such as controllers/rays
  40356. */
  40357. export class WebXRInput implements IDisposable {
  40358. private helper;
  40359. /**
  40360. * XR controllers being tracked
  40361. */
  40362. controllers: Array<WebXRController>;
  40363. private _tmpMatrix;
  40364. private _frameObserver;
  40365. /**
  40366. * Initializes the WebXRInput
  40367. * @param helper experience helper which the input should be created for
  40368. */
  40369. constructor(helper: WebXRExperienceHelper);
  40370. /**
  40371. * Disposes of the object
  40372. */
  40373. dispose(): void;
  40374. }
  40375. }
  40376. declare module BABYLON {
  40377. /**
  40378. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40379. */
  40380. export class WebXRManagedOutputCanvas implements IDisposable {
  40381. private _canvas;
  40382. /**
  40383. * xrpresent context of the canvas which can be used to display/mirror xr content
  40384. */
  40385. canvasContext: Nullable<WebGLRenderingContext>;
  40386. /**
  40387. * Initializes the canvas to be added/removed upon entering/exiting xr
  40388. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  40389. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40390. */
  40391. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  40392. /**
  40393. * Disposes of the object
  40394. */
  40395. dispose(): void;
  40396. private _setManagedOutputCanvas;
  40397. private _addCanvas;
  40398. private _removeCanvas;
  40399. }
  40400. }
  40401. declare module BABYLON {
  40402. /**
  40403. * Contains an array of blocks representing the octree
  40404. */
  40405. export interface IOctreeContainer<T> {
  40406. /**
  40407. * Blocks within the octree
  40408. */
  40409. blocks: Array<OctreeBlock<T>>;
  40410. }
  40411. /**
  40412. * Class used to store a cell in an octree
  40413. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40414. */
  40415. export class OctreeBlock<T> {
  40416. /**
  40417. * Gets the content of the current block
  40418. */
  40419. entries: T[];
  40420. /**
  40421. * Gets the list of block children
  40422. */
  40423. blocks: Array<OctreeBlock<T>>;
  40424. private _depth;
  40425. private _maxDepth;
  40426. private _capacity;
  40427. private _minPoint;
  40428. private _maxPoint;
  40429. private _boundingVectors;
  40430. private _creationFunc;
  40431. /**
  40432. * Creates a new block
  40433. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  40434. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  40435. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40436. * @param depth defines the current depth of this block in the octree
  40437. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  40438. * @param creationFunc defines a callback to call when an element is added to the block
  40439. */
  40440. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  40441. /**
  40442. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40443. */
  40444. readonly capacity: number;
  40445. /**
  40446. * Gets the minimum vector (in world space) of the block's bounding box
  40447. */
  40448. readonly minPoint: Vector3;
  40449. /**
  40450. * Gets the maximum vector (in world space) of the block's bounding box
  40451. */
  40452. readonly maxPoint: Vector3;
  40453. /**
  40454. * Add a new element to this block
  40455. * @param entry defines the element to add
  40456. */
  40457. addEntry(entry: T): void;
  40458. /**
  40459. * Remove an element from this block
  40460. * @param entry defines the element to remove
  40461. */
  40462. removeEntry(entry: T): void;
  40463. /**
  40464. * Add an array of elements to this block
  40465. * @param entries defines the array of elements to add
  40466. */
  40467. addEntries(entries: T[]): void;
  40468. /**
  40469. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  40470. * @param frustumPlanes defines the frustum planes to test
  40471. * @param selection defines the array to store current content if selection is positive
  40472. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40473. */
  40474. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40475. /**
  40476. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  40477. * @param sphereCenter defines the bounding sphere center
  40478. * @param sphereRadius defines the bounding sphere radius
  40479. * @param selection defines the array to store current content if selection is positive
  40480. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40481. */
  40482. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40483. /**
  40484. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  40485. * @param ray defines the ray to test with
  40486. * @param selection defines the array to store current content if selection is positive
  40487. */
  40488. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  40489. /**
  40490. * Subdivide the content into child blocks (this block will then be empty)
  40491. */
  40492. createInnerBlocks(): void;
  40493. /**
  40494. * @hidden
  40495. */
  40496. 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;
  40497. }
  40498. }
  40499. declare module BABYLON {
  40500. /**
  40501. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  40502. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40503. */
  40504. export class Octree<T> {
  40505. /** 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.) */
  40506. maxDepth: number;
  40507. /**
  40508. * Blocks within the octree containing objects
  40509. */
  40510. blocks: Array<OctreeBlock<T>>;
  40511. /**
  40512. * Content stored in the octree
  40513. */
  40514. dynamicContent: T[];
  40515. private _maxBlockCapacity;
  40516. private _selectionContent;
  40517. private _creationFunc;
  40518. /**
  40519. * Creates a octree
  40520. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40521. * @param creationFunc function to be used to instatiate the octree
  40522. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  40523. * @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.)
  40524. */
  40525. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  40526. /** 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.) */
  40527. maxDepth?: number);
  40528. /**
  40529. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  40530. * @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);
  40531. * @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);
  40532. * @param entries meshes to be added to the octree blocks
  40533. */
  40534. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  40535. /**
  40536. * Adds a mesh to the octree
  40537. * @param entry Mesh to add to the octree
  40538. */
  40539. addMesh(entry: T): void;
  40540. /**
  40541. * Remove an element from the octree
  40542. * @param entry defines the element to remove
  40543. */
  40544. removeMesh(entry: T): void;
  40545. /**
  40546. * Selects an array of meshes within the frustum
  40547. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  40548. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  40549. * @returns array of meshes within the frustum
  40550. */
  40551. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  40552. /**
  40553. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  40554. * @param sphereCenter defines the bounding sphere center
  40555. * @param sphereRadius defines the bounding sphere radius
  40556. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40557. * @returns an array of objects that intersect the sphere
  40558. */
  40559. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  40560. /**
  40561. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  40562. * @param ray defines the ray to test with
  40563. * @returns array of intersected objects
  40564. */
  40565. intersectsRay(ray: Ray): SmartArray<T>;
  40566. /**
  40567. * Adds a mesh into the octree block if it intersects the block
  40568. */
  40569. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  40570. /**
  40571. * Adds a submesh into the octree block if it intersects the block
  40572. */
  40573. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  40574. }
  40575. }
  40576. declare module BABYLON {
  40577. interface Scene {
  40578. /**
  40579. * @hidden
  40580. * Backing Filed
  40581. */
  40582. _selectionOctree: Octree<AbstractMesh>;
  40583. /**
  40584. * Gets the octree used to boost mesh selection (picking)
  40585. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40586. */
  40587. selectionOctree: Octree<AbstractMesh>;
  40588. /**
  40589. * Creates or updates the octree used to boost selection (picking)
  40590. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40591. * @param maxCapacity defines the maximum capacity per leaf
  40592. * @param maxDepth defines the maximum depth of the octree
  40593. * @returns an octree of AbstractMesh
  40594. */
  40595. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  40596. }
  40597. interface AbstractMesh {
  40598. /**
  40599. * @hidden
  40600. * Backing Field
  40601. */
  40602. _submeshesOctree: Octree<SubMesh>;
  40603. /**
  40604. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  40605. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  40606. * @param maxCapacity defines the maximum size of each block (64 by default)
  40607. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  40608. * @returns the new octree
  40609. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  40610. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40611. */
  40612. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  40613. }
  40614. /**
  40615. * Defines the octree scene component responsible to manage any octrees
  40616. * in a given scene.
  40617. */
  40618. export class OctreeSceneComponent {
  40619. /**
  40620. * The component name help to identify the component in the list of scene components.
  40621. */
  40622. readonly name: string;
  40623. /**
  40624. * The scene the component belongs to.
  40625. */
  40626. scene: Scene;
  40627. /**
  40628. * Indicates if the meshes have been checked to make sure they are isEnabled()
  40629. */
  40630. readonly checksIsEnabled: boolean;
  40631. /**
  40632. * Creates a new instance of the component for the given scene
  40633. * @param scene Defines the scene to register the component in
  40634. */
  40635. constructor(scene: Scene);
  40636. /**
  40637. * Registers the component in a given scene
  40638. */
  40639. register(): void;
  40640. /**
  40641. * Return the list of active meshes
  40642. * @returns the list of active meshes
  40643. */
  40644. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40645. /**
  40646. * Return the list of active sub meshes
  40647. * @param mesh The mesh to get the candidates sub meshes from
  40648. * @returns the list of active sub meshes
  40649. */
  40650. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40651. private _tempRay;
  40652. /**
  40653. * Return the list of sub meshes intersecting with a given local ray
  40654. * @param mesh defines the mesh to find the submesh for
  40655. * @param localRay defines the ray in local space
  40656. * @returns the list of intersecting sub meshes
  40657. */
  40658. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  40659. /**
  40660. * Return the list of sub meshes colliding with a collider
  40661. * @param mesh defines the mesh to find the submesh for
  40662. * @param collider defines the collider to evaluate the collision against
  40663. * @returns the list of colliding sub meshes
  40664. */
  40665. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  40666. /**
  40667. * Rebuilds the elements related to this component in case of
  40668. * context lost for instance.
  40669. */
  40670. rebuild(): void;
  40671. /**
  40672. * Disposes the component and the associated ressources.
  40673. */
  40674. dispose(): void;
  40675. }
  40676. }
  40677. declare module BABYLON {
  40678. /**
  40679. * Renders a layer on top of an existing scene
  40680. */
  40681. export class UtilityLayerRenderer implements IDisposable {
  40682. /** the original scene that will be rendered on top of */
  40683. originalScene: Scene;
  40684. private _pointerCaptures;
  40685. private _lastPointerEvents;
  40686. private static _DefaultUtilityLayer;
  40687. private static _DefaultKeepDepthUtilityLayer;
  40688. private _sharedGizmoLight;
  40689. /**
  40690. * @hidden
  40691. * Light which used by gizmos to get light shading
  40692. */
  40693. _getSharedGizmoLight(): HemisphericLight;
  40694. /**
  40695. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  40696. */
  40697. pickUtilitySceneFirst: boolean;
  40698. /**
  40699. * 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)
  40700. */
  40701. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  40702. /**
  40703. * 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)
  40704. */
  40705. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  40706. /**
  40707. * The scene that is rendered on top of the original scene
  40708. */
  40709. utilityLayerScene: Scene;
  40710. /**
  40711. * If the utility layer should automatically be rendered on top of existing scene
  40712. */
  40713. shouldRender: boolean;
  40714. /**
  40715. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  40716. */
  40717. onlyCheckPointerDownEvents: boolean;
  40718. /**
  40719. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  40720. */
  40721. processAllEvents: boolean;
  40722. /**
  40723. * Observable raised when the pointer move from the utility layer scene to the main scene
  40724. */
  40725. onPointerOutObservable: Observable<number>;
  40726. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  40727. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  40728. private _afterRenderObserver;
  40729. private _sceneDisposeObserver;
  40730. private _originalPointerObserver;
  40731. /**
  40732. * Instantiates a UtilityLayerRenderer
  40733. * @param originalScene the original scene that will be rendered on top of
  40734. * @param handleEvents boolean indicating if the utility layer should handle events
  40735. */
  40736. constructor(
  40737. /** the original scene that will be rendered on top of */
  40738. originalScene: Scene, handleEvents?: boolean);
  40739. private _notifyObservers;
  40740. /**
  40741. * Renders the utility layers scene on top of the original scene
  40742. */
  40743. render(): void;
  40744. /**
  40745. * Disposes of the renderer
  40746. */
  40747. dispose(): void;
  40748. private _updateCamera;
  40749. }
  40750. }
  40751. declare module BABYLON {
  40752. /**
  40753. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  40754. */
  40755. export class Gizmo implements IDisposable {
  40756. /** The utility layer the gizmo will be added to */
  40757. gizmoLayer: UtilityLayerRenderer;
  40758. /**
  40759. * The root mesh of the gizmo
  40760. */
  40761. _rootMesh: Mesh;
  40762. private _attachedMesh;
  40763. /**
  40764. * Ratio for the scale of the gizmo (Default: 1)
  40765. */
  40766. scaleRatio: number;
  40767. /**
  40768. * If a custom mesh has been set (Default: false)
  40769. */
  40770. protected _customMeshSet: boolean;
  40771. /**
  40772. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  40773. * * When set, interactions will be enabled
  40774. */
  40775. attachedMesh: Nullable<AbstractMesh>;
  40776. /**
  40777. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  40778. * @param mesh The mesh to replace the default mesh of the gizmo
  40779. */
  40780. setCustomMesh(mesh: Mesh): void;
  40781. /**
  40782. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  40783. */
  40784. updateGizmoRotationToMatchAttachedMesh: boolean;
  40785. /**
  40786. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  40787. */
  40788. updateGizmoPositionToMatchAttachedMesh: boolean;
  40789. /**
  40790. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  40791. */
  40792. protected _updateScale: boolean;
  40793. protected _interactionsEnabled: boolean;
  40794. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40795. private _beforeRenderObserver;
  40796. private _tempVector;
  40797. /**
  40798. * Creates a gizmo
  40799. * @param gizmoLayer The utility layer the gizmo will be added to
  40800. */
  40801. constructor(
  40802. /** The utility layer the gizmo will be added to */
  40803. gizmoLayer?: UtilityLayerRenderer);
  40804. /**
  40805. * Updates the gizmo to match the attached mesh's position/rotation
  40806. */
  40807. protected _update(): void;
  40808. /**
  40809. * Disposes of the gizmo
  40810. */
  40811. dispose(): void;
  40812. }
  40813. }
  40814. declare module BABYLON {
  40815. /**
  40816. * Single axis drag gizmo
  40817. */
  40818. export class AxisDragGizmo extends Gizmo {
  40819. /**
  40820. * Drag behavior responsible for the gizmos dragging interactions
  40821. */
  40822. dragBehavior: PointerDragBehavior;
  40823. private _pointerObserver;
  40824. /**
  40825. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40826. */
  40827. snapDistance: number;
  40828. /**
  40829. * Event that fires each time the gizmo snaps to a new location.
  40830. * * snapDistance is the the change in distance
  40831. */
  40832. onSnapObservable: Observable<{
  40833. snapDistance: number;
  40834. }>;
  40835. /** @hidden */
  40836. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  40837. /** @hidden */
  40838. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  40839. /**
  40840. * Creates an AxisDragGizmo
  40841. * @param gizmoLayer The utility layer the gizmo will be added to
  40842. * @param dragAxis The axis which the gizmo will be able to drag on
  40843. * @param color The color of the gizmo
  40844. */
  40845. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  40846. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40847. /**
  40848. * Disposes of the gizmo
  40849. */
  40850. dispose(): void;
  40851. }
  40852. }
  40853. declare module BABYLON.Debug {
  40854. /**
  40855. * The Axes viewer will show 3 axes in a specific point in space
  40856. */
  40857. export class AxesViewer {
  40858. private _xAxis;
  40859. private _yAxis;
  40860. private _zAxis;
  40861. private _scaleLinesFactor;
  40862. private _instanced;
  40863. /**
  40864. * Gets the hosting scene
  40865. */
  40866. scene: Scene;
  40867. /**
  40868. * Gets or sets a number used to scale line length
  40869. */
  40870. scaleLines: number;
  40871. /** Gets the node hierarchy used to render x-axis */
  40872. readonly xAxis: TransformNode;
  40873. /** Gets the node hierarchy used to render y-axis */
  40874. readonly yAxis: TransformNode;
  40875. /** Gets the node hierarchy used to render z-axis */
  40876. readonly zAxis: TransformNode;
  40877. /**
  40878. * Creates a new AxesViewer
  40879. * @param scene defines the hosting scene
  40880. * @param scaleLines defines a number used to scale line length (1 by default)
  40881. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  40882. * @param xAxis defines the node hierarchy used to render the x-axis
  40883. * @param yAxis defines the node hierarchy used to render the y-axis
  40884. * @param zAxis defines the node hierarchy used to render the z-axis
  40885. */
  40886. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  40887. /**
  40888. * Force the viewer to update
  40889. * @param position defines the position of the viewer
  40890. * @param xaxis defines the x axis of the viewer
  40891. * @param yaxis defines the y axis of the viewer
  40892. * @param zaxis defines the z axis of the viewer
  40893. */
  40894. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  40895. /**
  40896. * Creates an instance of this axes viewer.
  40897. * @returns a new axes viewer with instanced meshes
  40898. */
  40899. createInstance(): AxesViewer;
  40900. /** Releases resources */
  40901. dispose(): void;
  40902. private static _SetRenderingGroupId;
  40903. }
  40904. }
  40905. declare module BABYLON.Debug {
  40906. /**
  40907. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  40908. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  40909. */
  40910. export class BoneAxesViewer extends AxesViewer {
  40911. /**
  40912. * Gets or sets the target mesh where to display the axes viewer
  40913. */
  40914. mesh: Nullable<Mesh>;
  40915. /**
  40916. * Gets or sets the target bone where to display the axes viewer
  40917. */
  40918. bone: Nullable<Bone>;
  40919. /** Gets current position */
  40920. pos: Vector3;
  40921. /** Gets direction of X axis */
  40922. xaxis: Vector3;
  40923. /** Gets direction of Y axis */
  40924. yaxis: Vector3;
  40925. /** Gets direction of Z axis */
  40926. zaxis: Vector3;
  40927. /**
  40928. * Creates a new BoneAxesViewer
  40929. * @param scene defines the hosting scene
  40930. * @param bone defines the target bone
  40931. * @param mesh defines the target mesh
  40932. * @param scaleLines defines a scaling factor for line length (1 by default)
  40933. */
  40934. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  40935. /**
  40936. * Force the viewer to update
  40937. */
  40938. update(): void;
  40939. /** Releases resources */
  40940. dispose(): void;
  40941. }
  40942. }
  40943. declare module BABYLON {
  40944. /**
  40945. * Interface used to define scene explorer extensibility option
  40946. */
  40947. export interface IExplorerExtensibilityOption {
  40948. /**
  40949. * Define the option label
  40950. */
  40951. label: string;
  40952. /**
  40953. * Defines the action to execute on click
  40954. */
  40955. action: (entity: any) => void;
  40956. }
  40957. /**
  40958. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  40959. */
  40960. export interface IExplorerExtensibilityGroup {
  40961. /**
  40962. * Defines a predicate to test if a given type mut be extended
  40963. */
  40964. predicate: (entity: any) => boolean;
  40965. /**
  40966. * Gets the list of options added to a type
  40967. */
  40968. entries: IExplorerExtensibilityOption[];
  40969. }
  40970. /**
  40971. * Interface used to define the options to use to create the Inspector
  40972. */
  40973. export interface IInspectorOptions {
  40974. /**
  40975. * Display in overlay mode (default: false)
  40976. */
  40977. overlay?: boolean;
  40978. /**
  40979. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  40980. */
  40981. globalRoot?: HTMLElement;
  40982. /**
  40983. * Display the Scene explorer
  40984. */
  40985. showExplorer?: boolean;
  40986. /**
  40987. * Display the property inspector
  40988. */
  40989. showInspector?: boolean;
  40990. /**
  40991. * Display in embed mode (both panes on the right)
  40992. */
  40993. embedMode?: boolean;
  40994. /**
  40995. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  40996. */
  40997. handleResize?: boolean;
  40998. /**
  40999. * Allow the panes to popup (default: true)
  41000. */
  41001. enablePopup?: boolean;
  41002. /**
  41003. * Allow the panes to be closed by users (default: true)
  41004. */
  41005. enableClose?: boolean;
  41006. /**
  41007. * Optional list of extensibility entries
  41008. */
  41009. explorerExtensibility?: IExplorerExtensibilityGroup[];
  41010. /**
  41011. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  41012. */
  41013. inspectorURL?: string;
  41014. }
  41015. interface Scene {
  41016. /**
  41017. * @hidden
  41018. * Backing field
  41019. */
  41020. _debugLayer: DebugLayer;
  41021. /**
  41022. * Gets the debug layer (aka Inspector) associated with the scene
  41023. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41024. */
  41025. debugLayer: DebugLayer;
  41026. }
  41027. /**
  41028. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41029. * what is happening in your scene
  41030. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41031. */
  41032. export class DebugLayer {
  41033. /**
  41034. * Define the url to get the inspector script from.
  41035. * By default it uses the babylonjs CDN.
  41036. * @ignoreNaming
  41037. */
  41038. static InspectorURL: string;
  41039. private _scene;
  41040. private BJSINSPECTOR;
  41041. /**
  41042. * Observable triggered when a property is changed through the inspector.
  41043. */
  41044. onPropertyChangedObservable: Observable<{
  41045. object: any;
  41046. property: string;
  41047. value: any;
  41048. initialValue: any;
  41049. }>;
  41050. /**
  41051. * Instantiates a new debug layer.
  41052. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41053. * what is happening in your scene
  41054. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41055. * @param scene Defines the scene to inspect
  41056. */
  41057. constructor(scene: Scene);
  41058. /** Creates the inspector window. */
  41059. private _createInspector;
  41060. /**
  41061. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  41062. * @param entity defines the entity to select
  41063. * @param lineContainerTitle defines the specific block to highlight
  41064. */
  41065. select(entity: any, lineContainerTitle?: string): void;
  41066. /** Get the inspector from bundle or global */
  41067. private _getGlobalInspector;
  41068. /**
  41069. * Get if the inspector is visible or not.
  41070. * @returns true if visible otherwise, false
  41071. */
  41072. isVisible(): boolean;
  41073. /**
  41074. * Hide the inspector and close its window.
  41075. */
  41076. hide(): void;
  41077. /**
  41078. * Launch the debugLayer.
  41079. * @param config Define the configuration of the inspector
  41080. * @return a promise fulfilled when the debug layer is visible
  41081. */
  41082. show(config?: IInspectorOptions): Promise<DebugLayer>;
  41083. }
  41084. }
  41085. declare module BABYLON {
  41086. /**
  41087. * Class containing static functions to help procedurally build meshes
  41088. */
  41089. export class BoxBuilder {
  41090. /**
  41091. * Creates a box mesh
  41092. * * The parameter `size` sets the size (float) of each box side (default 1)
  41093. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  41094. * * 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)
  41095. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  41096. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41097. * * 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
  41098. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41099. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  41100. * @param name defines the name of the mesh
  41101. * @param options defines the options used to create the mesh
  41102. * @param scene defines the hosting scene
  41103. * @returns the box mesh
  41104. */
  41105. static CreateBox(name: string, options: {
  41106. size?: number;
  41107. width?: number;
  41108. height?: number;
  41109. depth?: number;
  41110. faceUV?: Vector4[];
  41111. faceColors?: Color4[];
  41112. sideOrientation?: number;
  41113. frontUVs?: Vector4;
  41114. backUVs?: Vector4;
  41115. wrap?: boolean;
  41116. topBaseAt?: number;
  41117. bottomBaseAt?: number;
  41118. updatable?: boolean;
  41119. }, scene?: Nullable<Scene>): Mesh;
  41120. }
  41121. }
  41122. declare module BABYLON {
  41123. /**
  41124. * Class containing static functions to help procedurally build meshes
  41125. */
  41126. export class SphereBuilder {
  41127. /**
  41128. * Creates a sphere mesh
  41129. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  41130. * * 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`)
  41131. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  41132. * * 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
  41133. * * 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)
  41134. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41135. * * 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
  41136. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41137. * @param name defines the name of the mesh
  41138. * @param options defines the options used to create the mesh
  41139. * @param scene defines the hosting scene
  41140. * @returns the sphere mesh
  41141. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  41142. */
  41143. static CreateSphere(name: string, options: {
  41144. segments?: number;
  41145. diameter?: number;
  41146. diameterX?: number;
  41147. diameterY?: number;
  41148. diameterZ?: number;
  41149. arc?: number;
  41150. slice?: number;
  41151. sideOrientation?: number;
  41152. frontUVs?: Vector4;
  41153. backUVs?: Vector4;
  41154. updatable?: boolean;
  41155. }, scene: any): Mesh;
  41156. }
  41157. }
  41158. declare module BABYLON.Debug {
  41159. /**
  41160. * Used to show the physics impostor around the specific mesh
  41161. */
  41162. export class PhysicsViewer {
  41163. /** @hidden */
  41164. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  41165. /** @hidden */
  41166. protected _meshes: Array<Nullable<AbstractMesh>>;
  41167. /** @hidden */
  41168. protected _scene: Nullable<Scene>;
  41169. /** @hidden */
  41170. protected _numMeshes: number;
  41171. /** @hidden */
  41172. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  41173. private _renderFunction;
  41174. private _utilityLayer;
  41175. private _debugBoxMesh;
  41176. private _debugSphereMesh;
  41177. private _debugCylinderMesh;
  41178. private _debugMaterial;
  41179. private _debugMeshMeshes;
  41180. /**
  41181. * Creates a new PhysicsViewer
  41182. * @param scene defines the hosting scene
  41183. */
  41184. constructor(scene: Scene);
  41185. /** @hidden */
  41186. protected _updateDebugMeshes(): void;
  41187. /**
  41188. * Renders a specified physic impostor
  41189. * @param impostor defines the impostor to render
  41190. * @param targetMesh defines the mesh represented by the impostor
  41191. * @returns the new debug mesh used to render the impostor
  41192. */
  41193. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  41194. /**
  41195. * Hides a specified physic impostor
  41196. * @param impostor defines the impostor to hide
  41197. */
  41198. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  41199. private _getDebugMaterial;
  41200. private _getDebugBoxMesh;
  41201. private _getDebugSphereMesh;
  41202. private _getDebugCylinderMesh;
  41203. private _getDebugMeshMesh;
  41204. private _getDebugMesh;
  41205. /** Releases all resources */
  41206. dispose(): void;
  41207. }
  41208. }
  41209. declare module BABYLON {
  41210. /**
  41211. * Class containing static functions to help procedurally build meshes
  41212. */
  41213. export class LinesBuilder {
  41214. /**
  41215. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  41216. * * 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
  41217. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  41218. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  41219. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  41220. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  41221. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  41222. * * 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
  41223. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  41224. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41225. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  41226. * @param name defines the name of the new line system
  41227. * @param options defines the options used to create the line system
  41228. * @param scene defines the hosting scene
  41229. * @returns a new line system mesh
  41230. */
  41231. static CreateLineSystem(name: string, options: {
  41232. lines: Vector3[][];
  41233. updatable?: boolean;
  41234. instance?: Nullable<LinesMesh>;
  41235. colors?: Nullable<Color4[][]>;
  41236. useVertexAlpha?: boolean;
  41237. }, scene: Nullable<Scene>): LinesMesh;
  41238. /**
  41239. * Creates a line mesh
  41240. * 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
  41241. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41242. * * The parameter `points` is an array successive Vector3
  41243. * * 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
  41244. * * The optional parameter `colors` is an array of successive Color4, one per line point
  41245. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  41246. * * When updating an instance, remember that only point positions can change, not the number of points
  41247. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41248. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  41249. * @param name defines the name of the new line system
  41250. * @param options defines the options used to create the line system
  41251. * @param scene defines the hosting scene
  41252. * @returns a new line mesh
  41253. */
  41254. static CreateLines(name: string, options: {
  41255. points: Vector3[];
  41256. updatable?: boolean;
  41257. instance?: Nullable<LinesMesh>;
  41258. colors?: Color4[];
  41259. useVertexAlpha?: boolean;
  41260. }, scene?: Nullable<Scene>): LinesMesh;
  41261. /**
  41262. * Creates a dashed line mesh
  41263. * * 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
  41264. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41265. * * The parameter `points` is an array successive Vector3
  41266. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  41267. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  41268. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  41269. * * 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
  41270. * * When updating an instance, remember that only point positions can change, not the number of points
  41271. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41272. * @param name defines the name of the mesh
  41273. * @param options defines the options used to create the mesh
  41274. * @param scene defines the hosting scene
  41275. * @returns the dashed line mesh
  41276. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  41277. */
  41278. static CreateDashedLines(name: string, options: {
  41279. points: Vector3[];
  41280. dashSize?: number;
  41281. gapSize?: number;
  41282. dashNb?: number;
  41283. updatable?: boolean;
  41284. instance?: LinesMesh;
  41285. }, scene?: Nullable<Scene>): LinesMesh;
  41286. }
  41287. }
  41288. declare module BABYLON {
  41289. /**
  41290. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41291. * in order to better appreciate the issue one might have.
  41292. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41293. */
  41294. export class RayHelper {
  41295. /**
  41296. * Defines the ray we are currently tryin to visualize.
  41297. */
  41298. ray: Nullable<Ray>;
  41299. private _renderPoints;
  41300. private _renderLine;
  41301. private _renderFunction;
  41302. private _scene;
  41303. private _updateToMeshFunction;
  41304. private _attachedToMesh;
  41305. private _meshSpaceDirection;
  41306. private _meshSpaceOrigin;
  41307. /**
  41308. * Helper function to create a colored helper in a scene in one line.
  41309. * @param ray Defines the ray we are currently tryin to visualize
  41310. * @param scene Defines the scene the ray is used in
  41311. * @param color Defines the color we want to see the ray in
  41312. * @returns The newly created ray helper.
  41313. */
  41314. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  41315. /**
  41316. * Instantiate a new ray helper.
  41317. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41318. * in order to better appreciate the issue one might have.
  41319. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41320. * @param ray Defines the ray we are currently tryin to visualize
  41321. */
  41322. constructor(ray: Ray);
  41323. /**
  41324. * Shows the ray we are willing to debug.
  41325. * @param scene Defines the scene the ray needs to be rendered in
  41326. * @param color Defines the color the ray needs to be rendered in
  41327. */
  41328. show(scene: Scene, color?: Color3): void;
  41329. /**
  41330. * Hides the ray we are debugging.
  41331. */
  41332. hide(): void;
  41333. private _render;
  41334. /**
  41335. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  41336. * @param mesh Defines the mesh we want the helper attached to
  41337. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  41338. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  41339. * @param length Defines the length of the ray
  41340. */
  41341. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  41342. /**
  41343. * Detach the ray helper from the mesh it has previously been attached to.
  41344. */
  41345. detachFromMesh(): void;
  41346. private _updateToMesh;
  41347. /**
  41348. * Dispose the helper and release its associated resources.
  41349. */
  41350. dispose(): void;
  41351. }
  41352. }
  41353. declare module BABYLON.Debug {
  41354. /**
  41355. * Class used to render a debug view of a given skeleton
  41356. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  41357. */
  41358. export class SkeletonViewer {
  41359. /** defines the skeleton to render */
  41360. skeleton: Skeleton;
  41361. /** defines the mesh attached to the skeleton */
  41362. mesh: AbstractMesh;
  41363. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41364. autoUpdateBonesMatrices: boolean;
  41365. /** defines the rendering group id to use with the viewer */
  41366. renderingGroupId: number;
  41367. /** Gets or sets the color used to render the skeleton */
  41368. color: Color3;
  41369. private _scene;
  41370. private _debugLines;
  41371. private _debugMesh;
  41372. private _isEnabled;
  41373. private _renderFunction;
  41374. private _utilityLayer;
  41375. /**
  41376. * Returns the mesh used to render the bones
  41377. */
  41378. readonly debugMesh: Nullable<LinesMesh>;
  41379. /**
  41380. * Creates a new SkeletonViewer
  41381. * @param skeleton defines the skeleton to render
  41382. * @param mesh defines the mesh attached to the skeleton
  41383. * @param scene defines the hosting scene
  41384. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  41385. * @param renderingGroupId defines the rendering group id to use with the viewer
  41386. */
  41387. constructor(
  41388. /** defines the skeleton to render */
  41389. skeleton: Skeleton,
  41390. /** defines the mesh attached to the skeleton */
  41391. mesh: AbstractMesh, scene: Scene,
  41392. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41393. autoUpdateBonesMatrices?: boolean,
  41394. /** defines the rendering group id to use with the viewer */
  41395. renderingGroupId?: number);
  41396. /** Gets or sets a boolean indicating if the viewer is enabled */
  41397. isEnabled: boolean;
  41398. private _getBonePosition;
  41399. private _getLinesForBonesWithLength;
  41400. private _getLinesForBonesNoLength;
  41401. /** Update the viewer to sync with current skeleton state */
  41402. update(): void;
  41403. /** Release associated resources */
  41404. dispose(): void;
  41405. }
  41406. }
  41407. declare module BABYLON {
  41408. /**
  41409. * Options to create the null engine
  41410. */
  41411. export class NullEngineOptions {
  41412. /**
  41413. * Render width (Default: 512)
  41414. */
  41415. renderWidth: number;
  41416. /**
  41417. * Render height (Default: 256)
  41418. */
  41419. renderHeight: number;
  41420. /**
  41421. * Texture size (Default: 512)
  41422. */
  41423. textureSize: number;
  41424. /**
  41425. * If delta time between frames should be constant
  41426. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41427. */
  41428. deterministicLockstep: boolean;
  41429. /**
  41430. * Maximum about of steps between frames (Default: 4)
  41431. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41432. */
  41433. lockstepMaxSteps: number;
  41434. }
  41435. /**
  41436. * The null engine class provides support for headless version of babylon.js.
  41437. * This can be used in server side scenario or for testing purposes
  41438. */
  41439. export class NullEngine extends Engine {
  41440. private _options;
  41441. /**
  41442. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41443. */
  41444. isDeterministicLockStep(): boolean;
  41445. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  41446. getLockstepMaxSteps(): number;
  41447. /**
  41448. * Sets hardware scaling, used to save performance if needed
  41449. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  41450. */
  41451. getHardwareScalingLevel(): number;
  41452. constructor(options?: NullEngineOptions);
  41453. createVertexBuffer(vertices: FloatArray): DataBuffer;
  41454. createIndexBuffer(indices: IndicesArray): DataBuffer;
  41455. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  41456. getRenderWidth(useScreen?: boolean): number;
  41457. getRenderHeight(useScreen?: boolean): number;
  41458. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  41459. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  41460. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  41461. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  41462. bindSamplers(effect: Effect): void;
  41463. enableEffect(effect: Effect): void;
  41464. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  41465. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  41466. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  41467. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  41468. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  41469. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  41470. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  41471. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  41472. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  41473. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  41474. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  41475. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  41476. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  41477. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  41478. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  41479. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41480. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41481. setFloat(uniform: WebGLUniformLocation, value: number): void;
  41482. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  41483. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  41484. setBool(uniform: WebGLUniformLocation, bool: number): void;
  41485. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  41486. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  41487. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  41488. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  41489. bindBuffers(vertexBuffers: {
  41490. [key: string]: VertexBuffer;
  41491. }, indexBuffer: DataBuffer, effect: Effect): void;
  41492. wipeCaches(bruteForce?: boolean): void;
  41493. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  41494. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  41495. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41496. /** @hidden */
  41497. _createTexture(): WebGLTexture;
  41498. /** @hidden */
  41499. _releaseTexture(texture: InternalTexture): void;
  41500. 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;
  41501. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  41502. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  41503. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  41504. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  41505. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  41506. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  41507. areAllEffectsReady(): boolean;
  41508. /**
  41509. * @hidden
  41510. * Get the current error code of the webGL context
  41511. * @returns the error code
  41512. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  41513. */
  41514. getError(): number;
  41515. /** @hidden */
  41516. _getUnpackAlignement(): number;
  41517. /** @hidden */
  41518. _unpackFlipY(value: boolean): void;
  41519. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  41520. /**
  41521. * Updates a dynamic vertex buffer.
  41522. * @param vertexBuffer the vertex buffer to update
  41523. * @param data the data used to update the vertex buffer
  41524. * @param byteOffset the byte offset of the data (optional)
  41525. * @param byteLength the byte length of the data (optional)
  41526. */
  41527. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  41528. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  41529. /** @hidden */
  41530. _bindTexture(channel: number, texture: InternalTexture): void;
  41531. /** @hidden */
  41532. _releaseBuffer(buffer: DataBuffer): boolean;
  41533. releaseEffects(): void;
  41534. displayLoadingUI(): void;
  41535. hideLoadingUI(): void;
  41536. /** @hidden */
  41537. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41538. /** @hidden */
  41539. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41540. /** @hidden */
  41541. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41542. /** @hidden */
  41543. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  41544. }
  41545. }
  41546. declare module BABYLON {
  41547. /** @hidden */
  41548. export class _OcclusionDataStorage {
  41549. /** @hidden */
  41550. occlusionInternalRetryCounter: number;
  41551. /** @hidden */
  41552. isOcclusionQueryInProgress: boolean;
  41553. /** @hidden */
  41554. isOccluded: boolean;
  41555. /** @hidden */
  41556. occlusionRetryCount: number;
  41557. /** @hidden */
  41558. occlusionType: number;
  41559. /** @hidden */
  41560. occlusionQueryAlgorithmType: number;
  41561. }
  41562. interface Engine {
  41563. /**
  41564. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  41565. * @return the new query
  41566. */
  41567. createQuery(): WebGLQuery;
  41568. /**
  41569. * Delete and release a webGL query
  41570. * @param query defines the query to delete
  41571. * @return the current engine
  41572. */
  41573. deleteQuery(query: WebGLQuery): Engine;
  41574. /**
  41575. * Check if a given query has resolved and got its value
  41576. * @param query defines the query to check
  41577. * @returns true if the query got its value
  41578. */
  41579. isQueryResultAvailable(query: WebGLQuery): boolean;
  41580. /**
  41581. * Gets the value of a given query
  41582. * @param query defines the query to check
  41583. * @returns the value of the query
  41584. */
  41585. getQueryResult(query: WebGLQuery): number;
  41586. /**
  41587. * Initiates an occlusion query
  41588. * @param algorithmType defines the algorithm to use
  41589. * @param query defines the query to use
  41590. * @returns the current engine
  41591. * @see http://doc.babylonjs.com/features/occlusionquery
  41592. */
  41593. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  41594. /**
  41595. * Ends an occlusion query
  41596. * @see http://doc.babylonjs.com/features/occlusionquery
  41597. * @param algorithmType defines the algorithm to use
  41598. * @returns the current engine
  41599. */
  41600. endOcclusionQuery(algorithmType: number): Engine;
  41601. /**
  41602. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  41603. * Please note that only one query can be issued at a time
  41604. * @returns a time token used to track the time span
  41605. */
  41606. startTimeQuery(): Nullable<_TimeToken>;
  41607. /**
  41608. * Ends a time query
  41609. * @param token defines the token used to measure the time span
  41610. * @returns the time spent (in ns)
  41611. */
  41612. endTimeQuery(token: _TimeToken): int;
  41613. /** @hidden */
  41614. _currentNonTimestampToken: Nullable<_TimeToken>;
  41615. /** @hidden */
  41616. _createTimeQuery(): WebGLQuery;
  41617. /** @hidden */
  41618. _deleteTimeQuery(query: WebGLQuery): void;
  41619. /** @hidden */
  41620. _getGlAlgorithmType(algorithmType: number): number;
  41621. /** @hidden */
  41622. _getTimeQueryResult(query: WebGLQuery): any;
  41623. /** @hidden */
  41624. _getTimeQueryAvailability(query: WebGLQuery): any;
  41625. }
  41626. interface AbstractMesh {
  41627. /**
  41628. * Backing filed
  41629. * @hidden
  41630. */
  41631. __occlusionDataStorage: _OcclusionDataStorage;
  41632. /**
  41633. * Access property
  41634. * @hidden
  41635. */
  41636. _occlusionDataStorage: _OcclusionDataStorage;
  41637. /**
  41638. * 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.
  41639. * The default value is -1 which means don't break the query and wait till the result
  41640. * @see http://doc.babylonjs.com/features/occlusionquery
  41641. */
  41642. occlusionRetryCount: number;
  41643. /**
  41644. * 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:
  41645. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  41646. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  41647. * * 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.
  41648. * @see http://doc.babylonjs.com/features/occlusionquery
  41649. */
  41650. occlusionType: number;
  41651. /**
  41652. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  41653. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  41654. * * 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.
  41655. * @see http://doc.babylonjs.com/features/occlusionquery
  41656. */
  41657. occlusionQueryAlgorithmType: number;
  41658. /**
  41659. * 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
  41660. * @see http://doc.babylonjs.com/features/occlusionquery
  41661. */
  41662. isOccluded: boolean;
  41663. /**
  41664. * Flag to check the progress status of the query
  41665. * @see http://doc.babylonjs.com/features/occlusionquery
  41666. */
  41667. isOcclusionQueryInProgress: boolean;
  41668. }
  41669. }
  41670. declare module BABYLON {
  41671. /** @hidden */
  41672. export var _forceTransformFeedbackToBundle: boolean;
  41673. interface Engine {
  41674. /**
  41675. * Creates a webGL transform feedback object
  41676. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  41677. * @returns the webGL transform feedback object
  41678. */
  41679. createTransformFeedback(): WebGLTransformFeedback;
  41680. /**
  41681. * Delete a webGL transform feedback object
  41682. * @param value defines the webGL transform feedback object to delete
  41683. */
  41684. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  41685. /**
  41686. * Bind a webGL transform feedback object to the webgl context
  41687. * @param value defines the webGL transform feedback object to bind
  41688. */
  41689. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  41690. /**
  41691. * Begins a transform feedback operation
  41692. * @param usePoints defines if points or triangles must be used
  41693. */
  41694. beginTransformFeedback(usePoints: boolean): void;
  41695. /**
  41696. * Ends a transform feedback operation
  41697. */
  41698. endTransformFeedback(): void;
  41699. /**
  41700. * Specify the varyings to use with transform feedback
  41701. * @param program defines the associated webGL program
  41702. * @param value defines the list of strings representing the varying names
  41703. */
  41704. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  41705. /**
  41706. * Bind a webGL buffer for a transform feedback operation
  41707. * @param value defines the webGL buffer to bind
  41708. */
  41709. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  41710. }
  41711. }
  41712. declare module BABYLON {
  41713. /**
  41714. * Creation options of the multi render target texture.
  41715. */
  41716. export interface IMultiRenderTargetOptions {
  41717. /**
  41718. * Define if the texture needs to create mip maps after render.
  41719. */
  41720. generateMipMaps?: boolean;
  41721. /**
  41722. * Define the types of all the draw buffers we want to create
  41723. */
  41724. types?: number[];
  41725. /**
  41726. * Define the sampling modes of all the draw buffers we want to create
  41727. */
  41728. samplingModes?: number[];
  41729. /**
  41730. * Define if a depth buffer is required
  41731. */
  41732. generateDepthBuffer?: boolean;
  41733. /**
  41734. * Define if a stencil buffer is required
  41735. */
  41736. generateStencilBuffer?: boolean;
  41737. /**
  41738. * Define if a depth texture is required instead of a depth buffer
  41739. */
  41740. generateDepthTexture?: boolean;
  41741. /**
  41742. * Define the number of desired draw buffers
  41743. */
  41744. textureCount?: number;
  41745. /**
  41746. * Define if aspect ratio should be adapted to the texture or stay the scene one
  41747. */
  41748. doNotChangeAspectRatio?: boolean;
  41749. /**
  41750. * Define the default type of the buffers we are creating
  41751. */
  41752. defaultType?: number;
  41753. }
  41754. /**
  41755. * A multi render target, like a render target provides the ability to render to a texture.
  41756. * Unlike the render target, it can render to several draw buffers in one draw.
  41757. * This is specially interesting in deferred rendering or for any effects requiring more than
  41758. * just one color from a single pass.
  41759. */
  41760. export class MultiRenderTarget extends RenderTargetTexture {
  41761. private _internalTextures;
  41762. private _textures;
  41763. private _multiRenderTargetOptions;
  41764. /**
  41765. * Get if draw buffers are currently supported by the used hardware and browser.
  41766. */
  41767. readonly isSupported: boolean;
  41768. /**
  41769. * Get the list of textures generated by the multi render target.
  41770. */
  41771. readonly textures: Texture[];
  41772. /**
  41773. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  41774. */
  41775. readonly depthTexture: Texture;
  41776. /**
  41777. * Set the wrapping mode on U of all the textures we are rendering to.
  41778. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  41779. */
  41780. wrapU: number;
  41781. /**
  41782. * Set the wrapping mode on V of all the textures we are rendering to.
  41783. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  41784. */
  41785. wrapV: number;
  41786. /**
  41787. * Instantiate a new multi render target texture.
  41788. * A multi render target, like a render target provides the ability to render to a texture.
  41789. * Unlike the render target, it can render to several draw buffers in one draw.
  41790. * This is specially interesting in deferred rendering or for any effects requiring more than
  41791. * just one color from a single pass.
  41792. * @param name Define the name of the texture
  41793. * @param size Define the size of the buffers to render to
  41794. * @param count Define the number of target we are rendering into
  41795. * @param scene Define the scene the texture belongs to
  41796. * @param options Define the options used to create the multi render target
  41797. */
  41798. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  41799. /** @hidden */
  41800. _rebuild(): void;
  41801. private _createInternalTextures;
  41802. private _createTextures;
  41803. /**
  41804. * Define the number of samples used if MSAA is enabled.
  41805. */
  41806. samples: number;
  41807. /**
  41808. * Resize all the textures in the multi render target.
  41809. * Be carrefull as it will recreate all the data in the new texture.
  41810. * @param size Define the new size
  41811. */
  41812. resize(size: any): void;
  41813. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  41814. /**
  41815. * Dispose the render targets and their associated resources
  41816. */
  41817. dispose(): void;
  41818. /**
  41819. * Release all the underlying texture used as draw buffers.
  41820. */
  41821. releaseInternalTextures(): void;
  41822. }
  41823. }
  41824. declare module BABYLON {
  41825. interface Engine {
  41826. /**
  41827. * Unbind a list of render target textures from the webGL context
  41828. * This is used only when drawBuffer extension or webGL2 are active
  41829. * @param textures defines the render target textures to unbind
  41830. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  41831. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  41832. */
  41833. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  41834. /**
  41835. * Create a multi render target texture
  41836. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  41837. * @param size defines the size of the texture
  41838. * @param options defines the creation options
  41839. * @returns the cube texture as an InternalTexture
  41840. */
  41841. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  41842. /**
  41843. * Update the sample count for a given multiple render target texture
  41844. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  41845. * @param textures defines the textures to update
  41846. * @param samples defines the sample count to set
  41847. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  41848. */
  41849. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  41850. }
  41851. }
  41852. declare module BABYLON {
  41853. /**
  41854. * Gather the list of clipboard event types as constants.
  41855. */
  41856. export class ClipboardEventTypes {
  41857. /**
  41858. * The clipboard event is fired when a copy command is active (pressed).
  41859. */
  41860. static readonly COPY: number;
  41861. /**
  41862. * The clipboard event is fired when a cut command is active (pressed).
  41863. */
  41864. static readonly CUT: number;
  41865. /**
  41866. * The clipboard event is fired when a paste command is active (pressed).
  41867. */
  41868. static readonly PASTE: number;
  41869. }
  41870. /**
  41871. * This class is used to store clipboard related info for the onClipboardObservable event.
  41872. */
  41873. export class ClipboardInfo {
  41874. /**
  41875. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41876. */
  41877. type: number;
  41878. /**
  41879. * Defines the related dom event
  41880. */
  41881. event: ClipboardEvent;
  41882. /**
  41883. *Creates an instance of ClipboardInfo.
  41884. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  41885. * @param event Defines the related dom event
  41886. */
  41887. constructor(
  41888. /**
  41889. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41890. */
  41891. type: number,
  41892. /**
  41893. * Defines the related dom event
  41894. */
  41895. event: ClipboardEvent);
  41896. /**
  41897. * Get the clipboard event's type from the keycode.
  41898. * @param keyCode Defines the keyCode for the current keyboard event.
  41899. * @return {number}
  41900. */
  41901. static GetTypeFromCharacter(keyCode: number): number;
  41902. }
  41903. }
  41904. declare module BABYLON {
  41905. /**
  41906. * Class used to represent data loading progression
  41907. */
  41908. export class SceneLoaderProgressEvent {
  41909. /** defines if data length to load can be evaluated */
  41910. readonly lengthComputable: boolean;
  41911. /** defines the loaded data length */
  41912. readonly loaded: number;
  41913. /** defines the data length to load */
  41914. readonly total: number;
  41915. /**
  41916. * Create a new progress event
  41917. * @param lengthComputable defines if data length to load can be evaluated
  41918. * @param loaded defines the loaded data length
  41919. * @param total defines the data length to load
  41920. */
  41921. constructor(
  41922. /** defines if data length to load can be evaluated */
  41923. lengthComputable: boolean,
  41924. /** defines the loaded data length */
  41925. loaded: number,
  41926. /** defines the data length to load */
  41927. total: number);
  41928. /**
  41929. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41930. * @param event defines the source event
  41931. * @returns a new SceneLoaderProgressEvent
  41932. */
  41933. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41934. }
  41935. /**
  41936. * Interface used by SceneLoader plugins to define supported file extensions
  41937. */
  41938. export interface ISceneLoaderPluginExtensions {
  41939. /**
  41940. * Defines the list of supported extensions
  41941. */
  41942. [extension: string]: {
  41943. isBinary: boolean;
  41944. };
  41945. }
  41946. /**
  41947. * Interface used by SceneLoader plugin factory
  41948. */
  41949. export interface ISceneLoaderPluginFactory {
  41950. /**
  41951. * Defines the name of the factory
  41952. */
  41953. name: string;
  41954. /**
  41955. * Function called to create a new plugin
  41956. * @return the new plugin
  41957. */
  41958. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41959. /**
  41960. * Boolean indicating if the plugin can direct load specific data
  41961. */
  41962. canDirectLoad?: (data: string) => boolean;
  41963. }
  41964. /**
  41965. * Interface used to define a SceneLoader plugin
  41966. */
  41967. export interface ISceneLoaderPlugin {
  41968. /**
  41969. * The friendly name of this plugin.
  41970. */
  41971. name: string;
  41972. /**
  41973. * The file extensions supported by this plugin.
  41974. */
  41975. extensions: string | ISceneLoaderPluginExtensions;
  41976. /**
  41977. * Import meshes into a scene.
  41978. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41979. * @param scene The scene to import into
  41980. * @param data The data to import
  41981. * @param rootUrl The root url for scene and resources
  41982. * @param meshes The meshes array to import into
  41983. * @param particleSystems The particle systems array to import into
  41984. * @param skeletons The skeletons array to import into
  41985. * @param onError The callback when import fails
  41986. * @returns True if successful or false otherwise
  41987. */
  41988. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41989. /**
  41990. * Load into a scene.
  41991. * @param scene The scene to load into
  41992. * @param data The data to import
  41993. * @param rootUrl The root url for scene and resources
  41994. * @param onError The callback when import fails
  41995. * @returns true if successful or false otherwise
  41996. */
  41997. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41998. /**
  41999. * The callback that returns true if the data can be directly loaded.
  42000. */
  42001. canDirectLoad?: (data: string) => boolean;
  42002. /**
  42003. * The callback that allows custom handling of the root url based on the response url.
  42004. */
  42005. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42006. /**
  42007. * Load into an asset container.
  42008. * @param scene The scene to load into
  42009. * @param data The data to import
  42010. * @param rootUrl The root url for scene and resources
  42011. * @param onError The callback when import fails
  42012. * @returns The loaded asset container
  42013. */
  42014. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  42015. }
  42016. /**
  42017. * Interface used to define an async SceneLoader plugin
  42018. */
  42019. export interface ISceneLoaderPluginAsync {
  42020. /**
  42021. * The friendly name of this plugin.
  42022. */
  42023. name: string;
  42024. /**
  42025. * The file extensions supported by this plugin.
  42026. */
  42027. extensions: string | ISceneLoaderPluginExtensions;
  42028. /**
  42029. * Import meshes into a scene.
  42030. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42031. * @param scene The scene to import into
  42032. * @param data The data to import
  42033. * @param rootUrl The root url for scene and resources
  42034. * @param onProgress The callback when the load progresses
  42035. * @param fileName Defines the name of the file to load
  42036. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42037. */
  42038. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42039. meshes: AbstractMesh[];
  42040. particleSystems: IParticleSystem[];
  42041. skeletons: Skeleton[];
  42042. animationGroups: AnimationGroup[];
  42043. }>;
  42044. /**
  42045. * Load into a scene.
  42046. * @param scene The scene to load into
  42047. * @param data The data to import
  42048. * @param rootUrl The root url for scene and resources
  42049. * @param onProgress The callback when the load progresses
  42050. * @param fileName Defines the name of the file to load
  42051. * @returns Nothing
  42052. */
  42053. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42054. /**
  42055. * The callback that returns true if the data can be directly loaded.
  42056. */
  42057. canDirectLoad?: (data: string) => boolean;
  42058. /**
  42059. * The callback that allows custom handling of the root url based on the response url.
  42060. */
  42061. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42062. /**
  42063. * Load into an asset container.
  42064. * @param scene The scene to load into
  42065. * @param data The data to import
  42066. * @param rootUrl The root url for scene and resources
  42067. * @param onProgress The callback when the load progresses
  42068. * @param fileName Defines the name of the file to load
  42069. * @returns The loaded asset container
  42070. */
  42071. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42072. }
  42073. /**
  42074. * Class used to load scene from various file formats using registered plugins
  42075. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42076. */
  42077. export class SceneLoader {
  42078. /**
  42079. * No logging while loading
  42080. */
  42081. static readonly NO_LOGGING: number;
  42082. /**
  42083. * Minimal logging while loading
  42084. */
  42085. static readonly MINIMAL_LOGGING: number;
  42086. /**
  42087. * Summary logging while loading
  42088. */
  42089. static readonly SUMMARY_LOGGING: number;
  42090. /**
  42091. * Detailled logging while loading
  42092. */
  42093. static readonly DETAILED_LOGGING: number;
  42094. /**
  42095. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42096. */
  42097. static ForceFullSceneLoadingForIncremental: boolean;
  42098. /**
  42099. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42100. */
  42101. static ShowLoadingScreen: boolean;
  42102. /**
  42103. * Defines the current logging level (while loading the scene)
  42104. * @ignorenaming
  42105. */
  42106. static loggingLevel: number;
  42107. /**
  42108. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42109. */
  42110. static CleanBoneMatrixWeights: boolean;
  42111. /**
  42112. * Event raised when a plugin is used to load a scene
  42113. */
  42114. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42115. private static _registeredPlugins;
  42116. private static _getDefaultPlugin;
  42117. private static _getPluginForExtension;
  42118. private static _getPluginForDirectLoad;
  42119. private static _getPluginForFilename;
  42120. private static _getDirectLoad;
  42121. private static _loadData;
  42122. private static _getFileInfo;
  42123. /**
  42124. * Gets a plugin that can load the given extension
  42125. * @param extension defines the extension to load
  42126. * @returns a plugin or null if none works
  42127. */
  42128. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42129. /**
  42130. * Gets a boolean indicating that the given extension can be loaded
  42131. * @param extension defines the extension to load
  42132. * @returns true if the extension is supported
  42133. */
  42134. static IsPluginForExtensionAvailable(extension: string): boolean;
  42135. /**
  42136. * Adds a new plugin to the list of registered plugins
  42137. * @param plugin defines the plugin to add
  42138. */
  42139. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42140. /**
  42141. * Import meshes into a scene
  42142. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42143. * @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)
  42144. * @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)
  42145. * @param scene the instance of BABYLON.Scene to append to
  42146. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42147. * @param onProgress a callback with a progress event for each file being loaded
  42148. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42149. * @param pluginExtension the extension used to determine the plugin
  42150. * @returns The loaded plugin
  42151. */
  42152. 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>;
  42153. /**
  42154. * Import meshes into a scene
  42155. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42156. * @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)
  42157. * @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)
  42158. * @param scene the instance of BABYLON.Scene to append to
  42159. * @param onProgress a callback with a progress event for each file being loaded
  42160. * @param pluginExtension the extension used to determine the plugin
  42161. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42162. */
  42163. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42164. meshes: AbstractMesh[];
  42165. particleSystems: IParticleSystem[];
  42166. skeletons: Skeleton[];
  42167. animationGroups: AnimationGroup[];
  42168. }>;
  42169. /**
  42170. * Load a scene
  42171. * @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)
  42172. * @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)
  42173. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42174. * @param onSuccess a callback with the scene when import succeeds
  42175. * @param onProgress a callback with a progress event for each file being loaded
  42176. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42177. * @param pluginExtension the extension used to determine the plugin
  42178. * @returns The loaded plugin
  42179. */
  42180. 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>;
  42181. /**
  42182. * Load a scene
  42183. * @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)
  42184. * @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)
  42185. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42186. * @param onProgress a callback with a progress event for each file being loaded
  42187. * @param pluginExtension the extension used to determine the plugin
  42188. * @returns The loaded scene
  42189. */
  42190. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42191. /**
  42192. * Append a scene
  42193. * @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)
  42194. * @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)
  42195. * @param scene is the instance of BABYLON.Scene to append to
  42196. * @param onSuccess a callback with the scene when import succeeds
  42197. * @param onProgress a callback with a progress event for each file being loaded
  42198. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42199. * @param pluginExtension the extension used to determine the plugin
  42200. * @returns The loaded plugin
  42201. */
  42202. 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>;
  42203. /**
  42204. * Append a scene
  42205. * @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)
  42206. * @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)
  42207. * @param scene is the instance of BABYLON.Scene to append to
  42208. * @param onProgress a callback with a progress event for each file being loaded
  42209. * @param pluginExtension the extension used to determine the plugin
  42210. * @returns The given scene
  42211. */
  42212. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42213. /**
  42214. * Load a scene into an asset container
  42215. * @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)
  42216. * @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)
  42217. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42218. * @param onSuccess a callback with the scene when import succeeds
  42219. * @param onProgress a callback with a progress event for each file being loaded
  42220. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42221. * @param pluginExtension the extension used to determine the plugin
  42222. * @returns The loaded plugin
  42223. */
  42224. 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>;
  42225. /**
  42226. * Load a scene into an asset container
  42227. * @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)
  42228. * @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)
  42229. * @param scene is the instance of Scene to append to
  42230. * @param onProgress a callback with a progress event for each file being loaded
  42231. * @param pluginExtension the extension used to determine the plugin
  42232. * @returns The loaded asset container
  42233. */
  42234. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42235. }
  42236. }
  42237. declare module BABYLON {
  42238. /**
  42239. * Google Daydream controller
  42240. */
  42241. export class DaydreamController extends WebVRController {
  42242. /**
  42243. * Base Url for the controller model.
  42244. */
  42245. static MODEL_BASE_URL: string;
  42246. /**
  42247. * File name for the controller model.
  42248. */
  42249. static MODEL_FILENAME: string;
  42250. /**
  42251. * Gamepad Id prefix used to identify Daydream Controller.
  42252. */
  42253. static readonly GAMEPAD_ID_PREFIX: string;
  42254. /**
  42255. * Creates a new DaydreamController from a gamepad
  42256. * @param vrGamepad the gamepad that the controller should be created from
  42257. */
  42258. constructor(vrGamepad: any);
  42259. /**
  42260. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42261. * @param scene scene in which to add meshes
  42262. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42263. */
  42264. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42265. /**
  42266. * Called once for each button that changed state since the last frame
  42267. * @param buttonIdx Which button index changed
  42268. * @param state New state of the button
  42269. * @param changes Which properties on the state changed since last frame
  42270. */
  42271. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42272. }
  42273. }
  42274. declare module BABYLON {
  42275. /**
  42276. * Gear VR Controller
  42277. */
  42278. export class GearVRController extends WebVRController {
  42279. /**
  42280. * Base Url for the controller model.
  42281. */
  42282. static MODEL_BASE_URL: string;
  42283. /**
  42284. * File name for the controller model.
  42285. */
  42286. static MODEL_FILENAME: string;
  42287. /**
  42288. * Gamepad Id prefix used to identify this controller.
  42289. */
  42290. static readonly GAMEPAD_ID_PREFIX: string;
  42291. private readonly _buttonIndexToObservableNameMap;
  42292. /**
  42293. * Creates a new GearVRController from a gamepad
  42294. * @param vrGamepad the gamepad that the controller should be created from
  42295. */
  42296. constructor(vrGamepad: any);
  42297. /**
  42298. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42299. * @param scene scene in which to add meshes
  42300. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42301. */
  42302. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42303. /**
  42304. * Called once for each button that changed state since the last frame
  42305. * @param buttonIdx Which button index changed
  42306. * @param state New state of the button
  42307. * @param changes Which properties on the state changed since last frame
  42308. */
  42309. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42310. }
  42311. }
  42312. declare module BABYLON {
  42313. /**
  42314. * Generic Controller
  42315. */
  42316. export class GenericController extends WebVRController {
  42317. /**
  42318. * Base Url for the controller model.
  42319. */
  42320. static readonly MODEL_BASE_URL: string;
  42321. /**
  42322. * File name for the controller model.
  42323. */
  42324. static readonly MODEL_FILENAME: string;
  42325. /**
  42326. * Creates a new GenericController from a gamepad
  42327. * @param vrGamepad the gamepad that the controller should be created from
  42328. */
  42329. constructor(vrGamepad: any);
  42330. /**
  42331. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42332. * @param scene scene in which to add meshes
  42333. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42334. */
  42335. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42336. /**
  42337. * Called once for each button that changed state since the last frame
  42338. * @param buttonIdx Which button index changed
  42339. * @param state New state of the button
  42340. * @param changes Which properties on the state changed since last frame
  42341. */
  42342. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42343. }
  42344. }
  42345. declare module BABYLON {
  42346. /**
  42347. * Oculus Touch Controller
  42348. */
  42349. export class OculusTouchController extends WebVRController {
  42350. /**
  42351. * Base Url for the controller model.
  42352. */
  42353. static MODEL_BASE_URL: string;
  42354. /**
  42355. * File name for the left controller model.
  42356. */
  42357. static MODEL_LEFT_FILENAME: string;
  42358. /**
  42359. * File name for the right controller model.
  42360. */
  42361. static MODEL_RIGHT_FILENAME: string;
  42362. /**
  42363. * Fired when the secondary trigger on this controller is modified
  42364. */
  42365. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42366. /**
  42367. * Fired when the thumb rest on this controller is modified
  42368. */
  42369. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42370. /**
  42371. * Creates a new OculusTouchController from a gamepad
  42372. * @param vrGamepad the gamepad that the controller should be created from
  42373. */
  42374. constructor(vrGamepad: any);
  42375. /**
  42376. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42377. * @param scene scene in which to add meshes
  42378. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42379. */
  42380. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42381. /**
  42382. * Fired when the A button on this controller is modified
  42383. */
  42384. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42385. /**
  42386. * Fired when the B button on this controller is modified
  42387. */
  42388. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42389. /**
  42390. * Fired when the X button on this controller is modified
  42391. */
  42392. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42393. /**
  42394. * Fired when the Y button on this controller is modified
  42395. */
  42396. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42397. /**
  42398. * Called once for each button that changed state since the last frame
  42399. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42400. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42401. * 2) secondary trigger (same)
  42402. * 3) A (right) X (left), touch, pressed = value
  42403. * 4) B / Y
  42404. * 5) thumb rest
  42405. * @param buttonIdx Which button index changed
  42406. * @param state New state of the button
  42407. * @param changes Which properties on the state changed since last frame
  42408. */
  42409. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42410. }
  42411. }
  42412. declare module BABYLON {
  42413. /**
  42414. * Vive Controller
  42415. */
  42416. export class ViveController extends WebVRController {
  42417. /**
  42418. * Base Url for the controller model.
  42419. */
  42420. static MODEL_BASE_URL: string;
  42421. /**
  42422. * File name for the controller model.
  42423. */
  42424. static MODEL_FILENAME: string;
  42425. /**
  42426. * Creates a new ViveController from a gamepad
  42427. * @param vrGamepad the gamepad that the controller should be created from
  42428. */
  42429. constructor(vrGamepad: any);
  42430. /**
  42431. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42432. * @param scene scene in which to add meshes
  42433. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42434. */
  42435. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42436. /**
  42437. * Fired when the left button on this controller is modified
  42438. */
  42439. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42440. /**
  42441. * Fired when the right button on this controller is modified
  42442. */
  42443. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42444. /**
  42445. * Fired when the menu button on this controller is modified
  42446. */
  42447. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42448. /**
  42449. * Called once for each button that changed state since the last frame
  42450. * Vive mapping:
  42451. * 0: touchpad
  42452. * 1: trigger
  42453. * 2: left AND right buttons
  42454. * 3: menu button
  42455. * @param buttonIdx Which button index changed
  42456. * @param state New state of the button
  42457. * @param changes Which properties on the state changed since last frame
  42458. */
  42459. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42460. }
  42461. }
  42462. declare module BABYLON {
  42463. /**
  42464. * Defines the WindowsMotionController object that the state of the windows motion controller
  42465. */
  42466. export class WindowsMotionController extends WebVRController {
  42467. /**
  42468. * The base url used to load the left and right controller models
  42469. */
  42470. static MODEL_BASE_URL: string;
  42471. /**
  42472. * The name of the left controller model file
  42473. */
  42474. static MODEL_LEFT_FILENAME: string;
  42475. /**
  42476. * The name of the right controller model file
  42477. */
  42478. static MODEL_RIGHT_FILENAME: string;
  42479. /**
  42480. * The controller name prefix for this controller type
  42481. */
  42482. static readonly GAMEPAD_ID_PREFIX: string;
  42483. /**
  42484. * The controller id pattern for this controller type
  42485. */
  42486. private static readonly GAMEPAD_ID_PATTERN;
  42487. private _loadedMeshInfo;
  42488. private readonly _mapping;
  42489. /**
  42490. * Fired when the trackpad on this controller is clicked
  42491. */
  42492. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42493. /**
  42494. * Fired when the trackpad on this controller is modified
  42495. */
  42496. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42497. /**
  42498. * The current x and y values of this controller's trackpad
  42499. */
  42500. trackpad: StickValues;
  42501. /**
  42502. * Creates a new WindowsMotionController from a gamepad
  42503. * @param vrGamepad the gamepad that the controller should be created from
  42504. */
  42505. constructor(vrGamepad: any);
  42506. /**
  42507. * Fired when the trigger on this controller is modified
  42508. */
  42509. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42510. /**
  42511. * Fired when the menu button on this controller is modified
  42512. */
  42513. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42514. /**
  42515. * Fired when the grip button on this controller is modified
  42516. */
  42517. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42518. /**
  42519. * Fired when the thumbstick button on this controller is modified
  42520. */
  42521. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42522. /**
  42523. * Fired when the touchpad button on this controller is modified
  42524. */
  42525. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42526. /**
  42527. * Fired when the touchpad values on this controller are modified
  42528. */
  42529. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42530. private _updateTrackpad;
  42531. /**
  42532. * Called once per frame by the engine.
  42533. */
  42534. update(): void;
  42535. /**
  42536. * Called once for each button that changed state since the last frame
  42537. * @param buttonIdx Which button index changed
  42538. * @param state New state of the button
  42539. * @param changes Which properties on the state changed since last frame
  42540. */
  42541. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42542. /**
  42543. * Moves the buttons on the controller mesh based on their current state
  42544. * @param buttonName the name of the button to move
  42545. * @param buttonValue the value of the button which determines the buttons new position
  42546. */
  42547. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42548. /**
  42549. * Moves the axis on the controller mesh based on its current state
  42550. * @param axis the index of the axis
  42551. * @param axisValue the value of the axis which determines the meshes new position
  42552. * @hidden
  42553. */
  42554. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42555. /**
  42556. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42557. * @param scene scene in which to add meshes
  42558. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42559. */
  42560. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42561. /**
  42562. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42563. * can be transformed by button presses and axes values, based on this._mapping.
  42564. *
  42565. * @param scene scene in which the meshes exist
  42566. * @param meshes list of meshes that make up the controller model to process
  42567. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42568. */
  42569. private processModel;
  42570. private createMeshInfo;
  42571. /**
  42572. * Gets the ray of the controller in the direction the controller is pointing
  42573. * @param length the length the resulting ray should be
  42574. * @returns a ray in the direction the controller is pointing
  42575. */
  42576. getForwardRay(length?: number): Ray;
  42577. /**
  42578. * Disposes of the controller
  42579. */
  42580. dispose(): void;
  42581. }
  42582. }
  42583. declare module BABYLON {
  42584. /**
  42585. * Single axis scale gizmo
  42586. */
  42587. export class AxisScaleGizmo extends Gizmo {
  42588. private _coloredMaterial;
  42589. /**
  42590. * Drag behavior responsible for the gizmos dragging interactions
  42591. */
  42592. dragBehavior: PointerDragBehavior;
  42593. private _pointerObserver;
  42594. /**
  42595. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42596. */
  42597. snapDistance: number;
  42598. /**
  42599. * Event that fires each time the gizmo snaps to a new location.
  42600. * * snapDistance is the the change in distance
  42601. */
  42602. onSnapObservable: Observable<{
  42603. snapDistance: number;
  42604. }>;
  42605. /**
  42606. * If the scaling operation should be done on all axis (default: false)
  42607. */
  42608. uniformScaling: boolean;
  42609. /**
  42610. * Creates an AxisScaleGizmo
  42611. * @param gizmoLayer The utility layer the gizmo will be added to
  42612. * @param dragAxis The axis which the gizmo will be able to scale on
  42613. * @param color The color of the gizmo
  42614. */
  42615. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42616. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42617. /**
  42618. * Disposes of the gizmo
  42619. */
  42620. dispose(): void;
  42621. /**
  42622. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42623. * @param mesh The mesh to replace the default mesh of the gizmo
  42624. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  42625. */
  42626. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  42627. }
  42628. }
  42629. declare module BABYLON {
  42630. /**
  42631. * Bounding box gizmo
  42632. */
  42633. export class BoundingBoxGizmo extends Gizmo {
  42634. private _lineBoundingBox;
  42635. private _rotateSpheresParent;
  42636. private _scaleBoxesParent;
  42637. private _boundingDimensions;
  42638. private _renderObserver;
  42639. private _pointerObserver;
  42640. private _scaleDragSpeed;
  42641. private _tmpQuaternion;
  42642. private _tmpVector;
  42643. private _tmpRotationMatrix;
  42644. /**
  42645. * 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)
  42646. */
  42647. ignoreChildren: boolean;
  42648. /**
  42649. * 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)
  42650. */
  42651. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  42652. /**
  42653. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  42654. */
  42655. rotationSphereSize: number;
  42656. /**
  42657. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  42658. */
  42659. scaleBoxSize: number;
  42660. /**
  42661. * 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)
  42662. */
  42663. fixedDragMeshScreenSize: boolean;
  42664. /**
  42665. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  42666. */
  42667. fixedDragMeshScreenSizeDistanceFactor: number;
  42668. /**
  42669. * Fired when a rotation sphere or scale box is dragged
  42670. */
  42671. onDragStartObservable: Observable<{}>;
  42672. /**
  42673. * Fired when a scale box is dragged
  42674. */
  42675. onScaleBoxDragObservable: Observable<{}>;
  42676. /**
  42677. * Fired when a scale box drag is ended
  42678. */
  42679. onScaleBoxDragEndObservable: Observable<{}>;
  42680. /**
  42681. * Fired when a rotation sphere is dragged
  42682. */
  42683. onRotationSphereDragObservable: Observable<{}>;
  42684. /**
  42685. * Fired when a rotation sphere drag is ended
  42686. */
  42687. onRotationSphereDragEndObservable: Observable<{}>;
  42688. /**
  42689. * 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)
  42690. */
  42691. scalePivot: Nullable<Vector3>;
  42692. /**
  42693. * Mesh used as a pivot to rotate the attached mesh
  42694. */
  42695. private _anchorMesh;
  42696. private _existingMeshScale;
  42697. private _dragMesh;
  42698. private pointerDragBehavior;
  42699. private coloredMaterial;
  42700. private hoverColoredMaterial;
  42701. /**
  42702. * Sets the color of the bounding box gizmo
  42703. * @param color the color to set
  42704. */
  42705. setColor(color: Color3): void;
  42706. /**
  42707. * Creates an BoundingBoxGizmo
  42708. * @param gizmoLayer The utility layer the gizmo will be added to
  42709. * @param color The color of the gizmo
  42710. */
  42711. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42712. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42713. private _selectNode;
  42714. /**
  42715. * Updates the bounding box information for the Gizmo
  42716. */
  42717. updateBoundingBox(): void;
  42718. private _updateRotationSpheres;
  42719. private _updateScaleBoxes;
  42720. /**
  42721. * Enables rotation on the specified axis and disables rotation on the others
  42722. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  42723. */
  42724. setEnabledRotationAxis(axis: string): void;
  42725. /**
  42726. * Enables/disables scaling
  42727. * @param enable if scaling should be enabled
  42728. */
  42729. setEnabledScaling(enable: boolean): void;
  42730. private _updateDummy;
  42731. /**
  42732. * Enables a pointer drag behavior on the bounding box of the gizmo
  42733. */
  42734. enableDragBehavior(): void;
  42735. /**
  42736. * Disposes of the gizmo
  42737. */
  42738. dispose(): void;
  42739. /**
  42740. * 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)
  42741. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  42742. * @returns the bounding box mesh with the passed in mesh as a child
  42743. */
  42744. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  42745. /**
  42746. * CustomMeshes are not supported by this gizmo
  42747. * @param mesh The mesh to replace the default mesh of the gizmo
  42748. */
  42749. setCustomMesh(mesh: Mesh): void;
  42750. }
  42751. }
  42752. declare module BABYLON {
  42753. /**
  42754. * Single plane rotation gizmo
  42755. */
  42756. export class PlaneRotationGizmo extends Gizmo {
  42757. /**
  42758. * Drag behavior responsible for the gizmos dragging interactions
  42759. */
  42760. dragBehavior: PointerDragBehavior;
  42761. private _pointerObserver;
  42762. /**
  42763. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  42764. */
  42765. snapDistance: number;
  42766. /**
  42767. * Event that fires each time the gizmo snaps to a new location.
  42768. * * snapDistance is the the change in distance
  42769. */
  42770. onSnapObservable: Observable<{
  42771. snapDistance: number;
  42772. }>;
  42773. /**
  42774. * Creates a PlaneRotationGizmo
  42775. * @param gizmoLayer The utility layer the gizmo will be added to
  42776. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  42777. * @param color The color of the gizmo
  42778. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42779. */
  42780. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  42781. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42782. /**
  42783. * Disposes of the gizmo
  42784. */
  42785. dispose(): void;
  42786. }
  42787. }
  42788. declare module BABYLON {
  42789. /**
  42790. * Gizmo that enables rotating a mesh along 3 axis
  42791. */
  42792. export class RotationGizmo extends Gizmo {
  42793. /**
  42794. * Internal gizmo used for interactions on the x axis
  42795. */
  42796. xGizmo: PlaneRotationGizmo;
  42797. /**
  42798. * Internal gizmo used for interactions on the y axis
  42799. */
  42800. yGizmo: PlaneRotationGizmo;
  42801. /**
  42802. * Internal gizmo used for interactions on the z axis
  42803. */
  42804. zGizmo: PlaneRotationGizmo;
  42805. /** Fires an event when any of it's sub gizmos are dragged */
  42806. onDragStartObservable: Observable<{}>;
  42807. /** Fires an event when any of it's sub gizmos are released from dragging */
  42808. onDragEndObservable: Observable<{}>;
  42809. attachedMesh: Nullable<AbstractMesh>;
  42810. /**
  42811. * Creates a RotationGizmo
  42812. * @param gizmoLayer The utility layer the gizmo will be added to
  42813. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42814. */
  42815. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  42816. updateGizmoRotationToMatchAttachedMesh: boolean;
  42817. /**
  42818. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42819. */
  42820. snapDistance: number;
  42821. /**
  42822. * Ratio for the scale of the gizmo (Default: 1)
  42823. */
  42824. scaleRatio: number;
  42825. /**
  42826. * Disposes of the gizmo
  42827. */
  42828. dispose(): void;
  42829. /**
  42830. * CustomMeshes are not supported by this gizmo
  42831. * @param mesh The mesh to replace the default mesh of the gizmo
  42832. */
  42833. setCustomMesh(mesh: Mesh): void;
  42834. }
  42835. }
  42836. declare module BABYLON {
  42837. /**
  42838. * Gizmo that enables dragging a mesh along 3 axis
  42839. */
  42840. export class PositionGizmo extends Gizmo {
  42841. /**
  42842. * Internal gizmo used for interactions on the x axis
  42843. */
  42844. xGizmo: AxisDragGizmo;
  42845. /**
  42846. * Internal gizmo used for interactions on the y axis
  42847. */
  42848. yGizmo: AxisDragGizmo;
  42849. /**
  42850. * Internal gizmo used for interactions on the z axis
  42851. */
  42852. zGizmo: AxisDragGizmo;
  42853. /** Fires an event when any of it's sub gizmos are dragged */
  42854. onDragStartObservable: Observable<{}>;
  42855. /** Fires an event when any of it's sub gizmos are released from dragging */
  42856. onDragEndObservable: Observable<{}>;
  42857. attachedMesh: Nullable<AbstractMesh>;
  42858. /**
  42859. * Creates a PositionGizmo
  42860. * @param gizmoLayer The utility layer the gizmo will be added to
  42861. */
  42862. constructor(gizmoLayer?: UtilityLayerRenderer);
  42863. updateGizmoRotationToMatchAttachedMesh: boolean;
  42864. /**
  42865. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42866. */
  42867. snapDistance: number;
  42868. /**
  42869. * Ratio for the scale of the gizmo (Default: 1)
  42870. */
  42871. scaleRatio: number;
  42872. /**
  42873. * Disposes of the gizmo
  42874. */
  42875. dispose(): void;
  42876. /**
  42877. * CustomMeshes are not supported by this gizmo
  42878. * @param mesh The mesh to replace the default mesh of the gizmo
  42879. */
  42880. setCustomMesh(mesh: Mesh): void;
  42881. }
  42882. }
  42883. declare module BABYLON {
  42884. /**
  42885. * Class containing static functions to help procedurally build meshes
  42886. */
  42887. export class PolyhedronBuilder {
  42888. /**
  42889. * Creates a polyhedron mesh
  42890. * * 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
  42891. * * The parameter `size` (positive float, default 1) sets the polygon size
  42892. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  42893. * * 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`
  42894. * * 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
  42895. * * 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)`)
  42896. * * 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
  42897. * * 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
  42898. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42899. * * 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
  42900. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42901. * @param name defines the name of the mesh
  42902. * @param options defines the options used to create the mesh
  42903. * @param scene defines the hosting scene
  42904. * @returns the polyhedron mesh
  42905. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  42906. */
  42907. static CreatePolyhedron(name: string, options: {
  42908. type?: number;
  42909. size?: number;
  42910. sizeX?: number;
  42911. sizeY?: number;
  42912. sizeZ?: number;
  42913. custom?: any;
  42914. faceUV?: Vector4[];
  42915. faceColors?: Color4[];
  42916. flat?: boolean;
  42917. updatable?: boolean;
  42918. sideOrientation?: number;
  42919. frontUVs?: Vector4;
  42920. backUVs?: Vector4;
  42921. }, scene?: Nullable<Scene>): Mesh;
  42922. }
  42923. }
  42924. declare module BABYLON {
  42925. /**
  42926. * Gizmo that enables scaling a mesh along 3 axis
  42927. */
  42928. export class ScaleGizmo extends Gizmo {
  42929. /**
  42930. * Internal gizmo used for interactions on the x axis
  42931. */
  42932. xGizmo: AxisScaleGizmo;
  42933. /**
  42934. * Internal gizmo used for interactions on the y axis
  42935. */
  42936. yGizmo: AxisScaleGizmo;
  42937. /**
  42938. * Internal gizmo used for interactions on the z axis
  42939. */
  42940. zGizmo: AxisScaleGizmo;
  42941. /**
  42942. * Internal gizmo used to scale all axis equally
  42943. */
  42944. uniformScaleGizmo: AxisScaleGizmo;
  42945. /** Fires an event when any of it's sub gizmos are dragged */
  42946. onDragStartObservable: Observable<{}>;
  42947. /** Fires an event when any of it's sub gizmos are released from dragging */
  42948. onDragEndObservable: Observable<{}>;
  42949. attachedMesh: Nullable<AbstractMesh>;
  42950. /**
  42951. * Creates a ScaleGizmo
  42952. * @param gizmoLayer The utility layer the gizmo will be added to
  42953. */
  42954. constructor(gizmoLayer?: UtilityLayerRenderer);
  42955. updateGizmoRotationToMatchAttachedMesh: boolean;
  42956. /**
  42957. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42958. */
  42959. snapDistance: number;
  42960. /**
  42961. * Ratio for the scale of the gizmo (Default: 1)
  42962. */
  42963. scaleRatio: number;
  42964. /**
  42965. * Disposes of the gizmo
  42966. */
  42967. dispose(): void;
  42968. }
  42969. }
  42970. declare module BABYLON {
  42971. /**
  42972. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  42973. */
  42974. export class GizmoManager implements IDisposable {
  42975. private scene;
  42976. /**
  42977. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  42978. */
  42979. gizmos: {
  42980. positionGizmo: Nullable<PositionGizmo>;
  42981. rotationGizmo: Nullable<RotationGizmo>;
  42982. scaleGizmo: Nullable<ScaleGizmo>;
  42983. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  42984. };
  42985. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  42986. clearGizmoOnEmptyPointerEvent: boolean;
  42987. /** Fires an event when the manager is attached to a mesh */
  42988. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  42989. private _gizmosEnabled;
  42990. private _pointerObserver;
  42991. private _attachedMesh;
  42992. private _boundingBoxColor;
  42993. private _defaultUtilityLayer;
  42994. private _defaultKeepDepthUtilityLayer;
  42995. /**
  42996. * When bounding box gizmo is enabled, this can be used to track drag/end events
  42997. */
  42998. boundingBoxDragBehavior: SixDofDragBehavior;
  42999. /**
  43000. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  43001. */
  43002. attachableMeshes: Nullable<Array<AbstractMesh>>;
  43003. /**
  43004. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  43005. */
  43006. usePointerToAttachGizmos: boolean;
  43007. /**
  43008. * Instatiates a gizmo manager
  43009. * @param scene the scene to overlay the gizmos on top of
  43010. */
  43011. constructor(scene: Scene);
  43012. /**
  43013. * Attaches a set of gizmos to the specified mesh
  43014. * @param mesh The mesh the gizmo's should be attached to
  43015. */
  43016. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  43017. /**
  43018. * If the position gizmo is enabled
  43019. */
  43020. positionGizmoEnabled: boolean;
  43021. /**
  43022. * If the rotation gizmo is enabled
  43023. */
  43024. rotationGizmoEnabled: boolean;
  43025. /**
  43026. * If the scale gizmo is enabled
  43027. */
  43028. scaleGizmoEnabled: boolean;
  43029. /**
  43030. * If the boundingBox gizmo is enabled
  43031. */
  43032. boundingBoxGizmoEnabled: boolean;
  43033. /**
  43034. * Disposes of the gizmo manager
  43035. */
  43036. dispose(): void;
  43037. }
  43038. }
  43039. declare module BABYLON {
  43040. /**
  43041. * A directional light is defined by a direction (what a surprise!).
  43042. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  43043. * 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.
  43044. * Documentation: https://doc.babylonjs.com/babylon101/lights
  43045. */
  43046. export class DirectionalLight extends ShadowLight {
  43047. private _shadowFrustumSize;
  43048. /**
  43049. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  43050. */
  43051. /**
  43052. * Specifies a fix frustum size for the shadow generation.
  43053. */
  43054. shadowFrustumSize: number;
  43055. private _shadowOrthoScale;
  43056. /**
  43057. * Gets the shadow projection scale against the optimal computed one.
  43058. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  43059. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  43060. */
  43061. /**
  43062. * Sets the shadow projection scale against the optimal computed one.
  43063. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  43064. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  43065. */
  43066. shadowOrthoScale: number;
  43067. /**
  43068. * Automatically compute the projection matrix to best fit (including all the casters)
  43069. * on each frame.
  43070. */
  43071. autoUpdateExtends: boolean;
  43072. private _orthoLeft;
  43073. private _orthoRight;
  43074. private _orthoTop;
  43075. private _orthoBottom;
  43076. /**
  43077. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  43078. * The directional light is emitted from everywhere in the given direction.
  43079. * It can cast shadows.
  43080. * Documentation : https://doc.babylonjs.com/babylon101/lights
  43081. * @param name The friendly name of the light
  43082. * @param direction The direction of the light
  43083. * @param scene The scene the light belongs to
  43084. */
  43085. constructor(name: string, direction: Vector3, scene: Scene);
  43086. /**
  43087. * Returns the string "DirectionalLight".
  43088. * @return The class name
  43089. */
  43090. getClassName(): string;
  43091. /**
  43092. * Returns the integer 1.
  43093. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  43094. */
  43095. getTypeID(): number;
  43096. /**
  43097. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  43098. * Returns the DirectionalLight Shadow projection matrix.
  43099. */
  43100. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43101. /**
  43102. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  43103. * Returns the DirectionalLight Shadow projection matrix.
  43104. */
  43105. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  43106. /**
  43107. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  43108. * Returns the DirectionalLight Shadow projection matrix.
  43109. */
  43110. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43111. protected _buildUniformLayout(): void;
  43112. /**
  43113. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  43114. * @param effect The effect to update
  43115. * @param lightIndex The index of the light in the effect to update
  43116. * @returns The directional light
  43117. */
  43118. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  43119. /**
  43120. * Gets the minZ used for shadow according to both the scene and the light.
  43121. *
  43122. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  43123. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  43124. * @param activeCamera The camera we are returning the min for
  43125. * @returns the depth min z
  43126. */
  43127. getDepthMinZ(activeCamera: Camera): number;
  43128. /**
  43129. * Gets the maxZ used for shadow according to both the scene and the light.
  43130. *
  43131. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  43132. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  43133. * @param activeCamera The camera we are returning the max for
  43134. * @returns the depth max z
  43135. */
  43136. getDepthMaxZ(activeCamera: Camera): number;
  43137. /**
  43138. * Prepares the list of defines specific to the light type.
  43139. * @param defines the list of defines
  43140. * @param lightIndex defines the index of the light for the effect
  43141. */
  43142. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  43143. }
  43144. }
  43145. declare module BABYLON {
  43146. /**
  43147. * Class containing static functions to help procedurally build meshes
  43148. */
  43149. export class HemisphereBuilder {
  43150. /**
  43151. * Creates a hemisphere mesh
  43152. * @param name defines the name of the mesh
  43153. * @param options defines the options used to create the mesh
  43154. * @param scene defines the hosting scene
  43155. * @returns the hemisphere mesh
  43156. */
  43157. static CreateHemisphere(name: string, options: {
  43158. segments?: number;
  43159. diameter?: number;
  43160. sideOrientation?: number;
  43161. }, scene: any): Mesh;
  43162. }
  43163. }
  43164. declare module BABYLON {
  43165. /**
  43166. * A spot light is defined by a position, a direction, an angle, and an exponent.
  43167. * These values define a cone of light starting from the position, emitting toward the direction.
  43168. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  43169. * and the exponent defines the speed of the decay of the light with distance (reach).
  43170. * Documentation: https://doc.babylonjs.com/babylon101/lights
  43171. */
  43172. export class SpotLight extends ShadowLight {
  43173. private _angle;
  43174. private _innerAngle;
  43175. private _cosHalfAngle;
  43176. private _lightAngleScale;
  43177. private _lightAngleOffset;
  43178. /**
  43179. * Gets the cone angle of the spot light in Radians.
  43180. */
  43181. /**
  43182. * Sets the cone angle of the spot light in Radians.
  43183. */
  43184. angle: number;
  43185. /**
  43186. * Only used in gltf falloff mode, this defines the angle where
  43187. * the directional falloff will start before cutting at angle which could be seen
  43188. * as outer angle.
  43189. */
  43190. /**
  43191. * Only used in gltf falloff mode, this defines the angle where
  43192. * the directional falloff will start before cutting at angle which could be seen
  43193. * as outer angle.
  43194. */
  43195. innerAngle: number;
  43196. private _shadowAngleScale;
  43197. /**
  43198. * Allows scaling the angle of the light for shadow generation only.
  43199. */
  43200. /**
  43201. * Allows scaling the angle of the light for shadow generation only.
  43202. */
  43203. shadowAngleScale: number;
  43204. /**
  43205. * The light decay speed with the distance from the emission spot.
  43206. */
  43207. exponent: number;
  43208. private _projectionTextureMatrix;
  43209. /**
  43210. * Allows reading the projecton texture
  43211. */
  43212. readonly projectionTextureMatrix: Matrix;
  43213. protected _projectionTextureLightNear: number;
  43214. /**
  43215. * Gets the near clip of the Spotlight for texture projection.
  43216. */
  43217. /**
  43218. * Sets the near clip of the Spotlight for texture projection.
  43219. */
  43220. projectionTextureLightNear: number;
  43221. protected _projectionTextureLightFar: number;
  43222. /**
  43223. * Gets the far clip of the Spotlight for texture projection.
  43224. */
  43225. /**
  43226. * Sets the far clip of the Spotlight for texture projection.
  43227. */
  43228. projectionTextureLightFar: number;
  43229. protected _projectionTextureUpDirection: Vector3;
  43230. /**
  43231. * Gets the Up vector of the Spotlight for texture projection.
  43232. */
  43233. /**
  43234. * Sets the Up vector of the Spotlight for texture projection.
  43235. */
  43236. projectionTextureUpDirection: Vector3;
  43237. private _projectionTexture;
  43238. /**
  43239. * Gets the projection texture of the light.
  43240. */
  43241. /**
  43242. * Sets the projection texture of the light.
  43243. */
  43244. projectionTexture: Nullable<BaseTexture>;
  43245. private _projectionTextureViewLightDirty;
  43246. private _projectionTextureProjectionLightDirty;
  43247. private _projectionTextureDirty;
  43248. private _projectionTextureViewTargetVector;
  43249. private _projectionTextureViewLightMatrix;
  43250. private _projectionTextureProjectionLightMatrix;
  43251. private _projectionTextureScalingMatrix;
  43252. /**
  43253. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  43254. * It can cast shadows.
  43255. * Documentation : https://doc.babylonjs.com/babylon101/lights
  43256. * @param name The light friendly name
  43257. * @param position The position of the spot light in the scene
  43258. * @param direction The direction of the light in the scene
  43259. * @param angle The cone angle of the light in Radians
  43260. * @param exponent The light decay speed with the distance from the emission spot
  43261. * @param scene The scene the lights belongs to
  43262. */
  43263. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  43264. /**
  43265. * Returns the string "SpotLight".
  43266. * @returns the class name
  43267. */
  43268. getClassName(): string;
  43269. /**
  43270. * Returns the integer 2.
  43271. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  43272. */
  43273. getTypeID(): number;
  43274. /**
  43275. * Overrides the direction setter to recompute the projection texture view light Matrix.
  43276. */
  43277. protected _setDirection(value: Vector3): void;
  43278. /**
  43279. * Overrides the position setter to recompute the projection texture view light Matrix.
  43280. */
  43281. protected _setPosition(value: Vector3): void;
  43282. /**
  43283. * 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.
  43284. * Returns the SpotLight.
  43285. */
  43286. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43287. protected _computeProjectionTextureViewLightMatrix(): void;
  43288. protected _computeProjectionTextureProjectionLightMatrix(): void;
  43289. /**
  43290. * Main function for light texture projection matrix computing.
  43291. */
  43292. protected _computeProjectionTextureMatrix(): void;
  43293. protected _buildUniformLayout(): void;
  43294. private _computeAngleValues;
  43295. /**
  43296. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  43297. * @param effect The effect to update
  43298. * @param lightIndex The index of the light in the effect to update
  43299. * @returns The spot light
  43300. */
  43301. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  43302. /**
  43303. * Disposes the light and the associated resources.
  43304. */
  43305. dispose(): void;
  43306. /**
  43307. * Prepares the list of defines specific to the light type.
  43308. * @param defines the list of defines
  43309. * @param lightIndex defines the index of the light for the effect
  43310. */
  43311. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  43312. }
  43313. }
  43314. declare module BABYLON {
  43315. /**
  43316. * Gizmo that enables viewing a light
  43317. */
  43318. export class LightGizmo extends Gizmo {
  43319. private _lightMesh;
  43320. private _material;
  43321. private cachedPosition;
  43322. private cachedForward;
  43323. /**
  43324. * Creates a LightGizmo
  43325. * @param gizmoLayer The utility layer the gizmo will be added to
  43326. */
  43327. constructor(gizmoLayer?: UtilityLayerRenderer);
  43328. private _light;
  43329. /**
  43330. * The light that the gizmo is attached to
  43331. */
  43332. light: Nullable<Light>;
  43333. /**
  43334. * @hidden
  43335. * Updates the gizmo to match the attached mesh's position/rotation
  43336. */
  43337. protected _update(): void;
  43338. private static _Scale;
  43339. /**
  43340. * Creates the lines for a light mesh
  43341. */
  43342. private static _createLightLines;
  43343. /**
  43344. * Disposes of the light gizmo
  43345. */
  43346. dispose(): void;
  43347. private static _CreateHemisphericLightMesh;
  43348. private static _CreatePointLightMesh;
  43349. private static _CreateSpotLightMesh;
  43350. private static _CreateDirectionalLightMesh;
  43351. }
  43352. }
  43353. declare module BABYLON {
  43354. /** @hidden */
  43355. export var backgroundFragmentDeclaration: {
  43356. name: string;
  43357. shader: string;
  43358. };
  43359. }
  43360. declare module BABYLON {
  43361. /** @hidden */
  43362. export var backgroundUboDeclaration: {
  43363. name: string;
  43364. shader: string;
  43365. };
  43366. }
  43367. declare module BABYLON {
  43368. /** @hidden */
  43369. export var backgroundPixelShader: {
  43370. name: string;
  43371. shader: string;
  43372. };
  43373. }
  43374. declare module BABYLON {
  43375. /** @hidden */
  43376. export var backgroundVertexDeclaration: {
  43377. name: string;
  43378. shader: string;
  43379. };
  43380. }
  43381. declare module BABYLON {
  43382. /** @hidden */
  43383. export var backgroundVertexShader: {
  43384. name: string;
  43385. shader: string;
  43386. };
  43387. }
  43388. declare module BABYLON {
  43389. /**
  43390. * Background material used to create an efficient environement around your scene.
  43391. */
  43392. export class BackgroundMaterial extends PushMaterial {
  43393. /**
  43394. * Standard reflectance value at parallel view angle.
  43395. */
  43396. static StandardReflectance0: number;
  43397. /**
  43398. * Standard reflectance value at grazing angle.
  43399. */
  43400. static StandardReflectance90: number;
  43401. protected _primaryColor: Color3;
  43402. /**
  43403. * Key light Color (multiply against the environement texture)
  43404. */
  43405. primaryColor: Color3;
  43406. protected __perceptualColor: Nullable<Color3>;
  43407. /**
  43408. * Experimental Internal Use Only.
  43409. *
  43410. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  43411. * This acts as a helper to set the primary color to a more "human friendly" value.
  43412. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  43413. * output color as close as possible from the chosen value.
  43414. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  43415. * part of lighting setup.)
  43416. */
  43417. _perceptualColor: Nullable<Color3>;
  43418. protected _primaryColorShadowLevel: float;
  43419. /**
  43420. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  43421. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  43422. */
  43423. primaryColorShadowLevel: float;
  43424. protected _primaryColorHighlightLevel: float;
  43425. /**
  43426. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  43427. * The primary color is used at the level chosen to define what the white area would look.
  43428. */
  43429. primaryColorHighlightLevel: float;
  43430. protected _reflectionTexture: Nullable<BaseTexture>;
  43431. /**
  43432. * Reflection Texture used in the material.
  43433. * Should be author in a specific way for the best result (refer to the documentation).
  43434. */
  43435. reflectionTexture: Nullable<BaseTexture>;
  43436. protected _reflectionBlur: float;
  43437. /**
  43438. * Reflection Texture level of blur.
  43439. *
  43440. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  43441. * texture twice.
  43442. */
  43443. reflectionBlur: float;
  43444. protected _diffuseTexture: Nullable<BaseTexture>;
  43445. /**
  43446. * Diffuse Texture used in the material.
  43447. * Should be author in a specific way for the best result (refer to the documentation).
  43448. */
  43449. diffuseTexture: Nullable<BaseTexture>;
  43450. protected _shadowLights: Nullable<IShadowLight[]>;
  43451. /**
  43452. * Specify the list of lights casting shadow on the material.
  43453. * All scene shadow lights will be included if null.
  43454. */
  43455. shadowLights: Nullable<IShadowLight[]>;
  43456. protected _shadowLevel: float;
  43457. /**
  43458. * Helps adjusting the shadow to a softer level if required.
  43459. * 0 means black shadows and 1 means no shadows.
  43460. */
  43461. shadowLevel: float;
  43462. protected _sceneCenter: Vector3;
  43463. /**
  43464. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  43465. * It is usually zero but might be interesting to modify according to your setup.
  43466. */
  43467. sceneCenter: Vector3;
  43468. protected _opacityFresnel: boolean;
  43469. /**
  43470. * This helps specifying that the material is falling off to the sky box at grazing angle.
  43471. * This helps ensuring a nice transition when the camera goes under the ground.
  43472. */
  43473. opacityFresnel: boolean;
  43474. protected _reflectionFresnel: boolean;
  43475. /**
  43476. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  43477. * This helps adding a mirror texture on the ground.
  43478. */
  43479. reflectionFresnel: boolean;
  43480. protected _reflectionFalloffDistance: number;
  43481. /**
  43482. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  43483. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  43484. */
  43485. reflectionFalloffDistance: number;
  43486. protected _reflectionAmount: number;
  43487. /**
  43488. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  43489. */
  43490. reflectionAmount: number;
  43491. protected _reflectionReflectance0: number;
  43492. /**
  43493. * This specifies the weight of the reflection at grazing angle.
  43494. */
  43495. reflectionReflectance0: number;
  43496. protected _reflectionReflectance90: number;
  43497. /**
  43498. * This specifies the weight of the reflection at a perpendicular point of view.
  43499. */
  43500. reflectionReflectance90: number;
  43501. /**
  43502. * Sets the reflection reflectance fresnel values according to the default standard
  43503. * empirically know to work well :-)
  43504. */
  43505. reflectionStandardFresnelWeight: number;
  43506. protected _useRGBColor: boolean;
  43507. /**
  43508. * Helps to directly use the maps channels instead of their level.
  43509. */
  43510. useRGBColor: boolean;
  43511. protected _enableNoise: boolean;
  43512. /**
  43513. * This helps reducing the banding effect that could occur on the background.
  43514. */
  43515. enableNoise: boolean;
  43516. /**
  43517. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43518. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  43519. * Recommended to be keep at 1.0 except for special cases.
  43520. */
  43521. fovMultiplier: number;
  43522. private _fovMultiplier;
  43523. /**
  43524. * Enable the FOV adjustment feature controlled by fovMultiplier.
  43525. */
  43526. useEquirectangularFOV: boolean;
  43527. private _maxSimultaneousLights;
  43528. /**
  43529. * Number of Simultaneous lights allowed on the material.
  43530. */
  43531. maxSimultaneousLights: int;
  43532. /**
  43533. * Default configuration related to image processing available in the Background Material.
  43534. */
  43535. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43536. /**
  43537. * Keep track of the image processing observer to allow dispose and replace.
  43538. */
  43539. private _imageProcessingObserver;
  43540. /**
  43541. * Attaches a new image processing configuration to the PBR Material.
  43542. * @param configuration (if null the scene configuration will be use)
  43543. */
  43544. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  43545. /**
  43546. * Gets the image processing configuration used either in this material.
  43547. */
  43548. /**
  43549. * Sets the Default image processing configuration used either in the this material.
  43550. *
  43551. * If sets to null, the scene one is in use.
  43552. */
  43553. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  43554. /**
  43555. * Gets wether the color curves effect is enabled.
  43556. */
  43557. /**
  43558. * Sets wether the color curves effect is enabled.
  43559. */
  43560. cameraColorCurvesEnabled: boolean;
  43561. /**
  43562. * Gets wether the color grading effect is enabled.
  43563. */
  43564. /**
  43565. * Gets wether the color grading effect is enabled.
  43566. */
  43567. cameraColorGradingEnabled: boolean;
  43568. /**
  43569. * Gets wether tonemapping is enabled or not.
  43570. */
  43571. /**
  43572. * Sets wether tonemapping is enabled or not
  43573. */
  43574. cameraToneMappingEnabled: boolean;
  43575. /**
  43576. * The camera exposure used on this material.
  43577. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43578. * This corresponds to a photographic exposure.
  43579. */
  43580. /**
  43581. * The camera exposure used on this material.
  43582. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43583. * This corresponds to a photographic exposure.
  43584. */
  43585. cameraExposure: float;
  43586. /**
  43587. * Gets The camera contrast used on this material.
  43588. */
  43589. /**
  43590. * Sets The camera contrast used on this material.
  43591. */
  43592. cameraContrast: float;
  43593. /**
  43594. * Gets the Color Grading 2D Lookup Texture.
  43595. */
  43596. /**
  43597. * Sets the Color Grading 2D Lookup Texture.
  43598. */
  43599. cameraColorGradingTexture: Nullable<BaseTexture>;
  43600. /**
  43601. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43602. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43603. * 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;
  43604. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43605. */
  43606. /**
  43607. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43608. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43609. * 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;
  43610. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43611. */
  43612. cameraColorCurves: Nullable<ColorCurves>;
  43613. /**
  43614. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  43615. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  43616. */
  43617. switchToBGR: boolean;
  43618. private _renderTargets;
  43619. private _reflectionControls;
  43620. private _white;
  43621. private _primaryShadowColor;
  43622. private _primaryHighlightColor;
  43623. /**
  43624. * Instantiates a Background Material in the given scene
  43625. * @param name The friendly name of the material
  43626. * @param scene The scene to add the material to
  43627. */
  43628. constructor(name: string, scene: Scene);
  43629. /**
  43630. * Gets a boolean indicating that current material needs to register RTT
  43631. */
  43632. readonly hasRenderTargetTextures: boolean;
  43633. /**
  43634. * The entire material has been created in order to prevent overdraw.
  43635. * @returns false
  43636. */
  43637. needAlphaTesting(): boolean;
  43638. /**
  43639. * The entire material has been created in order to prevent overdraw.
  43640. * @returns true if blending is enable
  43641. */
  43642. needAlphaBlending(): boolean;
  43643. /**
  43644. * Checks wether the material is ready to be rendered for a given mesh.
  43645. * @param mesh The mesh to render
  43646. * @param subMesh The submesh to check against
  43647. * @param useInstances Specify wether or not the material is used with instances
  43648. * @returns true if all the dependencies are ready (Textures, Effects...)
  43649. */
  43650. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  43651. /**
  43652. * Compute the primary color according to the chosen perceptual color.
  43653. */
  43654. private _computePrimaryColorFromPerceptualColor;
  43655. /**
  43656. * Compute the highlights and shadow colors according to their chosen levels.
  43657. */
  43658. private _computePrimaryColors;
  43659. /**
  43660. * Build the uniform buffer used in the material.
  43661. */
  43662. buildUniformLayout(): void;
  43663. /**
  43664. * Unbind the material.
  43665. */
  43666. unbind(): void;
  43667. /**
  43668. * Bind only the world matrix to the material.
  43669. * @param world The world matrix to bind.
  43670. */
  43671. bindOnlyWorldMatrix(world: Matrix): void;
  43672. /**
  43673. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  43674. * @param world The world matrix to bind.
  43675. * @param subMesh The submesh to bind for.
  43676. */
  43677. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  43678. /**
  43679. * Dispose the material.
  43680. * @param forceDisposeEffect Force disposal of the associated effect.
  43681. * @param forceDisposeTextures Force disposal of the associated textures.
  43682. */
  43683. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  43684. /**
  43685. * Clones the material.
  43686. * @param name The cloned name.
  43687. * @returns The cloned material.
  43688. */
  43689. clone(name: string): BackgroundMaterial;
  43690. /**
  43691. * Serializes the current material to its JSON representation.
  43692. * @returns The JSON representation.
  43693. */
  43694. serialize(): any;
  43695. /**
  43696. * Gets the class name of the material
  43697. * @returns "BackgroundMaterial"
  43698. */
  43699. getClassName(): string;
  43700. /**
  43701. * Parse a JSON input to create back a background material.
  43702. * @param source The JSON data to parse
  43703. * @param scene The scene to create the parsed material in
  43704. * @param rootUrl The root url of the assets the material depends upon
  43705. * @returns the instantiated BackgroundMaterial.
  43706. */
  43707. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  43708. }
  43709. }
  43710. declare module BABYLON {
  43711. /**
  43712. * Represents the different options available during the creation of
  43713. * a Environment helper.
  43714. *
  43715. * This can control the default ground, skybox and image processing setup of your scene.
  43716. */
  43717. export interface IEnvironmentHelperOptions {
  43718. /**
  43719. * Specifies wether or not to create a ground.
  43720. * True by default.
  43721. */
  43722. createGround: boolean;
  43723. /**
  43724. * Specifies the ground size.
  43725. * 15 by default.
  43726. */
  43727. groundSize: number;
  43728. /**
  43729. * The texture used on the ground for the main color.
  43730. * Comes from the BabylonJS CDN by default.
  43731. *
  43732. * Remarks: Can be either a texture or a url.
  43733. */
  43734. groundTexture: string | BaseTexture;
  43735. /**
  43736. * The color mixed in the ground texture by default.
  43737. * BabylonJS clearColor by default.
  43738. */
  43739. groundColor: Color3;
  43740. /**
  43741. * Specifies the ground opacity.
  43742. * 1 by default.
  43743. */
  43744. groundOpacity: number;
  43745. /**
  43746. * Enables the ground to receive shadows.
  43747. * True by default.
  43748. */
  43749. enableGroundShadow: boolean;
  43750. /**
  43751. * Helps preventing the shadow to be fully black on the ground.
  43752. * 0.5 by default.
  43753. */
  43754. groundShadowLevel: number;
  43755. /**
  43756. * Creates a mirror texture attach to the ground.
  43757. * false by default.
  43758. */
  43759. enableGroundMirror: boolean;
  43760. /**
  43761. * Specifies the ground mirror size ratio.
  43762. * 0.3 by default as the default kernel is 64.
  43763. */
  43764. groundMirrorSizeRatio: number;
  43765. /**
  43766. * Specifies the ground mirror blur kernel size.
  43767. * 64 by default.
  43768. */
  43769. groundMirrorBlurKernel: number;
  43770. /**
  43771. * Specifies the ground mirror visibility amount.
  43772. * 1 by default
  43773. */
  43774. groundMirrorAmount: number;
  43775. /**
  43776. * Specifies the ground mirror reflectance weight.
  43777. * This uses the standard weight of the background material to setup the fresnel effect
  43778. * of the mirror.
  43779. * 1 by default.
  43780. */
  43781. groundMirrorFresnelWeight: number;
  43782. /**
  43783. * Specifies the ground mirror Falloff distance.
  43784. * This can helps reducing the size of the reflection.
  43785. * 0 by Default.
  43786. */
  43787. groundMirrorFallOffDistance: number;
  43788. /**
  43789. * Specifies the ground mirror texture type.
  43790. * Unsigned Int by Default.
  43791. */
  43792. groundMirrorTextureType: number;
  43793. /**
  43794. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  43795. * the shown objects.
  43796. */
  43797. groundYBias: number;
  43798. /**
  43799. * Specifies wether or not to create a skybox.
  43800. * True by default.
  43801. */
  43802. createSkybox: boolean;
  43803. /**
  43804. * Specifies the skybox size.
  43805. * 20 by default.
  43806. */
  43807. skyboxSize: number;
  43808. /**
  43809. * The texture used on the skybox for the main color.
  43810. * Comes from the BabylonJS CDN by default.
  43811. *
  43812. * Remarks: Can be either a texture or a url.
  43813. */
  43814. skyboxTexture: string | BaseTexture;
  43815. /**
  43816. * The color mixed in the skybox texture by default.
  43817. * BabylonJS clearColor by default.
  43818. */
  43819. skyboxColor: Color3;
  43820. /**
  43821. * The background rotation around the Y axis of the scene.
  43822. * This helps aligning the key lights of your scene with the background.
  43823. * 0 by default.
  43824. */
  43825. backgroundYRotation: number;
  43826. /**
  43827. * Compute automatically the size of the elements to best fit with the scene.
  43828. */
  43829. sizeAuto: boolean;
  43830. /**
  43831. * Default position of the rootMesh if autoSize is not true.
  43832. */
  43833. rootPosition: Vector3;
  43834. /**
  43835. * Sets up the image processing in the scene.
  43836. * true by default.
  43837. */
  43838. setupImageProcessing: boolean;
  43839. /**
  43840. * The texture used as your environment texture in the scene.
  43841. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  43842. *
  43843. * Remarks: Can be either a texture or a url.
  43844. */
  43845. environmentTexture: string | BaseTexture;
  43846. /**
  43847. * The value of the exposure to apply to the scene.
  43848. * 0.6 by default if setupImageProcessing is true.
  43849. */
  43850. cameraExposure: number;
  43851. /**
  43852. * The value of the contrast to apply to the scene.
  43853. * 1.6 by default if setupImageProcessing is true.
  43854. */
  43855. cameraContrast: number;
  43856. /**
  43857. * Specifies wether or not tonemapping should be enabled in the scene.
  43858. * true by default if setupImageProcessing is true.
  43859. */
  43860. toneMappingEnabled: boolean;
  43861. }
  43862. /**
  43863. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  43864. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  43865. * It also helps with the default setup of your imageProcessing configuration.
  43866. */
  43867. export class EnvironmentHelper {
  43868. /**
  43869. * Default ground texture URL.
  43870. */
  43871. private static _groundTextureCDNUrl;
  43872. /**
  43873. * Default skybox texture URL.
  43874. */
  43875. private static _skyboxTextureCDNUrl;
  43876. /**
  43877. * Default environment texture URL.
  43878. */
  43879. private static _environmentTextureCDNUrl;
  43880. /**
  43881. * Creates the default options for the helper.
  43882. */
  43883. private static _getDefaultOptions;
  43884. private _rootMesh;
  43885. /**
  43886. * Gets the root mesh created by the helper.
  43887. */
  43888. readonly rootMesh: Mesh;
  43889. private _skybox;
  43890. /**
  43891. * Gets the skybox created by the helper.
  43892. */
  43893. readonly skybox: Nullable<Mesh>;
  43894. private _skyboxTexture;
  43895. /**
  43896. * Gets the skybox texture created by the helper.
  43897. */
  43898. readonly skyboxTexture: Nullable<BaseTexture>;
  43899. private _skyboxMaterial;
  43900. /**
  43901. * Gets the skybox material created by the helper.
  43902. */
  43903. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  43904. private _ground;
  43905. /**
  43906. * Gets the ground mesh created by the helper.
  43907. */
  43908. readonly ground: Nullable<Mesh>;
  43909. private _groundTexture;
  43910. /**
  43911. * Gets the ground texture created by the helper.
  43912. */
  43913. readonly groundTexture: Nullable<BaseTexture>;
  43914. private _groundMirror;
  43915. /**
  43916. * Gets the ground mirror created by the helper.
  43917. */
  43918. readonly groundMirror: Nullable<MirrorTexture>;
  43919. /**
  43920. * Gets the ground mirror render list to helps pushing the meshes
  43921. * you wish in the ground reflection.
  43922. */
  43923. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  43924. private _groundMaterial;
  43925. /**
  43926. * Gets the ground material created by the helper.
  43927. */
  43928. readonly groundMaterial: Nullable<BackgroundMaterial>;
  43929. /**
  43930. * Stores the creation options.
  43931. */
  43932. private readonly _scene;
  43933. private _options;
  43934. /**
  43935. * This observable will be notified with any error during the creation of the environment,
  43936. * mainly texture creation errors.
  43937. */
  43938. onErrorObservable: Observable<{
  43939. message?: string;
  43940. exception?: any;
  43941. }>;
  43942. /**
  43943. * constructor
  43944. * @param options Defines the options we want to customize the helper
  43945. * @param scene The scene to add the material to
  43946. */
  43947. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  43948. /**
  43949. * Updates the background according to the new options
  43950. * @param options
  43951. */
  43952. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  43953. /**
  43954. * Sets the primary color of all the available elements.
  43955. * @param color the main color to affect to the ground and the background
  43956. */
  43957. setMainColor(color: Color3): void;
  43958. /**
  43959. * Setup the image processing according to the specified options.
  43960. */
  43961. private _setupImageProcessing;
  43962. /**
  43963. * Setup the environment texture according to the specified options.
  43964. */
  43965. private _setupEnvironmentTexture;
  43966. /**
  43967. * Setup the background according to the specified options.
  43968. */
  43969. private _setupBackground;
  43970. /**
  43971. * Get the scene sizes according to the setup.
  43972. */
  43973. private _getSceneSize;
  43974. /**
  43975. * Setup the ground according to the specified options.
  43976. */
  43977. private _setupGround;
  43978. /**
  43979. * Setup the ground material according to the specified options.
  43980. */
  43981. private _setupGroundMaterial;
  43982. /**
  43983. * Setup the ground diffuse texture according to the specified options.
  43984. */
  43985. private _setupGroundDiffuseTexture;
  43986. /**
  43987. * Setup the ground mirror texture according to the specified options.
  43988. */
  43989. private _setupGroundMirrorTexture;
  43990. /**
  43991. * Setup the ground to receive the mirror texture.
  43992. */
  43993. private _setupMirrorInGroundMaterial;
  43994. /**
  43995. * Setup the skybox according to the specified options.
  43996. */
  43997. private _setupSkybox;
  43998. /**
  43999. * Setup the skybox material according to the specified options.
  44000. */
  44001. private _setupSkyboxMaterial;
  44002. /**
  44003. * Setup the skybox reflection texture according to the specified options.
  44004. */
  44005. private _setupSkyboxReflectionTexture;
  44006. private _errorHandler;
  44007. /**
  44008. * Dispose all the elements created by the Helper.
  44009. */
  44010. dispose(): void;
  44011. }
  44012. }
  44013. declare module BABYLON {
  44014. /**
  44015. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  44016. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  44017. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  44018. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  44019. */
  44020. export class PhotoDome extends TransformNode {
  44021. private _useDirectMapping;
  44022. /**
  44023. * The texture being displayed on the sphere
  44024. */
  44025. protected _photoTexture: Texture;
  44026. /**
  44027. * Gets or sets the texture being displayed on the sphere
  44028. */
  44029. photoTexture: Texture;
  44030. /**
  44031. * Observable raised when an error occured while loading the 360 image
  44032. */
  44033. onLoadErrorObservable: Observable<string>;
  44034. /**
  44035. * The skybox material
  44036. */
  44037. protected _material: BackgroundMaterial;
  44038. /**
  44039. * The surface used for the skybox
  44040. */
  44041. protected _mesh: Mesh;
  44042. /**
  44043. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44044. * Also see the options.resolution property.
  44045. */
  44046. fovMultiplier: number;
  44047. /**
  44048. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  44049. * @param name Element's name, child elements will append suffixes for their own names.
  44050. * @param urlsOfPhoto defines the url of the photo to display
  44051. * @param options defines an object containing optional or exposed sub element properties
  44052. * @param onError defines a callback called when an error occured while loading the texture
  44053. */
  44054. constructor(name: string, urlOfPhoto: string, options: {
  44055. resolution?: number;
  44056. size?: number;
  44057. useDirectMapping?: boolean;
  44058. faceForward?: boolean;
  44059. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  44060. /**
  44061. * Releases resources associated with this node.
  44062. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  44063. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  44064. */
  44065. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  44066. }
  44067. }
  44068. declare module BABYLON {
  44069. /** @hidden */
  44070. export var rgbdDecodePixelShader: {
  44071. name: string;
  44072. shader: string;
  44073. };
  44074. }
  44075. declare module BABYLON {
  44076. /**
  44077. * Class used to host texture specific utilities
  44078. */
  44079. export class BRDFTextureTools {
  44080. /**
  44081. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  44082. * @param texture the texture to expand.
  44083. */
  44084. private static _ExpandDefaultBRDFTexture;
  44085. /**
  44086. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  44087. * @param scene defines the hosting scene
  44088. * @returns the environment BRDF texture
  44089. */
  44090. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  44091. private static _environmentBRDFBase64Texture;
  44092. }
  44093. }
  44094. declare module BABYLON {
  44095. /**
  44096. * @hidden
  44097. */
  44098. export interface IMaterialClearCoatDefines {
  44099. CLEARCOAT: boolean;
  44100. CLEARCOAT_DEFAULTIOR: boolean;
  44101. CLEARCOAT_TEXTURE: boolean;
  44102. CLEARCOAT_TEXTUREDIRECTUV: number;
  44103. CLEARCOAT_BUMP: boolean;
  44104. CLEARCOAT_BUMPDIRECTUV: number;
  44105. CLEARCOAT_TINT: boolean;
  44106. CLEARCOAT_TINT_TEXTURE: boolean;
  44107. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  44108. /** @hidden */
  44109. _areTexturesDirty: boolean;
  44110. }
  44111. /**
  44112. * Define the code related to the clear coat parameters of the pbr material.
  44113. */
  44114. export class PBRClearCoatConfiguration {
  44115. /**
  44116. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44117. * The default fits with a polyurethane material.
  44118. */
  44119. private static readonly _DefaultIndiceOfRefraction;
  44120. private _isEnabled;
  44121. /**
  44122. * Defines if the clear coat is enabled in the material.
  44123. */
  44124. isEnabled: boolean;
  44125. /**
  44126. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  44127. */
  44128. intensity: number;
  44129. /**
  44130. * Defines the clear coat layer roughness.
  44131. */
  44132. roughness: number;
  44133. private _indiceOfRefraction;
  44134. /**
  44135. * Defines the indice of refraction of the clear coat.
  44136. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44137. * The default fits with a polyurethane material.
  44138. * Changing the default value is more performance intensive.
  44139. */
  44140. indiceOfRefraction: number;
  44141. private _texture;
  44142. /**
  44143. * Stores the clear coat values in a texture.
  44144. */
  44145. texture: Nullable<BaseTexture>;
  44146. private _bumpTexture;
  44147. /**
  44148. * Define the clear coat specific bump texture.
  44149. */
  44150. bumpTexture: Nullable<BaseTexture>;
  44151. private _isTintEnabled;
  44152. /**
  44153. * Defines if the clear coat tint is enabled in the material.
  44154. */
  44155. isTintEnabled: boolean;
  44156. /**
  44157. * Defines the clear coat tint of the material.
  44158. * This is only use if tint is enabled
  44159. */
  44160. tintColor: Color3;
  44161. /**
  44162. * Defines the distance at which the tint color should be found in the
  44163. * clear coat media.
  44164. * This is only use if tint is enabled
  44165. */
  44166. tintColorAtDistance: number;
  44167. /**
  44168. * Defines the clear coat layer thickness.
  44169. * This is only use if tint is enabled
  44170. */
  44171. tintThickness: number;
  44172. private _tintTexture;
  44173. /**
  44174. * Stores the clear tint values in a texture.
  44175. * rgb is tint
  44176. * a is a thickness factor
  44177. */
  44178. tintTexture: Nullable<BaseTexture>;
  44179. /** @hidden */
  44180. private _internalMarkAllSubMeshesAsTexturesDirty;
  44181. /** @hidden */
  44182. _markAllSubMeshesAsTexturesDirty(): void;
  44183. /**
  44184. * Instantiate a new istance of clear coat configuration.
  44185. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44186. */
  44187. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44188. /**
  44189. * Gets wehter the submesh is ready to be used or not.
  44190. * @param defines the list of "defines" to update.
  44191. * @param scene defines the scene the material belongs to.
  44192. * @param engine defines the engine the material belongs to.
  44193. * @param disableBumpMap defines wether the material disables bump or not.
  44194. * @returns - boolean indicating that the submesh is ready or not.
  44195. */
  44196. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  44197. /**
  44198. * Checks to see if a texture is used in the material.
  44199. * @param defines the list of "defines" to update.
  44200. * @param scene defines the scene to the material belongs to.
  44201. */
  44202. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  44203. /**
  44204. * Binds the material data.
  44205. * @param uniformBuffer defines the Uniform buffer to fill in.
  44206. * @param scene defines the scene the material belongs to.
  44207. * @param engine defines the engine the material belongs to.
  44208. * @param disableBumpMap defines wether the material disables bump or not.
  44209. * @param isFrozen defines wether the material is frozen or not.
  44210. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44211. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44212. */
  44213. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  44214. /**
  44215. * Checks to see if a texture is used in the material.
  44216. * @param texture - Base texture to use.
  44217. * @returns - Boolean specifying if a texture is used in the material.
  44218. */
  44219. hasTexture(texture: BaseTexture): boolean;
  44220. /**
  44221. * Returns an array of the actively used textures.
  44222. * @param activeTextures Array of BaseTextures
  44223. */
  44224. getActiveTextures(activeTextures: BaseTexture[]): void;
  44225. /**
  44226. * Returns the animatable textures.
  44227. * @param animatables Array of animatable textures.
  44228. */
  44229. getAnimatables(animatables: IAnimatable[]): void;
  44230. /**
  44231. * Disposes the resources of the material.
  44232. * @param forceDisposeTextures - Forces the disposal of all textures.
  44233. */
  44234. dispose(forceDisposeTextures?: boolean): void;
  44235. /**
  44236. * Get the current class name of the texture useful for serialization or dynamic coding.
  44237. * @returns "PBRClearCoatConfiguration"
  44238. */
  44239. getClassName(): string;
  44240. /**
  44241. * Add fallbacks to the effect fallbacks list.
  44242. * @param defines defines the Base texture to use.
  44243. * @param fallbacks defines the current fallback list.
  44244. * @param currentRank defines the current fallback rank.
  44245. * @returns the new fallback rank.
  44246. */
  44247. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44248. /**
  44249. * Add the required uniforms to the current list.
  44250. * @param uniforms defines the current uniform list.
  44251. */
  44252. static AddUniforms(uniforms: string[]): void;
  44253. /**
  44254. * Add the required samplers to the current list.
  44255. * @param samplers defines the current sampler list.
  44256. */
  44257. static AddSamplers(samplers: string[]): void;
  44258. /**
  44259. * Add the required uniforms to the current buffer.
  44260. * @param uniformBuffer defines the current uniform buffer.
  44261. */
  44262. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44263. /**
  44264. * Makes a duplicate of the current configuration into another one.
  44265. * @param clearCoatConfiguration define the config where to copy the info
  44266. */
  44267. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  44268. /**
  44269. * Serializes this clear coat configuration.
  44270. * @returns - An object with the serialized config.
  44271. */
  44272. serialize(): any;
  44273. /**
  44274. * Parses a Clear Coat Configuration from a serialized object.
  44275. * @param source - Serialized object.
  44276. */
  44277. parse(source: any): void;
  44278. }
  44279. }
  44280. declare module BABYLON {
  44281. /**
  44282. * @hidden
  44283. */
  44284. export interface IMaterialAnisotropicDefines {
  44285. ANISOTROPIC: boolean;
  44286. ANISOTROPIC_TEXTURE: boolean;
  44287. ANISOTROPIC_TEXTUREDIRECTUV: number;
  44288. MAINUV1: boolean;
  44289. _areTexturesDirty: boolean;
  44290. _needUVs: boolean;
  44291. }
  44292. /**
  44293. * Define the code related to the anisotropic parameters of the pbr material.
  44294. */
  44295. export class PBRAnisotropicConfiguration {
  44296. private _isEnabled;
  44297. /**
  44298. * Defines if the anisotropy is enabled in the material.
  44299. */
  44300. isEnabled: boolean;
  44301. /**
  44302. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  44303. */
  44304. intensity: number;
  44305. /**
  44306. * Defines if the effect is along the tangents, bitangents or in between.
  44307. * By default, the effect is "strectching" the highlights along the tangents.
  44308. */
  44309. direction: Vector2;
  44310. private _texture;
  44311. /**
  44312. * Stores the anisotropy values in a texture.
  44313. * rg is direction (like normal from -1 to 1)
  44314. * b is a intensity
  44315. */
  44316. texture: Nullable<BaseTexture>;
  44317. /** @hidden */
  44318. private _internalMarkAllSubMeshesAsTexturesDirty;
  44319. /** @hidden */
  44320. _markAllSubMeshesAsTexturesDirty(): void;
  44321. /**
  44322. * Instantiate a new istance of anisotropy configuration.
  44323. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44324. */
  44325. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44326. /**
  44327. * Specifies that the submesh is ready to be used.
  44328. * @param defines the list of "defines" to update.
  44329. * @param scene defines the scene the material belongs to.
  44330. * @returns - boolean indicating that the submesh is ready or not.
  44331. */
  44332. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  44333. /**
  44334. * Checks to see if a texture is used in the material.
  44335. * @param defines the list of "defines" to update.
  44336. * @param mesh the mesh we are preparing the defines for.
  44337. * @param scene defines the scene the material belongs to.
  44338. */
  44339. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  44340. /**
  44341. * Binds the material data.
  44342. * @param uniformBuffer defines the Uniform buffer to fill in.
  44343. * @param scene defines the scene the material belongs to.
  44344. * @param isFrozen defines wether the material is frozen or not.
  44345. */
  44346. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44347. /**
  44348. * Checks to see if a texture is used in the material.
  44349. * @param texture - Base texture to use.
  44350. * @returns - Boolean specifying if a texture is used in the material.
  44351. */
  44352. hasTexture(texture: BaseTexture): boolean;
  44353. /**
  44354. * Returns an array of the actively used textures.
  44355. * @param activeTextures Array of BaseTextures
  44356. */
  44357. getActiveTextures(activeTextures: BaseTexture[]): void;
  44358. /**
  44359. * Returns the animatable textures.
  44360. * @param animatables Array of animatable textures.
  44361. */
  44362. getAnimatables(animatables: IAnimatable[]): void;
  44363. /**
  44364. * Disposes the resources of the material.
  44365. * @param forceDisposeTextures - Forces the disposal of all textures.
  44366. */
  44367. dispose(forceDisposeTextures?: boolean): void;
  44368. /**
  44369. * Get the current class name of the texture useful for serialization or dynamic coding.
  44370. * @returns "PBRAnisotropicConfiguration"
  44371. */
  44372. getClassName(): string;
  44373. /**
  44374. * Add fallbacks to the effect fallbacks list.
  44375. * @param defines defines the Base texture to use.
  44376. * @param fallbacks defines the current fallback list.
  44377. * @param currentRank defines the current fallback rank.
  44378. * @returns the new fallback rank.
  44379. */
  44380. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44381. /**
  44382. * Add the required uniforms to the current list.
  44383. * @param uniforms defines the current uniform list.
  44384. */
  44385. static AddUniforms(uniforms: string[]): void;
  44386. /**
  44387. * Add the required uniforms to the current buffer.
  44388. * @param uniformBuffer defines the current uniform buffer.
  44389. */
  44390. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44391. /**
  44392. * Add the required samplers to the current list.
  44393. * @param samplers defines the current sampler list.
  44394. */
  44395. static AddSamplers(samplers: string[]): void;
  44396. /**
  44397. * Makes a duplicate of the current configuration into another one.
  44398. * @param anisotropicConfiguration define the config where to copy the info
  44399. */
  44400. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  44401. /**
  44402. * Serializes this anisotropy configuration.
  44403. * @returns - An object with the serialized config.
  44404. */
  44405. serialize(): any;
  44406. /**
  44407. * Parses a anisotropy Configuration from a serialized object.
  44408. * @param source - Serialized object.
  44409. */
  44410. parse(source: any): void;
  44411. }
  44412. }
  44413. declare module BABYLON {
  44414. /**
  44415. * @hidden
  44416. */
  44417. export interface IMaterialBRDFDefines {
  44418. BRDF_V_HEIGHT_CORRELATED: boolean;
  44419. MS_BRDF_ENERGY_CONSERVATION: boolean;
  44420. SPHERICAL_HARMONICS: boolean;
  44421. /** @hidden */
  44422. _areMiscDirty: boolean;
  44423. }
  44424. /**
  44425. * Define the code related to the BRDF parameters of the pbr material.
  44426. */
  44427. export class PBRBRDFConfiguration {
  44428. /**
  44429. * Default value used for the energy conservation.
  44430. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  44431. */
  44432. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  44433. /**
  44434. * Default value used for the Smith Visibility Height Correlated mode.
  44435. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  44436. */
  44437. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  44438. /**
  44439. * Default value used for the IBL diffuse part.
  44440. * This can help switching back to the polynomials mode globally which is a tiny bit
  44441. * less GPU intensive at the drawback of a lower quality.
  44442. */
  44443. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  44444. private _useEnergyConservation;
  44445. /**
  44446. * Defines if the material uses energy conservation.
  44447. */
  44448. useEnergyConservation: boolean;
  44449. private _useSmithVisibilityHeightCorrelated;
  44450. /**
  44451. * LEGACY Mode set to false
  44452. * Defines if the material uses height smith correlated visibility term.
  44453. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  44454. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  44455. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  44456. * Not relying on height correlated will also disable energy conservation.
  44457. */
  44458. useSmithVisibilityHeightCorrelated: boolean;
  44459. private _useSphericalHarmonics;
  44460. /**
  44461. * LEGACY Mode set to false
  44462. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  44463. * diffuse part of the IBL.
  44464. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  44465. * to the ground truth.
  44466. */
  44467. useSphericalHarmonics: boolean;
  44468. /** @hidden */
  44469. private _internalMarkAllSubMeshesAsMiscDirty;
  44470. /** @hidden */
  44471. _markAllSubMeshesAsMiscDirty(): void;
  44472. /**
  44473. * Instantiate a new istance of clear coat configuration.
  44474. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  44475. */
  44476. constructor(markAllSubMeshesAsMiscDirty: () => void);
  44477. /**
  44478. * Checks to see if a texture is used in the material.
  44479. * @param defines the list of "defines" to update.
  44480. */
  44481. prepareDefines(defines: IMaterialBRDFDefines): void;
  44482. /**
  44483. * Get the current class name of the texture useful for serialization or dynamic coding.
  44484. * @returns "PBRClearCoatConfiguration"
  44485. */
  44486. getClassName(): string;
  44487. /**
  44488. * Makes a duplicate of the current configuration into another one.
  44489. * @param brdfConfiguration define the config where to copy the info
  44490. */
  44491. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  44492. /**
  44493. * Serializes this BRDF configuration.
  44494. * @returns - An object with the serialized config.
  44495. */
  44496. serialize(): any;
  44497. /**
  44498. * Parses a BRDF Configuration from a serialized object.
  44499. * @param source - Serialized object.
  44500. */
  44501. parse(source: any): void;
  44502. }
  44503. }
  44504. declare module BABYLON {
  44505. /**
  44506. * @hidden
  44507. */
  44508. export interface IMaterialSheenDefines {
  44509. SHEEN: boolean;
  44510. SHEEN_TEXTURE: boolean;
  44511. SHEEN_TEXTUREDIRECTUV: number;
  44512. SHEEN_LINKWITHALBEDO: boolean;
  44513. /** @hidden */
  44514. _areTexturesDirty: boolean;
  44515. }
  44516. /**
  44517. * Define the code related to the Sheen parameters of the pbr material.
  44518. */
  44519. export class PBRSheenConfiguration {
  44520. private _isEnabled;
  44521. /**
  44522. * Defines if the material uses sheen.
  44523. */
  44524. isEnabled: boolean;
  44525. private _linkSheenWithAlbedo;
  44526. /**
  44527. * Defines if the sheen is linked to the sheen color.
  44528. */
  44529. linkSheenWithAlbedo: boolean;
  44530. /**
  44531. * Defines the sheen intensity.
  44532. */
  44533. intensity: number;
  44534. /**
  44535. * Defines the sheen color.
  44536. */
  44537. color: Color3;
  44538. private _texture;
  44539. /**
  44540. * Stores the sheen tint values in a texture.
  44541. * rgb is tint
  44542. * a is a intensity
  44543. */
  44544. texture: Nullable<BaseTexture>;
  44545. /** @hidden */
  44546. private _internalMarkAllSubMeshesAsTexturesDirty;
  44547. /** @hidden */
  44548. _markAllSubMeshesAsTexturesDirty(): void;
  44549. /**
  44550. * Instantiate a new istance of clear coat configuration.
  44551. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44552. */
  44553. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44554. /**
  44555. * Specifies that the submesh is ready to be used.
  44556. * @param defines the list of "defines" to update.
  44557. * @param scene defines the scene the material belongs to.
  44558. * @returns - boolean indicating that the submesh is ready or not.
  44559. */
  44560. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  44561. /**
  44562. * Checks to see if a texture is used in the material.
  44563. * @param defines the list of "defines" to update.
  44564. * @param scene defines the scene the material belongs to.
  44565. */
  44566. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  44567. /**
  44568. * Binds the material data.
  44569. * @param uniformBuffer defines the Uniform buffer to fill in.
  44570. * @param scene defines the scene the material belongs to.
  44571. * @param isFrozen defines wether the material is frozen or not.
  44572. */
  44573. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44574. /**
  44575. * Checks to see if a texture is used in the material.
  44576. * @param texture - Base texture to use.
  44577. * @returns - Boolean specifying if a texture is used in the material.
  44578. */
  44579. hasTexture(texture: BaseTexture): boolean;
  44580. /**
  44581. * Returns an array of the actively used textures.
  44582. * @param activeTextures Array of BaseTextures
  44583. */
  44584. getActiveTextures(activeTextures: BaseTexture[]): void;
  44585. /**
  44586. * Returns the animatable textures.
  44587. * @param animatables Array of animatable textures.
  44588. */
  44589. getAnimatables(animatables: IAnimatable[]): void;
  44590. /**
  44591. * Disposes the resources of the material.
  44592. * @param forceDisposeTextures - Forces the disposal of all textures.
  44593. */
  44594. dispose(forceDisposeTextures?: boolean): void;
  44595. /**
  44596. * Get the current class name of the texture useful for serialization or dynamic coding.
  44597. * @returns "PBRSheenConfiguration"
  44598. */
  44599. getClassName(): string;
  44600. /**
  44601. * Add fallbacks to the effect fallbacks list.
  44602. * @param defines defines the Base texture to use.
  44603. * @param fallbacks defines the current fallback list.
  44604. * @param currentRank defines the current fallback rank.
  44605. * @returns the new fallback rank.
  44606. */
  44607. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44608. /**
  44609. * Add the required uniforms to the current list.
  44610. * @param uniforms defines the current uniform list.
  44611. */
  44612. static AddUniforms(uniforms: string[]): void;
  44613. /**
  44614. * Add the required uniforms to the current buffer.
  44615. * @param uniformBuffer defines the current uniform buffer.
  44616. */
  44617. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44618. /**
  44619. * Add the required samplers to the current list.
  44620. * @param samplers defines the current sampler list.
  44621. */
  44622. static AddSamplers(samplers: string[]): void;
  44623. /**
  44624. * Makes a duplicate of the current configuration into another one.
  44625. * @param sheenConfiguration define the config where to copy the info
  44626. */
  44627. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  44628. /**
  44629. * Serializes this BRDF configuration.
  44630. * @returns - An object with the serialized config.
  44631. */
  44632. serialize(): any;
  44633. /**
  44634. * Parses a Sheen Configuration from a serialized object.
  44635. * @param source - Serialized object.
  44636. */
  44637. parse(source: any): void;
  44638. }
  44639. }
  44640. declare module BABYLON {
  44641. /**
  44642. * @hidden
  44643. */
  44644. export interface IMaterialSubSurfaceDefines {
  44645. SUBSURFACE: boolean;
  44646. SS_REFRACTION: boolean;
  44647. SS_TRANSLUCENCY: boolean;
  44648. SS_SCATERRING: boolean;
  44649. SS_THICKNESSANDMASK_TEXTURE: boolean;
  44650. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  44651. SS_REFRACTIONMAP_3D: boolean;
  44652. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  44653. SS_LODINREFRACTIONALPHA: boolean;
  44654. SS_GAMMAREFRACTION: boolean;
  44655. SS_RGBDREFRACTION: boolean;
  44656. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  44657. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  44658. /** @hidden */
  44659. _areTexturesDirty: boolean;
  44660. }
  44661. /**
  44662. * Define the code related to the sub surface parameters of the pbr material.
  44663. */
  44664. export class PBRSubSurfaceConfiguration {
  44665. private _isRefractionEnabled;
  44666. /**
  44667. * Defines if the refraction is enabled in the material.
  44668. */
  44669. isRefractionEnabled: boolean;
  44670. private _isTranslucencyEnabled;
  44671. /**
  44672. * Defines if the translucency is enabled in the material.
  44673. */
  44674. isTranslucencyEnabled: boolean;
  44675. private _isScatteringEnabled;
  44676. /**
  44677. * Defines the refraction intensity of the material.
  44678. * The refraction when enabled replaces the Diffuse part of the material.
  44679. * The intensity helps transitionning between diffuse and refraction.
  44680. */
  44681. refractionIntensity: number;
  44682. /**
  44683. * Defines the translucency intensity of the material.
  44684. * When translucency has been enabled, this defines how much of the "translucency"
  44685. * is addded to the diffuse part of the material.
  44686. */
  44687. translucencyIntensity: number;
  44688. /**
  44689. * Defines the scattering intensity of the material.
  44690. * When scattering has been enabled, this defines how much of the "scattered light"
  44691. * is addded to the diffuse part of the material.
  44692. */
  44693. scatteringIntensity: number;
  44694. private _thicknessTexture;
  44695. /**
  44696. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  44697. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  44698. * 0 would mean minimumThickness
  44699. * 1 would mean maximumThickness
  44700. * The other channels might be use as a mask to vary the different effects intensity.
  44701. */
  44702. thicknessTexture: Nullable<BaseTexture>;
  44703. private _refractionTexture;
  44704. /**
  44705. * Defines the texture to use for refraction.
  44706. */
  44707. refractionTexture: Nullable<BaseTexture>;
  44708. private _indexOfRefraction;
  44709. /**
  44710. * Defines the indice of refraction used in the material.
  44711. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  44712. */
  44713. indexOfRefraction: number;
  44714. private _invertRefractionY;
  44715. /**
  44716. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  44717. */
  44718. invertRefractionY: boolean;
  44719. private _linkRefractionWithTransparency;
  44720. /**
  44721. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44722. * Materials half opaque for instance using refraction could benefit from this control.
  44723. */
  44724. linkRefractionWithTransparency: boolean;
  44725. /**
  44726. * Defines the minimum thickness stored in the thickness map.
  44727. * If no thickness map is defined, this value will be used to simulate thickness.
  44728. */
  44729. minimumThickness: number;
  44730. /**
  44731. * Defines the maximum thickness stored in the thickness map.
  44732. */
  44733. maximumThickness: number;
  44734. /**
  44735. * Defines the volume tint of the material.
  44736. * This is used for both translucency and scattering.
  44737. */
  44738. tintColor: Color3;
  44739. /**
  44740. * Defines the distance at which the tint color should be found in the media.
  44741. * This is used for refraction only.
  44742. */
  44743. tintColorAtDistance: number;
  44744. /**
  44745. * Defines how far each channel transmit through the media.
  44746. * It is defined as a color to simplify it selection.
  44747. */
  44748. diffusionDistance: Color3;
  44749. private _useMaskFromThicknessTexture;
  44750. /**
  44751. * Stores the intensity of the different subsurface effects in the thickness texture.
  44752. * * the green channel is the translucency intensity.
  44753. * * the blue channel is the scattering intensity.
  44754. * * the alpha channel is the refraction intensity.
  44755. */
  44756. useMaskFromThicknessTexture: boolean;
  44757. /** @hidden */
  44758. private _internalMarkAllSubMeshesAsTexturesDirty;
  44759. /** @hidden */
  44760. _markAllSubMeshesAsTexturesDirty(): void;
  44761. /**
  44762. * Instantiate a new istance of sub surface configuration.
  44763. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44764. */
  44765. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44766. /**
  44767. * Gets wehter the submesh is ready to be used or not.
  44768. * @param defines the list of "defines" to update.
  44769. * @param scene defines the scene the material belongs to.
  44770. * @returns - boolean indicating that the submesh is ready or not.
  44771. */
  44772. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  44773. /**
  44774. * Checks to see if a texture is used in the material.
  44775. * @param defines the list of "defines" to update.
  44776. * @param scene defines the scene to the material belongs to.
  44777. */
  44778. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  44779. /**
  44780. * Binds the material data.
  44781. * @param uniformBuffer defines the Uniform buffer to fill in.
  44782. * @param scene defines the scene the material belongs to.
  44783. * @param engine defines the engine the material belongs to.
  44784. * @param isFrozen defines wether the material is frozen or not.
  44785. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  44786. */
  44787. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  44788. /**
  44789. * Unbinds the material from the mesh.
  44790. * @param activeEffect defines the effect that should be unbound from.
  44791. * @returns true if unbound, otherwise false
  44792. */
  44793. unbind(activeEffect: Effect): boolean;
  44794. /**
  44795. * Returns the texture used for refraction or null if none is used.
  44796. * @param scene defines the scene the material belongs to.
  44797. * @returns - Refraction texture if present. If no refraction texture and refraction
  44798. * is linked with transparency, returns environment texture. Otherwise, returns null.
  44799. */
  44800. private _getRefractionTexture;
  44801. /**
  44802. * Returns true if alpha blending should be disabled.
  44803. */
  44804. readonly disableAlphaBlending: boolean;
  44805. /**
  44806. * Fills the list of render target textures.
  44807. * @param renderTargets the list of render targets to update
  44808. */
  44809. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  44810. /**
  44811. * Checks to see if a texture is used in the material.
  44812. * @param texture - Base texture to use.
  44813. * @returns - Boolean specifying if a texture is used in the material.
  44814. */
  44815. hasTexture(texture: BaseTexture): boolean;
  44816. /**
  44817. * Gets a boolean indicating that current material needs to register RTT
  44818. * @returns true if this uses a render target otherwise false.
  44819. */
  44820. hasRenderTargetTextures(): boolean;
  44821. /**
  44822. * Returns an array of the actively used textures.
  44823. * @param activeTextures Array of BaseTextures
  44824. */
  44825. getActiveTextures(activeTextures: BaseTexture[]): void;
  44826. /**
  44827. * Returns the animatable textures.
  44828. * @param animatables Array of animatable textures.
  44829. */
  44830. getAnimatables(animatables: IAnimatable[]): void;
  44831. /**
  44832. * Disposes the resources of the material.
  44833. * @param forceDisposeTextures - Forces the disposal of all textures.
  44834. */
  44835. dispose(forceDisposeTextures?: boolean): void;
  44836. /**
  44837. * Get the current class name of the texture useful for serialization or dynamic coding.
  44838. * @returns "PBRSubSurfaceConfiguration"
  44839. */
  44840. getClassName(): string;
  44841. /**
  44842. * Add fallbacks to the effect fallbacks list.
  44843. * @param defines defines the Base texture to use.
  44844. * @param fallbacks defines the current fallback list.
  44845. * @param currentRank defines the current fallback rank.
  44846. * @returns the new fallback rank.
  44847. */
  44848. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44849. /**
  44850. * Add the required uniforms to the current list.
  44851. * @param uniforms defines the current uniform list.
  44852. */
  44853. static AddUniforms(uniforms: string[]): void;
  44854. /**
  44855. * Add the required samplers to the current list.
  44856. * @param samplers defines the current sampler list.
  44857. */
  44858. static AddSamplers(samplers: string[]): void;
  44859. /**
  44860. * Add the required uniforms to the current buffer.
  44861. * @param uniformBuffer defines the current uniform buffer.
  44862. */
  44863. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44864. /**
  44865. * Makes a duplicate of the current configuration into another one.
  44866. * @param configuration define the config where to copy the info
  44867. */
  44868. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  44869. /**
  44870. * Serializes this Sub Surface configuration.
  44871. * @returns - An object with the serialized config.
  44872. */
  44873. serialize(): any;
  44874. /**
  44875. * Parses a Sub Surface Configuration from a serialized object.
  44876. * @param source - Serialized object.
  44877. */
  44878. parse(source: any): void;
  44879. }
  44880. }
  44881. declare module BABYLON {
  44882. /** @hidden */
  44883. export var pbrFragmentDeclaration: {
  44884. name: string;
  44885. shader: string;
  44886. };
  44887. }
  44888. declare module BABYLON {
  44889. /** @hidden */
  44890. export var pbrUboDeclaration: {
  44891. name: string;
  44892. shader: string;
  44893. };
  44894. }
  44895. declare module BABYLON {
  44896. /** @hidden */
  44897. export var pbrFragmentExtraDeclaration: {
  44898. name: string;
  44899. shader: string;
  44900. };
  44901. }
  44902. declare module BABYLON {
  44903. /** @hidden */
  44904. export var pbrFragmentSamplersDeclaration: {
  44905. name: string;
  44906. shader: string;
  44907. };
  44908. }
  44909. declare module BABYLON {
  44910. /** @hidden */
  44911. export var pbrHelperFunctions: {
  44912. name: string;
  44913. shader: string;
  44914. };
  44915. }
  44916. declare module BABYLON {
  44917. /** @hidden */
  44918. export var harmonicsFunctions: {
  44919. name: string;
  44920. shader: string;
  44921. };
  44922. }
  44923. declare module BABYLON {
  44924. /** @hidden */
  44925. export var pbrDirectLightingSetupFunctions: {
  44926. name: string;
  44927. shader: string;
  44928. };
  44929. }
  44930. declare module BABYLON {
  44931. /** @hidden */
  44932. export var pbrDirectLightingFalloffFunctions: {
  44933. name: string;
  44934. shader: string;
  44935. };
  44936. }
  44937. declare module BABYLON {
  44938. /** @hidden */
  44939. export var pbrBRDFFunctions: {
  44940. name: string;
  44941. shader: string;
  44942. };
  44943. }
  44944. declare module BABYLON {
  44945. /** @hidden */
  44946. export var pbrDirectLightingFunctions: {
  44947. name: string;
  44948. shader: string;
  44949. };
  44950. }
  44951. declare module BABYLON {
  44952. /** @hidden */
  44953. export var pbrIBLFunctions: {
  44954. name: string;
  44955. shader: string;
  44956. };
  44957. }
  44958. declare module BABYLON {
  44959. /** @hidden */
  44960. export var pbrDebug: {
  44961. name: string;
  44962. shader: string;
  44963. };
  44964. }
  44965. declare module BABYLON {
  44966. /** @hidden */
  44967. export var pbrPixelShader: {
  44968. name: string;
  44969. shader: string;
  44970. };
  44971. }
  44972. declare module BABYLON {
  44973. /** @hidden */
  44974. export var pbrVertexDeclaration: {
  44975. name: string;
  44976. shader: string;
  44977. };
  44978. }
  44979. declare module BABYLON {
  44980. /** @hidden */
  44981. export var pbrVertexShader: {
  44982. name: string;
  44983. shader: string;
  44984. };
  44985. }
  44986. declare module BABYLON {
  44987. /**
  44988. * Manages the defines for the PBR Material.
  44989. * @hidden
  44990. */
  44991. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  44992. PBR: boolean;
  44993. MAINUV1: boolean;
  44994. MAINUV2: boolean;
  44995. UV1: boolean;
  44996. UV2: boolean;
  44997. ALBEDO: boolean;
  44998. ALBEDODIRECTUV: number;
  44999. VERTEXCOLOR: boolean;
  45000. AMBIENT: boolean;
  45001. AMBIENTDIRECTUV: number;
  45002. AMBIENTINGRAYSCALE: boolean;
  45003. OPACITY: boolean;
  45004. VERTEXALPHA: boolean;
  45005. OPACITYDIRECTUV: number;
  45006. OPACITYRGB: boolean;
  45007. ALPHATEST: boolean;
  45008. DEPTHPREPASS: boolean;
  45009. ALPHABLEND: boolean;
  45010. ALPHAFROMALBEDO: boolean;
  45011. ALPHATESTVALUE: string;
  45012. SPECULAROVERALPHA: boolean;
  45013. RADIANCEOVERALPHA: boolean;
  45014. ALPHAFRESNEL: boolean;
  45015. LINEARALPHAFRESNEL: boolean;
  45016. PREMULTIPLYALPHA: boolean;
  45017. EMISSIVE: boolean;
  45018. EMISSIVEDIRECTUV: number;
  45019. REFLECTIVITY: boolean;
  45020. REFLECTIVITYDIRECTUV: number;
  45021. SPECULARTERM: boolean;
  45022. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  45023. MICROSURFACEAUTOMATIC: boolean;
  45024. LODBASEDMICROSFURACE: boolean;
  45025. MICROSURFACEMAP: boolean;
  45026. MICROSURFACEMAPDIRECTUV: number;
  45027. METALLICWORKFLOW: boolean;
  45028. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  45029. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  45030. METALLNESSSTOREINMETALMAPBLUE: boolean;
  45031. AOSTOREINMETALMAPRED: boolean;
  45032. ENVIRONMENTBRDF: boolean;
  45033. ENVIRONMENTBRDF_RGBD: boolean;
  45034. NORMAL: boolean;
  45035. TANGENT: boolean;
  45036. BUMP: boolean;
  45037. BUMPDIRECTUV: number;
  45038. OBJECTSPACE_NORMALMAP: boolean;
  45039. PARALLAX: boolean;
  45040. PARALLAXOCCLUSION: boolean;
  45041. NORMALXYSCALE: boolean;
  45042. LIGHTMAP: boolean;
  45043. LIGHTMAPDIRECTUV: number;
  45044. USELIGHTMAPASSHADOWMAP: boolean;
  45045. GAMMALIGHTMAP: boolean;
  45046. REFLECTION: boolean;
  45047. REFLECTIONMAP_3D: boolean;
  45048. REFLECTIONMAP_SPHERICAL: boolean;
  45049. REFLECTIONMAP_PLANAR: boolean;
  45050. REFLECTIONMAP_CUBIC: boolean;
  45051. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  45052. REFLECTIONMAP_PROJECTION: boolean;
  45053. REFLECTIONMAP_SKYBOX: boolean;
  45054. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  45055. REFLECTIONMAP_EXPLICIT: boolean;
  45056. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  45057. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  45058. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  45059. INVERTCUBICMAP: boolean;
  45060. USESPHERICALFROMREFLECTIONMAP: boolean;
  45061. SPHERICAL_HARMONICS: boolean;
  45062. USESPHERICALINVERTEX: boolean;
  45063. REFLECTIONMAP_OPPOSITEZ: boolean;
  45064. LODINREFLECTIONALPHA: boolean;
  45065. GAMMAREFLECTION: boolean;
  45066. RGBDREFLECTION: boolean;
  45067. RADIANCEOCCLUSION: boolean;
  45068. HORIZONOCCLUSION: boolean;
  45069. INSTANCES: boolean;
  45070. NUM_BONE_INFLUENCERS: number;
  45071. BonesPerMesh: number;
  45072. BONETEXTURE: boolean;
  45073. NONUNIFORMSCALING: boolean;
  45074. MORPHTARGETS: boolean;
  45075. MORPHTARGETS_NORMAL: boolean;
  45076. MORPHTARGETS_TANGENT: boolean;
  45077. NUM_MORPH_INFLUENCERS: number;
  45078. IMAGEPROCESSING: boolean;
  45079. VIGNETTE: boolean;
  45080. VIGNETTEBLENDMODEMULTIPLY: boolean;
  45081. VIGNETTEBLENDMODEOPAQUE: boolean;
  45082. TONEMAPPING: boolean;
  45083. TONEMAPPING_ACES: boolean;
  45084. CONTRAST: boolean;
  45085. COLORCURVES: boolean;
  45086. COLORGRADING: boolean;
  45087. COLORGRADING3D: boolean;
  45088. SAMPLER3DGREENDEPTH: boolean;
  45089. SAMPLER3DBGRMAP: boolean;
  45090. IMAGEPROCESSINGPOSTPROCESS: boolean;
  45091. EXPOSURE: boolean;
  45092. MULTIVIEW: boolean;
  45093. USEPHYSICALLIGHTFALLOFF: boolean;
  45094. USEGLTFLIGHTFALLOFF: boolean;
  45095. TWOSIDEDLIGHTING: boolean;
  45096. SHADOWFLOAT: boolean;
  45097. CLIPPLANE: boolean;
  45098. CLIPPLANE2: boolean;
  45099. CLIPPLANE3: boolean;
  45100. CLIPPLANE4: boolean;
  45101. POINTSIZE: boolean;
  45102. FOG: boolean;
  45103. LOGARITHMICDEPTH: boolean;
  45104. FORCENORMALFORWARD: boolean;
  45105. SPECULARAA: boolean;
  45106. CLEARCOAT: boolean;
  45107. CLEARCOAT_DEFAULTIOR: boolean;
  45108. CLEARCOAT_TEXTURE: boolean;
  45109. CLEARCOAT_TEXTUREDIRECTUV: number;
  45110. CLEARCOAT_BUMP: boolean;
  45111. CLEARCOAT_BUMPDIRECTUV: number;
  45112. CLEARCOAT_TINT: boolean;
  45113. CLEARCOAT_TINT_TEXTURE: boolean;
  45114. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45115. ANISOTROPIC: boolean;
  45116. ANISOTROPIC_TEXTURE: boolean;
  45117. ANISOTROPIC_TEXTUREDIRECTUV: number;
  45118. BRDF_V_HEIGHT_CORRELATED: boolean;
  45119. MS_BRDF_ENERGY_CONSERVATION: boolean;
  45120. SHEEN: boolean;
  45121. SHEEN_TEXTURE: boolean;
  45122. SHEEN_TEXTUREDIRECTUV: number;
  45123. SHEEN_LINKWITHALBEDO: boolean;
  45124. SUBSURFACE: boolean;
  45125. SS_REFRACTION: boolean;
  45126. SS_TRANSLUCENCY: boolean;
  45127. SS_SCATERRING: boolean;
  45128. SS_THICKNESSANDMASK_TEXTURE: boolean;
  45129. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  45130. SS_REFRACTIONMAP_3D: boolean;
  45131. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  45132. SS_LODINREFRACTIONALPHA: boolean;
  45133. SS_GAMMAREFRACTION: boolean;
  45134. SS_RGBDREFRACTION: boolean;
  45135. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  45136. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  45137. UNLIT: boolean;
  45138. DEBUGMODE: number;
  45139. /**
  45140. * Initializes the PBR Material defines.
  45141. */
  45142. constructor();
  45143. /**
  45144. * Resets the PBR Material defines.
  45145. */
  45146. reset(): void;
  45147. }
  45148. /**
  45149. * The Physically based material base class of BJS.
  45150. *
  45151. * This offers the main features of a standard PBR material.
  45152. * For more information, please refer to the documentation :
  45153. * https://doc.babylonjs.com/how_to/physically_based_rendering
  45154. */
  45155. export abstract class PBRBaseMaterial extends PushMaterial {
  45156. /**
  45157. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45158. */
  45159. static readonly PBRMATERIAL_OPAQUE: number;
  45160. /**
  45161. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45162. */
  45163. static readonly PBRMATERIAL_ALPHATEST: number;
  45164. /**
  45165. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45166. */
  45167. static readonly PBRMATERIAL_ALPHABLEND: number;
  45168. /**
  45169. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45170. * They are also discarded below the alpha cutoff threshold to improve performances.
  45171. */
  45172. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45173. /**
  45174. * Defines the default value of how much AO map is occluding the analytical lights
  45175. * (point spot...).
  45176. */
  45177. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45178. /**
  45179. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  45180. */
  45181. static readonly LIGHTFALLOFF_PHYSICAL: number;
  45182. /**
  45183. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  45184. * to enhance interoperability with other engines.
  45185. */
  45186. static readonly LIGHTFALLOFF_GLTF: number;
  45187. /**
  45188. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  45189. * to enhance interoperability with other materials.
  45190. */
  45191. static readonly LIGHTFALLOFF_STANDARD: number;
  45192. /**
  45193. * Intensity of the direct lights e.g. the four lights available in your scene.
  45194. * This impacts both the direct diffuse and specular highlights.
  45195. */
  45196. protected _directIntensity: number;
  45197. /**
  45198. * Intensity of the emissive part of the material.
  45199. * This helps controlling the emissive effect without modifying the emissive color.
  45200. */
  45201. protected _emissiveIntensity: number;
  45202. /**
  45203. * Intensity of the environment e.g. how much the environment will light the object
  45204. * either through harmonics for rough material or through the refelction for shiny ones.
  45205. */
  45206. protected _environmentIntensity: number;
  45207. /**
  45208. * This is a special control allowing the reduction of the specular highlights coming from the
  45209. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45210. */
  45211. protected _specularIntensity: number;
  45212. /**
  45213. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  45214. */
  45215. private _lightingInfos;
  45216. /**
  45217. * Debug Control allowing disabling the bump map on this material.
  45218. */
  45219. protected _disableBumpMap: boolean;
  45220. /**
  45221. * AKA Diffuse Texture in standard nomenclature.
  45222. */
  45223. protected _albedoTexture: Nullable<BaseTexture>;
  45224. /**
  45225. * AKA Occlusion Texture in other nomenclature.
  45226. */
  45227. protected _ambientTexture: Nullable<BaseTexture>;
  45228. /**
  45229. * AKA Occlusion Texture Intensity in other nomenclature.
  45230. */
  45231. protected _ambientTextureStrength: number;
  45232. /**
  45233. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45234. * 1 means it completely occludes it
  45235. * 0 mean it has no impact
  45236. */
  45237. protected _ambientTextureImpactOnAnalyticalLights: number;
  45238. /**
  45239. * Stores the alpha values in a texture.
  45240. */
  45241. protected _opacityTexture: Nullable<BaseTexture>;
  45242. /**
  45243. * Stores the reflection values in a texture.
  45244. */
  45245. protected _reflectionTexture: Nullable<BaseTexture>;
  45246. /**
  45247. * Stores the emissive values in a texture.
  45248. */
  45249. protected _emissiveTexture: Nullable<BaseTexture>;
  45250. /**
  45251. * AKA Specular texture in other nomenclature.
  45252. */
  45253. protected _reflectivityTexture: Nullable<BaseTexture>;
  45254. /**
  45255. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45256. */
  45257. protected _metallicTexture: Nullable<BaseTexture>;
  45258. /**
  45259. * Specifies the metallic scalar of the metallic/roughness workflow.
  45260. * Can also be used to scale the metalness values of the metallic texture.
  45261. */
  45262. protected _metallic: Nullable<number>;
  45263. /**
  45264. * Specifies the roughness scalar of the metallic/roughness workflow.
  45265. * Can also be used to scale the roughness values of the metallic texture.
  45266. */
  45267. protected _roughness: Nullable<number>;
  45268. /**
  45269. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45270. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45271. */
  45272. protected _microSurfaceTexture: Nullable<BaseTexture>;
  45273. /**
  45274. * Stores surface normal data used to displace a mesh in a texture.
  45275. */
  45276. protected _bumpTexture: Nullable<BaseTexture>;
  45277. /**
  45278. * Stores the pre-calculated light information of a mesh in a texture.
  45279. */
  45280. protected _lightmapTexture: Nullable<BaseTexture>;
  45281. /**
  45282. * The color of a material in ambient lighting.
  45283. */
  45284. protected _ambientColor: Color3;
  45285. /**
  45286. * AKA Diffuse Color in other nomenclature.
  45287. */
  45288. protected _albedoColor: Color3;
  45289. /**
  45290. * AKA Specular Color in other nomenclature.
  45291. */
  45292. protected _reflectivityColor: Color3;
  45293. /**
  45294. * The color applied when light is reflected from a material.
  45295. */
  45296. protected _reflectionColor: Color3;
  45297. /**
  45298. * The color applied when light is emitted from a material.
  45299. */
  45300. protected _emissiveColor: Color3;
  45301. /**
  45302. * AKA Glossiness in other nomenclature.
  45303. */
  45304. protected _microSurface: number;
  45305. /**
  45306. * Specifies that the material will use the light map as a show map.
  45307. */
  45308. protected _useLightmapAsShadowmap: boolean;
  45309. /**
  45310. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45311. * makes the reflect vector face the model (under horizon).
  45312. */
  45313. protected _useHorizonOcclusion: boolean;
  45314. /**
  45315. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45316. * too much the area relying on ambient texture to define their ambient occlusion.
  45317. */
  45318. protected _useRadianceOcclusion: boolean;
  45319. /**
  45320. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45321. */
  45322. protected _useAlphaFromAlbedoTexture: boolean;
  45323. /**
  45324. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  45325. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45326. */
  45327. protected _useSpecularOverAlpha: boolean;
  45328. /**
  45329. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45330. */
  45331. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45332. /**
  45333. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45334. */
  45335. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  45336. /**
  45337. * Specifies if the metallic texture contains the roughness information in its green channel.
  45338. */
  45339. protected _useRoughnessFromMetallicTextureGreen: boolean;
  45340. /**
  45341. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45342. */
  45343. protected _useMetallnessFromMetallicTextureBlue: boolean;
  45344. /**
  45345. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45346. */
  45347. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  45348. /**
  45349. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45350. */
  45351. protected _useAmbientInGrayScale: boolean;
  45352. /**
  45353. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45354. * The material will try to infer what glossiness each pixel should be.
  45355. */
  45356. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  45357. /**
  45358. * Defines the falloff type used in this material.
  45359. * It by default is Physical.
  45360. */
  45361. protected _lightFalloff: number;
  45362. /**
  45363. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45364. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45365. */
  45366. protected _useRadianceOverAlpha: boolean;
  45367. /**
  45368. * Allows using an object space normal map (instead of tangent space).
  45369. */
  45370. protected _useObjectSpaceNormalMap: boolean;
  45371. /**
  45372. * Allows using the bump map in parallax mode.
  45373. */
  45374. protected _useParallax: boolean;
  45375. /**
  45376. * Allows using the bump map in parallax occlusion mode.
  45377. */
  45378. protected _useParallaxOcclusion: boolean;
  45379. /**
  45380. * Controls the scale bias of the parallax mode.
  45381. */
  45382. protected _parallaxScaleBias: number;
  45383. /**
  45384. * If sets to true, disables all the lights affecting the material.
  45385. */
  45386. protected _disableLighting: boolean;
  45387. /**
  45388. * Number of Simultaneous lights allowed on the material.
  45389. */
  45390. protected _maxSimultaneousLights: number;
  45391. /**
  45392. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45393. */
  45394. protected _invertNormalMapX: boolean;
  45395. /**
  45396. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45397. */
  45398. protected _invertNormalMapY: boolean;
  45399. /**
  45400. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45401. */
  45402. protected _twoSidedLighting: boolean;
  45403. /**
  45404. * Defines the alpha limits in alpha test mode.
  45405. */
  45406. protected _alphaCutOff: number;
  45407. /**
  45408. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45409. */
  45410. protected _forceAlphaTest: boolean;
  45411. /**
  45412. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45413. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45414. */
  45415. protected _useAlphaFresnel: boolean;
  45416. /**
  45417. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45418. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45419. */
  45420. protected _useLinearAlphaFresnel: boolean;
  45421. /**
  45422. * The transparency mode of the material.
  45423. */
  45424. protected _transparencyMode: Nullable<number>;
  45425. /**
  45426. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  45427. * from cos thetav and roughness:
  45428. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  45429. */
  45430. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  45431. /**
  45432. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45433. */
  45434. protected _forceIrradianceInFragment: boolean;
  45435. /**
  45436. * Force normal to face away from face.
  45437. */
  45438. protected _forceNormalForward: boolean;
  45439. /**
  45440. * Enables specular anti aliasing in the PBR shader.
  45441. * It will both interacts on the Geometry for analytical and IBL lighting.
  45442. * It also prefilter the roughness map based on the bump values.
  45443. */
  45444. protected _enableSpecularAntiAliasing: boolean;
  45445. /**
  45446. * Default configuration related to image processing available in the PBR Material.
  45447. */
  45448. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45449. /**
  45450. * Keep track of the image processing observer to allow dispose and replace.
  45451. */
  45452. private _imageProcessingObserver;
  45453. /**
  45454. * Attaches a new image processing configuration to the PBR Material.
  45455. * @param configuration
  45456. */
  45457. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45458. /**
  45459. * Stores the available render targets.
  45460. */
  45461. private _renderTargets;
  45462. /**
  45463. * Sets the global ambient color for the material used in lighting calculations.
  45464. */
  45465. private _globalAmbientColor;
  45466. /**
  45467. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  45468. */
  45469. private _useLogarithmicDepth;
  45470. /**
  45471. * If set to true, no lighting calculations will be applied.
  45472. */
  45473. private _unlit;
  45474. private _debugMode;
  45475. /**
  45476. * @hidden
  45477. * This is reserved for the inspector.
  45478. * Defines the material debug mode.
  45479. * It helps seeing only some components of the material while troubleshooting.
  45480. */
  45481. debugMode: number;
  45482. /**
  45483. * @hidden
  45484. * This is reserved for the inspector.
  45485. * Specify from where on screen the debug mode should start.
  45486. * The value goes from -1 (full screen) to 1 (not visible)
  45487. * It helps with side by side comparison against the final render
  45488. * This defaults to -1
  45489. */
  45490. private debugLimit;
  45491. /**
  45492. * @hidden
  45493. * This is reserved for the inspector.
  45494. * As the default viewing range might not be enough (if the ambient is really small for instance)
  45495. * You can use the factor to better multiply the final value.
  45496. */
  45497. private debugFactor;
  45498. /**
  45499. * Defines the clear coat layer parameters for the material.
  45500. */
  45501. readonly clearCoat: PBRClearCoatConfiguration;
  45502. /**
  45503. * Defines the anisotropic parameters for the material.
  45504. */
  45505. readonly anisotropy: PBRAnisotropicConfiguration;
  45506. /**
  45507. * Defines the BRDF parameters for the material.
  45508. */
  45509. readonly brdf: PBRBRDFConfiguration;
  45510. /**
  45511. * Defines the Sheen parameters for the material.
  45512. */
  45513. readonly sheen: PBRSheenConfiguration;
  45514. /**
  45515. * Defines the SubSurface parameters for the material.
  45516. */
  45517. readonly subSurface: PBRSubSurfaceConfiguration;
  45518. /**
  45519. * Custom callback helping to override the default shader used in the material.
  45520. */
  45521. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  45522. /**
  45523. * Instantiates a new PBRMaterial instance.
  45524. *
  45525. * @param name The material name
  45526. * @param scene The scene the material will be use in.
  45527. */
  45528. constructor(name: string, scene: Scene);
  45529. /**
  45530. * Gets a boolean indicating that current material needs to register RTT
  45531. */
  45532. readonly hasRenderTargetTextures: boolean;
  45533. /**
  45534. * Gets the name of the material class.
  45535. */
  45536. getClassName(): string;
  45537. /**
  45538. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45539. */
  45540. /**
  45541. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45542. */
  45543. useLogarithmicDepth: boolean;
  45544. /**
  45545. * Gets the current transparency mode.
  45546. */
  45547. /**
  45548. * Sets the transparency mode of the material.
  45549. *
  45550. * | Value | Type | Description |
  45551. * | ----- | ----------------------------------- | ----------- |
  45552. * | 0 | OPAQUE | |
  45553. * | 1 | ALPHATEST | |
  45554. * | 2 | ALPHABLEND | |
  45555. * | 3 | ALPHATESTANDBLEND | |
  45556. *
  45557. */
  45558. transparencyMode: Nullable<number>;
  45559. /**
  45560. * Returns true if alpha blending should be disabled.
  45561. */
  45562. private readonly _disableAlphaBlending;
  45563. /**
  45564. * Specifies whether or not this material should be rendered in alpha blend mode.
  45565. */
  45566. needAlphaBlending(): boolean;
  45567. /**
  45568. * Specifies if the mesh will require alpha blending.
  45569. * @param mesh - BJS mesh.
  45570. */
  45571. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  45572. /**
  45573. * Specifies whether or not this material should be rendered in alpha test mode.
  45574. */
  45575. needAlphaTesting(): boolean;
  45576. /**
  45577. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  45578. */
  45579. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  45580. /**
  45581. * Gets the texture used for the alpha test.
  45582. */
  45583. getAlphaTestTexture(): Nullable<BaseTexture>;
  45584. /**
  45585. * Specifies that the submesh is ready to be used.
  45586. * @param mesh - BJS mesh.
  45587. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  45588. * @param useInstances - Specifies that instances should be used.
  45589. * @returns - boolean indicating that the submesh is ready or not.
  45590. */
  45591. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45592. /**
  45593. * Specifies if the material uses metallic roughness workflow.
  45594. * @returns boolean specifiying if the material uses metallic roughness workflow.
  45595. */
  45596. isMetallicWorkflow(): boolean;
  45597. private _prepareEffect;
  45598. private _prepareDefines;
  45599. /**
  45600. * Force shader compilation
  45601. */
  45602. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  45603. clipPlane: boolean;
  45604. }>): void;
  45605. /**
  45606. * Initializes the uniform buffer layout for the shader.
  45607. */
  45608. buildUniformLayout(): void;
  45609. /**
  45610. * Unbinds the material from the mesh
  45611. */
  45612. unbind(): void;
  45613. /**
  45614. * Binds the submesh data.
  45615. * @param world - The world matrix.
  45616. * @param mesh - The BJS mesh.
  45617. * @param subMesh - A submesh of the BJS mesh.
  45618. */
  45619. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45620. /**
  45621. * Returns the animatable textures.
  45622. * @returns - Array of animatable textures.
  45623. */
  45624. getAnimatables(): IAnimatable[];
  45625. /**
  45626. * Returns the texture used for reflections.
  45627. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  45628. */
  45629. private _getReflectionTexture;
  45630. /**
  45631. * Returns an array of the actively used textures.
  45632. * @returns - Array of BaseTextures
  45633. */
  45634. getActiveTextures(): BaseTexture[];
  45635. /**
  45636. * Checks to see if a texture is used in the material.
  45637. * @param texture - Base texture to use.
  45638. * @returns - Boolean specifying if a texture is used in the material.
  45639. */
  45640. hasTexture(texture: BaseTexture): boolean;
  45641. /**
  45642. * Disposes the resources of the material.
  45643. * @param forceDisposeEffect - Forces the disposal of effects.
  45644. * @param forceDisposeTextures - Forces the disposal of all textures.
  45645. */
  45646. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45647. }
  45648. }
  45649. declare module BABYLON {
  45650. /**
  45651. * The Physically based material of BJS.
  45652. *
  45653. * This offers the main features of a standard PBR material.
  45654. * For more information, please refer to the documentation :
  45655. * https://doc.babylonjs.com/how_to/physically_based_rendering
  45656. */
  45657. export class PBRMaterial extends PBRBaseMaterial {
  45658. /**
  45659. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45660. */
  45661. static readonly PBRMATERIAL_OPAQUE: number;
  45662. /**
  45663. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45664. */
  45665. static readonly PBRMATERIAL_ALPHATEST: number;
  45666. /**
  45667. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45668. */
  45669. static readonly PBRMATERIAL_ALPHABLEND: number;
  45670. /**
  45671. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45672. * They are also discarded below the alpha cutoff threshold to improve performances.
  45673. */
  45674. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45675. /**
  45676. * Defines the default value of how much AO map is occluding the analytical lights
  45677. * (point spot...).
  45678. */
  45679. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45680. /**
  45681. * Intensity of the direct lights e.g. the four lights available in your scene.
  45682. * This impacts both the direct diffuse and specular highlights.
  45683. */
  45684. directIntensity: number;
  45685. /**
  45686. * Intensity of the emissive part of the material.
  45687. * This helps controlling the emissive effect without modifying the emissive color.
  45688. */
  45689. emissiveIntensity: number;
  45690. /**
  45691. * Intensity of the environment e.g. how much the environment will light the object
  45692. * either through harmonics for rough material or through the refelction for shiny ones.
  45693. */
  45694. environmentIntensity: number;
  45695. /**
  45696. * This is a special control allowing the reduction of the specular highlights coming from the
  45697. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45698. */
  45699. specularIntensity: number;
  45700. /**
  45701. * Debug Control allowing disabling the bump map on this material.
  45702. */
  45703. disableBumpMap: boolean;
  45704. /**
  45705. * AKA Diffuse Texture in standard nomenclature.
  45706. */
  45707. albedoTexture: BaseTexture;
  45708. /**
  45709. * AKA Occlusion Texture in other nomenclature.
  45710. */
  45711. ambientTexture: BaseTexture;
  45712. /**
  45713. * AKA Occlusion Texture Intensity in other nomenclature.
  45714. */
  45715. ambientTextureStrength: number;
  45716. /**
  45717. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45718. * 1 means it completely occludes it
  45719. * 0 mean it has no impact
  45720. */
  45721. ambientTextureImpactOnAnalyticalLights: number;
  45722. /**
  45723. * Stores the alpha values in a texture.
  45724. */
  45725. opacityTexture: BaseTexture;
  45726. /**
  45727. * Stores the reflection values in a texture.
  45728. */
  45729. reflectionTexture: Nullable<BaseTexture>;
  45730. /**
  45731. * Stores the emissive values in a texture.
  45732. */
  45733. emissiveTexture: BaseTexture;
  45734. /**
  45735. * AKA Specular texture in other nomenclature.
  45736. */
  45737. reflectivityTexture: BaseTexture;
  45738. /**
  45739. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45740. */
  45741. metallicTexture: BaseTexture;
  45742. /**
  45743. * Specifies the metallic scalar of the metallic/roughness workflow.
  45744. * Can also be used to scale the metalness values of the metallic texture.
  45745. */
  45746. metallic: Nullable<number>;
  45747. /**
  45748. * Specifies the roughness scalar of the metallic/roughness workflow.
  45749. * Can also be used to scale the roughness values of the metallic texture.
  45750. */
  45751. roughness: Nullable<number>;
  45752. /**
  45753. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45754. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45755. */
  45756. microSurfaceTexture: BaseTexture;
  45757. /**
  45758. * Stores surface normal data used to displace a mesh in a texture.
  45759. */
  45760. bumpTexture: BaseTexture;
  45761. /**
  45762. * Stores the pre-calculated light information of a mesh in a texture.
  45763. */
  45764. lightmapTexture: BaseTexture;
  45765. /**
  45766. * Stores the refracted light information in a texture.
  45767. */
  45768. refractionTexture: Nullable<BaseTexture>;
  45769. /**
  45770. * The color of a material in ambient lighting.
  45771. */
  45772. ambientColor: Color3;
  45773. /**
  45774. * AKA Diffuse Color in other nomenclature.
  45775. */
  45776. albedoColor: Color3;
  45777. /**
  45778. * AKA Specular Color in other nomenclature.
  45779. */
  45780. reflectivityColor: Color3;
  45781. /**
  45782. * The color reflected from the material.
  45783. */
  45784. reflectionColor: Color3;
  45785. /**
  45786. * The color emitted from the material.
  45787. */
  45788. emissiveColor: Color3;
  45789. /**
  45790. * AKA Glossiness in other nomenclature.
  45791. */
  45792. microSurface: number;
  45793. /**
  45794. * source material index of refraction (IOR)' / 'destination material IOR.
  45795. */
  45796. indexOfRefraction: number;
  45797. /**
  45798. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45799. */
  45800. invertRefractionY: boolean;
  45801. /**
  45802. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45803. * Materials half opaque for instance using refraction could benefit from this control.
  45804. */
  45805. linkRefractionWithTransparency: boolean;
  45806. /**
  45807. * If true, the light map contains occlusion information instead of lighting info.
  45808. */
  45809. useLightmapAsShadowmap: boolean;
  45810. /**
  45811. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45812. */
  45813. useAlphaFromAlbedoTexture: boolean;
  45814. /**
  45815. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45816. */
  45817. forceAlphaTest: boolean;
  45818. /**
  45819. * Defines the alpha limits in alpha test mode.
  45820. */
  45821. alphaCutOff: number;
  45822. /**
  45823. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  45824. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45825. */
  45826. useSpecularOverAlpha: boolean;
  45827. /**
  45828. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45829. */
  45830. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45831. /**
  45832. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45833. */
  45834. useRoughnessFromMetallicTextureAlpha: boolean;
  45835. /**
  45836. * Specifies if the metallic texture contains the roughness information in its green channel.
  45837. */
  45838. useRoughnessFromMetallicTextureGreen: boolean;
  45839. /**
  45840. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45841. */
  45842. useMetallnessFromMetallicTextureBlue: boolean;
  45843. /**
  45844. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45845. */
  45846. useAmbientOcclusionFromMetallicTextureRed: boolean;
  45847. /**
  45848. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45849. */
  45850. useAmbientInGrayScale: boolean;
  45851. /**
  45852. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45853. * The material will try to infer what glossiness each pixel should be.
  45854. */
  45855. useAutoMicroSurfaceFromReflectivityMap: boolean;
  45856. /**
  45857. * BJS is using an harcoded light falloff based on a manually sets up range.
  45858. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45859. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45860. */
  45861. /**
  45862. * BJS is using an harcoded light falloff based on a manually sets up range.
  45863. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45864. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45865. */
  45866. usePhysicalLightFalloff: boolean;
  45867. /**
  45868. * In order to support the falloff compatibility with gltf, a special mode has been added
  45869. * to reproduce the gltf light falloff.
  45870. */
  45871. /**
  45872. * In order to support the falloff compatibility with gltf, a special mode has been added
  45873. * to reproduce the gltf light falloff.
  45874. */
  45875. useGLTFLightFalloff: boolean;
  45876. /**
  45877. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45878. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45879. */
  45880. useRadianceOverAlpha: boolean;
  45881. /**
  45882. * Allows using an object space normal map (instead of tangent space).
  45883. */
  45884. useObjectSpaceNormalMap: boolean;
  45885. /**
  45886. * Allows using the bump map in parallax mode.
  45887. */
  45888. useParallax: boolean;
  45889. /**
  45890. * Allows using the bump map in parallax occlusion mode.
  45891. */
  45892. useParallaxOcclusion: boolean;
  45893. /**
  45894. * Controls the scale bias of the parallax mode.
  45895. */
  45896. parallaxScaleBias: number;
  45897. /**
  45898. * If sets to true, disables all the lights affecting the material.
  45899. */
  45900. disableLighting: boolean;
  45901. /**
  45902. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45903. */
  45904. forceIrradianceInFragment: boolean;
  45905. /**
  45906. * Number of Simultaneous lights allowed on the material.
  45907. */
  45908. maxSimultaneousLights: number;
  45909. /**
  45910. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45911. */
  45912. invertNormalMapX: boolean;
  45913. /**
  45914. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45915. */
  45916. invertNormalMapY: boolean;
  45917. /**
  45918. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45919. */
  45920. twoSidedLighting: boolean;
  45921. /**
  45922. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45923. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45924. */
  45925. useAlphaFresnel: boolean;
  45926. /**
  45927. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45928. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45929. */
  45930. useLinearAlphaFresnel: boolean;
  45931. /**
  45932. * Let user defines the brdf lookup texture used for IBL.
  45933. * A default 8bit version is embedded but you could point at :
  45934. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  45935. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  45936. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45937. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  45938. */
  45939. environmentBRDFTexture: Nullable<BaseTexture>;
  45940. /**
  45941. * Force normal to face away from face.
  45942. */
  45943. forceNormalForward: boolean;
  45944. /**
  45945. * Enables specular anti aliasing in the PBR shader.
  45946. * It will both interacts on the Geometry for analytical and IBL lighting.
  45947. * It also prefilter the roughness map based on the bump values.
  45948. */
  45949. enableSpecularAntiAliasing: boolean;
  45950. /**
  45951. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45952. * makes the reflect vector face the model (under horizon).
  45953. */
  45954. useHorizonOcclusion: boolean;
  45955. /**
  45956. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45957. * too much the area relying on ambient texture to define their ambient occlusion.
  45958. */
  45959. useRadianceOcclusion: boolean;
  45960. /**
  45961. * If set to true, no lighting calculations will be applied.
  45962. */
  45963. unlit: boolean;
  45964. /**
  45965. * Gets the image processing configuration used either in this material.
  45966. */
  45967. /**
  45968. * Sets the Default image processing configuration used either in the this material.
  45969. *
  45970. * If sets to null, the scene one is in use.
  45971. */
  45972. imageProcessingConfiguration: ImageProcessingConfiguration;
  45973. /**
  45974. * Gets wether the color curves effect is enabled.
  45975. */
  45976. /**
  45977. * Sets wether the color curves effect is enabled.
  45978. */
  45979. cameraColorCurvesEnabled: boolean;
  45980. /**
  45981. * Gets wether the color grading effect is enabled.
  45982. */
  45983. /**
  45984. * Gets wether the color grading effect is enabled.
  45985. */
  45986. cameraColorGradingEnabled: boolean;
  45987. /**
  45988. * Gets wether tonemapping is enabled or not.
  45989. */
  45990. /**
  45991. * Sets wether tonemapping is enabled or not
  45992. */
  45993. cameraToneMappingEnabled: boolean;
  45994. /**
  45995. * The camera exposure used on this material.
  45996. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45997. * This corresponds to a photographic exposure.
  45998. */
  45999. /**
  46000. * The camera exposure used on this material.
  46001. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46002. * This corresponds to a photographic exposure.
  46003. */
  46004. cameraExposure: number;
  46005. /**
  46006. * Gets The camera contrast used on this material.
  46007. */
  46008. /**
  46009. * Sets The camera contrast used on this material.
  46010. */
  46011. cameraContrast: number;
  46012. /**
  46013. * Gets the Color Grading 2D Lookup Texture.
  46014. */
  46015. /**
  46016. * Sets the Color Grading 2D Lookup Texture.
  46017. */
  46018. cameraColorGradingTexture: Nullable<BaseTexture>;
  46019. /**
  46020. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46021. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46022. * 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;
  46023. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46024. */
  46025. /**
  46026. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46027. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46028. * 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;
  46029. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46030. */
  46031. cameraColorCurves: Nullable<ColorCurves>;
  46032. /**
  46033. * Instantiates a new PBRMaterial instance.
  46034. *
  46035. * @param name The material name
  46036. * @param scene The scene the material will be use in.
  46037. */
  46038. constructor(name: string, scene: Scene);
  46039. /**
  46040. * Returns the name of this material class.
  46041. */
  46042. getClassName(): string;
  46043. /**
  46044. * Makes a duplicate of the current material.
  46045. * @param name - name to use for the new material.
  46046. */
  46047. clone(name: string): PBRMaterial;
  46048. /**
  46049. * Serializes this PBR Material.
  46050. * @returns - An object with the serialized material.
  46051. */
  46052. serialize(): any;
  46053. /**
  46054. * Parses a PBR Material from a serialized object.
  46055. * @param source - Serialized object.
  46056. * @param scene - BJS scene instance.
  46057. * @param rootUrl - url for the scene object
  46058. * @returns - PBRMaterial
  46059. */
  46060. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  46061. }
  46062. }
  46063. declare module BABYLON {
  46064. /**
  46065. * Direct draw surface info
  46066. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  46067. */
  46068. export interface DDSInfo {
  46069. /**
  46070. * Width of the texture
  46071. */
  46072. width: number;
  46073. /**
  46074. * Width of the texture
  46075. */
  46076. height: number;
  46077. /**
  46078. * Number of Mipmaps for the texture
  46079. * @see https://en.wikipedia.org/wiki/Mipmap
  46080. */
  46081. mipmapCount: number;
  46082. /**
  46083. * If the textures format is a known fourCC format
  46084. * @see https://www.fourcc.org/
  46085. */
  46086. isFourCC: boolean;
  46087. /**
  46088. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  46089. */
  46090. isRGB: boolean;
  46091. /**
  46092. * If the texture is a lumincance format
  46093. */
  46094. isLuminance: boolean;
  46095. /**
  46096. * If this is a cube texture
  46097. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  46098. */
  46099. isCube: boolean;
  46100. /**
  46101. * If the texture is a compressed format eg. FOURCC_DXT1
  46102. */
  46103. isCompressed: boolean;
  46104. /**
  46105. * The dxgiFormat of the texture
  46106. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  46107. */
  46108. dxgiFormat: number;
  46109. /**
  46110. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  46111. */
  46112. textureType: number;
  46113. /**
  46114. * Sphericle polynomial created for the dds texture
  46115. */
  46116. sphericalPolynomial?: SphericalPolynomial;
  46117. }
  46118. /**
  46119. * Class used to provide DDS decompression tools
  46120. */
  46121. export class DDSTools {
  46122. /**
  46123. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  46124. */
  46125. static StoreLODInAlphaChannel: boolean;
  46126. /**
  46127. * Gets DDS information from an array buffer
  46128. * @param arrayBuffer defines the array buffer to read data from
  46129. * @returns the DDS information
  46130. */
  46131. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  46132. private static _FloatView;
  46133. private static _Int32View;
  46134. private static _ToHalfFloat;
  46135. private static _FromHalfFloat;
  46136. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  46137. private static _GetHalfFloatRGBAArrayBuffer;
  46138. private static _GetFloatRGBAArrayBuffer;
  46139. private static _GetFloatAsUIntRGBAArrayBuffer;
  46140. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  46141. private static _GetRGBAArrayBuffer;
  46142. private static _ExtractLongWordOrder;
  46143. private static _GetRGBArrayBuffer;
  46144. private static _GetLuminanceArrayBuffer;
  46145. /**
  46146. * Uploads DDS Levels to a Babylon Texture
  46147. * @hidden
  46148. */
  46149. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  46150. }
  46151. interface Engine {
  46152. /**
  46153. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  46154. * @param rootUrl defines the url where the file to load is located
  46155. * @param scene defines the current scene
  46156. * @param lodScale defines scale to apply to the mip map selection
  46157. * @param lodOffset defines offset to apply to the mip map selection
  46158. * @param onLoad defines an optional callback raised when the texture is loaded
  46159. * @param onError defines an optional callback raised if there is an issue to load the texture
  46160. * @param format defines the format of the data
  46161. * @param forcedExtension defines the extension to use to pick the right loader
  46162. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  46163. * @returns the cube texture as an InternalTexture
  46164. */
  46165. 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;
  46166. }
  46167. }
  46168. declare module BABYLON {
  46169. /**
  46170. * Implementation of the DDS Texture Loader.
  46171. * @hidden
  46172. */
  46173. export class _DDSTextureLoader implements IInternalTextureLoader {
  46174. /**
  46175. * Defines wether the loader supports cascade loading the different faces.
  46176. */
  46177. readonly supportCascades: boolean;
  46178. /**
  46179. * This returns if the loader support the current file information.
  46180. * @param extension defines the file extension of the file being loaded
  46181. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46182. * @param fallback defines the fallback internal texture if any
  46183. * @param isBase64 defines whether the texture is encoded as a base64
  46184. * @param isBuffer defines whether the texture data are stored as a buffer
  46185. * @returns true if the loader can load the specified file
  46186. */
  46187. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46188. /**
  46189. * Transform the url before loading if required.
  46190. * @param rootUrl the url of the texture
  46191. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46192. * @returns the transformed texture
  46193. */
  46194. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46195. /**
  46196. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46197. * @param rootUrl the url of the texture
  46198. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46199. * @returns the fallback texture
  46200. */
  46201. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46202. /**
  46203. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46204. * @param data contains the texture data
  46205. * @param texture defines the BabylonJS internal texture
  46206. * @param createPolynomials will be true if polynomials have been requested
  46207. * @param onLoad defines the callback to trigger once the texture is ready
  46208. * @param onError defines the callback to trigger in case of error
  46209. */
  46210. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46211. /**
  46212. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46213. * @param data contains the texture data
  46214. * @param texture defines the BabylonJS internal texture
  46215. * @param callback defines the method to call once ready to upload
  46216. */
  46217. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46218. }
  46219. }
  46220. declare module BABYLON {
  46221. /** @hidden */
  46222. export var rgbdEncodePixelShader: {
  46223. name: string;
  46224. shader: string;
  46225. };
  46226. }
  46227. declare module BABYLON {
  46228. /**
  46229. * Raw texture data and descriptor sufficient for WebGL texture upload
  46230. */
  46231. export interface EnvironmentTextureInfo {
  46232. /**
  46233. * Version of the environment map
  46234. */
  46235. version: number;
  46236. /**
  46237. * Width of image
  46238. */
  46239. width: number;
  46240. /**
  46241. * Irradiance information stored in the file.
  46242. */
  46243. irradiance: any;
  46244. /**
  46245. * Specular information stored in the file.
  46246. */
  46247. specular: any;
  46248. }
  46249. /**
  46250. * Sets of helpers addressing the serialization and deserialization of environment texture
  46251. * stored in a BabylonJS env file.
  46252. * Those files are usually stored as .env files.
  46253. */
  46254. export class EnvironmentTextureTools {
  46255. /**
  46256. * Magic number identifying the env file.
  46257. */
  46258. private static _MagicBytes;
  46259. /**
  46260. * Gets the environment info from an env file.
  46261. * @param data The array buffer containing the .env bytes.
  46262. * @returns the environment file info (the json header) if successfully parsed.
  46263. */
  46264. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46265. /**
  46266. * Creates an environment texture from a loaded cube texture.
  46267. * @param texture defines the cube texture to convert in env file
  46268. * @return a promise containing the environment data if succesfull.
  46269. */
  46270. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46271. /**
  46272. * Creates a JSON representation of the spherical data.
  46273. * @param texture defines the texture containing the polynomials
  46274. * @return the JSON representation of the spherical info
  46275. */
  46276. private static _CreateEnvTextureIrradiance;
  46277. /**
  46278. * Uploads the texture info contained in the env file to the GPU.
  46279. * @param texture defines the internal texture to upload to
  46280. * @param arrayBuffer defines the buffer cotaining the data to load
  46281. * @param info defines the texture info retrieved through the GetEnvInfo method
  46282. * @returns a promise
  46283. */
  46284. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46285. /**
  46286. * Uploads the levels of image data to the GPU.
  46287. * @param texture defines the internal texture to upload to
  46288. * @param imageData defines the array buffer views of image data [mipmap][face]
  46289. * @returns a promise
  46290. */
  46291. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46292. /**
  46293. * Uploads spherical polynomials information to the texture.
  46294. * @param texture defines the texture we are trying to upload the information to
  46295. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46296. */
  46297. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46298. /** @hidden */
  46299. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46300. }
  46301. }
  46302. declare module BABYLON {
  46303. /**
  46304. * Implementation of the ENV Texture Loader.
  46305. * @hidden
  46306. */
  46307. export class _ENVTextureLoader implements IInternalTextureLoader {
  46308. /**
  46309. * Defines wether the loader supports cascade loading the different faces.
  46310. */
  46311. readonly supportCascades: boolean;
  46312. /**
  46313. * This returns if the loader support the current file information.
  46314. * @param extension defines the file extension of the file being loaded
  46315. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46316. * @param fallback defines the fallback internal texture if any
  46317. * @param isBase64 defines whether the texture is encoded as a base64
  46318. * @param isBuffer defines whether the texture data are stored as a buffer
  46319. * @returns true if the loader can load the specified file
  46320. */
  46321. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46322. /**
  46323. * Transform the url before loading if required.
  46324. * @param rootUrl the url of the texture
  46325. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46326. * @returns the transformed texture
  46327. */
  46328. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46329. /**
  46330. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46331. * @param rootUrl the url of the texture
  46332. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46333. * @returns the fallback texture
  46334. */
  46335. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46336. /**
  46337. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46338. * @param data contains the texture data
  46339. * @param texture defines the BabylonJS internal texture
  46340. * @param createPolynomials will be true if polynomials have been requested
  46341. * @param onLoad defines the callback to trigger once the texture is ready
  46342. * @param onError defines the callback to trigger in case of error
  46343. */
  46344. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46345. /**
  46346. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46347. * @param data contains the texture data
  46348. * @param texture defines the BabylonJS internal texture
  46349. * @param callback defines the method to call once ready to upload
  46350. */
  46351. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46352. }
  46353. }
  46354. declare module BABYLON {
  46355. /**
  46356. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  46357. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  46358. */
  46359. export class KhronosTextureContainer {
  46360. /** contents of the KTX container file */
  46361. arrayBuffer: any;
  46362. private static HEADER_LEN;
  46363. private static COMPRESSED_2D;
  46364. private static COMPRESSED_3D;
  46365. private static TEX_2D;
  46366. private static TEX_3D;
  46367. /**
  46368. * Gets the openGL type
  46369. */
  46370. glType: number;
  46371. /**
  46372. * Gets the openGL type size
  46373. */
  46374. glTypeSize: number;
  46375. /**
  46376. * Gets the openGL format
  46377. */
  46378. glFormat: number;
  46379. /**
  46380. * Gets the openGL internal format
  46381. */
  46382. glInternalFormat: number;
  46383. /**
  46384. * Gets the base internal format
  46385. */
  46386. glBaseInternalFormat: number;
  46387. /**
  46388. * Gets image width in pixel
  46389. */
  46390. pixelWidth: number;
  46391. /**
  46392. * Gets image height in pixel
  46393. */
  46394. pixelHeight: number;
  46395. /**
  46396. * Gets image depth in pixels
  46397. */
  46398. pixelDepth: number;
  46399. /**
  46400. * Gets the number of array elements
  46401. */
  46402. numberOfArrayElements: number;
  46403. /**
  46404. * Gets the number of faces
  46405. */
  46406. numberOfFaces: number;
  46407. /**
  46408. * Gets the number of mipmap levels
  46409. */
  46410. numberOfMipmapLevels: number;
  46411. /**
  46412. * Gets the bytes of key value data
  46413. */
  46414. bytesOfKeyValueData: number;
  46415. /**
  46416. * Gets the load type
  46417. */
  46418. loadType: number;
  46419. /**
  46420. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  46421. */
  46422. isInvalid: boolean;
  46423. /**
  46424. * Creates a new KhronosTextureContainer
  46425. * @param arrayBuffer contents of the KTX container file
  46426. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  46427. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  46428. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  46429. */
  46430. constructor(
  46431. /** contents of the KTX container file */
  46432. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  46433. /**
  46434. * Uploads KTX content to a Babylon Texture.
  46435. * It is assumed that the texture has already been created & is currently bound
  46436. * @hidden
  46437. */
  46438. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  46439. private _upload2DCompressedLevels;
  46440. }
  46441. }
  46442. declare module BABYLON {
  46443. /**
  46444. * Implementation of the KTX Texture Loader.
  46445. * @hidden
  46446. */
  46447. export class _KTXTextureLoader implements IInternalTextureLoader {
  46448. /**
  46449. * Defines wether the loader supports cascade loading the different faces.
  46450. */
  46451. readonly supportCascades: boolean;
  46452. /**
  46453. * This returns if the loader support the current file information.
  46454. * @param extension defines the file extension of the file being loaded
  46455. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46456. * @param fallback defines the fallback internal texture if any
  46457. * @param isBase64 defines whether the texture is encoded as a base64
  46458. * @param isBuffer defines whether the texture data are stored as a buffer
  46459. * @returns true if the loader can load the specified file
  46460. */
  46461. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46462. /**
  46463. * Transform the url before loading if required.
  46464. * @param rootUrl the url of the texture
  46465. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46466. * @returns the transformed texture
  46467. */
  46468. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46469. /**
  46470. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46471. * @param rootUrl the url of the texture
  46472. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46473. * @returns the fallback texture
  46474. */
  46475. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46476. /**
  46477. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46478. * @param data contains the texture data
  46479. * @param texture defines the BabylonJS internal texture
  46480. * @param createPolynomials will be true if polynomials have been requested
  46481. * @param onLoad defines the callback to trigger once the texture is ready
  46482. * @param onError defines the callback to trigger in case of error
  46483. */
  46484. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46485. /**
  46486. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46487. * @param data contains the texture data
  46488. * @param texture defines the BabylonJS internal texture
  46489. * @param callback defines the method to call once ready to upload
  46490. */
  46491. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  46492. }
  46493. }
  46494. declare module BABYLON {
  46495. /** @hidden */
  46496. export var _forceSceneHelpersToBundle: boolean;
  46497. interface Scene {
  46498. /**
  46499. * Creates a default light for the scene.
  46500. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  46501. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  46502. */
  46503. createDefaultLight(replace?: boolean): void;
  46504. /**
  46505. * Creates a default camera for the scene.
  46506. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  46507. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46508. * @param replace has default false, when true replaces the active camera in the scene
  46509. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  46510. */
  46511. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46512. /**
  46513. * Creates a default camera and a default light.
  46514. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  46515. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46516. * @param replace has the default false, when true replaces the active camera/light in the scene
  46517. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  46518. */
  46519. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46520. /**
  46521. * Creates a new sky box
  46522. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  46523. * @param environmentTexture defines the texture to use as environment texture
  46524. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  46525. * @param scale defines the overall scale of the skybox
  46526. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  46527. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  46528. * @returns a new mesh holding the sky box
  46529. */
  46530. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  46531. /**
  46532. * Creates a new environment
  46533. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  46534. * @param options defines the options you can use to configure the environment
  46535. * @returns the new EnvironmentHelper
  46536. */
  46537. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  46538. /**
  46539. * Creates a new VREXperienceHelper
  46540. * @see http://doc.babylonjs.com/how_to/webvr_helper
  46541. * @param webVROptions defines the options used to create the new VREXperienceHelper
  46542. * @returns a new VREXperienceHelper
  46543. */
  46544. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  46545. /**
  46546. * Creates a new XREXperienceHelper
  46547. * @see http://doc.babylonjs.com/how_to/webxr
  46548. * @returns a promise for a new XREXperienceHelper
  46549. */
  46550. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  46551. }
  46552. }
  46553. declare module BABYLON {
  46554. /**
  46555. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  46556. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  46557. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  46558. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46559. */
  46560. export class VideoDome extends TransformNode {
  46561. /**
  46562. * Define the video source as a Monoscopic panoramic 360 video.
  46563. */
  46564. static readonly MODE_MONOSCOPIC: number;
  46565. /**
  46566. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46567. */
  46568. static readonly MODE_TOPBOTTOM: number;
  46569. /**
  46570. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46571. */
  46572. static readonly MODE_SIDEBYSIDE: number;
  46573. private _useDirectMapping;
  46574. /**
  46575. * The video texture being displayed on the sphere
  46576. */
  46577. protected _videoTexture: VideoTexture;
  46578. /**
  46579. * Gets the video texture being displayed on the sphere
  46580. */
  46581. readonly videoTexture: VideoTexture;
  46582. /**
  46583. * The skybox material
  46584. */
  46585. protected _material: BackgroundMaterial;
  46586. /**
  46587. * The surface used for the skybox
  46588. */
  46589. protected _mesh: Mesh;
  46590. /**
  46591. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46592. * Also see the options.resolution property.
  46593. */
  46594. fovMultiplier: number;
  46595. private _videoMode;
  46596. /**
  46597. * Gets or set the current video mode for the video. It can be:
  46598. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  46599. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46600. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46601. */
  46602. videoMode: number;
  46603. /**
  46604. * Oberserver used in Stereoscopic VR Mode.
  46605. */
  46606. private _onBeforeCameraRenderObserver;
  46607. /**
  46608. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  46609. * @param name Element's name, child elements will append suffixes for their own names.
  46610. * @param urlsOrVideo defines the url(s) or the video element to use
  46611. * @param options An object containing optional or exposed sub element properties
  46612. */
  46613. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  46614. resolution?: number;
  46615. clickToPlay?: boolean;
  46616. autoPlay?: boolean;
  46617. loop?: boolean;
  46618. size?: number;
  46619. poster?: string;
  46620. faceForward?: boolean;
  46621. useDirectMapping?: boolean;
  46622. }, scene: Scene);
  46623. private _changeVideoMode;
  46624. /**
  46625. * Releases resources associated with this node.
  46626. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46627. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46628. */
  46629. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46630. }
  46631. }
  46632. declare module BABYLON {
  46633. /**
  46634. * This class can be used to get instrumentation data from a Babylon engine
  46635. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  46636. */
  46637. export class EngineInstrumentation implements IDisposable {
  46638. /**
  46639. * Define the instrumented engine.
  46640. */
  46641. engine: Engine;
  46642. private _captureGPUFrameTime;
  46643. private _gpuFrameTimeToken;
  46644. private _gpuFrameTime;
  46645. private _captureShaderCompilationTime;
  46646. private _shaderCompilationTime;
  46647. private _onBeginFrameObserver;
  46648. private _onEndFrameObserver;
  46649. private _onBeforeShaderCompilationObserver;
  46650. private _onAfterShaderCompilationObserver;
  46651. /**
  46652. * Gets the perf counter used for GPU frame time
  46653. */
  46654. readonly gpuFrameTimeCounter: PerfCounter;
  46655. /**
  46656. * Gets the GPU frame time capture status
  46657. */
  46658. /**
  46659. * Enable or disable the GPU frame time capture
  46660. */
  46661. captureGPUFrameTime: boolean;
  46662. /**
  46663. * Gets the perf counter used for shader compilation time
  46664. */
  46665. readonly shaderCompilationTimeCounter: PerfCounter;
  46666. /**
  46667. * Gets the shader compilation time capture status
  46668. */
  46669. /**
  46670. * Enable or disable the shader compilation time capture
  46671. */
  46672. captureShaderCompilationTime: boolean;
  46673. /**
  46674. * Instantiates a new engine instrumentation.
  46675. * This class can be used to get instrumentation data from a Babylon engine
  46676. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  46677. * @param engine Defines the engine to instrument
  46678. */
  46679. constructor(
  46680. /**
  46681. * Define the instrumented engine.
  46682. */
  46683. engine: Engine);
  46684. /**
  46685. * Dispose and release associated resources.
  46686. */
  46687. dispose(): void;
  46688. }
  46689. }
  46690. declare module BABYLON {
  46691. /**
  46692. * This class can be used to get instrumentation data from a Babylon engine
  46693. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  46694. */
  46695. export class SceneInstrumentation implements IDisposable {
  46696. /**
  46697. * Defines the scene to instrument
  46698. */
  46699. scene: Scene;
  46700. private _captureActiveMeshesEvaluationTime;
  46701. private _activeMeshesEvaluationTime;
  46702. private _captureRenderTargetsRenderTime;
  46703. private _renderTargetsRenderTime;
  46704. private _captureFrameTime;
  46705. private _frameTime;
  46706. private _captureRenderTime;
  46707. private _renderTime;
  46708. private _captureInterFrameTime;
  46709. private _interFrameTime;
  46710. private _captureParticlesRenderTime;
  46711. private _particlesRenderTime;
  46712. private _captureSpritesRenderTime;
  46713. private _spritesRenderTime;
  46714. private _capturePhysicsTime;
  46715. private _physicsTime;
  46716. private _captureAnimationsTime;
  46717. private _animationsTime;
  46718. private _captureCameraRenderTime;
  46719. private _cameraRenderTime;
  46720. private _onBeforeActiveMeshesEvaluationObserver;
  46721. private _onAfterActiveMeshesEvaluationObserver;
  46722. private _onBeforeRenderTargetsRenderObserver;
  46723. private _onAfterRenderTargetsRenderObserver;
  46724. private _onAfterRenderObserver;
  46725. private _onBeforeDrawPhaseObserver;
  46726. private _onAfterDrawPhaseObserver;
  46727. private _onBeforeAnimationsObserver;
  46728. private _onBeforeParticlesRenderingObserver;
  46729. private _onAfterParticlesRenderingObserver;
  46730. private _onBeforeSpritesRenderingObserver;
  46731. private _onAfterSpritesRenderingObserver;
  46732. private _onBeforePhysicsObserver;
  46733. private _onAfterPhysicsObserver;
  46734. private _onAfterAnimationsObserver;
  46735. private _onBeforeCameraRenderObserver;
  46736. private _onAfterCameraRenderObserver;
  46737. /**
  46738. * Gets the perf counter used for active meshes evaluation time
  46739. */
  46740. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  46741. /**
  46742. * Gets the active meshes evaluation time capture status
  46743. */
  46744. /**
  46745. * Enable or disable the active meshes evaluation time capture
  46746. */
  46747. captureActiveMeshesEvaluationTime: boolean;
  46748. /**
  46749. * Gets the perf counter used for render targets render time
  46750. */
  46751. readonly renderTargetsRenderTimeCounter: PerfCounter;
  46752. /**
  46753. * Gets the render targets render time capture status
  46754. */
  46755. /**
  46756. * Enable or disable the render targets render time capture
  46757. */
  46758. captureRenderTargetsRenderTime: boolean;
  46759. /**
  46760. * Gets the perf counter used for particles render time
  46761. */
  46762. readonly particlesRenderTimeCounter: PerfCounter;
  46763. /**
  46764. * Gets the particles render time capture status
  46765. */
  46766. /**
  46767. * Enable or disable the particles render time capture
  46768. */
  46769. captureParticlesRenderTime: boolean;
  46770. /**
  46771. * Gets the perf counter used for sprites render time
  46772. */
  46773. readonly spritesRenderTimeCounter: PerfCounter;
  46774. /**
  46775. * Gets the sprites render time capture status
  46776. */
  46777. /**
  46778. * Enable or disable the sprites render time capture
  46779. */
  46780. captureSpritesRenderTime: boolean;
  46781. /**
  46782. * Gets the perf counter used for physics time
  46783. */
  46784. readonly physicsTimeCounter: PerfCounter;
  46785. /**
  46786. * Gets the physics time capture status
  46787. */
  46788. /**
  46789. * Enable or disable the physics time capture
  46790. */
  46791. capturePhysicsTime: boolean;
  46792. /**
  46793. * Gets the perf counter used for animations time
  46794. */
  46795. readonly animationsTimeCounter: PerfCounter;
  46796. /**
  46797. * Gets the animations time capture status
  46798. */
  46799. /**
  46800. * Enable or disable the animations time capture
  46801. */
  46802. captureAnimationsTime: boolean;
  46803. /**
  46804. * Gets the perf counter used for frame time capture
  46805. */
  46806. readonly frameTimeCounter: PerfCounter;
  46807. /**
  46808. * Gets the frame time capture status
  46809. */
  46810. /**
  46811. * Enable or disable the frame time capture
  46812. */
  46813. captureFrameTime: boolean;
  46814. /**
  46815. * Gets the perf counter used for inter-frames time capture
  46816. */
  46817. readonly interFrameTimeCounter: PerfCounter;
  46818. /**
  46819. * Gets the inter-frames time capture status
  46820. */
  46821. /**
  46822. * Enable or disable the inter-frames time capture
  46823. */
  46824. captureInterFrameTime: boolean;
  46825. /**
  46826. * Gets the perf counter used for render time capture
  46827. */
  46828. readonly renderTimeCounter: PerfCounter;
  46829. /**
  46830. * Gets the render time capture status
  46831. */
  46832. /**
  46833. * Enable or disable the render time capture
  46834. */
  46835. captureRenderTime: boolean;
  46836. /**
  46837. * Gets the perf counter used for camera render time capture
  46838. */
  46839. readonly cameraRenderTimeCounter: PerfCounter;
  46840. /**
  46841. * Gets the camera render time capture status
  46842. */
  46843. /**
  46844. * Enable or disable the camera render time capture
  46845. */
  46846. captureCameraRenderTime: boolean;
  46847. /**
  46848. * Gets the perf counter used for draw calls
  46849. */
  46850. readonly drawCallsCounter: PerfCounter;
  46851. /**
  46852. * Instantiates a new scene instrumentation.
  46853. * This class can be used to get instrumentation data from a Babylon engine
  46854. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  46855. * @param scene Defines the scene to instrument
  46856. */
  46857. constructor(
  46858. /**
  46859. * Defines the scene to instrument
  46860. */
  46861. scene: Scene);
  46862. /**
  46863. * Dispose and release associated resources.
  46864. */
  46865. dispose(): void;
  46866. }
  46867. }
  46868. declare module BABYLON {
  46869. /** @hidden */
  46870. export var glowMapGenerationPixelShader: {
  46871. name: string;
  46872. shader: string;
  46873. };
  46874. }
  46875. declare module BABYLON {
  46876. /** @hidden */
  46877. export var glowMapGenerationVertexShader: {
  46878. name: string;
  46879. shader: string;
  46880. };
  46881. }
  46882. declare module BABYLON {
  46883. /**
  46884. * Effect layer options. This helps customizing the behaviour
  46885. * of the effect layer.
  46886. */
  46887. export interface IEffectLayerOptions {
  46888. /**
  46889. * Multiplication factor apply to the canvas size to compute the render target size
  46890. * used to generated the objects (the smaller the faster).
  46891. */
  46892. mainTextureRatio: number;
  46893. /**
  46894. * Enforces a fixed size texture to ensure effect stability across devices.
  46895. */
  46896. mainTextureFixedSize?: number;
  46897. /**
  46898. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  46899. */
  46900. alphaBlendingMode: number;
  46901. /**
  46902. * The camera attached to the layer.
  46903. */
  46904. camera: Nullable<Camera>;
  46905. /**
  46906. * The rendering group to draw the layer in.
  46907. */
  46908. renderingGroupId: number;
  46909. }
  46910. /**
  46911. * The effect layer Helps adding post process effect blended with the main pass.
  46912. *
  46913. * This can be for instance use to generate glow or higlight effects on the scene.
  46914. *
  46915. * The effect layer class can not be used directly and is intented to inherited from to be
  46916. * customized per effects.
  46917. */
  46918. export abstract class EffectLayer {
  46919. private _vertexBuffers;
  46920. private _indexBuffer;
  46921. private _cachedDefines;
  46922. private _effectLayerMapGenerationEffect;
  46923. private _effectLayerOptions;
  46924. private _mergeEffect;
  46925. protected _scene: Scene;
  46926. protected _engine: Engine;
  46927. protected _maxSize: number;
  46928. protected _mainTextureDesiredSize: ISize;
  46929. protected _mainTexture: RenderTargetTexture;
  46930. protected _shouldRender: boolean;
  46931. protected _postProcesses: PostProcess[];
  46932. protected _textures: BaseTexture[];
  46933. protected _emissiveTextureAndColor: {
  46934. texture: Nullable<BaseTexture>;
  46935. color: Color4;
  46936. };
  46937. /**
  46938. * The name of the layer
  46939. */
  46940. name: string;
  46941. /**
  46942. * The clear color of the texture used to generate the glow map.
  46943. */
  46944. neutralColor: Color4;
  46945. /**
  46946. * Specifies wether the highlight layer is enabled or not.
  46947. */
  46948. isEnabled: boolean;
  46949. /**
  46950. * Gets the camera attached to the layer.
  46951. */
  46952. readonly camera: Nullable<Camera>;
  46953. /**
  46954. * Gets the rendering group id the layer should render in.
  46955. */
  46956. readonly renderingGroupId: number;
  46957. /**
  46958. * An event triggered when the effect layer has been disposed.
  46959. */
  46960. onDisposeObservable: Observable<EffectLayer>;
  46961. /**
  46962. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  46963. */
  46964. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  46965. /**
  46966. * An event triggered when the generated texture is being merged in the scene.
  46967. */
  46968. onBeforeComposeObservable: Observable<EffectLayer>;
  46969. /**
  46970. * An event triggered when the generated texture has been merged in the scene.
  46971. */
  46972. onAfterComposeObservable: Observable<EffectLayer>;
  46973. /**
  46974. * An event triggered when the efffect layer changes its size.
  46975. */
  46976. onSizeChangedObservable: Observable<EffectLayer>;
  46977. /** @hidden */
  46978. static _SceneComponentInitialization: (scene: Scene) => void;
  46979. /**
  46980. * Instantiates a new effect Layer and references it in the scene.
  46981. * @param name The name of the layer
  46982. * @param scene The scene to use the layer in
  46983. */
  46984. constructor(
  46985. /** The Friendly of the effect in the scene */
  46986. name: string, scene: Scene);
  46987. /**
  46988. * Get the effect name of the layer.
  46989. * @return The effect name
  46990. */
  46991. abstract getEffectName(): string;
  46992. /**
  46993. * Checks for the readiness of the element composing the layer.
  46994. * @param subMesh the mesh to check for
  46995. * @param useInstances specify wether or not to use instances to render the mesh
  46996. * @return true if ready otherwise, false
  46997. */
  46998. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46999. /**
  47000. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47001. * @returns true if the effect requires stencil during the main canvas render pass.
  47002. */
  47003. abstract needStencil(): boolean;
  47004. /**
  47005. * Create the merge effect. This is the shader use to blit the information back
  47006. * to the main canvas at the end of the scene rendering.
  47007. * @returns The effect containing the shader used to merge the effect on the main canvas
  47008. */
  47009. protected abstract _createMergeEffect(): Effect;
  47010. /**
  47011. * Creates the render target textures and post processes used in the effect layer.
  47012. */
  47013. protected abstract _createTextureAndPostProcesses(): void;
  47014. /**
  47015. * Implementation specific of rendering the generating effect on the main canvas.
  47016. * @param effect The effect used to render through
  47017. */
  47018. protected abstract _internalRender(effect: Effect): void;
  47019. /**
  47020. * Sets the required values for both the emissive texture and and the main color.
  47021. */
  47022. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47023. /**
  47024. * Free any resources and references associated to a mesh.
  47025. * Internal use
  47026. * @param mesh The mesh to free.
  47027. */
  47028. abstract _disposeMesh(mesh: Mesh): void;
  47029. /**
  47030. * Serializes this layer (Glow or Highlight for example)
  47031. * @returns a serialized layer object
  47032. */
  47033. abstract serialize?(): any;
  47034. /**
  47035. * Initializes the effect layer with the required options.
  47036. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  47037. */
  47038. protected _init(options: Partial<IEffectLayerOptions>): void;
  47039. /**
  47040. * Generates the index buffer of the full screen quad blending to the main canvas.
  47041. */
  47042. private _generateIndexBuffer;
  47043. /**
  47044. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  47045. */
  47046. private _generateVertexBuffer;
  47047. /**
  47048. * Sets the main texture desired size which is the closest power of two
  47049. * of the engine canvas size.
  47050. */
  47051. private _setMainTextureSize;
  47052. /**
  47053. * Creates the main texture for the effect layer.
  47054. */
  47055. protected _createMainTexture(): void;
  47056. /**
  47057. * Adds specific effects defines.
  47058. * @param defines The defines to add specifics to.
  47059. */
  47060. protected _addCustomEffectDefines(defines: string[]): void;
  47061. /**
  47062. * Checks for the readiness of the element composing the layer.
  47063. * @param subMesh the mesh to check for
  47064. * @param useInstances specify wether or not to use instances to render the mesh
  47065. * @param emissiveTexture the associated emissive texture used to generate the glow
  47066. * @return true if ready otherwise, false
  47067. */
  47068. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  47069. /**
  47070. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  47071. */
  47072. render(): void;
  47073. /**
  47074. * Determine if a given mesh will be used in the current effect.
  47075. * @param mesh mesh to test
  47076. * @returns true if the mesh will be used
  47077. */
  47078. hasMesh(mesh: AbstractMesh): boolean;
  47079. /**
  47080. * Returns true if the layer contains information to display, otherwise false.
  47081. * @returns true if the glow layer should be rendered
  47082. */
  47083. shouldRender(): boolean;
  47084. /**
  47085. * Returns true if the mesh should render, otherwise false.
  47086. * @param mesh The mesh to render
  47087. * @returns true if it should render otherwise false
  47088. */
  47089. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  47090. /**
  47091. * Returns true if the mesh can be rendered, otherwise false.
  47092. * @param mesh The mesh to render
  47093. * @param material The material used on the mesh
  47094. * @returns true if it can be rendered otherwise false
  47095. */
  47096. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47097. /**
  47098. * Returns true if the mesh should render, otherwise false.
  47099. * @param mesh The mesh to render
  47100. * @returns true if it should render otherwise false
  47101. */
  47102. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  47103. /**
  47104. * Renders the submesh passed in parameter to the generation map.
  47105. */
  47106. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  47107. /**
  47108. * Rebuild the required buffers.
  47109. * @hidden Internal use only.
  47110. */
  47111. _rebuild(): void;
  47112. /**
  47113. * Dispose only the render target textures and post process.
  47114. */
  47115. private _disposeTextureAndPostProcesses;
  47116. /**
  47117. * Dispose the highlight layer and free resources.
  47118. */
  47119. dispose(): void;
  47120. /**
  47121. * Gets the class name of the effect layer
  47122. * @returns the string with the class name of the effect layer
  47123. */
  47124. getClassName(): string;
  47125. /**
  47126. * Creates an effect layer from parsed effect layer data
  47127. * @param parsedEffectLayer defines effect layer data
  47128. * @param scene defines the current scene
  47129. * @param rootUrl defines the root URL containing the effect layer information
  47130. * @returns a parsed effect Layer
  47131. */
  47132. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  47133. }
  47134. }
  47135. declare module BABYLON {
  47136. interface AbstractScene {
  47137. /**
  47138. * The list of effect layers (highlights/glow) added to the scene
  47139. * @see http://doc.babylonjs.com/how_to/highlight_layer
  47140. * @see http://doc.babylonjs.com/how_to/glow_layer
  47141. */
  47142. effectLayers: Array<EffectLayer>;
  47143. /**
  47144. * Removes the given effect layer from this scene.
  47145. * @param toRemove defines the effect layer to remove
  47146. * @returns the index of the removed effect layer
  47147. */
  47148. removeEffectLayer(toRemove: EffectLayer): number;
  47149. /**
  47150. * Adds the given effect layer to this scene
  47151. * @param newEffectLayer defines the effect layer to add
  47152. */
  47153. addEffectLayer(newEffectLayer: EffectLayer): void;
  47154. }
  47155. /**
  47156. * Defines the layer scene component responsible to manage any effect layers
  47157. * in a given scene.
  47158. */
  47159. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  47160. /**
  47161. * The component name helpfull to identify the component in the list of scene components.
  47162. */
  47163. readonly name: string;
  47164. /**
  47165. * The scene the component belongs to.
  47166. */
  47167. scene: Scene;
  47168. private _engine;
  47169. private _renderEffects;
  47170. private _needStencil;
  47171. private _previousStencilState;
  47172. /**
  47173. * Creates a new instance of the component for the given scene
  47174. * @param scene Defines the scene to register the component in
  47175. */
  47176. constructor(scene: Scene);
  47177. /**
  47178. * Registers the component in a given scene
  47179. */
  47180. register(): void;
  47181. /**
  47182. * Rebuilds the elements related to this component in case of
  47183. * context lost for instance.
  47184. */
  47185. rebuild(): void;
  47186. /**
  47187. * Serializes the component data to the specified json object
  47188. * @param serializationObject The object to serialize to
  47189. */
  47190. serialize(serializationObject: any): void;
  47191. /**
  47192. * Adds all the elements from the container to the scene
  47193. * @param container the container holding the elements
  47194. */
  47195. addFromContainer(container: AbstractScene): void;
  47196. /**
  47197. * Removes all the elements in the container from the scene
  47198. * @param container contains the elements to remove
  47199. * @param dispose if the removed element should be disposed (default: false)
  47200. */
  47201. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47202. /**
  47203. * Disposes the component and the associated ressources.
  47204. */
  47205. dispose(): void;
  47206. private _isReadyForMesh;
  47207. private _renderMainTexture;
  47208. private _setStencil;
  47209. private _setStencilBack;
  47210. private _draw;
  47211. private _drawCamera;
  47212. private _drawRenderingGroup;
  47213. }
  47214. }
  47215. declare module BABYLON {
  47216. /** @hidden */
  47217. export var glowMapMergePixelShader: {
  47218. name: string;
  47219. shader: string;
  47220. };
  47221. }
  47222. declare module BABYLON {
  47223. /** @hidden */
  47224. export var glowMapMergeVertexShader: {
  47225. name: string;
  47226. shader: string;
  47227. };
  47228. }
  47229. declare module BABYLON {
  47230. interface AbstractScene {
  47231. /**
  47232. * Return a the first highlight layer of the scene with a given name.
  47233. * @param name The name of the highlight layer to look for.
  47234. * @return The highlight layer if found otherwise null.
  47235. */
  47236. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  47237. }
  47238. /**
  47239. * Glow layer options. This helps customizing the behaviour
  47240. * of the glow layer.
  47241. */
  47242. export interface IGlowLayerOptions {
  47243. /**
  47244. * Multiplication factor apply to the canvas size to compute the render target size
  47245. * used to generated the glowing objects (the smaller the faster).
  47246. */
  47247. mainTextureRatio: number;
  47248. /**
  47249. * Enforces a fixed size texture to ensure resize independant blur.
  47250. */
  47251. mainTextureFixedSize?: number;
  47252. /**
  47253. * How big is the kernel of the blur texture.
  47254. */
  47255. blurKernelSize: number;
  47256. /**
  47257. * The camera attached to the layer.
  47258. */
  47259. camera: Nullable<Camera>;
  47260. /**
  47261. * Enable MSAA by chosing the number of samples.
  47262. */
  47263. mainTextureSamples?: number;
  47264. /**
  47265. * The rendering group to draw the layer in.
  47266. */
  47267. renderingGroupId: number;
  47268. }
  47269. /**
  47270. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  47271. *
  47272. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47273. * glowy meshes to your scene.
  47274. *
  47275. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  47276. */
  47277. export class GlowLayer extends EffectLayer {
  47278. /**
  47279. * Effect Name of the layer.
  47280. */
  47281. static readonly EffectName: string;
  47282. /**
  47283. * The default blur kernel size used for the glow.
  47284. */
  47285. static DefaultBlurKernelSize: number;
  47286. /**
  47287. * The default texture size ratio used for the glow.
  47288. */
  47289. static DefaultTextureRatio: number;
  47290. /**
  47291. * Sets the kernel size of the blur.
  47292. */
  47293. /**
  47294. * Gets the kernel size of the blur.
  47295. */
  47296. blurKernelSize: number;
  47297. /**
  47298. * Sets the glow intensity.
  47299. */
  47300. /**
  47301. * Gets the glow intensity.
  47302. */
  47303. intensity: number;
  47304. private _options;
  47305. private _intensity;
  47306. private _horizontalBlurPostprocess1;
  47307. private _verticalBlurPostprocess1;
  47308. private _horizontalBlurPostprocess2;
  47309. private _verticalBlurPostprocess2;
  47310. private _blurTexture1;
  47311. private _blurTexture2;
  47312. private _postProcesses1;
  47313. private _postProcesses2;
  47314. private _includedOnlyMeshes;
  47315. private _excludedMeshes;
  47316. /**
  47317. * Callback used to let the user override the color selection on a per mesh basis
  47318. */
  47319. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  47320. /**
  47321. * Callback used to let the user override the texture selection on a per mesh basis
  47322. */
  47323. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  47324. /**
  47325. * Instantiates a new glow Layer and references it to the scene.
  47326. * @param name The name of the layer
  47327. * @param scene The scene to use the layer in
  47328. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  47329. */
  47330. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  47331. /**
  47332. * Get the effect name of the layer.
  47333. * @return The effect name
  47334. */
  47335. getEffectName(): string;
  47336. /**
  47337. * Create the merge effect. This is the shader use to blit the information back
  47338. * to the main canvas at the end of the scene rendering.
  47339. */
  47340. protected _createMergeEffect(): Effect;
  47341. /**
  47342. * Creates the render target textures and post processes used in the glow layer.
  47343. */
  47344. protected _createTextureAndPostProcesses(): void;
  47345. /**
  47346. * Checks for the readiness of the element composing the layer.
  47347. * @param subMesh the mesh to check for
  47348. * @param useInstances specify wether or not to use instances to render the mesh
  47349. * @param emissiveTexture the associated emissive texture used to generate the glow
  47350. * @return true if ready otherwise, false
  47351. */
  47352. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47353. /**
  47354. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47355. */
  47356. needStencil(): boolean;
  47357. /**
  47358. * Returns true if the mesh can be rendered, otherwise false.
  47359. * @param mesh The mesh to render
  47360. * @param material The material used on the mesh
  47361. * @returns true if it can be rendered otherwise false
  47362. */
  47363. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47364. /**
  47365. * Implementation specific of rendering the generating effect on the main canvas.
  47366. * @param effect The effect used to render through
  47367. */
  47368. protected _internalRender(effect: Effect): void;
  47369. /**
  47370. * Sets the required values for both the emissive texture and and the main color.
  47371. */
  47372. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47373. /**
  47374. * Returns true if the mesh should render, otherwise false.
  47375. * @param mesh The mesh to render
  47376. * @returns true if it should render otherwise false
  47377. */
  47378. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47379. /**
  47380. * Adds specific effects defines.
  47381. * @param defines The defines to add specifics to.
  47382. */
  47383. protected _addCustomEffectDefines(defines: string[]): void;
  47384. /**
  47385. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  47386. * @param mesh The mesh to exclude from the glow layer
  47387. */
  47388. addExcludedMesh(mesh: Mesh): void;
  47389. /**
  47390. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  47391. * @param mesh The mesh to remove
  47392. */
  47393. removeExcludedMesh(mesh: Mesh): void;
  47394. /**
  47395. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  47396. * @param mesh The mesh to include in the glow layer
  47397. */
  47398. addIncludedOnlyMesh(mesh: Mesh): void;
  47399. /**
  47400. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  47401. * @param mesh The mesh to remove
  47402. */
  47403. removeIncludedOnlyMesh(mesh: Mesh): void;
  47404. /**
  47405. * Determine if a given mesh will be used in the glow layer
  47406. * @param mesh The mesh to test
  47407. * @returns true if the mesh will be highlighted by the current glow layer
  47408. */
  47409. hasMesh(mesh: AbstractMesh): boolean;
  47410. /**
  47411. * Free any resources and references associated to a mesh.
  47412. * Internal use
  47413. * @param mesh The mesh to free.
  47414. * @hidden
  47415. */
  47416. _disposeMesh(mesh: Mesh): void;
  47417. /**
  47418. * Gets the class name of the effect layer
  47419. * @returns the string with the class name of the effect layer
  47420. */
  47421. getClassName(): string;
  47422. /**
  47423. * Serializes this glow layer
  47424. * @returns a serialized glow layer object
  47425. */
  47426. serialize(): any;
  47427. /**
  47428. * Creates a Glow Layer from parsed glow layer data
  47429. * @param parsedGlowLayer defines glow layer data
  47430. * @param scene defines the current scene
  47431. * @param rootUrl defines the root URL containing the glow layer information
  47432. * @returns a parsed Glow Layer
  47433. */
  47434. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  47435. }
  47436. }
  47437. declare module BABYLON {
  47438. /** @hidden */
  47439. export var glowBlurPostProcessPixelShader: {
  47440. name: string;
  47441. shader: string;
  47442. };
  47443. }
  47444. declare module BABYLON {
  47445. interface AbstractScene {
  47446. /**
  47447. * Return a the first highlight layer of the scene with a given name.
  47448. * @param name The name of the highlight layer to look for.
  47449. * @return The highlight layer if found otherwise null.
  47450. */
  47451. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  47452. }
  47453. /**
  47454. * Highlight layer options. This helps customizing the behaviour
  47455. * of the highlight layer.
  47456. */
  47457. export interface IHighlightLayerOptions {
  47458. /**
  47459. * Multiplication factor apply to the canvas size to compute the render target size
  47460. * used to generated the glowing objects (the smaller the faster).
  47461. */
  47462. mainTextureRatio: number;
  47463. /**
  47464. * Enforces a fixed size texture to ensure resize independant blur.
  47465. */
  47466. mainTextureFixedSize?: number;
  47467. /**
  47468. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  47469. * of the picture to blur (the smaller the faster).
  47470. */
  47471. blurTextureSizeRatio: number;
  47472. /**
  47473. * How big in texel of the blur texture is the vertical blur.
  47474. */
  47475. blurVerticalSize: number;
  47476. /**
  47477. * How big in texel of the blur texture is the horizontal blur.
  47478. */
  47479. blurHorizontalSize: number;
  47480. /**
  47481. * Alpha blending mode used to apply the blur. Default is combine.
  47482. */
  47483. alphaBlendingMode: number;
  47484. /**
  47485. * The camera attached to the layer.
  47486. */
  47487. camera: Nullable<Camera>;
  47488. /**
  47489. * Should we display highlight as a solid stroke?
  47490. */
  47491. isStroke?: boolean;
  47492. /**
  47493. * The rendering group to draw the layer in.
  47494. */
  47495. renderingGroupId: number;
  47496. }
  47497. /**
  47498. * The highlight layer Helps adding a glow effect around a mesh.
  47499. *
  47500. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47501. * glowy meshes to your scene.
  47502. *
  47503. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  47504. */
  47505. export class HighlightLayer extends EffectLayer {
  47506. name: string;
  47507. /**
  47508. * Effect Name of the highlight layer.
  47509. */
  47510. static readonly EffectName: string;
  47511. /**
  47512. * The neutral color used during the preparation of the glow effect.
  47513. * This is black by default as the blend operation is a blend operation.
  47514. */
  47515. static NeutralColor: Color4;
  47516. /**
  47517. * Stencil value used for glowing meshes.
  47518. */
  47519. static GlowingMeshStencilReference: number;
  47520. /**
  47521. * Stencil value used for the other meshes in the scene.
  47522. */
  47523. static NormalMeshStencilReference: number;
  47524. /**
  47525. * Specifies whether or not the inner glow is ACTIVE in the layer.
  47526. */
  47527. innerGlow: boolean;
  47528. /**
  47529. * Specifies whether or not the outer glow is ACTIVE in the layer.
  47530. */
  47531. outerGlow: boolean;
  47532. /**
  47533. * Specifies the horizontal size of the blur.
  47534. */
  47535. /**
  47536. * Gets the horizontal size of the blur.
  47537. */
  47538. blurHorizontalSize: number;
  47539. /**
  47540. * Specifies the vertical size of the blur.
  47541. */
  47542. /**
  47543. * Gets the vertical size of the blur.
  47544. */
  47545. blurVerticalSize: number;
  47546. /**
  47547. * An event triggered when the highlight layer is being blurred.
  47548. */
  47549. onBeforeBlurObservable: Observable<HighlightLayer>;
  47550. /**
  47551. * An event triggered when the highlight layer has been blurred.
  47552. */
  47553. onAfterBlurObservable: Observable<HighlightLayer>;
  47554. private _instanceGlowingMeshStencilReference;
  47555. private _options;
  47556. private _downSamplePostprocess;
  47557. private _horizontalBlurPostprocess;
  47558. private _verticalBlurPostprocess;
  47559. private _blurTexture;
  47560. private _meshes;
  47561. private _excludedMeshes;
  47562. /**
  47563. * Instantiates a new highlight Layer and references it to the scene..
  47564. * @param name The name of the layer
  47565. * @param scene The scene to use the layer in
  47566. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  47567. */
  47568. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  47569. /**
  47570. * Get the effect name of the layer.
  47571. * @return The effect name
  47572. */
  47573. getEffectName(): string;
  47574. /**
  47575. * Create the merge effect. This is the shader use to blit the information back
  47576. * to the main canvas at the end of the scene rendering.
  47577. */
  47578. protected _createMergeEffect(): Effect;
  47579. /**
  47580. * Creates the render target textures and post processes used in the highlight layer.
  47581. */
  47582. protected _createTextureAndPostProcesses(): void;
  47583. /**
  47584. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47585. */
  47586. needStencil(): boolean;
  47587. /**
  47588. * Checks for the readiness of the element composing the layer.
  47589. * @param subMesh the mesh to check for
  47590. * @param useInstances specify wether or not to use instances to render the mesh
  47591. * @param emissiveTexture the associated emissive texture used to generate the glow
  47592. * @return true if ready otherwise, false
  47593. */
  47594. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47595. /**
  47596. * Implementation specific of rendering the generating effect on the main canvas.
  47597. * @param effect The effect used to render through
  47598. */
  47599. protected _internalRender(effect: Effect): void;
  47600. /**
  47601. * Returns true if the layer contains information to display, otherwise false.
  47602. */
  47603. shouldRender(): boolean;
  47604. /**
  47605. * Returns true if the mesh should render, otherwise false.
  47606. * @param mesh The mesh to render
  47607. * @returns true if it should render otherwise false
  47608. */
  47609. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47610. /**
  47611. * Sets the required values for both the emissive texture and and the main color.
  47612. */
  47613. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47614. /**
  47615. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  47616. * @param mesh The mesh to exclude from the highlight layer
  47617. */
  47618. addExcludedMesh(mesh: Mesh): void;
  47619. /**
  47620. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  47621. * @param mesh The mesh to highlight
  47622. */
  47623. removeExcludedMesh(mesh: Mesh): void;
  47624. /**
  47625. * Determine if a given mesh will be highlighted by the current HighlightLayer
  47626. * @param mesh mesh to test
  47627. * @returns true if the mesh will be highlighted by the current HighlightLayer
  47628. */
  47629. hasMesh(mesh: AbstractMesh): boolean;
  47630. /**
  47631. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  47632. * @param mesh The mesh to highlight
  47633. * @param color The color of the highlight
  47634. * @param glowEmissiveOnly Extract the glow from the emissive texture
  47635. */
  47636. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  47637. /**
  47638. * Remove a mesh from the highlight layer in order to make it stop glowing.
  47639. * @param mesh The mesh to highlight
  47640. */
  47641. removeMesh(mesh: Mesh): void;
  47642. /**
  47643. * Force the stencil to the normal expected value for none glowing parts
  47644. */
  47645. private _defaultStencilReference;
  47646. /**
  47647. * Free any resources and references associated to a mesh.
  47648. * Internal use
  47649. * @param mesh The mesh to free.
  47650. * @hidden
  47651. */
  47652. _disposeMesh(mesh: Mesh): void;
  47653. /**
  47654. * Dispose the highlight layer and free resources.
  47655. */
  47656. dispose(): void;
  47657. /**
  47658. * Gets the class name of the effect layer
  47659. * @returns the string with the class name of the effect layer
  47660. */
  47661. getClassName(): string;
  47662. /**
  47663. * Serializes this Highlight layer
  47664. * @returns a serialized Highlight layer object
  47665. */
  47666. serialize(): any;
  47667. /**
  47668. * Creates a Highlight layer from parsed Highlight layer data
  47669. * @param parsedHightlightLayer defines the Highlight layer data
  47670. * @param scene defines the current scene
  47671. * @param rootUrl defines the root URL containing the Highlight layer information
  47672. * @returns a parsed Highlight layer
  47673. */
  47674. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  47675. }
  47676. }
  47677. declare module BABYLON {
  47678. interface AbstractScene {
  47679. /**
  47680. * The list of layers (background and foreground) of the scene
  47681. */
  47682. layers: Array<Layer>;
  47683. }
  47684. /**
  47685. * Defines the layer scene component responsible to manage any layers
  47686. * in a given scene.
  47687. */
  47688. export class LayerSceneComponent implements ISceneComponent {
  47689. /**
  47690. * The component name helpfull to identify the component in the list of scene components.
  47691. */
  47692. readonly name: string;
  47693. /**
  47694. * The scene the component belongs to.
  47695. */
  47696. scene: Scene;
  47697. private _engine;
  47698. /**
  47699. * Creates a new instance of the component for the given scene
  47700. * @param scene Defines the scene to register the component in
  47701. */
  47702. constructor(scene: Scene);
  47703. /**
  47704. * Registers the component in a given scene
  47705. */
  47706. register(): void;
  47707. /**
  47708. * Rebuilds the elements related to this component in case of
  47709. * context lost for instance.
  47710. */
  47711. rebuild(): void;
  47712. /**
  47713. * Disposes the component and the associated ressources.
  47714. */
  47715. dispose(): void;
  47716. private _draw;
  47717. private _drawCameraPredicate;
  47718. private _drawCameraBackground;
  47719. private _drawCameraForeground;
  47720. private _drawRenderTargetPredicate;
  47721. private _drawRenderTargetBackground;
  47722. private _drawRenderTargetForeground;
  47723. /**
  47724. * Adds all the elements from the container to the scene
  47725. * @param container the container holding the elements
  47726. */
  47727. addFromContainer(container: AbstractScene): void;
  47728. /**
  47729. * Removes all the elements in the container from the scene
  47730. * @param container contains the elements to remove
  47731. * @param dispose if the removed element should be disposed (default: false)
  47732. */
  47733. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47734. }
  47735. }
  47736. declare module BABYLON {
  47737. /** @hidden */
  47738. export var layerPixelShader: {
  47739. name: string;
  47740. shader: string;
  47741. };
  47742. }
  47743. declare module BABYLON {
  47744. /** @hidden */
  47745. export var layerVertexShader: {
  47746. name: string;
  47747. shader: string;
  47748. };
  47749. }
  47750. declare module BABYLON {
  47751. /**
  47752. * This represents a full screen 2d layer.
  47753. * This can be useful to display a picture in the background of your scene for instance.
  47754. * @see https://www.babylonjs-playground.com/#08A2BS#1
  47755. */
  47756. export class Layer {
  47757. /**
  47758. * Define the name of the layer.
  47759. */
  47760. name: string;
  47761. /**
  47762. * Define the texture the layer should display.
  47763. */
  47764. texture: Nullable<Texture>;
  47765. /**
  47766. * Is the layer in background or foreground.
  47767. */
  47768. isBackground: boolean;
  47769. /**
  47770. * Define the color of the layer (instead of texture).
  47771. */
  47772. color: Color4;
  47773. /**
  47774. * Define the scale of the layer in order to zoom in out of the texture.
  47775. */
  47776. scale: Vector2;
  47777. /**
  47778. * Define an offset for the layer in order to shift the texture.
  47779. */
  47780. offset: Vector2;
  47781. /**
  47782. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  47783. */
  47784. alphaBlendingMode: number;
  47785. /**
  47786. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  47787. * Alpha test will not mix with the background color in case of transparency.
  47788. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  47789. */
  47790. alphaTest: boolean;
  47791. /**
  47792. * Define a mask to restrict the layer to only some of the scene cameras.
  47793. */
  47794. layerMask: number;
  47795. /**
  47796. * Define the list of render target the layer is visible into.
  47797. */
  47798. renderTargetTextures: RenderTargetTexture[];
  47799. /**
  47800. * Define if the layer is only used in renderTarget or if it also
  47801. * renders in the main frame buffer of the canvas.
  47802. */
  47803. renderOnlyInRenderTargetTextures: boolean;
  47804. private _scene;
  47805. private _vertexBuffers;
  47806. private _indexBuffer;
  47807. private _effect;
  47808. private _alphaTestEffect;
  47809. /**
  47810. * An event triggered when the layer is disposed.
  47811. */
  47812. onDisposeObservable: Observable<Layer>;
  47813. private _onDisposeObserver;
  47814. /**
  47815. * Back compatibility with callback before the onDisposeObservable existed.
  47816. * The set callback will be triggered when the layer has been disposed.
  47817. */
  47818. onDispose: () => void;
  47819. /**
  47820. * An event triggered before rendering the scene
  47821. */
  47822. onBeforeRenderObservable: Observable<Layer>;
  47823. private _onBeforeRenderObserver;
  47824. /**
  47825. * Back compatibility with callback before the onBeforeRenderObservable existed.
  47826. * The set callback will be triggered just before rendering the layer.
  47827. */
  47828. onBeforeRender: () => void;
  47829. /**
  47830. * An event triggered after rendering the scene
  47831. */
  47832. onAfterRenderObservable: Observable<Layer>;
  47833. private _onAfterRenderObserver;
  47834. /**
  47835. * Back compatibility with callback before the onAfterRenderObservable existed.
  47836. * The set callback will be triggered just after rendering the layer.
  47837. */
  47838. onAfterRender: () => void;
  47839. /**
  47840. * Instantiates a new layer.
  47841. * This represents a full screen 2d layer.
  47842. * This can be useful to display a picture in the background of your scene for instance.
  47843. * @see https://www.babylonjs-playground.com/#08A2BS#1
  47844. * @param name Define the name of the layer in the scene
  47845. * @param imgUrl Define the url of the texture to display in the layer
  47846. * @param scene Define the scene the layer belongs to
  47847. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  47848. * @param color Defines a color for the layer
  47849. */
  47850. constructor(
  47851. /**
  47852. * Define the name of the layer.
  47853. */
  47854. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  47855. private _createIndexBuffer;
  47856. /** @hidden */
  47857. _rebuild(): void;
  47858. /**
  47859. * Renders the layer in the scene.
  47860. */
  47861. render(): void;
  47862. /**
  47863. * Disposes and releases the associated ressources.
  47864. */
  47865. dispose(): void;
  47866. }
  47867. }
  47868. declare module BABYLON {
  47869. /** @hidden */
  47870. export var lensFlarePixelShader: {
  47871. name: string;
  47872. shader: string;
  47873. };
  47874. }
  47875. declare module BABYLON {
  47876. /** @hidden */
  47877. export var lensFlareVertexShader: {
  47878. name: string;
  47879. shader: string;
  47880. };
  47881. }
  47882. declare module BABYLON {
  47883. /**
  47884. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  47885. * It is usually composed of several `lensFlare`.
  47886. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47887. */
  47888. export class LensFlareSystem {
  47889. /**
  47890. * Define the name of the lens flare system
  47891. */
  47892. name: string;
  47893. /**
  47894. * List of lens flares used in this system.
  47895. */
  47896. lensFlares: LensFlare[];
  47897. /**
  47898. * Define a limit from the border the lens flare can be visible.
  47899. */
  47900. borderLimit: number;
  47901. /**
  47902. * Define a viewport border we do not want to see the lens flare in.
  47903. */
  47904. viewportBorder: number;
  47905. /**
  47906. * Define a predicate which could limit the list of meshes able to occlude the effect.
  47907. */
  47908. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  47909. /**
  47910. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  47911. */
  47912. layerMask: number;
  47913. /**
  47914. * Define the id of the lens flare system in the scene.
  47915. * (equal to name by default)
  47916. */
  47917. id: string;
  47918. private _scene;
  47919. private _emitter;
  47920. private _vertexBuffers;
  47921. private _indexBuffer;
  47922. private _effect;
  47923. private _positionX;
  47924. private _positionY;
  47925. private _isEnabled;
  47926. /** @hidden */
  47927. static _SceneComponentInitialization: (scene: Scene) => void;
  47928. /**
  47929. * Instantiates a lens flare system.
  47930. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  47931. * It is usually composed of several `lensFlare`.
  47932. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47933. * @param name Define the name of the lens flare system in the scene
  47934. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  47935. * @param scene Define the scene the lens flare system belongs to
  47936. */
  47937. constructor(
  47938. /**
  47939. * Define the name of the lens flare system
  47940. */
  47941. name: string, emitter: any, scene: Scene);
  47942. /**
  47943. * Define if the lens flare system is enabled.
  47944. */
  47945. isEnabled: boolean;
  47946. /**
  47947. * Get the scene the effects belongs to.
  47948. * @returns the scene holding the lens flare system
  47949. */
  47950. getScene(): Scene;
  47951. /**
  47952. * Get the emitter of the lens flare system.
  47953. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  47954. * @returns the emitter of the lens flare system
  47955. */
  47956. getEmitter(): any;
  47957. /**
  47958. * Set the emitter of the lens flare system.
  47959. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  47960. * @param newEmitter Define the new emitter of the system
  47961. */
  47962. setEmitter(newEmitter: any): void;
  47963. /**
  47964. * Get the lens flare system emitter position.
  47965. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  47966. * @returns the position
  47967. */
  47968. getEmitterPosition(): Vector3;
  47969. /**
  47970. * @hidden
  47971. */
  47972. computeEffectivePosition(globalViewport: Viewport): boolean;
  47973. /** @hidden */
  47974. _isVisible(): boolean;
  47975. /**
  47976. * @hidden
  47977. */
  47978. render(): boolean;
  47979. /**
  47980. * Dispose and release the lens flare with its associated resources.
  47981. */
  47982. dispose(): void;
  47983. /**
  47984. * Parse a lens flare system from a JSON repressentation
  47985. * @param parsedLensFlareSystem Define the JSON to parse
  47986. * @param scene Define the scene the parsed system should be instantiated in
  47987. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  47988. * @returns the parsed system
  47989. */
  47990. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  47991. /**
  47992. * Serialize the current Lens Flare System into a JSON representation.
  47993. * @returns the serialized JSON
  47994. */
  47995. serialize(): any;
  47996. }
  47997. }
  47998. declare module BABYLON {
  47999. /**
  48000. * This represents one of the lens effect in a `lensFlareSystem`.
  48001. * It controls one of the indiviual texture used in the effect.
  48002. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48003. */
  48004. export class LensFlare {
  48005. /**
  48006. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  48007. */
  48008. size: number;
  48009. /**
  48010. * 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.
  48011. */
  48012. position: number;
  48013. /**
  48014. * Define the lens color.
  48015. */
  48016. color: Color3;
  48017. /**
  48018. * Define the lens texture.
  48019. */
  48020. texture: Nullable<Texture>;
  48021. /**
  48022. * Define the alpha mode to render this particular lens.
  48023. */
  48024. alphaMode: number;
  48025. private _system;
  48026. /**
  48027. * Creates a new Lens Flare.
  48028. * This represents one of the lens effect in a `lensFlareSystem`.
  48029. * It controls one of the indiviual texture used in the effect.
  48030. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48031. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  48032. * @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.
  48033. * @param color Define the lens color
  48034. * @param imgUrl Define the lens texture url
  48035. * @param system Define the `lensFlareSystem` this flare is part of
  48036. * @returns The newly created Lens Flare
  48037. */
  48038. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  48039. /**
  48040. * Instantiates a new Lens Flare.
  48041. * This represents one of the lens effect in a `lensFlareSystem`.
  48042. * It controls one of the indiviual texture used in the effect.
  48043. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48044. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  48045. * @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.
  48046. * @param color Define the lens color
  48047. * @param imgUrl Define the lens texture url
  48048. * @param system Define the `lensFlareSystem` this flare is part of
  48049. */
  48050. constructor(
  48051. /**
  48052. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  48053. */
  48054. size: number,
  48055. /**
  48056. * 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.
  48057. */
  48058. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  48059. /**
  48060. * Dispose and release the lens flare with its associated resources.
  48061. */
  48062. dispose(): void;
  48063. }
  48064. }
  48065. declare module BABYLON {
  48066. interface AbstractScene {
  48067. /**
  48068. * The list of lens flare system added to the scene
  48069. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48070. */
  48071. lensFlareSystems: Array<LensFlareSystem>;
  48072. /**
  48073. * Removes the given lens flare system from this scene.
  48074. * @param toRemove The lens flare system to remove
  48075. * @returns The index of the removed lens flare system
  48076. */
  48077. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  48078. /**
  48079. * Adds the given lens flare system to this scene
  48080. * @param newLensFlareSystem The lens flare system to add
  48081. */
  48082. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  48083. /**
  48084. * Gets a lens flare system using its name
  48085. * @param name defines the name to look for
  48086. * @returns the lens flare system or null if not found
  48087. */
  48088. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  48089. /**
  48090. * Gets a lens flare system using its id
  48091. * @param id defines the id to look for
  48092. * @returns the lens flare system or null if not found
  48093. */
  48094. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  48095. }
  48096. /**
  48097. * Defines the lens flare scene component responsible to manage any lens flares
  48098. * in a given scene.
  48099. */
  48100. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  48101. /**
  48102. * The component name helpfull to identify the component in the list of scene components.
  48103. */
  48104. readonly name: string;
  48105. /**
  48106. * The scene the component belongs to.
  48107. */
  48108. scene: Scene;
  48109. /**
  48110. * Creates a new instance of the component for the given scene
  48111. * @param scene Defines the scene to register the component in
  48112. */
  48113. constructor(scene: Scene);
  48114. /**
  48115. * Registers the component in a given scene
  48116. */
  48117. register(): void;
  48118. /**
  48119. * Rebuilds the elements related to this component in case of
  48120. * context lost for instance.
  48121. */
  48122. rebuild(): void;
  48123. /**
  48124. * Adds all the elements from the container to the scene
  48125. * @param container the container holding the elements
  48126. */
  48127. addFromContainer(container: AbstractScene): void;
  48128. /**
  48129. * Removes all the elements in the container from the scene
  48130. * @param container contains the elements to remove
  48131. * @param dispose if the removed element should be disposed (default: false)
  48132. */
  48133. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48134. /**
  48135. * Serializes the component data to the specified json object
  48136. * @param serializationObject The object to serialize to
  48137. */
  48138. serialize(serializationObject: any): void;
  48139. /**
  48140. * Disposes the component and the associated ressources.
  48141. */
  48142. dispose(): void;
  48143. private _draw;
  48144. }
  48145. }
  48146. declare module BABYLON {
  48147. /**
  48148. * Defines the shadow generator component responsible to manage any shadow generators
  48149. * in a given scene.
  48150. */
  48151. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  48152. /**
  48153. * The component name helpfull to identify the component in the list of scene components.
  48154. */
  48155. readonly name: string;
  48156. /**
  48157. * The scene the component belongs to.
  48158. */
  48159. scene: Scene;
  48160. /**
  48161. * Creates a new instance of the component for the given scene
  48162. * @param scene Defines the scene to register the component in
  48163. */
  48164. constructor(scene: Scene);
  48165. /**
  48166. * Registers the component in a given scene
  48167. */
  48168. register(): void;
  48169. /**
  48170. * Rebuilds the elements related to this component in case of
  48171. * context lost for instance.
  48172. */
  48173. rebuild(): void;
  48174. /**
  48175. * Serializes the component data to the specified json object
  48176. * @param serializationObject The object to serialize to
  48177. */
  48178. serialize(serializationObject: any): void;
  48179. /**
  48180. * Adds all the elements from the container to the scene
  48181. * @param container the container holding the elements
  48182. */
  48183. addFromContainer(container: AbstractScene): void;
  48184. /**
  48185. * Removes all the elements in the container from the scene
  48186. * @param container contains the elements to remove
  48187. * @param dispose if the removed element should be disposed (default: false)
  48188. */
  48189. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48190. /**
  48191. * Rebuilds the elements related to this component in case of
  48192. * context lost for instance.
  48193. */
  48194. dispose(): void;
  48195. private _gatherRenderTargets;
  48196. }
  48197. }
  48198. declare module BABYLON {
  48199. /**
  48200. * A point light is a light defined by an unique point in world space.
  48201. * The light is emitted in every direction from this point.
  48202. * A good example of a point light is a standard light bulb.
  48203. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48204. */
  48205. export class PointLight extends ShadowLight {
  48206. private _shadowAngle;
  48207. /**
  48208. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48209. * This specifies what angle the shadow will use to be created.
  48210. *
  48211. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48212. */
  48213. /**
  48214. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48215. * This specifies what angle the shadow will use to be created.
  48216. *
  48217. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48218. */
  48219. shadowAngle: number;
  48220. /**
  48221. * Gets the direction if it has been set.
  48222. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48223. */
  48224. /**
  48225. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48226. */
  48227. direction: Vector3;
  48228. /**
  48229. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  48230. * A PointLight emits the light in every direction.
  48231. * It can cast shadows.
  48232. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  48233. * ```javascript
  48234. * var pointLight = new PointLight("pl", camera.position, scene);
  48235. * ```
  48236. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48237. * @param name The light friendly name
  48238. * @param position The position of the point light in the scene
  48239. * @param scene The scene the lights belongs to
  48240. */
  48241. constructor(name: string, position: Vector3, scene: Scene);
  48242. /**
  48243. * Returns the string "PointLight"
  48244. * @returns the class name
  48245. */
  48246. getClassName(): string;
  48247. /**
  48248. * Returns the integer 0.
  48249. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48250. */
  48251. getTypeID(): number;
  48252. /**
  48253. * Specifies wether or not the shadowmap should be a cube texture.
  48254. * @returns true if the shadowmap needs to be a cube texture.
  48255. */
  48256. needCube(): boolean;
  48257. /**
  48258. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  48259. * @param faceIndex The index of the face we are computed the direction to generate shadow
  48260. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  48261. */
  48262. getShadowDirection(faceIndex?: number): Vector3;
  48263. /**
  48264. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  48265. * - fov = PI / 2
  48266. * - aspect ratio : 1.0
  48267. * - z-near and far equal to the active camera minZ and maxZ.
  48268. * Returns the PointLight.
  48269. */
  48270. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48271. protected _buildUniformLayout(): void;
  48272. /**
  48273. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  48274. * @param effect The effect to update
  48275. * @param lightIndex The index of the light in the effect to update
  48276. * @returns The point light
  48277. */
  48278. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  48279. /**
  48280. * Prepares the list of defines specific to the light type.
  48281. * @param defines the list of defines
  48282. * @param lightIndex defines the index of the light for the effect
  48283. */
  48284. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48285. }
  48286. }
  48287. declare module BABYLON {
  48288. /**
  48289. * Header information of HDR texture files.
  48290. */
  48291. export interface HDRInfo {
  48292. /**
  48293. * The height of the texture in pixels.
  48294. */
  48295. height: number;
  48296. /**
  48297. * The width of the texture in pixels.
  48298. */
  48299. width: number;
  48300. /**
  48301. * The index of the beginning of the data in the binary file.
  48302. */
  48303. dataPosition: number;
  48304. }
  48305. /**
  48306. * This groups tools to convert HDR texture to native colors array.
  48307. */
  48308. export class HDRTools {
  48309. private static Ldexp;
  48310. private static Rgbe2float;
  48311. private static readStringLine;
  48312. /**
  48313. * Reads header information from an RGBE texture stored in a native array.
  48314. * More information on this format are available here:
  48315. * https://en.wikipedia.org/wiki/RGBE_image_format
  48316. *
  48317. * @param uint8array The binary file stored in native array.
  48318. * @return The header information.
  48319. */
  48320. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  48321. /**
  48322. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  48323. * This RGBE texture needs to store the information as a panorama.
  48324. *
  48325. * More information on this format are available here:
  48326. * https://en.wikipedia.org/wiki/RGBE_image_format
  48327. *
  48328. * @param buffer The binary file stored in an array buffer.
  48329. * @param size The expected size of the extracted cubemap.
  48330. * @return The Cube Map information.
  48331. */
  48332. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  48333. /**
  48334. * Returns the pixels data extracted from an RGBE texture.
  48335. * This pixels will be stored left to right up to down in the R G B order in one array.
  48336. *
  48337. * More information on this format are available here:
  48338. * https://en.wikipedia.org/wiki/RGBE_image_format
  48339. *
  48340. * @param uint8array The binary file stored in an array buffer.
  48341. * @param hdrInfo The header information of the file.
  48342. * @return The pixels data in RGB right to left up to down order.
  48343. */
  48344. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  48345. private static RGBE_ReadPixels_RLE;
  48346. }
  48347. }
  48348. declare module BABYLON {
  48349. /**
  48350. * This represents a texture coming from an HDR input.
  48351. *
  48352. * The only supported format is currently panorama picture stored in RGBE format.
  48353. * Example of such files can be found on HDRLib: http://hdrlib.com/
  48354. */
  48355. export class HDRCubeTexture extends BaseTexture {
  48356. private static _facesMapping;
  48357. private _generateHarmonics;
  48358. private _noMipmap;
  48359. private _textureMatrix;
  48360. private _size;
  48361. private _onLoad;
  48362. private _onError;
  48363. /**
  48364. * The texture URL.
  48365. */
  48366. url: string;
  48367. /**
  48368. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  48369. */
  48370. coordinatesMode: number;
  48371. protected _isBlocking: boolean;
  48372. /**
  48373. * Sets wether or not the texture is blocking during loading.
  48374. */
  48375. /**
  48376. * Gets wether or not the texture is blocking during loading.
  48377. */
  48378. isBlocking: boolean;
  48379. protected _rotationY: number;
  48380. /**
  48381. * Sets texture matrix rotation angle around Y axis in radians.
  48382. */
  48383. /**
  48384. * Gets texture matrix rotation angle around Y axis radians.
  48385. */
  48386. rotationY: number;
  48387. /**
  48388. * Gets or sets the center of the bounding box associated with the cube texture
  48389. * It must define where the camera used to render the texture was set
  48390. */
  48391. boundingBoxPosition: Vector3;
  48392. private _boundingBoxSize;
  48393. /**
  48394. * Gets or sets the size of the bounding box associated with the cube texture
  48395. * When defined, the cubemap will switch to local mode
  48396. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  48397. * @example https://www.babylonjs-playground.com/#RNASML
  48398. */
  48399. boundingBoxSize: Vector3;
  48400. /**
  48401. * Instantiates an HDRTexture from the following parameters.
  48402. *
  48403. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  48404. * @param scene The scene the texture will be used in
  48405. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  48406. * @param noMipmap Forces to not generate the mipmap if true
  48407. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  48408. * @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)
  48409. * @param reserved Reserved flag for internal use.
  48410. */
  48411. 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>);
  48412. /**
  48413. * Get the current class name of the texture useful for serialization or dynamic coding.
  48414. * @returns "HDRCubeTexture"
  48415. */
  48416. getClassName(): string;
  48417. /**
  48418. * Occurs when the file is raw .hdr file.
  48419. */
  48420. private loadTexture;
  48421. clone(): HDRCubeTexture;
  48422. delayLoad(): void;
  48423. /**
  48424. * Get the texture reflection matrix used to rotate/transform the reflection.
  48425. * @returns the reflection matrix
  48426. */
  48427. getReflectionTextureMatrix(): Matrix;
  48428. /**
  48429. * Set the texture reflection matrix used to rotate/transform the reflection.
  48430. * @param value Define the reflection matrix to set
  48431. */
  48432. setReflectionTextureMatrix(value: Matrix): void;
  48433. /**
  48434. * Parses a JSON representation of an HDR Texture in order to create the texture
  48435. * @param parsedTexture Define the JSON representation
  48436. * @param scene Define the scene the texture should be created in
  48437. * @param rootUrl Define the root url in case we need to load relative dependencies
  48438. * @returns the newly created texture after parsing
  48439. */
  48440. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  48441. serialize(): any;
  48442. }
  48443. }
  48444. declare module BABYLON {
  48445. /**
  48446. * Class used to control physics engine
  48447. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  48448. */
  48449. export class PhysicsEngine implements IPhysicsEngine {
  48450. private _physicsPlugin;
  48451. /**
  48452. * Global value used to control the smallest number supported by the simulation
  48453. */
  48454. static Epsilon: number;
  48455. private _impostors;
  48456. private _joints;
  48457. /**
  48458. * Gets the gravity vector used by the simulation
  48459. */
  48460. gravity: Vector3;
  48461. /**
  48462. * Factory used to create the default physics plugin.
  48463. * @returns The default physics plugin
  48464. */
  48465. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  48466. /**
  48467. * Creates a new Physics Engine
  48468. * @param gravity defines the gravity vector used by the simulation
  48469. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  48470. */
  48471. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  48472. /**
  48473. * Sets the gravity vector used by the simulation
  48474. * @param gravity defines the gravity vector to use
  48475. */
  48476. setGravity(gravity: Vector3): void;
  48477. /**
  48478. * Set the time step of the physics engine.
  48479. * Default is 1/60.
  48480. * To slow it down, enter 1/600 for example.
  48481. * To speed it up, 1/30
  48482. * @param newTimeStep defines the new timestep to apply to this world.
  48483. */
  48484. setTimeStep(newTimeStep?: number): void;
  48485. /**
  48486. * Get the time step of the physics engine.
  48487. * @returns the current time step
  48488. */
  48489. getTimeStep(): number;
  48490. /**
  48491. * Release all resources
  48492. */
  48493. dispose(): void;
  48494. /**
  48495. * Gets the name of the current physics plugin
  48496. * @returns the name of the plugin
  48497. */
  48498. getPhysicsPluginName(): string;
  48499. /**
  48500. * Adding a new impostor for the impostor tracking.
  48501. * This will be done by the impostor itself.
  48502. * @param impostor the impostor to add
  48503. */
  48504. addImpostor(impostor: PhysicsImpostor): void;
  48505. /**
  48506. * Remove an impostor from the engine.
  48507. * This impostor and its mesh will not longer be updated by the physics engine.
  48508. * @param impostor the impostor to remove
  48509. */
  48510. removeImpostor(impostor: PhysicsImpostor): void;
  48511. /**
  48512. * Add a joint to the physics engine
  48513. * @param mainImpostor defines the main impostor to which the joint is added.
  48514. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  48515. * @param joint defines the joint that will connect both impostors.
  48516. */
  48517. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  48518. /**
  48519. * Removes a joint from the simulation
  48520. * @param mainImpostor defines the impostor used with the joint
  48521. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  48522. * @param joint defines the joint to remove
  48523. */
  48524. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  48525. /**
  48526. * Called by the scene. No need to call it.
  48527. * @param delta defines the timespam between frames
  48528. */
  48529. _step(delta: number): void;
  48530. /**
  48531. * Gets the current plugin used to run the simulation
  48532. * @returns current plugin
  48533. */
  48534. getPhysicsPlugin(): IPhysicsEnginePlugin;
  48535. /**
  48536. * Gets the list of physic impostors
  48537. * @returns an array of PhysicsImpostor
  48538. */
  48539. getImpostors(): Array<PhysicsImpostor>;
  48540. /**
  48541. * Gets the impostor for a physics enabled object
  48542. * @param object defines the object impersonated by the impostor
  48543. * @returns the PhysicsImpostor or null if not found
  48544. */
  48545. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  48546. /**
  48547. * Gets the impostor for a physics body object
  48548. * @param body defines physics body used by the impostor
  48549. * @returns the PhysicsImpostor or null if not found
  48550. */
  48551. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  48552. /**
  48553. * Does a raycast in the physics world
  48554. * @param from when should the ray start?
  48555. * @param to when should the ray end?
  48556. * @returns PhysicsRaycastResult
  48557. */
  48558. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48559. }
  48560. }
  48561. declare module BABYLON {
  48562. /** @hidden */
  48563. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  48564. private _useDeltaForWorldStep;
  48565. world: any;
  48566. name: string;
  48567. private _physicsMaterials;
  48568. private _fixedTimeStep;
  48569. private _cannonRaycastResult;
  48570. private _raycastResult;
  48571. private _removeAfterStep;
  48572. BJSCANNON: any;
  48573. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  48574. setGravity(gravity: Vector3): void;
  48575. setTimeStep(timeStep: number): void;
  48576. getTimeStep(): number;
  48577. executeStep(delta: number): void;
  48578. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48579. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48580. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48581. private _processChildMeshes;
  48582. removePhysicsBody(impostor: PhysicsImpostor): void;
  48583. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48584. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48585. private _addMaterial;
  48586. private _checkWithEpsilon;
  48587. private _createShape;
  48588. private _createHeightmap;
  48589. private _minus90X;
  48590. private _plus90X;
  48591. private _tmpPosition;
  48592. private _tmpDeltaPosition;
  48593. private _tmpUnityRotation;
  48594. private _updatePhysicsBodyTransformation;
  48595. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48596. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48597. isSupported(): boolean;
  48598. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48599. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48600. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48601. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48602. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48603. getBodyMass(impostor: PhysicsImpostor): number;
  48604. getBodyFriction(impostor: PhysicsImpostor): number;
  48605. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48606. getBodyRestitution(impostor: PhysicsImpostor): number;
  48607. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48608. sleepBody(impostor: PhysicsImpostor): void;
  48609. wakeUpBody(impostor: PhysicsImpostor): void;
  48610. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  48611. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48612. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48613. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48614. getRadius(impostor: PhysicsImpostor): number;
  48615. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48616. dispose(): void;
  48617. private _extendNamespace;
  48618. /**
  48619. * Does a raycast in the physics world
  48620. * @param from when should the ray start?
  48621. * @param to when should the ray end?
  48622. * @returns PhysicsRaycastResult
  48623. */
  48624. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48625. }
  48626. }
  48627. declare module BABYLON {
  48628. /** @hidden */
  48629. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  48630. world: any;
  48631. name: string;
  48632. BJSOIMO: any;
  48633. private _raycastResult;
  48634. constructor(iterations?: number, oimoInjection?: any);
  48635. setGravity(gravity: Vector3): void;
  48636. setTimeStep(timeStep: number): void;
  48637. getTimeStep(): number;
  48638. private _tmpImpostorsArray;
  48639. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48640. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48641. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48642. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48643. private _tmpPositionVector;
  48644. removePhysicsBody(impostor: PhysicsImpostor): void;
  48645. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48646. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48647. isSupported(): boolean;
  48648. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48649. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48650. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48651. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48652. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48653. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48654. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48655. getBodyMass(impostor: PhysicsImpostor): number;
  48656. getBodyFriction(impostor: PhysicsImpostor): number;
  48657. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48658. getBodyRestitution(impostor: PhysicsImpostor): number;
  48659. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48660. sleepBody(impostor: PhysicsImpostor): void;
  48661. wakeUpBody(impostor: PhysicsImpostor): void;
  48662. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48663. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  48664. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  48665. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48666. getRadius(impostor: PhysicsImpostor): number;
  48667. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48668. dispose(): void;
  48669. /**
  48670. * Does a raycast in the physics world
  48671. * @param from when should the ray start?
  48672. * @param to when should the ray end?
  48673. * @returns PhysicsRaycastResult
  48674. */
  48675. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48676. }
  48677. }
  48678. declare module BABYLON {
  48679. /**
  48680. * Class containing static functions to help procedurally build meshes
  48681. */
  48682. export class RibbonBuilder {
  48683. /**
  48684. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  48685. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  48686. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  48687. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  48688. * * 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
  48689. * * 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
  48690. * * 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
  48691. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48692. * * 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
  48693. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  48694. * * 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
  48695. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  48696. * * 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
  48697. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  48698. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48699. * @param name defines the name of the mesh
  48700. * @param options defines the options used to create the mesh
  48701. * @param scene defines the hosting scene
  48702. * @returns the ribbon mesh
  48703. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  48704. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48705. */
  48706. static CreateRibbon(name: string, options: {
  48707. pathArray: Vector3[][];
  48708. closeArray?: boolean;
  48709. closePath?: boolean;
  48710. offset?: number;
  48711. updatable?: boolean;
  48712. sideOrientation?: number;
  48713. frontUVs?: Vector4;
  48714. backUVs?: Vector4;
  48715. instance?: Mesh;
  48716. invertUV?: boolean;
  48717. uvs?: Vector2[];
  48718. colors?: Color4[];
  48719. }, scene?: Nullable<Scene>): Mesh;
  48720. }
  48721. }
  48722. declare module BABYLON {
  48723. /**
  48724. * Class containing static functions to help procedurally build meshes
  48725. */
  48726. export class ShapeBuilder {
  48727. /**
  48728. * 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.
  48729. * * 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.
  48730. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  48731. * * 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.
  48732. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  48733. * * 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
  48734. * * 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
  48735. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  48736. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48737. * * 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
  48738. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  48739. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48740. * @param name defines the name of the mesh
  48741. * @param options defines the options used to create the mesh
  48742. * @param scene defines the hosting scene
  48743. * @returns the extruded shape mesh
  48744. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48745. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  48746. */
  48747. static ExtrudeShape(name: string, options: {
  48748. shape: Vector3[];
  48749. path: Vector3[];
  48750. scale?: number;
  48751. rotation?: number;
  48752. cap?: number;
  48753. updatable?: boolean;
  48754. sideOrientation?: number;
  48755. frontUVs?: Vector4;
  48756. backUVs?: Vector4;
  48757. instance?: Mesh;
  48758. invertUV?: boolean;
  48759. }, scene?: Nullable<Scene>): Mesh;
  48760. /**
  48761. * Creates an custom extruded shape mesh.
  48762. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  48763. * * 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.
  48764. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  48765. * * 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
  48766. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  48767. * * 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
  48768. * * It must returns a float value that will be the scale value applied to the shape on each path point
  48769. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  48770. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  48771. * * 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
  48772. * * 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
  48773. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  48774. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48775. * * 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
  48776. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  48777. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48778. * @param name defines the name of the mesh
  48779. * @param options defines the options used to create the mesh
  48780. * @param scene defines the hosting scene
  48781. * @returns the custom extruded shape mesh
  48782. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  48783. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48784. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  48785. */
  48786. static ExtrudeShapeCustom(name: string, options: {
  48787. shape: Vector3[];
  48788. path: Vector3[];
  48789. scaleFunction?: any;
  48790. rotationFunction?: any;
  48791. ribbonCloseArray?: boolean;
  48792. ribbonClosePath?: boolean;
  48793. cap?: number;
  48794. updatable?: boolean;
  48795. sideOrientation?: number;
  48796. frontUVs?: Vector4;
  48797. backUVs?: Vector4;
  48798. instance?: Mesh;
  48799. invertUV?: boolean;
  48800. }, scene?: Nullable<Scene>): Mesh;
  48801. private static _ExtrudeShapeGeneric;
  48802. }
  48803. }
  48804. declare module BABYLON {
  48805. /**
  48806. * AmmoJS Physics plugin
  48807. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48808. * @see https://github.com/kripken/ammo.js/
  48809. */
  48810. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  48811. private _useDeltaForWorldStep;
  48812. /**
  48813. * Reference to the Ammo library
  48814. */
  48815. bjsAMMO: any;
  48816. /**
  48817. * Created ammoJS world which physics bodies are added to
  48818. */
  48819. world: any;
  48820. /**
  48821. * Name of the plugin
  48822. */
  48823. name: string;
  48824. private _timeStep;
  48825. private _fixedTimeStep;
  48826. private _maxSteps;
  48827. private _tmpQuaternion;
  48828. private _tmpAmmoTransform;
  48829. private _tmpAmmoQuaternion;
  48830. private _tmpAmmoConcreteContactResultCallback;
  48831. private _collisionConfiguration;
  48832. private _dispatcher;
  48833. private _overlappingPairCache;
  48834. private _solver;
  48835. private _softBodySolver;
  48836. private _tmpAmmoVectorA;
  48837. private _tmpAmmoVectorB;
  48838. private _tmpAmmoVectorC;
  48839. private _tmpAmmoVectorD;
  48840. private _tmpContactCallbackResult;
  48841. private _tmpAmmoVectorRCA;
  48842. private _tmpAmmoVectorRCB;
  48843. private _raycastResult;
  48844. private static readonly DISABLE_COLLISION_FLAG;
  48845. private static readonly KINEMATIC_FLAG;
  48846. private static readonly DISABLE_DEACTIVATION_FLAG;
  48847. /**
  48848. * Initializes the ammoJS plugin
  48849. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  48850. * @param ammoInjection can be used to inject your own ammo reference
  48851. */
  48852. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  48853. /**
  48854. * Sets the gravity of the physics world (m/(s^2))
  48855. * @param gravity Gravity to set
  48856. */
  48857. setGravity(gravity: Vector3): void;
  48858. /**
  48859. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  48860. * @param timeStep timestep to use in seconds
  48861. */
  48862. setTimeStep(timeStep: number): void;
  48863. /**
  48864. * 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)
  48865. * @param fixedTimeStep fixedTimeStep to use in seconds
  48866. */
  48867. setFixedTimeStep(fixedTimeStep: number): void;
  48868. /**
  48869. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  48870. * @param maxSteps the maximum number of steps by the physics engine per frame
  48871. */
  48872. setMaxSteps(maxSteps: number): void;
  48873. /**
  48874. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  48875. * @returns the current timestep in seconds
  48876. */
  48877. getTimeStep(): number;
  48878. private _isImpostorInContact;
  48879. private _isImpostorPairInContact;
  48880. private _stepSimulation;
  48881. /**
  48882. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  48883. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  48884. * After the step the babylon meshes are set to the position of the physics imposters
  48885. * @param delta amount of time to step forward
  48886. * @param impostors array of imposters to update before/after the step
  48887. */
  48888. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48889. /**
  48890. * Update babylon mesh to match physics world object
  48891. * @param impostor imposter to match
  48892. */
  48893. private _afterSoftStep;
  48894. /**
  48895. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  48896. * @param impostor imposter to match
  48897. */
  48898. private _ropeStep;
  48899. /**
  48900. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  48901. * @param impostor imposter to match
  48902. */
  48903. private _softbodyOrClothStep;
  48904. private _tmpVector;
  48905. private _tmpMatrix;
  48906. /**
  48907. * Applies an impulse on the imposter
  48908. * @param impostor imposter to apply impulse to
  48909. * @param force amount of force to be applied to the imposter
  48910. * @param contactPoint the location to apply the impulse on the imposter
  48911. */
  48912. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48913. /**
  48914. * Applies a force on the imposter
  48915. * @param impostor imposter to apply force
  48916. * @param force amount of force to be applied to the imposter
  48917. * @param contactPoint the location to apply the force on the imposter
  48918. */
  48919. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48920. /**
  48921. * Creates a physics body using the plugin
  48922. * @param impostor the imposter to create the physics body on
  48923. */
  48924. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48925. /**
  48926. * Removes the physics body from the imposter and disposes of the body's memory
  48927. * @param impostor imposter to remove the physics body from
  48928. */
  48929. removePhysicsBody(impostor: PhysicsImpostor): void;
  48930. /**
  48931. * Generates a joint
  48932. * @param impostorJoint the imposter joint to create the joint with
  48933. */
  48934. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48935. /**
  48936. * Removes a joint
  48937. * @param impostorJoint the imposter joint to remove the joint from
  48938. */
  48939. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48940. private _addMeshVerts;
  48941. /**
  48942. * Initialise the soft body vertices to match its object's (mesh) vertices
  48943. * Softbody vertices (nodes) are in world space and to match this
  48944. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  48945. * @param impostor to create the softbody for
  48946. */
  48947. private _softVertexData;
  48948. /**
  48949. * Create an impostor's soft body
  48950. * @param impostor to create the softbody for
  48951. */
  48952. private _createSoftbody;
  48953. /**
  48954. * Create cloth for an impostor
  48955. * @param impostor to create the softbody for
  48956. */
  48957. private _createCloth;
  48958. /**
  48959. * Create rope for an impostor
  48960. * @param impostor to create the softbody for
  48961. */
  48962. private _createRope;
  48963. private _addHullVerts;
  48964. private _createShape;
  48965. /**
  48966. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  48967. * @param impostor imposter containing the physics body and babylon object
  48968. */
  48969. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48970. /**
  48971. * Sets the babylon object's position/rotation from the physics body's position/rotation
  48972. * @param impostor imposter containing the physics body and babylon object
  48973. * @param newPosition new position
  48974. * @param newRotation new rotation
  48975. */
  48976. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48977. /**
  48978. * If this plugin is supported
  48979. * @returns true if its supported
  48980. */
  48981. isSupported(): boolean;
  48982. /**
  48983. * Sets the linear velocity of the physics body
  48984. * @param impostor imposter to set the velocity on
  48985. * @param velocity velocity to set
  48986. */
  48987. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48988. /**
  48989. * Sets the angular velocity of the physics body
  48990. * @param impostor imposter to set the velocity on
  48991. * @param velocity velocity to set
  48992. */
  48993. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48994. /**
  48995. * gets the linear velocity
  48996. * @param impostor imposter to get linear velocity from
  48997. * @returns linear velocity
  48998. */
  48999. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49000. /**
  49001. * gets the angular velocity
  49002. * @param impostor imposter to get angular velocity from
  49003. * @returns angular velocity
  49004. */
  49005. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49006. /**
  49007. * Sets the mass of physics body
  49008. * @param impostor imposter to set the mass on
  49009. * @param mass mass to set
  49010. */
  49011. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49012. /**
  49013. * Gets the mass of the physics body
  49014. * @param impostor imposter to get the mass from
  49015. * @returns mass
  49016. */
  49017. getBodyMass(impostor: PhysicsImpostor): number;
  49018. /**
  49019. * Gets friction of the impostor
  49020. * @param impostor impostor to get friction from
  49021. * @returns friction value
  49022. */
  49023. getBodyFriction(impostor: PhysicsImpostor): number;
  49024. /**
  49025. * Sets friction of the impostor
  49026. * @param impostor impostor to set friction on
  49027. * @param friction friction value
  49028. */
  49029. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49030. /**
  49031. * Gets restitution of the impostor
  49032. * @param impostor impostor to get restitution from
  49033. * @returns restitution value
  49034. */
  49035. getBodyRestitution(impostor: PhysicsImpostor): number;
  49036. /**
  49037. * Sets resitution of the impostor
  49038. * @param impostor impostor to set resitution on
  49039. * @param restitution resitution value
  49040. */
  49041. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49042. /**
  49043. * Gets pressure inside the impostor
  49044. * @param impostor impostor to get pressure from
  49045. * @returns pressure value
  49046. */
  49047. getBodyPressure(impostor: PhysicsImpostor): number;
  49048. /**
  49049. * Sets pressure inside a soft body impostor
  49050. * Cloth and rope must remain 0 pressure
  49051. * @param impostor impostor to set pressure on
  49052. * @param pressure pressure value
  49053. */
  49054. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  49055. /**
  49056. * Gets stiffness of the impostor
  49057. * @param impostor impostor to get stiffness from
  49058. * @returns pressure value
  49059. */
  49060. getBodyStiffness(impostor: PhysicsImpostor): number;
  49061. /**
  49062. * Sets stiffness of the impostor
  49063. * @param impostor impostor to set stiffness on
  49064. * @param stiffness stiffness value from 0 to 1
  49065. */
  49066. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  49067. /**
  49068. * Gets velocityIterations of the impostor
  49069. * @param impostor impostor to get velocity iterations from
  49070. * @returns velocityIterations value
  49071. */
  49072. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  49073. /**
  49074. * Sets velocityIterations of the impostor
  49075. * @param impostor impostor to set velocity iterations on
  49076. * @param velocityIterations velocityIterations value
  49077. */
  49078. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  49079. /**
  49080. * Gets positionIterations of the impostor
  49081. * @param impostor impostor to get position iterations from
  49082. * @returns positionIterations value
  49083. */
  49084. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  49085. /**
  49086. * Sets positionIterations of the impostor
  49087. * @param impostor impostor to set position on
  49088. * @param positionIterations positionIterations value
  49089. */
  49090. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  49091. /**
  49092. * Append an anchor to a cloth object
  49093. * @param impostor is the cloth impostor to add anchor to
  49094. * @param otherImpostor is the rigid impostor to anchor to
  49095. * @param width ratio across width from 0 to 1
  49096. * @param height ratio up height from 0 to 1
  49097. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  49098. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  49099. */
  49100. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  49101. /**
  49102. * Append an hook to a rope object
  49103. * @param impostor is the rope impostor to add hook to
  49104. * @param otherImpostor is the rigid impostor to hook to
  49105. * @param length ratio along the rope from 0 to 1
  49106. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  49107. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  49108. */
  49109. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  49110. /**
  49111. * Sleeps the physics body and stops it from being active
  49112. * @param impostor impostor to sleep
  49113. */
  49114. sleepBody(impostor: PhysicsImpostor): void;
  49115. /**
  49116. * Activates the physics body
  49117. * @param impostor impostor to activate
  49118. */
  49119. wakeUpBody(impostor: PhysicsImpostor): void;
  49120. /**
  49121. * Updates the distance parameters of the joint
  49122. * @param joint joint to update
  49123. * @param maxDistance maximum distance of the joint
  49124. * @param minDistance minimum distance of the joint
  49125. */
  49126. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49127. /**
  49128. * Sets a motor on the joint
  49129. * @param joint joint to set motor on
  49130. * @param speed speed of the motor
  49131. * @param maxForce maximum force of the motor
  49132. * @param motorIndex index of the motor
  49133. */
  49134. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49135. /**
  49136. * Sets the motors limit
  49137. * @param joint joint to set limit on
  49138. * @param upperLimit upper limit
  49139. * @param lowerLimit lower limit
  49140. */
  49141. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49142. /**
  49143. * Syncs the position and rotation of a mesh with the impostor
  49144. * @param mesh mesh to sync
  49145. * @param impostor impostor to update the mesh with
  49146. */
  49147. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49148. /**
  49149. * Gets the radius of the impostor
  49150. * @param impostor impostor to get radius from
  49151. * @returns the radius
  49152. */
  49153. getRadius(impostor: PhysicsImpostor): number;
  49154. /**
  49155. * Gets the box size of the impostor
  49156. * @param impostor impostor to get box size from
  49157. * @param result the resulting box size
  49158. */
  49159. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49160. /**
  49161. * Disposes of the impostor
  49162. */
  49163. dispose(): void;
  49164. /**
  49165. * Does a raycast in the physics world
  49166. * @param from when should the ray start?
  49167. * @param to when should the ray end?
  49168. * @returns PhysicsRaycastResult
  49169. */
  49170. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49171. }
  49172. }
  49173. declare module BABYLON {
  49174. interface AbstractScene {
  49175. /**
  49176. * The list of reflection probes added to the scene
  49177. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  49178. */
  49179. reflectionProbes: Array<ReflectionProbe>;
  49180. /**
  49181. * Removes the given reflection probe from this scene.
  49182. * @param toRemove The reflection probe to remove
  49183. * @returns The index of the removed reflection probe
  49184. */
  49185. removeReflectionProbe(toRemove: ReflectionProbe): number;
  49186. /**
  49187. * Adds the given reflection probe to this scene.
  49188. * @param newReflectionProbe The reflection probe to add
  49189. */
  49190. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  49191. }
  49192. /**
  49193. * Class used to generate realtime reflection / refraction cube textures
  49194. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  49195. */
  49196. export class ReflectionProbe {
  49197. /** defines the name of the probe */
  49198. name: string;
  49199. private _scene;
  49200. private _renderTargetTexture;
  49201. private _projectionMatrix;
  49202. private _viewMatrix;
  49203. private _target;
  49204. private _add;
  49205. private _attachedMesh;
  49206. private _invertYAxis;
  49207. /** Gets or sets probe position (center of the cube map) */
  49208. position: Vector3;
  49209. /**
  49210. * Creates a new reflection probe
  49211. * @param name defines the name of the probe
  49212. * @param size defines the texture resolution (for each face)
  49213. * @param scene defines the hosting scene
  49214. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  49215. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  49216. */
  49217. constructor(
  49218. /** defines the name of the probe */
  49219. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  49220. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  49221. samples: number;
  49222. /** Gets or sets the refresh rate to use (on every frame by default) */
  49223. refreshRate: number;
  49224. /**
  49225. * Gets the hosting scene
  49226. * @returns a Scene
  49227. */
  49228. getScene(): Scene;
  49229. /** Gets the internal CubeTexture used to render to */
  49230. readonly cubeTexture: RenderTargetTexture;
  49231. /** Gets the list of meshes to render */
  49232. readonly renderList: Nullable<AbstractMesh[]>;
  49233. /**
  49234. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  49235. * @param mesh defines the mesh to attach to
  49236. */
  49237. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  49238. /**
  49239. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  49240. * @param renderingGroupId The rendering group id corresponding to its index
  49241. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  49242. */
  49243. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  49244. /**
  49245. * Clean all associated resources
  49246. */
  49247. dispose(): void;
  49248. /**
  49249. * Converts the reflection probe information to a readable string for debug purpose.
  49250. * @param fullDetails Supports for multiple levels of logging within scene loading
  49251. * @returns the human readable reflection probe info
  49252. */
  49253. toString(fullDetails?: boolean): string;
  49254. /**
  49255. * Get the class name of the relfection probe.
  49256. * @returns "ReflectionProbe"
  49257. */
  49258. getClassName(): string;
  49259. /**
  49260. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  49261. * @returns The JSON representation of the texture
  49262. */
  49263. serialize(): any;
  49264. /**
  49265. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  49266. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  49267. * @param scene Define the scene the parsed reflection probe should be instantiated in
  49268. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  49269. * @returns The parsed reflection probe if successful
  49270. */
  49271. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  49272. }
  49273. }
  49274. declare module BABYLON {
  49275. /** @hidden */
  49276. export var _BabylonLoaderRegistered: boolean;
  49277. }
  49278. declare module BABYLON {
  49279. /**
  49280. * The Physically based simple base material of BJS.
  49281. *
  49282. * This enables better naming and convention enforcements on top of the pbrMaterial.
  49283. * It is used as the base class for both the specGloss and metalRough conventions.
  49284. */
  49285. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  49286. /**
  49287. * Number of Simultaneous lights allowed on the material.
  49288. */
  49289. maxSimultaneousLights: number;
  49290. /**
  49291. * If sets to true, disables all the lights affecting the material.
  49292. */
  49293. disableLighting: boolean;
  49294. /**
  49295. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  49296. */
  49297. environmentTexture: BaseTexture;
  49298. /**
  49299. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  49300. */
  49301. invertNormalMapX: boolean;
  49302. /**
  49303. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  49304. */
  49305. invertNormalMapY: boolean;
  49306. /**
  49307. * Normal map used in the model.
  49308. */
  49309. normalTexture: BaseTexture;
  49310. /**
  49311. * Emissivie color used to self-illuminate the model.
  49312. */
  49313. emissiveColor: Color3;
  49314. /**
  49315. * Emissivie texture used to self-illuminate the model.
  49316. */
  49317. emissiveTexture: BaseTexture;
  49318. /**
  49319. * Occlusion Channel Strenght.
  49320. */
  49321. occlusionStrength: number;
  49322. /**
  49323. * Occlusion Texture of the material (adding extra occlusion effects).
  49324. */
  49325. occlusionTexture: BaseTexture;
  49326. /**
  49327. * Defines the alpha limits in alpha test mode.
  49328. */
  49329. alphaCutOff: number;
  49330. /**
  49331. * Gets the current double sided mode.
  49332. */
  49333. /**
  49334. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49335. */
  49336. doubleSided: boolean;
  49337. /**
  49338. * Stores the pre-calculated light information of a mesh in a texture.
  49339. */
  49340. lightmapTexture: BaseTexture;
  49341. /**
  49342. * If true, the light map contains occlusion information instead of lighting info.
  49343. */
  49344. useLightmapAsShadowmap: boolean;
  49345. /**
  49346. * Instantiates a new PBRMaterial instance.
  49347. *
  49348. * @param name The material name
  49349. * @param scene The scene the material will be use in.
  49350. */
  49351. constructor(name: string, scene: Scene);
  49352. getClassName(): string;
  49353. }
  49354. }
  49355. declare module BABYLON {
  49356. /**
  49357. * The PBR material of BJS following the metal roughness convention.
  49358. *
  49359. * This fits to the PBR convention in the GLTF definition:
  49360. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  49361. */
  49362. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  49363. /**
  49364. * The base color has two different interpretations depending on the value of metalness.
  49365. * When the material is a metal, the base color is the specific measured reflectance value
  49366. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  49367. * of the material.
  49368. */
  49369. baseColor: Color3;
  49370. /**
  49371. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  49372. * well as opacity information in the alpha channel.
  49373. */
  49374. baseTexture: BaseTexture;
  49375. /**
  49376. * Specifies the metallic scalar value of the material.
  49377. * Can also be used to scale the metalness values of the metallic texture.
  49378. */
  49379. metallic: number;
  49380. /**
  49381. * Specifies the roughness scalar value of the material.
  49382. * Can also be used to scale the roughness values of the metallic texture.
  49383. */
  49384. roughness: number;
  49385. /**
  49386. * Texture containing both the metallic value in the B channel and the
  49387. * roughness value in the G channel to keep better precision.
  49388. */
  49389. metallicRoughnessTexture: BaseTexture;
  49390. /**
  49391. * Instantiates a new PBRMetalRoughnessMaterial instance.
  49392. *
  49393. * @param name The material name
  49394. * @param scene The scene the material will be use in.
  49395. */
  49396. constructor(name: string, scene: Scene);
  49397. /**
  49398. * Return the currrent class name of the material.
  49399. */
  49400. getClassName(): string;
  49401. /**
  49402. * Makes a duplicate of the current material.
  49403. * @param name - name to use for the new material.
  49404. */
  49405. clone(name: string): PBRMetallicRoughnessMaterial;
  49406. /**
  49407. * Serialize the material to a parsable JSON object.
  49408. */
  49409. serialize(): any;
  49410. /**
  49411. * Parses a JSON object correponding to the serialize function.
  49412. */
  49413. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  49414. }
  49415. }
  49416. declare module BABYLON {
  49417. /**
  49418. * The PBR material of BJS following the specular glossiness convention.
  49419. *
  49420. * This fits to the PBR convention in the GLTF definition:
  49421. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  49422. */
  49423. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  49424. /**
  49425. * Specifies the diffuse color of the material.
  49426. */
  49427. diffuseColor: Color3;
  49428. /**
  49429. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  49430. * channel.
  49431. */
  49432. diffuseTexture: BaseTexture;
  49433. /**
  49434. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  49435. */
  49436. specularColor: Color3;
  49437. /**
  49438. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  49439. */
  49440. glossiness: number;
  49441. /**
  49442. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  49443. */
  49444. specularGlossinessTexture: BaseTexture;
  49445. /**
  49446. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  49447. *
  49448. * @param name The material name
  49449. * @param scene The scene the material will be use in.
  49450. */
  49451. constructor(name: string, scene: Scene);
  49452. /**
  49453. * Return the currrent class name of the material.
  49454. */
  49455. getClassName(): string;
  49456. /**
  49457. * Makes a duplicate of the current material.
  49458. * @param name - name to use for the new material.
  49459. */
  49460. clone(name: string): PBRSpecularGlossinessMaterial;
  49461. /**
  49462. * Serialize the material to a parsable JSON object.
  49463. */
  49464. serialize(): any;
  49465. /**
  49466. * Parses a JSON object correponding to the serialize function.
  49467. */
  49468. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  49469. }
  49470. }
  49471. declare module BABYLON {
  49472. /**
  49473. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  49474. * It can help converting any input color in a desired output one. This can then be used to create effects
  49475. * from sepia, black and white to sixties or futuristic rendering...
  49476. *
  49477. * The only supported format is currently 3dl.
  49478. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  49479. */
  49480. export class ColorGradingTexture extends BaseTexture {
  49481. /**
  49482. * The current texture matrix. (will always be identity in color grading texture)
  49483. */
  49484. private _textureMatrix;
  49485. /**
  49486. * The texture URL.
  49487. */
  49488. url: string;
  49489. /**
  49490. * Empty line regex stored for GC.
  49491. */
  49492. private static _noneEmptyLineRegex;
  49493. private _engine;
  49494. /**
  49495. * Instantiates a ColorGradingTexture from the following parameters.
  49496. *
  49497. * @param url The location of the color gradind data (currently only supporting 3dl)
  49498. * @param scene The scene the texture will be used in
  49499. */
  49500. constructor(url: string, scene: Scene);
  49501. /**
  49502. * Returns the texture matrix used in most of the material.
  49503. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  49504. */
  49505. getTextureMatrix(): Matrix;
  49506. /**
  49507. * Occurs when the file being loaded is a .3dl LUT file.
  49508. */
  49509. private load3dlTexture;
  49510. /**
  49511. * Starts the loading process of the texture.
  49512. */
  49513. private loadTexture;
  49514. /**
  49515. * Clones the color gradind texture.
  49516. */
  49517. clone(): ColorGradingTexture;
  49518. /**
  49519. * Called during delayed load for textures.
  49520. */
  49521. delayLoad(): void;
  49522. /**
  49523. * Parses a color grading texture serialized by Babylon.
  49524. * @param parsedTexture The texture information being parsedTexture
  49525. * @param scene The scene to load the texture in
  49526. * @param rootUrl The root url of the data assets to load
  49527. * @return A color gradind texture
  49528. */
  49529. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  49530. /**
  49531. * Serializes the LUT texture to json format.
  49532. */
  49533. serialize(): any;
  49534. }
  49535. }
  49536. declare module BABYLON {
  49537. /**
  49538. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  49539. */
  49540. export class EquiRectangularCubeTexture extends BaseTexture {
  49541. /** The six faces of the cube. */
  49542. private static _FacesMapping;
  49543. private _noMipmap;
  49544. private _onLoad;
  49545. private _onError;
  49546. /** The size of the cubemap. */
  49547. private _size;
  49548. /** The buffer of the image. */
  49549. private _buffer;
  49550. /** The width of the input image. */
  49551. private _width;
  49552. /** The height of the input image. */
  49553. private _height;
  49554. /** The URL to the image. */
  49555. url: string;
  49556. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  49557. coordinatesMode: number;
  49558. /**
  49559. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  49560. * @param url The location of the image
  49561. * @param scene The scene the texture will be used in
  49562. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  49563. * @param noMipmap Forces to not generate the mipmap if true
  49564. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  49565. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  49566. * @param onLoad — defines a callback called when texture is loaded
  49567. * @param onError — defines a callback called if there is an error
  49568. */
  49569. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  49570. /**
  49571. * Load the image data, by putting the image on a canvas and extracting its buffer.
  49572. */
  49573. private loadImage;
  49574. /**
  49575. * Convert the image buffer into a cubemap and create a CubeTexture.
  49576. */
  49577. private loadTexture;
  49578. /**
  49579. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  49580. * @param buffer The ArrayBuffer that should be converted.
  49581. * @returns The buffer as Float32Array.
  49582. */
  49583. private getFloat32ArrayFromArrayBuffer;
  49584. /**
  49585. * Get the current class name of the texture useful for serialization or dynamic coding.
  49586. * @returns "EquiRectangularCubeTexture"
  49587. */
  49588. getClassName(): string;
  49589. /**
  49590. * Create a clone of the current EquiRectangularCubeTexture and return it.
  49591. * @returns A clone of the current EquiRectangularCubeTexture.
  49592. */
  49593. clone(): EquiRectangularCubeTexture;
  49594. }
  49595. }
  49596. declare module BABYLON {
  49597. /**
  49598. * Based on jsTGALoader - Javascript loader for TGA file
  49599. * By Vincent Thibault
  49600. * @see http://blog.robrowser.com/javascript-tga-loader.html
  49601. */
  49602. export class TGATools {
  49603. private static _TYPE_INDEXED;
  49604. private static _TYPE_RGB;
  49605. private static _TYPE_GREY;
  49606. private static _TYPE_RLE_INDEXED;
  49607. private static _TYPE_RLE_RGB;
  49608. private static _TYPE_RLE_GREY;
  49609. private static _ORIGIN_MASK;
  49610. private static _ORIGIN_SHIFT;
  49611. private static _ORIGIN_BL;
  49612. private static _ORIGIN_BR;
  49613. private static _ORIGIN_UL;
  49614. private static _ORIGIN_UR;
  49615. /**
  49616. * Gets the header of a TGA file
  49617. * @param data defines the TGA data
  49618. * @returns the header
  49619. */
  49620. static GetTGAHeader(data: Uint8Array): any;
  49621. /**
  49622. * Uploads TGA content to a Babylon Texture
  49623. * @hidden
  49624. */
  49625. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  49626. /** @hidden */
  49627. 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;
  49628. /** @hidden */
  49629. 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;
  49630. /** @hidden */
  49631. 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;
  49632. /** @hidden */
  49633. 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;
  49634. /** @hidden */
  49635. 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;
  49636. /** @hidden */
  49637. 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;
  49638. }
  49639. }
  49640. declare module BABYLON {
  49641. /**
  49642. * Implementation of the TGA Texture Loader.
  49643. * @hidden
  49644. */
  49645. export class _TGATextureLoader implements IInternalTextureLoader {
  49646. /**
  49647. * Defines wether the loader supports cascade loading the different faces.
  49648. */
  49649. readonly supportCascades: boolean;
  49650. /**
  49651. * This returns if the loader support the current file information.
  49652. * @param extension defines the file extension of the file being loaded
  49653. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49654. * @param fallback defines the fallback internal texture if any
  49655. * @param isBase64 defines whether the texture is encoded as a base64
  49656. * @param isBuffer defines whether the texture data are stored as a buffer
  49657. * @returns true if the loader can load the specified file
  49658. */
  49659. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49660. /**
  49661. * Transform the url before loading if required.
  49662. * @param rootUrl the url of the texture
  49663. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49664. * @returns the transformed texture
  49665. */
  49666. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49667. /**
  49668. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49669. * @param rootUrl the url of the texture
  49670. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49671. * @returns the fallback texture
  49672. */
  49673. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49674. /**
  49675. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49676. * @param data contains the texture data
  49677. * @param texture defines the BabylonJS internal texture
  49678. * @param createPolynomials will be true if polynomials have been requested
  49679. * @param onLoad defines the callback to trigger once the texture is ready
  49680. * @param onError defines the callback to trigger in case of error
  49681. */
  49682. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49683. /**
  49684. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49685. * @param data contains the texture data
  49686. * @param texture defines the BabylonJS internal texture
  49687. * @param callback defines the method to call once ready to upload
  49688. */
  49689. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49690. }
  49691. }
  49692. declare module BABYLON {
  49693. /**
  49694. * 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.
  49695. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49696. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49697. */
  49698. export class CustomProceduralTexture extends ProceduralTexture {
  49699. private _animate;
  49700. private _time;
  49701. private _config;
  49702. private _texturePath;
  49703. /**
  49704. * Instantiates a new Custom Procedural Texture.
  49705. * 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.
  49706. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49707. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49708. * @param name Define the name of the texture
  49709. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  49710. * @param size Define the size of the texture to create
  49711. * @param scene Define the scene the texture belongs to
  49712. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  49713. * @param generateMipMaps Define if the texture should creates mip maps or not
  49714. */
  49715. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49716. private _loadJson;
  49717. /**
  49718. * Is the texture ready to be used ? (rendered at least once)
  49719. * @returns true if ready, otherwise, false.
  49720. */
  49721. isReady(): boolean;
  49722. /**
  49723. * Render the texture to its associated render target.
  49724. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  49725. */
  49726. render(useCameraPostProcess?: boolean): void;
  49727. /**
  49728. * Update the list of dependant textures samplers in the shader.
  49729. */
  49730. updateTextures(): void;
  49731. /**
  49732. * Update the uniform values of the procedural texture in the shader.
  49733. */
  49734. updateShaderUniforms(): void;
  49735. /**
  49736. * Define if the texture animates or not.
  49737. */
  49738. animate: boolean;
  49739. }
  49740. }
  49741. declare module BABYLON {
  49742. /** @hidden */
  49743. export var noisePixelShader: {
  49744. name: string;
  49745. shader: string;
  49746. };
  49747. }
  49748. declare module BABYLON {
  49749. /**
  49750. * Class used to generate noise procedural textures
  49751. */
  49752. export class NoiseProceduralTexture extends ProceduralTexture {
  49753. private _time;
  49754. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  49755. brightness: number;
  49756. /** Defines the number of octaves to process */
  49757. octaves: number;
  49758. /** Defines the level of persistence (0.8 by default) */
  49759. persistence: number;
  49760. /** Gets or sets animation speed factor (default is 1) */
  49761. animationSpeedFactor: number;
  49762. /**
  49763. * Creates a new NoiseProceduralTexture
  49764. * @param name defines the name fo the texture
  49765. * @param size defines the size of the texture (default is 256)
  49766. * @param scene defines the hosting scene
  49767. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  49768. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  49769. */
  49770. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49771. private _updateShaderUniforms;
  49772. protected _getDefines(): string;
  49773. /** Generate the current state of the procedural texture */
  49774. render(useCameraPostProcess?: boolean): void;
  49775. /**
  49776. * Serializes this noise procedural texture
  49777. * @returns a serialized noise procedural texture object
  49778. */
  49779. serialize(): any;
  49780. /**
  49781. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  49782. * @param parsedTexture defines parsed texture data
  49783. * @param scene defines the current scene
  49784. * @param rootUrl defines the root URL containing noise procedural texture information
  49785. * @returns a parsed NoiseProceduralTexture
  49786. */
  49787. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  49788. }
  49789. }
  49790. declare module BABYLON {
  49791. /**
  49792. * Raw cube texture where the raw buffers are passed in
  49793. */
  49794. export class RawCubeTexture extends CubeTexture {
  49795. /**
  49796. * Creates a cube texture where the raw buffers are passed in.
  49797. * @param scene defines the scene the texture is attached to
  49798. * @param data defines the array of data to use to create each face
  49799. * @param size defines the size of the textures
  49800. * @param format defines the format of the data
  49801. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  49802. * @param generateMipMaps defines if the engine should generate the mip levels
  49803. * @param invertY defines if data must be stored with Y axis inverted
  49804. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  49805. * @param compression defines the compression used (null by default)
  49806. */
  49807. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  49808. /**
  49809. * Updates the raw cube texture.
  49810. * @param data defines the data to store
  49811. * @param format defines the data format
  49812. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  49813. * @param invertY defines if data must be stored with Y axis inverted
  49814. * @param compression defines the compression used (null by default)
  49815. * @param level defines which level of the texture to update
  49816. */
  49817. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  49818. /**
  49819. * Updates a raw cube texture with RGBD encoded data.
  49820. * @param data defines the array of data [mipmap][face] to use to create each face
  49821. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  49822. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  49823. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  49824. * @returns a promsie that resolves when the operation is complete
  49825. */
  49826. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  49827. /**
  49828. * Clones the raw cube texture.
  49829. * @return a new cube texture
  49830. */
  49831. clone(): CubeTexture;
  49832. /** @hidden */
  49833. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49834. }
  49835. }
  49836. declare module BABYLON {
  49837. /**
  49838. * Class used to store 3D textures containing user data
  49839. */
  49840. export class RawTexture3D extends Texture {
  49841. /** Gets or sets the texture format to use */
  49842. format: number;
  49843. private _engine;
  49844. /**
  49845. * Create a new RawTexture3D
  49846. * @param data defines the data of the texture
  49847. * @param width defines the width of the texture
  49848. * @param height defines the height of the texture
  49849. * @param depth defines the depth of the texture
  49850. * @param format defines the texture format to use
  49851. * @param scene defines the hosting scene
  49852. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  49853. * @param invertY defines if texture must be stored with Y axis inverted
  49854. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  49855. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  49856. */
  49857. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  49858. /** Gets or sets the texture format to use */
  49859. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  49860. /**
  49861. * Update the texture with new data
  49862. * @param data defines the data to store in the texture
  49863. */
  49864. update(data: ArrayBufferView): void;
  49865. }
  49866. }
  49867. declare module BABYLON {
  49868. /**
  49869. * Creates a refraction texture used by refraction channel of the standard material.
  49870. * It is like a mirror but to see through a material.
  49871. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49872. */
  49873. export class RefractionTexture extends RenderTargetTexture {
  49874. /**
  49875. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  49876. * 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.
  49877. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49878. */
  49879. refractionPlane: Plane;
  49880. /**
  49881. * Define how deep under the surface we should see.
  49882. */
  49883. depth: number;
  49884. /**
  49885. * Creates a refraction texture used by refraction channel of the standard material.
  49886. * It is like a mirror but to see through a material.
  49887. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49888. * @param name Define the texture name
  49889. * @param size Define the size of the underlying texture
  49890. * @param scene Define the scene the refraction belongs to
  49891. * @param generateMipMaps Define if we need to generate mips level for the refraction
  49892. */
  49893. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  49894. /**
  49895. * Clone the refraction texture.
  49896. * @returns the cloned texture
  49897. */
  49898. clone(): RefractionTexture;
  49899. /**
  49900. * Serialize the texture to a JSON representation you could use in Parse later on
  49901. * @returns the serialized JSON representation
  49902. */
  49903. serialize(): any;
  49904. }
  49905. }
  49906. declare module BABYLON {
  49907. /**
  49908. * Defines the options related to the creation of an HtmlElementTexture
  49909. */
  49910. export interface IHtmlElementTextureOptions {
  49911. /**
  49912. * Defines wether mip maps should be created or not.
  49913. */
  49914. generateMipMaps?: boolean;
  49915. /**
  49916. * Defines the sampling mode of the texture.
  49917. */
  49918. samplingMode?: number;
  49919. /**
  49920. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  49921. */
  49922. engine: Nullable<Engine>;
  49923. /**
  49924. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  49925. */
  49926. scene: Nullable<Scene>;
  49927. }
  49928. /**
  49929. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  49930. * To be as efficient as possible depending on your constraints nothing aside the first upload
  49931. * is automatically managed.
  49932. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  49933. * in your application.
  49934. *
  49935. * As the update is not automatic, you need to call them manually.
  49936. */
  49937. export class HtmlElementTexture extends BaseTexture {
  49938. /**
  49939. * The texture URL.
  49940. */
  49941. element: HTMLVideoElement | HTMLCanvasElement;
  49942. private static readonly DefaultOptions;
  49943. private _textureMatrix;
  49944. private _engine;
  49945. private _isVideo;
  49946. private _generateMipMaps;
  49947. private _samplingMode;
  49948. /**
  49949. * Instantiates a HtmlElementTexture from the following parameters.
  49950. *
  49951. * @param name Defines the name of the texture
  49952. * @param element Defines the video or canvas the texture is filled with
  49953. * @param options Defines the other none mandatory texture creation options
  49954. */
  49955. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  49956. private _createInternalTexture;
  49957. /**
  49958. * Returns the texture matrix used in most of the material.
  49959. */
  49960. getTextureMatrix(): Matrix;
  49961. /**
  49962. * Updates the content of the texture.
  49963. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  49964. */
  49965. update(invertY?: Nullable<boolean>): void;
  49966. }
  49967. }
  49968. declare module BABYLON {
  49969. /**
  49970. * Enum used to define the target of a block
  49971. */
  49972. export enum NodeMaterialBlockTargets {
  49973. /** Vertex shader */
  49974. Vertex = 1,
  49975. /** Fragment shader */
  49976. Fragment = 2,
  49977. /** Vertex and Fragment */
  49978. VertexAndFragment = 3
  49979. }
  49980. }
  49981. declare module BABYLON {
  49982. /**
  49983. * Defines the kind of connection point for node based material
  49984. */
  49985. export enum NodeMaterialBlockConnectionPointTypes {
  49986. /** Float */
  49987. Float = 1,
  49988. /** Int */
  49989. Int = 2,
  49990. /** Vector2 */
  49991. Vector2 = 4,
  49992. /** Vector3 */
  49993. Vector3 = 8,
  49994. /** Vector4 */
  49995. Vector4 = 16,
  49996. /** Color3 */
  49997. Color3 = 32,
  49998. /** Color4 */
  49999. Color4 = 64,
  50000. /** Matrix */
  50001. Matrix = 128,
  50002. /** Texture */
  50003. Texture = 256,
  50004. /** Texture3D */
  50005. Texture3D = 512,
  50006. /** Vector3 or Color3 */
  50007. Vector3OrColor3 = 40,
  50008. /** Vector3 or Vector4 */
  50009. Vector3OrVector4 = 24,
  50010. /** Vector4 or Color4 */
  50011. Vector4OrColor4 = 80,
  50012. /** Color3 or Color4 */
  50013. Color3OrColor4 = 96,
  50014. /** Vector3 or Color3 */
  50015. Vector3OrColor3OrVector4OrColor4 = 120
  50016. }
  50017. }
  50018. declare module BABYLON {
  50019. /**
  50020. * Enum used to define well known values e.g. values automatically provided by the system
  50021. */
  50022. export enum NodeMaterialWellKnownValues {
  50023. /** World */
  50024. World = 1,
  50025. /** View */
  50026. View = 2,
  50027. /** Projection */
  50028. Projection = 3,
  50029. /** ViewProjection */
  50030. ViewProjection = 4,
  50031. /** WorldView */
  50032. WorldView = 5,
  50033. /** WorldViewProjection */
  50034. WorldViewProjection = 6,
  50035. /** Will be filled by the block itself */
  50036. Automatic = 7
  50037. }
  50038. }
  50039. declare module BABYLON {
  50040. /**
  50041. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  50042. */
  50043. export enum NodeMaterialBlockConnectionPointMode {
  50044. /** Value is an uniform */
  50045. Uniform = 0,
  50046. /** Value is a mesh attribute */
  50047. Attribute = 1,
  50048. /** Value is a varying between vertex and fragment shaders */
  50049. Varying = 2,
  50050. /** Mode is undefined */
  50051. Undefined = 3
  50052. }
  50053. }
  50054. declare module BABYLON {
  50055. /**
  50056. * Class used to store shared data between 2 NodeMaterialBuildState
  50057. */
  50058. export class NodeMaterialBuildStateSharedData {
  50059. /**
  50060. * Gets the list of emitted varyings
  50061. */
  50062. varyings: string[];
  50063. /**
  50064. * Gets the varying declaration string
  50065. */
  50066. varyingDeclaration: string;
  50067. /**
  50068. * Uniform connection points
  50069. */
  50070. uniformConnectionPoints: NodeMaterialConnectionPoint[];
  50071. /**
  50072. * Bindable blocks (Blocks that need to set data to the effect)
  50073. */
  50074. bindableBlocks: NodeMaterialBlock[];
  50075. /**
  50076. * List of blocks that can provide a compilation fallback
  50077. */
  50078. blocksWithFallbacks: NodeMaterialBlock[];
  50079. /**
  50080. * List of blocks that can provide a define update
  50081. */
  50082. blocksWithDefines: NodeMaterialBlock[];
  50083. /**
  50084. * List of blocks that can provide a repeatable content
  50085. */
  50086. repeatableContentBlocks: NodeMaterialBlock[];
  50087. /**
  50088. * List of blocks that can block the isReady function for the material
  50089. */
  50090. blockingBlocks: NodeMaterialBlock[];
  50091. /**
  50092. * Build Id used to avoid multiple recompilations
  50093. */
  50094. buildId: number;
  50095. /** List of emitted variables */
  50096. variableNames: {
  50097. [key: string]: number;
  50098. };
  50099. /** List of emitted defines */
  50100. defineNames: {
  50101. [key: string]: number;
  50102. };
  50103. /** Should emit comments? */
  50104. emitComments: boolean;
  50105. /** Emit build activity */
  50106. verbose: boolean;
  50107. /**
  50108. * Gets the compilation hints emitted at compilation time
  50109. */
  50110. hints: {
  50111. needWorldViewMatrix: boolean;
  50112. needWorldViewProjectionMatrix: boolean;
  50113. needAlphaBlending: boolean;
  50114. needAlphaTesting: boolean;
  50115. };
  50116. /**
  50117. * List of compilation checks
  50118. */
  50119. checks: {
  50120. emitVertex: boolean;
  50121. emitFragment: boolean;
  50122. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  50123. };
  50124. /** Creates a new shared data */
  50125. constructor();
  50126. /**
  50127. * Emits console errors and exceptions if there is a failing check
  50128. */
  50129. emitErrors(): void;
  50130. }
  50131. }
  50132. declare module BABYLON {
  50133. /**
  50134. * Class used to store node based material build state
  50135. */
  50136. export class NodeMaterialBuildState {
  50137. /**
  50138. * Gets the list of emitted attributes
  50139. */
  50140. attributes: string[];
  50141. /**
  50142. * Gets the list of emitted uniforms
  50143. */
  50144. uniforms: string[];
  50145. /**
  50146. * Gets the list of emitted samplers
  50147. */
  50148. samplers: string[];
  50149. /**
  50150. * Gets the list of emitted functions
  50151. */
  50152. functions: {
  50153. [key: string]: string;
  50154. };
  50155. /**
  50156. * Gets the target of the compilation state
  50157. */
  50158. target: NodeMaterialBlockTargets;
  50159. /**
  50160. * Shared data between multiple NodeMaterialBuildState instances
  50161. */
  50162. sharedData: NodeMaterialBuildStateSharedData;
  50163. /** @hidden */
  50164. _vertexState: NodeMaterialBuildState;
  50165. private _attributeDeclaration;
  50166. private _uniformDeclaration;
  50167. private _samplerDeclaration;
  50168. private _varyingTransfer;
  50169. private _repeatableContentAnchorIndex;
  50170. /** @hidden */
  50171. _builtCompilationString: string;
  50172. /**
  50173. * Gets the emitted compilation strings
  50174. */
  50175. compilationString: string;
  50176. /**
  50177. * Finalize the compilation strings
  50178. * @param state defines the current compilation state
  50179. */
  50180. finalize(state: NodeMaterialBuildState): void;
  50181. /** @hidden */
  50182. readonly _repeatableContentAnchor: string;
  50183. /** @hidden */
  50184. _getFreeVariableName(prefix: string): string;
  50185. /** @hidden */
  50186. _getFreeDefineName(prefix: string): string;
  50187. /** @hidden */
  50188. _excludeVariableName(name: string): void;
  50189. /** @hidden */
  50190. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  50191. /** @hidden */
  50192. _emitFunction(name: string, code: string, comments: string): void;
  50193. /** @hidden */
  50194. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  50195. replaceStrings?: {
  50196. search: RegExp;
  50197. replace: string;
  50198. }[];
  50199. }): string;
  50200. /** @hidden */
  50201. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  50202. repeatKey?: string;
  50203. removeAttributes?: boolean;
  50204. removeUniforms?: boolean;
  50205. removeVaryings?: boolean;
  50206. removeIfDef?: boolean;
  50207. replaceStrings?: {
  50208. search: RegExp;
  50209. replace: string;
  50210. }[];
  50211. }): void;
  50212. /** @hidden */
  50213. _emitVaryings(point: NodeMaterialConnectionPoint, define?: string, force?: boolean, fromFragment?: boolean, replacementName?: string): void;
  50214. private _emitDefine;
  50215. /** @hidden */
  50216. _emitUniformOrAttributes(point: NodeMaterialConnectionPoint, define?: string): void;
  50217. }
  50218. }
  50219. declare module BABYLON {
  50220. /**
  50221. * Root class for all node material optimizers
  50222. */
  50223. export class NodeMaterialOptimizer {
  50224. /**
  50225. * Function used to optimize a NodeMaterial graph
  50226. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  50227. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  50228. */
  50229. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  50230. }
  50231. }
  50232. declare module BABYLON {
  50233. /**
  50234. * Interface used to configure the node material editor
  50235. */
  50236. export interface INodeMaterialEditorOptions {
  50237. /** Define the URl to load node editor script */
  50238. editorURL?: string;
  50239. }
  50240. /** @hidden */
  50241. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  50242. /** BONES */
  50243. NUM_BONE_INFLUENCERS: number;
  50244. BonesPerMesh: number;
  50245. BONETEXTURE: boolean;
  50246. /** MORPH TARGETS */
  50247. MORPHTARGETS: boolean;
  50248. MORPHTARGETS_NORMAL: boolean;
  50249. MORPHTARGETS_TANGENT: boolean;
  50250. NUM_MORPH_INFLUENCERS: number;
  50251. /** IMAGE PROCESSING */
  50252. IMAGEPROCESSING: boolean;
  50253. VIGNETTE: boolean;
  50254. VIGNETTEBLENDMODEMULTIPLY: boolean;
  50255. VIGNETTEBLENDMODEOPAQUE: boolean;
  50256. TONEMAPPING: boolean;
  50257. TONEMAPPING_ACES: boolean;
  50258. CONTRAST: boolean;
  50259. EXPOSURE: boolean;
  50260. COLORCURVES: boolean;
  50261. COLORGRADING: boolean;
  50262. COLORGRADING3D: boolean;
  50263. SAMPLER3DGREENDEPTH: boolean;
  50264. SAMPLER3DBGRMAP: boolean;
  50265. IMAGEPROCESSINGPOSTPROCESS: boolean;
  50266. constructor();
  50267. setValue(name: string, value: boolean): void;
  50268. }
  50269. /**
  50270. * Class used to configure NodeMaterial
  50271. */
  50272. export interface INodeMaterialOptions {
  50273. /**
  50274. * Defines if blocks should emit comments
  50275. */
  50276. emitComments: boolean;
  50277. }
  50278. /**
  50279. * Class used to create a node based material built by assembling shader blocks
  50280. */
  50281. export class NodeMaterial extends PushMaterial {
  50282. private _options;
  50283. private _vertexCompilationState;
  50284. private _fragmentCompilationState;
  50285. private _sharedData;
  50286. private _buildId;
  50287. private _buildWasSuccessful;
  50288. private _cachedWorldViewMatrix;
  50289. private _cachedWorldViewProjectionMatrix;
  50290. private _textureConnectionPoints;
  50291. private _optimizers;
  50292. /** Define the URl to load node editor script */
  50293. static EditorURL: string;
  50294. private BJSNODEMATERIALEDITOR;
  50295. /** Get the inspector from bundle or global */
  50296. private _getGlobalNodeMaterialEditor;
  50297. /**
  50298. * Defines the maximum number of lights that can be used in the material
  50299. */
  50300. maxSimultaneousLights: number;
  50301. /**
  50302. * Observable raised when the material is built
  50303. */
  50304. onBuildObservable: Observable<NodeMaterial>;
  50305. /**
  50306. * Gets or sets the root nodes of the material vertex shader
  50307. */
  50308. _vertexOutputNodes: NodeMaterialBlock[];
  50309. /**
  50310. * Gets or sets the root nodes of the material fragment (pixel) shader
  50311. */
  50312. _fragmentOutputNodes: NodeMaterialBlock[];
  50313. /** Gets or sets options to control the node material overall behavior */
  50314. options: INodeMaterialOptions;
  50315. /**
  50316. * Default configuration related to image processing available in the standard Material.
  50317. */
  50318. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  50319. /**
  50320. * Gets the image processing configuration used either in this material.
  50321. */
  50322. /**
  50323. * Sets the Default image processing configuration used either in the this material.
  50324. *
  50325. * If sets to null, the scene one is in use.
  50326. */
  50327. imageProcessingConfiguration: ImageProcessingConfiguration;
  50328. /**
  50329. * Create a new node based material
  50330. * @param name defines the material name
  50331. * @param scene defines the hosting scene
  50332. * @param options defines creation option
  50333. */
  50334. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  50335. /**
  50336. * Gets the current class name of the material e.g. "NodeMaterial"
  50337. * @returns the class name
  50338. */
  50339. getClassName(): string;
  50340. /**
  50341. * Keep track of the image processing observer to allow dispose and replace.
  50342. */
  50343. private _imageProcessingObserver;
  50344. /**
  50345. * Attaches a new image processing configuration to the Standard Material.
  50346. * @param configuration
  50347. */
  50348. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  50349. /**
  50350. * Adds a new optimizer to the list of optimizers
  50351. * @param optimizer defines the optimizers to add
  50352. * @returns the current material
  50353. */
  50354. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  50355. /**
  50356. * Remove an optimizer from the list of optimizers
  50357. * @param optimizer defines the optimizers to remove
  50358. * @returns the current material
  50359. */
  50360. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  50361. /**
  50362. * Add a new block to the list of output nodes
  50363. * @param node defines the node to add
  50364. * @returns the current material
  50365. */
  50366. addOutputNode(node: NodeMaterialBlock): this;
  50367. /**
  50368. * Remove a block from the list of root nodes
  50369. * @param node defines the node to remove
  50370. * @returns the current material
  50371. */
  50372. removeOutputNode(node: NodeMaterialBlock): this;
  50373. private _addVertexOutputNode;
  50374. private _removeVertexOutputNode;
  50375. private _addFragmentOutputNode;
  50376. private _removeFragmentOutputNode;
  50377. /**
  50378. * Specifies if the material will require alpha blending
  50379. * @returns a boolean specifying if alpha blending is needed
  50380. */
  50381. needAlphaBlending(): boolean;
  50382. /**
  50383. * Specifies if this material should be rendered in alpha test mode
  50384. * @returns a boolean specifying if an alpha test is needed.
  50385. */
  50386. needAlphaTesting(): boolean;
  50387. private _initializeBlock;
  50388. private _resetDualBlocks;
  50389. /**
  50390. * Build the material and generates the inner effect
  50391. * @param verbose defines if the build should log activity
  50392. */
  50393. build(verbose?: boolean): void;
  50394. /**
  50395. * Runs an otpimization phase to try to improve the shader code
  50396. */
  50397. optimize(): void;
  50398. private _prepareDefinesForAttributes;
  50399. /**
  50400. * Get if the submesh is ready to be used and all its information available.
  50401. * Child classes can use it to update shaders
  50402. * @param mesh defines the mesh to check
  50403. * @param subMesh defines which submesh to check
  50404. * @param useInstances specifies that instances should be used
  50405. * @returns a boolean indicating that the submesh is ready or not
  50406. */
  50407. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  50408. /**
  50409. * Binds the world matrix to the material
  50410. * @param world defines the world transformation matrix
  50411. */
  50412. bindOnlyWorldMatrix(world: Matrix): void;
  50413. /**
  50414. * Binds the submesh to this material by preparing the effect and shader to draw
  50415. * @param world defines the world transformation matrix
  50416. * @param mesh defines the mesh containing the submesh
  50417. * @param subMesh defines the submesh to bind the material to
  50418. */
  50419. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  50420. /**
  50421. * Gets the active textures from the material
  50422. * @returns an array of textures
  50423. */
  50424. getActiveTextures(): BaseTexture[];
  50425. /**
  50426. * Specifies if the material uses a texture
  50427. * @param texture defines the texture to check against the material
  50428. * @returns a boolean specifying if the material uses the texture
  50429. */
  50430. hasTexture(texture: BaseTexture): boolean;
  50431. /**
  50432. * Disposes the material
  50433. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  50434. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  50435. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  50436. */
  50437. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  50438. /** Creates the node editor window. */
  50439. private _createNodeEditor;
  50440. /**
  50441. * Launch the node material editor
  50442. * @param config Define the configuration of the editor
  50443. * @return a promise fulfilled when the node editor is visible
  50444. */
  50445. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  50446. }
  50447. }
  50448. declare module BABYLON {
  50449. /**
  50450. * Defines a block that can be used inside a node based material
  50451. */
  50452. export class NodeMaterialBlock {
  50453. private _buildId;
  50454. private _target;
  50455. private _isFinalMerger;
  50456. /** @hidden */
  50457. _inputs: NodeMaterialConnectionPoint[];
  50458. /** @hidden */
  50459. _outputs: NodeMaterialConnectionPoint[];
  50460. /**
  50461. * Gets or sets the name of the block
  50462. */
  50463. name: string;
  50464. /**
  50465. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  50466. */
  50467. readonly isFinalMerger: boolean;
  50468. /**
  50469. * Gets or sets the build Id
  50470. */
  50471. buildId: number;
  50472. /**
  50473. * Gets or sets the target of the block
  50474. */
  50475. target: NodeMaterialBlockTargets;
  50476. /**
  50477. * Gets the list of input points
  50478. */
  50479. readonly inputs: NodeMaterialConnectionPoint[];
  50480. /** Gets the list of output points */
  50481. readonly outputs: NodeMaterialConnectionPoint[];
  50482. /**
  50483. * Find an input by its name
  50484. * @param name defines the name of the input to look for
  50485. * @returns the input or null if not found
  50486. */
  50487. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  50488. /**
  50489. * Find an output by its name
  50490. * @param name defines the name of the outputto look for
  50491. * @returns the output or null if not found
  50492. */
  50493. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  50494. /**
  50495. * Creates a new NodeMaterialBlock
  50496. * @param name defines the block name
  50497. * @param target defines the target of that block (Vertex by default)
  50498. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  50499. */
  50500. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean);
  50501. /**
  50502. * Initialize the block and prepare the context for build
  50503. * @param state defines the state that will be used for the build
  50504. */
  50505. initialize(state: NodeMaterialBuildState): void;
  50506. /**
  50507. * Bind data to effect. Will only be called for blocks with isBindable === true
  50508. * @param effect defines the effect to bind data to
  50509. * @param nodeMaterial defines the hosting NodeMaterial
  50510. * @param mesh defines the mesh that will be rendered
  50511. */
  50512. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  50513. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  50514. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  50515. protected _writeFloat(value: number): string;
  50516. /**
  50517. * Gets the current class name e.g. "NodeMaterialBlock"
  50518. * @returns the class name
  50519. */
  50520. getClassName(): string;
  50521. /**
  50522. * Register a new input. Must be called inside a block constructor
  50523. * @param name defines the connection point name
  50524. * @param type defines the connection point type
  50525. * @param isOptional defines a boolean indicating that this input can be omitted
  50526. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  50527. * @returns the current block
  50528. */
  50529. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  50530. /**
  50531. * Register a new output. Must be called inside a block constructor
  50532. * @param name defines the connection point name
  50533. * @param type defines the connection point type
  50534. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  50535. * @returns the current block
  50536. */
  50537. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  50538. /**
  50539. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  50540. * @param forOutput defines an optional connection point to check compatibility with
  50541. * @returns the first available input or null
  50542. */
  50543. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  50544. /**
  50545. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  50546. * @param forBlock defines an optional block to check compatibility with
  50547. * @returns the first available input or null
  50548. */
  50549. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  50550. /**
  50551. * Connect current block with another block
  50552. * @param other defines the block to connect with
  50553. * @param options define the various options to help pick the right connections
  50554. * @returns the current block
  50555. */
  50556. connectTo(other: NodeMaterialBlock, options?: {
  50557. input?: string;
  50558. output?: string;
  50559. outputSwizzle?: string;
  50560. }): this | undefined;
  50561. protected _buildBlock(state: NodeMaterialBuildState): void;
  50562. /**
  50563. * Add potential fallbacks if shader compilation fails
  50564. * @param mesh defines the mesh to be rendered
  50565. * @param fallbacks defines the current prioritized list of fallbacks
  50566. */
  50567. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  50568. /**
  50569. * Update defines for shader compilation
  50570. * @param mesh defines the mesh to be rendered
  50571. * @param nodeMaterial defines the node material requesting the update
  50572. * @param defines defines the material defines to update
  50573. * @param useInstances specifies that instances should be used
  50574. */
  50575. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  50576. /**
  50577. * Lets the block try to connect some inputs automatically
  50578. */
  50579. autoConfigure(): void;
  50580. /**
  50581. * Function called when a block is declared as repeatable content generator
  50582. * @param vertexShaderState defines the current compilation state for the vertex shader
  50583. * @param fragmentShaderState defines the current compilation state for the fragment shader
  50584. * @param mesh defines the mesh to be rendered
  50585. * @param defines defines the material defines to update
  50586. */
  50587. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  50588. /**
  50589. * Checks if the block is ready
  50590. * @param mesh defines the mesh to be rendered
  50591. * @param nodeMaterial defines the node material requesting the update
  50592. * @param defines defines the material defines to update
  50593. * @param useInstances specifies that instances should be used
  50594. * @returns true if the block is ready
  50595. */
  50596. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  50597. /**
  50598. * Compile the current node and generate the shader code
  50599. * @param state defines the current compilation state (uniforms, samplers, current string)
  50600. * @returns the current block
  50601. */
  50602. build(state: NodeMaterialBuildState): this | undefined;
  50603. }
  50604. }
  50605. declare module BABYLON {
  50606. /**
  50607. * Defines a connection point for a block
  50608. */
  50609. export class NodeMaterialConnectionPoint {
  50610. /** @hidden */
  50611. _ownerBlock: NodeMaterialBlock;
  50612. /** @hidden */
  50613. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  50614. private _associatedVariableName;
  50615. private _endpoints;
  50616. private _storedValue;
  50617. private _valueCallback;
  50618. private _mode;
  50619. /** @hidden */
  50620. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  50621. /**
  50622. * Gets or sets the connection point type (default is float)
  50623. */
  50624. type: NodeMaterialBlockConnectionPointTypes;
  50625. /**
  50626. * Gets or sets the connection point name
  50627. */
  50628. name: string;
  50629. /**
  50630. * Gets or sets the swizzle to apply to this connection point when reading or writing
  50631. */
  50632. swizzle: string;
  50633. /**
  50634. * Gets or sets a boolean indicating that this connection point can be omitted
  50635. */
  50636. isOptional: boolean;
  50637. /**
  50638. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  50639. */
  50640. define: string;
  50641. /** Gets or sets the target of that connection point */
  50642. target: NodeMaterialBlockTargets;
  50643. /**
  50644. * Gets or sets the value of that point.
  50645. * Please note that this value will be ignored if valueCallback is defined
  50646. */
  50647. value: any;
  50648. /**
  50649. * Gets or sets a callback used to get the value of that point.
  50650. * Please note that setting this value will force the connection point to ignore the value property
  50651. */
  50652. valueCallback: () => any;
  50653. /**
  50654. * Gets or sets the associated variable name in the shader
  50655. */
  50656. associatedVariableName: string;
  50657. /**
  50658. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  50659. * In this case the connection point name must be the name of the uniform to use.
  50660. * Can only be set on inputs
  50661. */
  50662. isUniform: boolean;
  50663. /**
  50664. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  50665. * In this case the connection point name must be the name of the attribute to use
  50666. * Can only be set on inputs
  50667. */
  50668. isAttribute: boolean;
  50669. /**
  50670. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  50671. * Can only be set on exit points
  50672. */
  50673. isVarying: boolean;
  50674. /** Get the other side of the connection (if any) */
  50675. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  50676. /** Get the block that owns this connection point */
  50677. readonly ownerBlock: NodeMaterialBlock;
  50678. /** Get the block connected on the other side of this connection (if any) */
  50679. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  50680. /** Get the block connected on the endpoints of this connection (if any) */
  50681. readonly connectedBlocks: Array<NodeMaterialBlock>;
  50682. /**
  50683. * Creates a new connection point
  50684. * @param name defines the connection point name
  50685. * @param ownerBlock defines the block hosting this connection point
  50686. */
  50687. constructor(name: string, ownerBlock: NodeMaterialBlock);
  50688. /**
  50689. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  50690. * @returns the class name
  50691. */
  50692. getClassName(): string;
  50693. /**
  50694. * Set the source of this connection point to a vertex attribute
  50695. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  50696. * @returns the current connection point
  50697. */
  50698. setAsAttribute(attributeName?: string): NodeMaterialConnectionPoint;
  50699. /**
  50700. * Set the source of this connection point to a well known value
  50701. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  50702. * @returns the current connection point
  50703. */
  50704. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): NodeMaterialConnectionPoint;
  50705. /**
  50706. * Gets a boolean indicating that the current connection point is a well known value
  50707. */
  50708. readonly isWellKnownValue: boolean;
  50709. /**
  50710. * Gets or sets the current well known value or null if not defined as well know value
  50711. */
  50712. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  50713. private _getTypeLength;
  50714. /**
  50715. * Connect this point to another connection point
  50716. * @param connectionPoint defines the other connection point
  50717. * @returns the current connection point
  50718. */
  50719. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  50720. /**
  50721. * Disconnect this point from one of his endpoint
  50722. * @param endpoint defines the other connection point
  50723. * @returns the current connection point
  50724. */
  50725. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  50726. /**
  50727. * When connection point is an uniform, this function will send its value to the effect
  50728. * @param effect defines the effect to transmit value to
  50729. * @param world defines the world matrix
  50730. * @param worldView defines the worldxview matrix
  50731. * @param worldViewProjection defines the worldxviewxprojection matrix
  50732. */
  50733. transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  50734. /**
  50735. * When connection point is an uniform, this function will send its value to the effect
  50736. * @param effect defines the effect to transmit value to
  50737. * @param scene defines the hosting scene
  50738. */
  50739. transmit(effect: Effect, scene: Scene): void;
  50740. }
  50741. }
  50742. declare module BABYLON {
  50743. /**
  50744. * Block used to output the vertex position
  50745. */
  50746. export class VertexOutputBlock extends NodeMaterialBlock {
  50747. /**
  50748. * Creates a new VertexOutputBlock
  50749. * @param name defines the block name
  50750. */
  50751. constructor(name: string);
  50752. /**
  50753. * Gets the current class name
  50754. * @returns the class name
  50755. */
  50756. getClassName(): string;
  50757. /**
  50758. * Gets the vector input component
  50759. */
  50760. readonly vector: NodeMaterialConnectionPoint;
  50761. protected _buildBlock(state: NodeMaterialBuildState): this;
  50762. }
  50763. }
  50764. declare module BABYLON {
  50765. /**
  50766. * Block used to add support for vertex skinning (bones)
  50767. */
  50768. export class BonesBlock extends NodeMaterialBlock {
  50769. /**
  50770. * Creates a new BonesBlock
  50771. * @param name defines the block name
  50772. */
  50773. constructor(name: string);
  50774. /**
  50775. * Initialize the block and prepare the context for build
  50776. * @param state defines the state that will be used for the build
  50777. */
  50778. initialize(state: NodeMaterialBuildState): void;
  50779. /**
  50780. * Gets the current class name
  50781. * @returns the class name
  50782. */
  50783. getClassName(): string;
  50784. /**
  50785. * Gets the matrix indices input component
  50786. */
  50787. readonly matricesIndices: NodeMaterialConnectionPoint;
  50788. /**
  50789. * Gets the matrix weights input component
  50790. */
  50791. readonly matricesWeights: NodeMaterialConnectionPoint;
  50792. /**
  50793. * Gets the extra matrix indices input component
  50794. */
  50795. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  50796. /**
  50797. * Gets the extra matrix weights input component
  50798. */
  50799. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  50800. /**
  50801. * Gets the world input component
  50802. */
  50803. readonly world: NodeMaterialConnectionPoint;
  50804. autoConfigure(): void;
  50805. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  50806. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  50807. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  50808. protected _buildBlock(state: NodeMaterialBuildState): this;
  50809. }
  50810. }
  50811. declare module BABYLON {
  50812. /**
  50813. * Block used to add support for instances
  50814. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  50815. */
  50816. export class InstancesBlock extends NodeMaterialBlock {
  50817. /**
  50818. * Creates a new InstancesBlock
  50819. * @param name defines the block name
  50820. */
  50821. constructor(name: string);
  50822. /**
  50823. * Gets the current class name
  50824. * @returns the class name
  50825. */
  50826. getClassName(): string;
  50827. /**
  50828. * Gets the first world row input component
  50829. */
  50830. readonly world0: NodeMaterialConnectionPoint;
  50831. /**
  50832. * Gets the second world row input component
  50833. */
  50834. readonly world1: NodeMaterialConnectionPoint;
  50835. /**
  50836. * Gets the third world row input component
  50837. */
  50838. readonly world2: NodeMaterialConnectionPoint;
  50839. /**
  50840. * Gets the forth world row input component
  50841. */
  50842. readonly world3: NodeMaterialConnectionPoint;
  50843. /**
  50844. * Gets the world input component
  50845. */
  50846. readonly world: NodeMaterialConnectionPoint;
  50847. /**
  50848. * Gets the output component
  50849. */
  50850. readonly output: NodeMaterialConnectionPoint;
  50851. autoConfigure(): void;
  50852. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  50853. protected _buildBlock(state: NodeMaterialBuildState): this;
  50854. }
  50855. }
  50856. declare module BABYLON {
  50857. /**
  50858. * Block used to add morph targets support to vertex shader
  50859. */
  50860. export class MorphTargetsBlock extends NodeMaterialBlock {
  50861. private _repeatableContentAnchor;
  50862. private _repeatebleContentGenerated;
  50863. /**
  50864. * Create a new MorphTargetsBlock
  50865. * @param name defines the block name
  50866. */
  50867. constructor(name: string);
  50868. /**
  50869. * Gets the current class name
  50870. * @returns the class name
  50871. */
  50872. getClassName(): string;
  50873. /**
  50874. * Gets the position input component
  50875. */
  50876. readonly position: NodeMaterialConnectionPoint;
  50877. /**
  50878. * Gets the normal input component
  50879. */
  50880. readonly normal: NodeMaterialConnectionPoint;
  50881. /**
  50882. * Gets the tangent input component
  50883. */
  50884. readonly tangent: NodeMaterialConnectionPoint;
  50885. /**
  50886. * Gets the position output component
  50887. */
  50888. readonly positionOutput: NodeMaterialConnectionPoint;
  50889. /**
  50890. * Gets the normal output component
  50891. */
  50892. readonly normalOutput: NodeMaterialConnectionPoint;
  50893. /**
  50894. * Gets the tangent output component
  50895. */
  50896. readonly tangentOutput: NodeMaterialConnectionPoint;
  50897. initialize(state: NodeMaterialBuildState): void;
  50898. autoConfigure(): void;
  50899. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  50900. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  50901. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  50902. protected _buildBlock(state: NodeMaterialBuildState): this;
  50903. }
  50904. }
  50905. declare module BABYLON {
  50906. /**
  50907. * Block used to output the final color
  50908. */
  50909. export class FragmentOutputBlock extends NodeMaterialBlock {
  50910. /**
  50911. * Gets or sets a boolean indicating if this block will output an alpha value
  50912. */
  50913. alphaBlendingEnabled: boolean;
  50914. /**
  50915. * Create a new FragmentOutputBlock
  50916. * @param name defines the block name
  50917. */
  50918. constructor(name: string);
  50919. /**
  50920. * Gets the current class name
  50921. * @returns the class name
  50922. */
  50923. getClassName(): string;
  50924. /**
  50925. * Gets the color input component
  50926. */
  50927. readonly color: NodeMaterialConnectionPoint;
  50928. protected _buildBlock(state: NodeMaterialBuildState): this;
  50929. }
  50930. }
  50931. declare module BABYLON {
  50932. /**
  50933. * Block used to add an alpha test in the fragment shader
  50934. */
  50935. export class AlphaTestBlock extends NodeMaterialBlock {
  50936. /**
  50937. * Gets or sets the alpha value where alpha testing happens
  50938. */
  50939. alphaCutOff: number;
  50940. /**
  50941. * Create a new AlphaTestBlock
  50942. * @param name defines the block name
  50943. */
  50944. constructor(name: string);
  50945. /**
  50946. * Gets the current class name
  50947. * @returns the class name
  50948. */
  50949. getClassName(): string;
  50950. /**
  50951. * Gets the color input component
  50952. */
  50953. readonly color: NodeMaterialConnectionPoint;
  50954. protected _buildBlock(state: NodeMaterialBuildState): this;
  50955. }
  50956. }
  50957. declare module BABYLON {
  50958. /**
  50959. * Block used to create a Color4 out of 4 inputs (one for each component)
  50960. */
  50961. export class RGBAMergerBlock extends NodeMaterialBlock {
  50962. /**
  50963. * Create a new RGBAMergerBlock
  50964. * @param name defines the block name
  50965. */
  50966. constructor(name: string);
  50967. /**
  50968. * Gets the current class name
  50969. * @returns the class name
  50970. */
  50971. getClassName(): string;
  50972. /**
  50973. * Gets the R input component
  50974. */
  50975. readonly r: NodeMaterialConnectionPoint;
  50976. /**
  50977. * Gets the G input component
  50978. */
  50979. readonly g: NodeMaterialConnectionPoint;
  50980. /**
  50981. * Gets the B input component
  50982. */
  50983. readonly b: NodeMaterialConnectionPoint;
  50984. /**
  50985. * Gets the RGB input component
  50986. */
  50987. readonly rgb: NodeMaterialConnectionPoint;
  50988. /**
  50989. * Gets the R input component
  50990. */
  50991. readonly a: NodeMaterialConnectionPoint;
  50992. protected _buildBlock(state: NodeMaterialBuildState): this;
  50993. }
  50994. }
  50995. declare module BABYLON {
  50996. /**
  50997. * Block used to create a Color3 out of 3 inputs (one for each component)
  50998. */
  50999. export class RGBMergerBlock extends NodeMaterialBlock {
  51000. /**
  51001. * Create a new RGBMergerBlock
  51002. * @param name defines the block name
  51003. */
  51004. constructor(name: string);
  51005. /**
  51006. * Gets the current class name
  51007. * @returns the class name
  51008. */
  51009. getClassName(): string;
  51010. /**
  51011. * Gets the R component input
  51012. */
  51013. readonly r: NodeMaterialConnectionPoint;
  51014. /**
  51015. * Gets the G component input
  51016. */
  51017. readonly g: NodeMaterialConnectionPoint;
  51018. /**
  51019. * Gets the B component input
  51020. */
  51021. readonly b: NodeMaterialConnectionPoint;
  51022. protected _buildBlock(state: NodeMaterialBuildState): this;
  51023. }
  51024. }
  51025. declare module BABYLON {
  51026. /**
  51027. * Block used to expand a Color4 or a Vector4 into 4 outputs (one for each component)
  51028. */
  51029. export class RGBASplitterBlock extends NodeMaterialBlock {
  51030. /**
  51031. * Create a new RGBASplitterBlock
  51032. * @param name defines the block name
  51033. */
  51034. constructor(name: string);
  51035. /**
  51036. * Gets the current class name
  51037. * @returns the class name
  51038. */
  51039. getClassName(): string;
  51040. /**
  51041. * Gets the input component
  51042. */
  51043. readonly input: NodeMaterialConnectionPoint;
  51044. protected _buildBlock(state: NodeMaterialBuildState): this;
  51045. }
  51046. }
  51047. declare module BABYLON {
  51048. /**
  51049. * Block used to expand a Color3 or a Vector3 into 3 outputs (one for each component)
  51050. */
  51051. export class RGBSplitterBlock extends NodeMaterialBlock {
  51052. /**
  51053. * Create a new RGBSplitterBlock
  51054. * @param name defines the block name
  51055. */
  51056. constructor(name: string);
  51057. /**
  51058. * Gets the current class name
  51059. * @returns the class name
  51060. */
  51061. getClassName(): string;
  51062. /**
  51063. * Gets the input component
  51064. */
  51065. readonly input: NodeMaterialConnectionPoint;
  51066. protected _buildBlock(state: NodeMaterialBuildState): this;
  51067. }
  51068. }
  51069. declare module BABYLON {
  51070. /**
  51071. * Block used to read a texture from a sampler
  51072. */
  51073. export class TextureBlock extends NodeMaterialBlock {
  51074. private _defineName;
  51075. /**
  51076. * Gets or sets a boolean indicating that the block can automatically fetch the texture matrix
  51077. */
  51078. autoConnectTextureMatrix: boolean;
  51079. /**
  51080. * Gets or sets a boolean indicating that the block can automatically select the uv channel based on texture
  51081. */
  51082. autoSelectUV: boolean;
  51083. /**
  51084. * Create a new TextureBlock
  51085. * @param name defines the block name
  51086. */
  51087. constructor(name: string);
  51088. /**
  51089. * Gets the current class name
  51090. * @returns the class name
  51091. */
  51092. getClassName(): string;
  51093. /**
  51094. * Gets the uv input component
  51095. */
  51096. readonly uv: NodeMaterialConnectionPoint;
  51097. /**
  51098. * Gets the texture information input component
  51099. */
  51100. readonly textureInfo: NodeMaterialConnectionPoint;
  51101. /**
  51102. * Gets the transformed uv input component
  51103. */
  51104. readonly transformedUV: NodeMaterialConnectionPoint;
  51105. /**
  51106. * Gets the texture input component
  51107. */
  51108. readonly texture: NodeMaterialConnectionPoint;
  51109. /**
  51110. * Gets the texture transform input component
  51111. */
  51112. readonly textureTransform: NodeMaterialConnectionPoint;
  51113. autoConfigure(): void;
  51114. initialize(state: NodeMaterialBuildState): void;
  51115. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51116. isReady(): boolean;
  51117. private _injectVertexCode;
  51118. protected _buildBlock(state: NodeMaterialBuildState): this;
  51119. }
  51120. }
  51121. declare module BABYLON {
  51122. /**
  51123. * Block used to add image processing support to fragment shader
  51124. */
  51125. export class ImageProcessingBlock extends NodeMaterialBlock {
  51126. /**
  51127. * Create a new ImageProcessingBlock
  51128. * @param name defines the block name
  51129. */
  51130. constructor(name: string);
  51131. /**
  51132. * Gets the current class name
  51133. * @returns the class name
  51134. */
  51135. getClassName(): string;
  51136. /**
  51137. * Gets the color input component
  51138. */
  51139. readonly color: NodeMaterialConnectionPoint;
  51140. /**
  51141. * Initialize the block and prepare the context for build
  51142. * @param state defines the state that will be used for the build
  51143. */
  51144. initialize(state: NodeMaterialBuildState): void;
  51145. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  51146. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51147. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51148. protected _buildBlock(state: NodeMaterialBuildState): this;
  51149. }
  51150. }
  51151. declare module BABYLON {
  51152. /**
  51153. * Block used to add support for scene fog
  51154. */
  51155. export class FogBlock extends NodeMaterialBlock {
  51156. /**
  51157. * Create a new FogBlock
  51158. * @param name defines the block name
  51159. */
  51160. constructor(name: string);
  51161. /**
  51162. * Gets the current class name
  51163. * @returns the class name
  51164. */
  51165. getClassName(): string;
  51166. /**
  51167. * Gets the world position input component
  51168. */
  51169. readonly worldPosition: NodeMaterialConnectionPoint;
  51170. /**
  51171. * Gets the view input component
  51172. */
  51173. readonly view: NodeMaterialConnectionPoint;
  51174. /**
  51175. * Gets the color input component
  51176. */
  51177. readonly color: NodeMaterialConnectionPoint;
  51178. /**
  51179. * Gets the fog color input component
  51180. */
  51181. readonly fogColor: NodeMaterialConnectionPoint;
  51182. /**
  51183. * Gets the for parameter input component
  51184. */
  51185. readonly fogParameters: NodeMaterialConnectionPoint;
  51186. autoConfigure(): void;
  51187. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51188. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51189. protected _buildBlock(state: NodeMaterialBuildState): this;
  51190. }
  51191. }
  51192. declare module BABYLON {
  51193. /**
  51194. * Block used to multiply 2 vector4
  51195. */
  51196. export class MultiplyBlock extends NodeMaterialBlock {
  51197. /**
  51198. * Creates a new MultiplyBlock
  51199. * @param name defines the block name
  51200. */
  51201. constructor(name: string);
  51202. /**
  51203. * Gets the current class name
  51204. * @returns the class name
  51205. */
  51206. getClassName(): string;
  51207. /**
  51208. * Gets the left operand input component
  51209. */
  51210. readonly left: NodeMaterialConnectionPoint;
  51211. /**
  51212. * Gets the right operand input component
  51213. */
  51214. readonly right: NodeMaterialConnectionPoint;
  51215. protected _buildBlock(state: NodeMaterialBuildState): this;
  51216. }
  51217. }
  51218. declare module BABYLON {
  51219. /**
  51220. * Block used to add 2 vector4
  51221. */
  51222. export class AddBlock extends NodeMaterialBlock {
  51223. /**
  51224. * Creates a new AddBlock
  51225. * @param name defines the block name
  51226. */
  51227. constructor(name: string);
  51228. /**
  51229. * Gets the current class name
  51230. * @returns the class name
  51231. */
  51232. getClassName(): string;
  51233. /**
  51234. * Gets the left operand input component
  51235. */
  51236. readonly left: NodeMaterialConnectionPoint;
  51237. /**
  51238. * Gets the right operand input component
  51239. */
  51240. readonly right: NodeMaterialConnectionPoint;
  51241. protected _buildBlock(state: NodeMaterialBuildState): this;
  51242. }
  51243. }
  51244. declare module BABYLON {
  51245. /**
  51246. * Block used to clamp a float
  51247. */
  51248. export class ClampBlock extends NodeMaterialBlock {
  51249. /** Gets or sets the minimum range */
  51250. minimum: number;
  51251. /** Gets or sets the maximum range */
  51252. maximum: number;
  51253. /**
  51254. * Creates a new ClampBlock
  51255. * @param name defines the block name
  51256. */
  51257. constructor(name: string);
  51258. /**
  51259. * Gets the current class name
  51260. * @returns the class name
  51261. */
  51262. getClassName(): string;
  51263. /**
  51264. * Gets the value input component
  51265. */
  51266. readonly value: NodeMaterialConnectionPoint;
  51267. protected _buildBlock(state: NodeMaterialBuildState): this;
  51268. }
  51269. }
  51270. declare module BABYLON {
  51271. /**
  51272. * Block used to transform a vector2 with a matrix
  51273. */
  51274. export class Vector2TransformBlock extends NodeMaterialBlock {
  51275. /**
  51276. * Defines the value to use to complement Vector2 to transform it to a Vector4
  51277. */
  51278. complementZ: number;
  51279. /**
  51280. * Defines the value to use to complement Vector2 to transform it to a Vector4
  51281. */
  51282. complementW: number;
  51283. /**
  51284. * Creates a new Vector2TransformBlock
  51285. * @param name defines the block name
  51286. */
  51287. constructor(name: string);
  51288. /**
  51289. * Gets the vector input
  51290. */
  51291. readonly vector: NodeMaterialConnectionPoint;
  51292. /**
  51293. * Gets the matrix transform input
  51294. */
  51295. readonly transform: NodeMaterialConnectionPoint;
  51296. /**
  51297. * Gets the current class name
  51298. * @returns the class name
  51299. */
  51300. getClassName(): string;
  51301. protected _buildBlock(state: NodeMaterialBuildState): this;
  51302. }
  51303. }
  51304. declare module BABYLON {
  51305. /**
  51306. * Block used to transform a vector3 with a matrix
  51307. */
  51308. export class Vector3TransformBlock extends NodeMaterialBlock {
  51309. /**
  51310. * Defines the value to use to complement Vector3 to transform it to a Vector4
  51311. */
  51312. complement: number;
  51313. /**
  51314. * Creates a new Vector3TransformBlock
  51315. * @param name defines the block name
  51316. */
  51317. constructor(name: string);
  51318. /**
  51319. * Gets the vector input
  51320. */
  51321. readonly vector: NodeMaterialConnectionPoint;
  51322. /**
  51323. * Gets the matrix transform input
  51324. */
  51325. readonly transform: NodeMaterialConnectionPoint;
  51326. /**
  51327. * Gets the current class name
  51328. * @returns the class name
  51329. */
  51330. getClassName(): string;
  51331. protected _buildBlock(state: NodeMaterialBuildState): this;
  51332. }
  51333. }
  51334. declare module BABYLON {
  51335. /**
  51336. * Block used to transform a vector4 with a matrix
  51337. */
  51338. export class Vector4TransformBlock extends NodeMaterialBlock {
  51339. /**
  51340. * Defines the value to use to complement Vector3 to transform it to a Vector4
  51341. */
  51342. complementW: number;
  51343. /**
  51344. * Creates a new Vector4TransformBlock
  51345. * @param name defines the block name
  51346. */
  51347. constructor(name: string);
  51348. /**
  51349. * Gets the current class name
  51350. * @returns the class name
  51351. */
  51352. getClassName(): string;
  51353. /**
  51354. * Gets the vector input
  51355. */
  51356. readonly vector: NodeMaterialConnectionPoint;
  51357. /**
  51358. * Gets the matrix transform input
  51359. */
  51360. readonly transform: NodeMaterialConnectionPoint;
  51361. protected _buildBlock(state: NodeMaterialBuildState): this;
  51362. }
  51363. }
  51364. declare module BABYLON {
  51365. /**
  51366. * Block used to multiply two matrices
  51367. */
  51368. export class MatrixMultiplicationBlock extends NodeMaterialBlock {
  51369. /**
  51370. * Creates a new MatrixMultiplicationBlock
  51371. * @param name defines the block name
  51372. */
  51373. constructor(name: string);
  51374. /**
  51375. * Gets the left operand
  51376. */
  51377. readonly left: NodeMaterialConnectionPoint;
  51378. /**
  51379. * Gets the right operand
  51380. */
  51381. readonly right: NodeMaterialConnectionPoint;
  51382. /**
  51383. * Gets the current class name
  51384. * @returns the class name
  51385. */
  51386. getClassName(): string;
  51387. protected _buildBlock(state: NodeMaterialBuildState): this;
  51388. }
  51389. }
  51390. declare module BABYLON {
  51391. /**
  51392. * Helper class to push actions to a pool of workers.
  51393. */
  51394. export class WorkerPool implements IDisposable {
  51395. private _workerInfos;
  51396. private _pendingActions;
  51397. /**
  51398. * Constructor
  51399. * @param workers Array of workers to use for actions
  51400. */
  51401. constructor(workers: Array<Worker>);
  51402. /**
  51403. * Terminates all workers and clears any pending actions.
  51404. */
  51405. dispose(): void;
  51406. /**
  51407. * Pushes an action to the worker pool. If all the workers are active, the action will be
  51408. * pended until a worker has completed its action.
  51409. * @param action The action to perform. Call onComplete when the action is complete.
  51410. */
  51411. push(action: (worker: Worker, onComplete: () => void) => void): void;
  51412. private _execute;
  51413. }
  51414. }
  51415. declare module BABYLON {
  51416. /**
  51417. * Configuration for Draco compression
  51418. */
  51419. export interface IDracoCompressionConfiguration {
  51420. /**
  51421. * Configuration for the decoder.
  51422. */
  51423. decoder: {
  51424. /**
  51425. * The url to the WebAssembly module.
  51426. */
  51427. wasmUrl?: string;
  51428. /**
  51429. * The url to the WebAssembly binary.
  51430. */
  51431. wasmBinaryUrl?: string;
  51432. /**
  51433. * The url to the fallback JavaScript module.
  51434. */
  51435. fallbackUrl?: string;
  51436. };
  51437. }
  51438. /**
  51439. * Draco compression (https://google.github.io/draco/)
  51440. *
  51441. * This class wraps the Draco module.
  51442. *
  51443. * **Encoder**
  51444. *
  51445. * The encoder is not currently implemented.
  51446. *
  51447. * **Decoder**
  51448. *
  51449. * 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.
  51450. *
  51451. * To update the configuration, use the following code:
  51452. * ```javascript
  51453. * DracoCompression.Configuration = {
  51454. * decoder: {
  51455. * wasmUrl: "<url to the WebAssembly library>",
  51456. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  51457. * fallbackUrl: "<url to the fallback JavaScript library>",
  51458. * }
  51459. * };
  51460. * ```
  51461. *
  51462. * 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.
  51463. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  51464. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  51465. *
  51466. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  51467. * ```javascript
  51468. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  51469. * ```
  51470. *
  51471. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  51472. */
  51473. export class DracoCompression implements IDisposable {
  51474. private _workerPoolPromise?;
  51475. private _decoderModulePromise?;
  51476. /**
  51477. * The configuration. Defaults to the following urls:
  51478. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  51479. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  51480. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  51481. */
  51482. static Configuration: IDracoCompressionConfiguration;
  51483. /**
  51484. * Returns true if the decoder configuration is available.
  51485. */
  51486. static readonly DecoderAvailable: boolean;
  51487. /**
  51488. * Default number of workers to create when creating the draco compression object.
  51489. */
  51490. static DefaultNumWorkers: number;
  51491. private static GetDefaultNumWorkers;
  51492. private static _Default;
  51493. /**
  51494. * Default instance for the draco compression object.
  51495. */
  51496. static readonly Default: DracoCompression;
  51497. /**
  51498. * Constructor
  51499. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  51500. */
  51501. constructor(numWorkers?: number);
  51502. /**
  51503. * Stop all async operations and release resources.
  51504. */
  51505. dispose(): void;
  51506. /**
  51507. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  51508. * @returns a promise that resolves when ready
  51509. */
  51510. whenReadyAsync(): Promise<void>;
  51511. /**
  51512. * Decode Draco compressed mesh data to vertex data.
  51513. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  51514. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  51515. * @returns A promise that resolves with the decoded vertex data
  51516. */
  51517. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  51518. [kind: string]: number;
  51519. }): Promise<VertexData>;
  51520. }
  51521. }
  51522. declare module BABYLON {
  51523. /**
  51524. * Class for building Constructive Solid Geometry
  51525. */
  51526. export class CSG {
  51527. private polygons;
  51528. /**
  51529. * The world matrix
  51530. */
  51531. matrix: Matrix;
  51532. /**
  51533. * Stores the position
  51534. */
  51535. position: Vector3;
  51536. /**
  51537. * Stores the rotation
  51538. */
  51539. rotation: Vector3;
  51540. /**
  51541. * Stores the rotation quaternion
  51542. */
  51543. rotationQuaternion: Nullable<Quaternion>;
  51544. /**
  51545. * Stores the scaling vector
  51546. */
  51547. scaling: Vector3;
  51548. /**
  51549. * Convert the Mesh to CSG
  51550. * @param mesh The Mesh to convert to CSG
  51551. * @returns A new CSG from the Mesh
  51552. */
  51553. static FromMesh(mesh: Mesh): CSG;
  51554. /**
  51555. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  51556. * @param polygons Polygons used to construct a CSG solid
  51557. */
  51558. private static FromPolygons;
  51559. /**
  51560. * Clones, or makes a deep copy, of the CSG
  51561. * @returns A new CSG
  51562. */
  51563. clone(): CSG;
  51564. /**
  51565. * Unions this CSG with another CSG
  51566. * @param csg The CSG to union against this CSG
  51567. * @returns The unioned CSG
  51568. */
  51569. union(csg: CSG): CSG;
  51570. /**
  51571. * Unions this CSG with another CSG in place
  51572. * @param csg The CSG to union against this CSG
  51573. */
  51574. unionInPlace(csg: CSG): void;
  51575. /**
  51576. * Subtracts this CSG with another CSG
  51577. * @param csg The CSG to subtract against this CSG
  51578. * @returns A new CSG
  51579. */
  51580. subtract(csg: CSG): CSG;
  51581. /**
  51582. * Subtracts this CSG with another CSG in place
  51583. * @param csg The CSG to subtact against this CSG
  51584. */
  51585. subtractInPlace(csg: CSG): void;
  51586. /**
  51587. * Intersect this CSG with another CSG
  51588. * @param csg The CSG to intersect against this CSG
  51589. * @returns A new CSG
  51590. */
  51591. intersect(csg: CSG): CSG;
  51592. /**
  51593. * Intersects this CSG with another CSG in place
  51594. * @param csg The CSG to intersect against this CSG
  51595. */
  51596. intersectInPlace(csg: CSG): void;
  51597. /**
  51598. * Return a new CSG solid with solid and empty space switched. This solid is
  51599. * not modified.
  51600. * @returns A new CSG solid with solid and empty space switched
  51601. */
  51602. inverse(): CSG;
  51603. /**
  51604. * Inverses the CSG in place
  51605. */
  51606. inverseInPlace(): void;
  51607. /**
  51608. * This is used to keep meshes transformations so they can be restored
  51609. * when we build back a Babylon Mesh
  51610. * NB : All CSG operations are performed in world coordinates
  51611. * @param csg The CSG to copy the transform attributes from
  51612. * @returns This CSG
  51613. */
  51614. copyTransformAttributes(csg: CSG): CSG;
  51615. /**
  51616. * Build Raw mesh from CSG
  51617. * Coordinates here are in world space
  51618. * @param name The name of the mesh geometry
  51619. * @param scene The Scene
  51620. * @param keepSubMeshes Specifies if the submeshes should be kept
  51621. * @returns A new Mesh
  51622. */
  51623. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  51624. /**
  51625. * Build Mesh from CSG taking material and transforms into account
  51626. * @param name The name of the Mesh
  51627. * @param material The material of the Mesh
  51628. * @param scene The Scene
  51629. * @param keepSubMeshes Specifies if submeshes should be kept
  51630. * @returns The new Mesh
  51631. */
  51632. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  51633. }
  51634. }
  51635. declare module BABYLON {
  51636. /**
  51637. * Class used to create a trail following a mesh
  51638. */
  51639. export class TrailMesh extends Mesh {
  51640. private _generator;
  51641. private _autoStart;
  51642. private _running;
  51643. private _diameter;
  51644. private _length;
  51645. private _sectionPolygonPointsCount;
  51646. private _sectionVectors;
  51647. private _sectionNormalVectors;
  51648. private _beforeRenderObserver;
  51649. /**
  51650. * @constructor
  51651. * @param name The value used by scene.getMeshByName() to do a lookup.
  51652. * @param generator The mesh to generate a trail.
  51653. * @param scene The scene to add this mesh to.
  51654. * @param diameter Diameter of trailing mesh. Default is 1.
  51655. * @param length Length of trailing mesh. Default is 60.
  51656. * @param autoStart Automatically start trailing mesh. Default true.
  51657. */
  51658. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  51659. /**
  51660. * "TrailMesh"
  51661. * @returns "TrailMesh"
  51662. */
  51663. getClassName(): string;
  51664. private _createMesh;
  51665. /**
  51666. * Start trailing mesh.
  51667. */
  51668. start(): void;
  51669. /**
  51670. * Stop trailing mesh.
  51671. */
  51672. stop(): void;
  51673. /**
  51674. * Update trailing mesh geometry.
  51675. */
  51676. update(): void;
  51677. /**
  51678. * Returns a new TrailMesh object.
  51679. * @param name is a string, the name given to the new mesh
  51680. * @param newGenerator use new generator object for cloned trail mesh
  51681. * @returns a new mesh
  51682. */
  51683. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  51684. /**
  51685. * Serializes this trail mesh
  51686. * @param serializationObject object to write serialization to
  51687. */
  51688. serialize(serializationObject: any): void;
  51689. /**
  51690. * Parses a serialized trail mesh
  51691. * @param parsedMesh the serialized mesh
  51692. * @param scene the scene to create the trail mesh in
  51693. * @returns the created trail mesh
  51694. */
  51695. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  51696. }
  51697. }
  51698. declare module BABYLON {
  51699. /**
  51700. * Class containing static functions to help procedurally build meshes
  51701. */
  51702. export class TiledBoxBuilder {
  51703. /**
  51704. * Creates a box mesh
  51705. * 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)
  51706. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  51707. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51708. * * 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
  51709. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51710. * @param name defines the name of the mesh
  51711. * @param options defines the options used to create the mesh
  51712. * @param scene defines the hosting scene
  51713. * @returns the box mesh
  51714. */
  51715. static CreateTiledBox(name: string, options: {
  51716. pattern?: number;
  51717. width?: number;
  51718. height?: number;
  51719. depth?: number;
  51720. tileSize?: number;
  51721. tileWidth?: number;
  51722. tileHeight?: number;
  51723. alignHorizontal?: number;
  51724. alignVertical?: number;
  51725. faceUV?: Vector4[];
  51726. faceColors?: Color4[];
  51727. sideOrientation?: number;
  51728. updatable?: boolean;
  51729. }, scene?: Nullable<Scene>): Mesh;
  51730. }
  51731. }
  51732. declare module BABYLON {
  51733. /**
  51734. * Class containing static functions to help procedurally build meshes
  51735. */
  51736. export class TorusKnotBuilder {
  51737. /**
  51738. * Creates a torus knot mesh
  51739. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  51740. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  51741. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  51742. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  51743. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51744. * * 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
  51745. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51746. * @param name defines the name of the mesh
  51747. * @param options defines the options used to create the mesh
  51748. * @param scene defines the hosting scene
  51749. * @returns the torus knot mesh
  51750. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  51751. */
  51752. static CreateTorusKnot(name: string, options: {
  51753. radius?: number;
  51754. tube?: number;
  51755. radialSegments?: number;
  51756. tubularSegments?: number;
  51757. p?: number;
  51758. q?: number;
  51759. updatable?: boolean;
  51760. sideOrientation?: number;
  51761. frontUVs?: Vector4;
  51762. backUVs?: Vector4;
  51763. }, scene: any): Mesh;
  51764. }
  51765. }
  51766. declare module BABYLON {
  51767. /**
  51768. * Polygon
  51769. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  51770. */
  51771. export class Polygon {
  51772. /**
  51773. * Creates a rectangle
  51774. * @param xmin bottom X coord
  51775. * @param ymin bottom Y coord
  51776. * @param xmax top X coord
  51777. * @param ymax top Y coord
  51778. * @returns points that make the resulting rectation
  51779. */
  51780. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  51781. /**
  51782. * Creates a circle
  51783. * @param radius radius of circle
  51784. * @param cx scale in x
  51785. * @param cy scale in y
  51786. * @param numberOfSides number of sides that make up the circle
  51787. * @returns points that make the resulting circle
  51788. */
  51789. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  51790. /**
  51791. * Creates a polygon from input string
  51792. * @param input Input polygon data
  51793. * @returns the parsed points
  51794. */
  51795. static Parse(input: string): Vector2[];
  51796. /**
  51797. * Starts building a polygon from x and y coordinates
  51798. * @param x x coordinate
  51799. * @param y y coordinate
  51800. * @returns the started path2
  51801. */
  51802. static StartingAt(x: number, y: number): Path2;
  51803. }
  51804. /**
  51805. * Builds a polygon
  51806. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  51807. */
  51808. export class PolygonMeshBuilder {
  51809. private _points;
  51810. private _outlinepoints;
  51811. private _holes;
  51812. private _name;
  51813. private _scene;
  51814. private _epoints;
  51815. private _eholes;
  51816. private _addToepoint;
  51817. /**
  51818. * Babylon reference to the earcut plugin.
  51819. */
  51820. bjsEarcut: any;
  51821. /**
  51822. * Creates a PolygonMeshBuilder
  51823. * @param name name of the builder
  51824. * @param contours Path of the polygon
  51825. * @param scene scene to add to when creating the mesh
  51826. * @param earcutInjection can be used to inject your own earcut reference
  51827. */
  51828. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  51829. /**
  51830. * Adds a whole within the polygon
  51831. * @param hole Array of points defining the hole
  51832. * @returns this
  51833. */
  51834. addHole(hole: Vector2[]): PolygonMeshBuilder;
  51835. /**
  51836. * Creates the polygon
  51837. * @param updatable If the mesh should be updatable
  51838. * @param depth The depth of the mesh created
  51839. * @returns the created mesh
  51840. */
  51841. build(updatable?: boolean, depth?: number): Mesh;
  51842. /**
  51843. * Creates the polygon
  51844. * @param depth The depth of the mesh created
  51845. * @returns the created VertexData
  51846. */
  51847. buildVertexData(depth?: number): VertexData;
  51848. /**
  51849. * Adds a side to the polygon
  51850. * @param positions points that make the polygon
  51851. * @param normals normals of the polygon
  51852. * @param uvs uvs of the polygon
  51853. * @param indices indices of the polygon
  51854. * @param bounds bounds of the polygon
  51855. * @param points points of the polygon
  51856. * @param depth depth of the polygon
  51857. * @param flip flip of the polygon
  51858. */
  51859. private addSide;
  51860. }
  51861. }
  51862. declare module BABYLON {
  51863. /**
  51864. * Class containing static functions to help procedurally build meshes
  51865. */
  51866. export class PolygonBuilder {
  51867. /**
  51868. * Creates a polygon mesh
  51869. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  51870. * * 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
  51871. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  51872. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51873. * * 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)
  51874. * * Remember you can only change the shape positions, not their number when updating a polygon
  51875. * @param name defines the name of the mesh
  51876. * @param options defines the options used to create the mesh
  51877. * @param scene defines the hosting scene
  51878. * @param earcutInjection can be used to inject your own earcut reference
  51879. * @returns the polygon mesh
  51880. */
  51881. static CreatePolygon(name: string, options: {
  51882. shape: Vector3[];
  51883. holes?: Vector3[][];
  51884. depth?: number;
  51885. faceUV?: Vector4[];
  51886. faceColors?: Color4[];
  51887. updatable?: boolean;
  51888. sideOrientation?: number;
  51889. frontUVs?: Vector4;
  51890. backUVs?: Vector4;
  51891. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  51892. /**
  51893. * Creates an extruded polygon mesh, with depth in the Y direction.
  51894. * * 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)
  51895. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  51896. * @param name defines the name of the mesh
  51897. * @param options defines the options used to create the mesh
  51898. * @param scene defines the hosting scene
  51899. * @param earcutInjection can be used to inject your own earcut reference
  51900. * @returns the polygon mesh
  51901. */
  51902. static ExtrudePolygon(name: string, options: {
  51903. shape: Vector3[];
  51904. holes?: Vector3[][];
  51905. depth?: number;
  51906. faceUV?: Vector4[];
  51907. faceColors?: Color4[];
  51908. updatable?: boolean;
  51909. sideOrientation?: number;
  51910. frontUVs?: Vector4;
  51911. backUVs?: Vector4;
  51912. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  51913. }
  51914. }
  51915. declare module BABYLON {
  51916. /**
  51917. * Class containing static functions to help procedurally build meshes
  51918. */
  51919. export class LatheBuilder {
  51920. /**
  51921. * Creates lathe mesh.
  51922. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  51923. * * 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
  51924. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  51925. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  51926. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  51927. * * 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
  51928. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  51929. * * 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
  51930. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51931. * * 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
  51932. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51933. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51934. * @param name defines the name of the mesh
  51935. * @param options defines the options used to create the mesh
  51936. * @param scene defines the hosting scene
  51937. * @returns the lathe mesh
  51938. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  51939. */
  51940. static CreateLathe(name: string, options: {
  51941. shape: Vector3[];
  51942. radius?: number;
  51943. tessellation?: number;
  51944. clip?: number;
  51945. arc?: number;
  51946. closed?: boolean;
  51947. updatable?: boolean;
  51948. sideOrientation?: number;
  51949. frontUVs?: Vector4;
  51950. backUVs?: Vector4;
  51951. cap?: number;
  51952. invertUV?: boolean;
  51953. }, scene?: Nullable<Scene>): Mesh;
  51954. }
  51955. }
  51956. declare module BABYLON {
  51957. /**
  51958. * Class containing static functions to help procedurally build meshes
  51959. */
  51960. export class TiledPlaneBuilder {
  51961. /**
  51962. * Creates a tiled plane mesh
  51963. * * The parameter `pattern` will, depending on value, do nothing or
  51964. * * * flip (reflect about central vertical) alternate tiles across and up
  51965. * * * flip every tile on alternate rows
  51966. * * * rotate (180 degs) alternate tiles across and up
  51967. * * * rotate every tile on alternate rows
  51968. * * * flip and rotate alternate tiles across and up
  51969. * * * flip and rotate every tile on alternate rows
  51970. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  51971. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  51972. * * 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
  51973. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  51974. * * 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)
  51975. * * 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)
  51976. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  51977. * @param name defines the name of the mesh
  51978. * @param options defines the options used to create the mesh
  51979. * @param scene defines the hosting scene
  51980. * @returns the box mesh
  51981. */
  51982. static CreateTiledPlane(name: string, options: {
  51983. pattern?: number;
  51984. tileSize?: number;
  51985. tileWidth?: number;
  51986. tileHeight?: number;
  51987. size?: number;
  51988. width?: number;
  51989. height?: number;
  51990. alignHorizontal?: number;
  51991. alignVertical?: number;
  51992. sideOrientation?: number;
  51993. frontUVs?: Vector4;
  51994. backUVs?: Vector4;
  51995. updatable?: boolean;
  51996. }, scene?: Nullable<Scene>): Mesh;
  51997. }
  51998. }
  51999. declare module BABYLON {
  52000. /**
  52001. * Class containing static functions to help procedurally build meshes
  52002. */
  52003. export class TubeBuilder {
  52004. /**
  52005. * Creates a tube mesh.
  52006. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52007. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  52008. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  52009. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  52010. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  52011. * * 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)
  52012. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  52013. * * 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
  52014. * * 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
  52015. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52016. * * 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
  52017. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52018. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52019. * @param name defines the name of the mesh
  52020. * @param options defines the options used to create the mesh
  52021. * @param scene defines the hosting scene
  52022. * @returns the tube mesh
  52023. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52024. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  52025. */
  52026. static CreateTube(name: string, options: {
  52027. path: Vector3[];
  52028. radius?: number;
  52029. tessellation?: number;
  52030. radiusFunction?: {
  52031. (i: number, distance: number): number;
  52032. };
  52033. cap?: number;
  52034. arc?: number;
  52035. updatable?: boolean;
  52036. sideOrientation?: number;
  52037. frontUVs?: Vector4;
  52038. backUVs?: Vector4;
  52039. instance?: Mesh;
  52040. invertUV?: boolean;
  52041. }, scene?: Nullable<Scene>): Mesh;
  52042. }
  52043. }
  52044. declare module BABYLON {
  52045. /**
  52046. * Class containing static functions to help procedurally build meshes
  52047. */
  52048. export class IcoSphereBuilder {
  52049. /**
  52050. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  52051. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  52052. * * 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`)
  52053. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  52054. * * 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
  52055. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52056. * * 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
  52057. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52058. * @param name defines the name of the mesh
  52059. * @param options defines the options used to create the mesh
  52060. * @param scene defines the hosting scene
  52061. * @returns the icosahedron mesh
  52062. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  52063. */
  52064. static CreateIcoSphere(name: string, options: {
  52065. radius?: number;
  52066. radiusX?: number;
  52067. radiusY?: number;
  52068. radiusZ?: number;
  52069. flat?: boolean;
  52070. subdivisions?: number;
  52071. sideOrientation?: number;
  52072. frontUVs?: Vector4;
  52073. backUVs?: Vector4;
  52074. updatable?: boolean;
  52075. }, scene?: Nullable<Scene>): Mesh;
  52076. }
  52077. }
  52078. declare module BABYLON {
  52079. /**
  52080. * Class containing static functions to help procedurally build meshes
  52081. */
  52082. export class DecalBuilder {
  52083. /**
  52084. * Creates a decal mesh.
  52085. * 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
  52086. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  52087. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  52088. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  52089. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  52090. * @param name defines the name of the mesh
  52091. * @param sourceMesh defines the mesh where the decal must be applied
  52092. * @param options defines the options used to create the mesh
  52093. * @param scene defines the hosting scene
  52094. * @returns the decal mesh
  52095. * @see https://doc.babylonjs.com/how_to/decals
  52096. */
  52097. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  52098. position?: Vector3;
  52099. normal?: Vector3;
  52100. size?: Vector3;
  52101. angle?: number;
  52102. }): Mesh;
  52103. }
  52104. }
  52105. declare module BABYLON {
  52106. /**
  52107. * Class containing static functions to help procedurally build meshes
  52108. */
  52109. export class MeshBuilder {
  52110. /**
  52111. * Creates a box mesh
  52112. * * The parameter `size` sets the size (float) of each box side (default 1)
  52113. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  52114. * * 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)
  52115. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52116. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52117. * * 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
  52118. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52119. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  52120. * @param name defines the name of the mesh
  52121. * @param options defines the options used to create the mesh
  52122. * @param scene defines the hosting scene
  52123. * @returns the box mesh
  52124. */
  52125. static CreateBox(name: string, options: {
  52126. size?: number;
  52127. width?: number;
  52128. height?: number;
  52129. depth?: number;
  52130. faceUV?: Vector4[];
  52131. faceColors?: Color4[];
  52132. sideOrientation?: number;
  52133. frontUVs?: Vector4;
  52134. backUVs?: Vector4;
  52135. updatable?: boolean;
  52136. }, scene?: Nullable<Scene>): Mesh;
  52137. /**
  52138. * Creates a tiled box mesh
  52139. * * faceTiles sets the pattern, tile size and number of tiles for a face
  52140. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52141. * @param name defines the name of the mesh
  52142. * @param options defines the options used to create the mesh
  52143. * @param scene defines the hosting scene
  52144. * @returns the tiled box mesh
  52145. */
  52146. static CreateTiledBox(name: string, options: {
  52147. pattern?: number;
  52148. size?: number;
  52149. width?: number;
  52150. height?: number;
  52151. depth: number;
  52152. tileSize?: number;
  52153. tileWidth?: number;
  52154. tileHeight?: number;
  52155. faceUV?: Vector4[];
  52156. faceColors?: Color4[];
  52157. alignHorizontal?: number;
  52158. alignVertical?: number;
  52159. sideOrientation?: number;
  52160. updatable?: boolean;
  52161. }, scene?: Nullable<Scene>): Mesh;
  52162. /**
  52163. * Creates a sphere mesh
  52164. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  52165. * * 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`)
  52166. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  52167. * * 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
  52168. * * 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)
  52169. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52170. * * 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
  52171. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52172. * @param name defines the name of the mesh
  52173. * @param options defines the options used to create the mesh
  52174. * @param scene defines the hosting scene
  52175. * @returns the sphere mesh
  52176. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  52177. */
  52178. static CreateSphere(name: string, options: {
  52179. segments?: number;
  52180. diameter?: number;
  52181. diameterX?: number;
  52182. diameterY?: number;
  52183. diameterZ?: number;
  52184. arc?: number;
  52185. slice?: number;
  52186. sideOrientation?: number;
  52187. frontUVs?: Vector4;
  52188. backUVs?: Vector4;
  52189. updatable?: boolean;
  52190. }, scene?: Nullable<Scene>): Mesh;
  52191. /**
  52192. * Creates a plane polygonal mesh. By default, this is a disc
  52193. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  52194. * * 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
  52195. * * 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
  52196. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52197. * * 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
  52198. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52199. * @param name defines the name of the mesh
  52200. * @param options defines the options used to create the mesh
  52201. * @param scene defines the hosting scene
  52202. * @returns the plane polygonal mesh
  52203. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  52204. */
  52205. static CreateDisc(name: string, options: {
  52206. radius?: number;
  52207. tessellation?: number;
  52208. arc?: number;
  52209. updatable?: boolean;
  52210. sideOrientation?: number;
  52211. frontUVs?: Vector4;
  52212. backUVs?: Vector4;
  52213. }, scene?: Nullable<Scene>): Mesh;
  52214. /**
  52215. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  52216. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  52217. * * 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`)
  52218. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  52219. * * 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
  52220. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52221. * * 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
  52222. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52223. * @param name defines the name of the mesh
  52224. * @param options defines the options used to create the mesh
  52225. * @param scene defines the hosting scene
  52226. * @returns the icosahedron mesh
  52227. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  52228. */
  52229. static CreateIcoSphere(name: string, options: {
  52230. radius?: number;
  52231. radiusX?: number;
  52232. radiusY?: number;
  52233. radiusZ?: number;
  52234. flat?: boolean;
  52235. subdivisions?: number;
  52236. sideOrientation?: number;
  52237. frontUVs?: Vector4;
  52238. backUVs?: Vector4;
  52239. updatable?: boolean;
  52240. }, scene?: Nullable<Scene>): Mesh;
  52241. /**
  52242. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52243. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52244. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52245. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52246. * * 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
  52247. * * 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
  52248. * * 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
  52249. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52250. * * 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
  52251. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52252. * * 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
  52253. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52254. * * 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
  52255. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52256. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52257. * @param name defines the name of the mesh
  52258. * @param options defines the options used to create the mesh
  52259. * @param scene defines the hosting scene
  52260. * @returns the ribbon mesh
  52261. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52262. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52263. */
  52264. static CreateRibbon(name: string, options: {
  52265. pathArray: Vector3[][];
  52266. closeArray?: boolean;
  52267. closePath?: boolean;
  52268. offset?: number;
  52269. updatable?: boolean;
  52270. sideOrientation?: number;
  52271. frontUVs?: Vector4;
  52272. backUVs?: Vector4;
  52273. instance?: Mesh;
  52274. invertUV?: boolean;
  52275. uvs?: Vector2[];
  52276. colors?: Color4[];
  52277. }, scene?: Nullable<Scene>): Mesh;
  52278. /**
  52279. * Creates a cylinder or a cone mesh
  52280. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  52281. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  52282. * * 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.
  52283. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  52284. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  52285. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  52286. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  52287. * * 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).
  52288. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  52289. * * 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).
  52290. * * 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
  52291. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  52292. * * 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
  52293. * * 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.
  52294. * * If `enclose` is false, a ring surface is one element.
  52295. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  52296. * * 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
  52297. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52298. * * 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
  52299. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52300. * @param name defines the name of the mesh
  52301. * @param options defines the options used to create the mesh
  52302. * @param scene defines the hosting scene
  52303. * @returns the cylinder mesh
  52304. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  52305. */
  52306. static CreateCylinder(name: string, options: {
  52307. height?: number;
  52308. diameterTop?: number;
  52309. diameterBottom?: number;
  52310. diameter?: number;
  52311. tessellation?: number;
  52312. subdivisions?: number;
  52313. arc?: number;
  52314. faceColors?: Color4[];
  52315. faceUV?: Vector4[];
  52316. updatable?: boolean;
  52317. hasRings?: boolean;
  52318. enclose?: boolean;
  52319. cap?: number;
  52320. sideOrientation?: number;
  52321. frontUVs?: Vector4;
  52322. backUVs?: Vector4;
  52323. }, scene?: Nullable<Scene>): Mesh;
  52324. /**
  52325. * Creates a torus mesh
  52326. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  52327. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  52328. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  52329. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52330. * * 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
  52331. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52332. * @param name defines the name of the mesh
  52333. * @param options defines the options used to create the mesh
  52334. * @param scene defines the hosting scene
  52335. * @returns the torus mesh
  52336. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  52337. */
  52338. static CreateTorus(name: string, options: {
  52339. diameter?: number;
  52340. thickness?: number;
  52341. tessellation?: number;
  52342. updatable?: boolean;
  52343. sideOrientation?: number;
  52344. frontUVs?: Vector4;
  52345. backUVs?: Vector4;
  52346. }, scene?: Nullable<Scene>): Mesh;
  52347. /**
  52348. * Creates a torus knot mesh
  52349. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  52350. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  52351. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  52352. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  52353. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52354. * * 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
  52355. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52356. * @param name defines the name of the mesh
  52357. * @param options defines the options used to create the mesh
  52358. * @param scene defines the hosting scene
  52359. * @returns the torus knot mesh
  52360. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  52361. */
  52362. static CreateTorusKnot(name: string, options: {
  52363. radius?: number;
  52364. tube?: number;
  52365. radialSegments?: number;
  52366. tubularSegments?: number;
  52367. p?: number;
  52368. q?: number;
  52369. updatable?: boolean;
  52370. sideOrientation?: number;
  52371. frontUVs?: Vector4;
  52372. backUVs?: Vector4;
  52373. }, scene?: Nullable<Scene>): Mesh;
  52374. /**
  52375. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  52376. * * 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
  52377. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  52378. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  52379. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  52380. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  52381. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52382. * * 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
  52383. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  52384. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52385. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  52386. * @param name defines the name of the new line system
  52387. * @param options defines the options used to create the line system
  52388. * @param scene defines the hosting scene
  52389. * @returns a new line system mesh
  52390. */
  52391. static CreateLineSystem(name: string, options: {
  52392. lines: Vector3[][];
  52393. updatable?: boolean;
  52394. instance?: Nullable<LinesMesh>;
  52395. colors?: Nullable<Color4[][]>;
  52396. useVertexAlpha?: boolean;
  52397. }, scene: Nullable<Scene>): LinesMesh;
  52398. /**
  52399. * Creates a line mesh
  52400. * 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
  52401. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52402. * * The parameter `points` is an array successive Vector3
  52403. * * 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
  52404. * * The optional parameter `colors` is an array of successive Color4, one per line point
  52405. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  52406. * * When updating an instance, remember that only point positions can change, not the number of points
  52407. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52408. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  52409. * @param name defines the name of the new line system
  52410. * @param options defines the options used to create the line system
  52411. * @param scene defines the hosting scene
  52412. * @returns a new line mesh
  52413. */
  52414. static CreateLines(name: string, options: {
  52415. points: Vector3[];
  52416. updatable?: boolean;
  52417. instance?: Nullable<LinesMesh>;
  52418. colors?: Color4[];
  52419. useVertexAlpha?: boolean;
  52420. }, scene?: Nullable<Scene>): LinesMesh;
  52421. /**
  52422. * Creates a dashed line mesh
  52423. * * 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
  52424. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52425. * * The parameter `points` is an array successive Vector3
  52426. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  52427. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  52428. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  52429. * * 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
  52430. * * When updating an instance, remember that only point positions can change, not the number of points
  52431. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52432. * @param name defines the name of the mesh
  52433. * @param options defines the options used to create the mesh
  52434. * @param scene defines the hosting scene
  52435. * @returns the dashed line mesh
  52436. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  52437. */
  52438. static CreateDashedLines(name: string, options: {
  52439. points: Vector3[];
  52440. dashSize?: number;
  52441. gapSize?: number;
  52442. dashNb?: number;
  52443. updatable?: boolean;
  52444. instance?: LinesMesh;
  52445. }, scene?: Nullable<Scene>): LinesMesh;
  52446. /**
  52447. * 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.
  52448. * * 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.
  52449. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52450. * * 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.
  52451. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52452. * * 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
  52453. * * 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
  52454. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52455. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52456. * * 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
  52457. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52458. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52459. * @param name defines the name of the mesh
  52460. * @param options defines the options used to create the mesh
  52461. * @param scene defines the hosting scene
  52462. * @returns the extruded shape mesh
  52463. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52464. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52465. */
  52466. static ExtrudeShape(name: string, options: {
  52467. shape: Vector3[];
  52468. path: Vector3[];
  52469. scale?: number;
  52470. rotation?: number;
  52471. cap?: number;
  52472. updatable?: boolean;
  52473. sideOrientation?: number;
  52474. frontUVs?: Vector4;
  52475. backUVs?: Vector4;
  52476. instance?: Mesh;
  52477. invertUV?: boolean;
  52478. }, scene?: Nullable<Scene>): Mesh;
  52479. /**
  52480. * Creates an custom extruded shape mesh.
  52481. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52482. * * 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.
  52483. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52484. * * 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
  52485. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52486. * * 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
  52487. * * It must returns a float value that will be the scale value applied to the shape on each path point
  52488. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  52489. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  52490. * * 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
  52491. * * 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
  52492. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  52493. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52494. * * 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
  52495. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52496. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52497. * @param name defines the name of the mesh
  52498. * @param options defines the options used to create the mesh
  52499. * @param scene defines the hosting scene
  52500. * @returns the custom extruded shape mesh
  52501. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  52502. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52503. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52504. */
  52505. static ExtrudeShapeCustom(name: string, options: {
  52506. shape: Vector3[];
  52507. path: Vector3[];
  52508. scaleFunction?: any;
  52509. rotationFunction?: any;
  52510. ribbonCloseArray?: boolean;
  52511. ribbonClosePath?: boolean;
  52512. cap?: number;
  52513. updatable?: boolean;
  52514. sideOrientation?: number;
  52515. frontUVs?: Vector4;
  52516. backUVs?: Vector4;
  52517. instance?: Mesh;
  52518. invertUV?: boolean;
  52519. }, scene?: Nullable<Scene>): Mesh;
  52520. /**
  52521. * Creates lathe mesh.
  52522. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  52523. * * 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
  52524. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  52525. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  52526. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  52527. * * 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
  52528. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  52529. * * 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
  52530. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52531. * * 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
  52532. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52533. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52534. * @param name defines the name of the mesh
  52535. * @param options defines the options used to create the mesh
  52536. * @param scene defines the hosting scene
  52537. * @returns the lathe mesh
  52538. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  52539. */
  52540. static CreateLathe(name: string, options: {
  52541. shape: Vector3[];
  52542. radius?: number;
  52543. tessellation?: number;
  52544. clip?: number;
  52545. arc?: number;
  52546. closed?: boolean;
  52547. updatable?: boolean;
  52548. sideOrientation?: number;
  52549. frontUVs?: Vector4;
  52550. backUVs?: Vector4;
  52551. cap?: number;
  52552. invertUV?: boolean;
  52553. }, scene?: Nullable<Scene>): Mesh;
  52554. /**
  52555. * Creates a tiled plane mesh
  52556. * * You can set a limited pattern arrangement with the tiles
  52557. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52558. * * 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
  52559. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52560. * @param name defines the name of the mesh
  52561. * @param options defines the options used to create the mesh
  52562. * @param scene defines the hosting scene
  52563. * @returns the plane mesh
  52564. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  52565. */
  52566. static CreateTiledPlane(name: string, options: {
  52567. pattern?: number;
  52568. tileSize?: number;
  52569. tileWidth?: number;
  52570. tileHeight?: number;
  52571. size?: number;
  52572. width?: number;
  52573. height?: number;
  52574. alignHorizontal?: number;
  52575. alignVertical?: number;
  52576. sideOrientation?: number;
  52577. frontUVs?: Vector4;
  52578. backUVs?: Vector4;
  52579. updatable?: boolean;
  52580. }, scene?: Nullable<Scene>): Mesh;
  52581. /**
  52582. * Creates a plane mesh
  52583. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  52584. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  52585. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  52586. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52587. * * 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
  52588. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52589. * @param name defines the name of the mesh
  52590. * @param options defines the options used to create the mesh
  52591. * @param scene defines the hosting scene
  52592. * @returns the plane mesh
  52593. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  52594. */
  52595. static CreatePlane(name: string, options: {
  52596. size?: number;
  52597. width?: number;
  52598. height?: number;
  52599. sideOrientation?: number;
  52600. frontUVs?: Vector4;
  52601. backUVs?: Vector4;
  52602. updatable?: boolean;
  52603. sourcePlane?: Plane;
  52604. }, scene?: Nullable<Scene>): Mesh;
  52605. /**
  52606. * Creates a ground mesh
  52607. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  52608. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  52609. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52610. * @param name defines the name of the mesh
  52611. * @param options defines the options used to create the mesh
  52612. * @param scene defines the hosting scene
  52613. * @returns the ground mesh
  52614. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  52615. */
  52616. static CreateGround(name: string, options: {
  52617. width?: number;
  52618. height?: number;
  52619. subdivisions?: number;
  52620. subdivisionsX?: number;
  52621. subdivisionsY?: number;
  52622. updatable?: boolean;
  52623. }, scene?: Nullable<Scene>): Mesh;
  52624. /**
  52625. * Creates a tiled ground mesh
  52626. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  52627. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  52628. * * 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
  52629. * * 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
  52630. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52631. * @param name defines the name of the mesh
  52632. * @param options defines the options used to create the mesh
  52633. * @param scene defines the hosting scene
  52634. * @returns the tiled ground mesh
  52635. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  52636. */
  52637. static CreateTiledGround(name: string, options: {
  52638. xmin: number;
  52639. zmin: number;
  52640. xmax: number;
  52641. zmax: number;
  52642. subdivisions?: {
  52643. w: number;
  52644. h: number;
  52645. };
  52646. precision?: {
  52647. w: number;
  52648. h: number;
  52649. };
  52650. updatable?: boolean;
  52651. }, scene?: Nullable<Scene>): Mesh;
  52652. /**
  52653. * Creates a ground mesh from a height map
  52654. * * The parameter `url` sets the URL of the height map image resource.
  52655. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  52656. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  52657. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  52658. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  52659. * * 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.
  52660. * * 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).
  52661. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  52662. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52663. * @param name defines the name of the mesh
  52664. * @param url defines the url to the height map
  52665. * @param options defines the options used to create the mesh
  52666. * @param scene defines the hosting scene
  52667. * @returns the ground mesh
  52668. * @see https://doc.babylonjs.com/babylon101/height_map
  52669. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  52670. */
  52671. static CreateGroundFromHeightMap(name: string, url: string, options: {
  52672. width?: number;
  52673. height?: number;
  52674. subdivisions?: number;
  52675. minHeight?: number;
  52676. maxHeight?: number;
  52677. colorFilter?: Color3;
  52678. alphaFilter?: number;
  52679. updatable?: boolean;
  52680. onReady?: (mesh: GroundMesh) => void;
  52681. }, scene?: Nullable<Scene>): GroundMesh;
  52682. /**
  52683. * Creates a polygon mesh
  52684. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  52685. * * 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
  52686. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  52687. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52688. * * 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)
  52689. * * Remember you can only change the shape positions, not their number when updating a polygon
  52690. * @param name defines the name of the mesh
  52691. * @param options defines the options used to create the mesh
  52692. * @param scene defines the hosting scene
  52693. * @param earcutInjection can be used to inject your own earcut reference
  52694. * @returns the polygon mesh
  52695. */
  52696. static CreatePolygon(name: string, options: {
  52697. shape: Vector3[];
  52698. holes?: Vector3[][];
  52699. depth?: number;
  52700. faceUV?: Vector4[];
  52701. faceColors?: Color4[];
  52702. updatable?: boolean;
  52703. sideOrientation?: number;
  52704. frontUVs?: Vector4;
  52705. backUVs?: Vector4;
  52706. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52707. /**
  52708. * Creates an extruded polygon mesh, with depth in the Y direction.
  52709. * * 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)
  52710. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52711. * @param name defines the name of the mesh
  52712. * @param options defines the options used to create the mesh
  52713. * @param scene defines the hosting scene
  52714. * @param earcutInjection can be used to inject your own earcut reference
  52715. * @returns the polygon mesh
  52716. */
  52717. static ExtrudePolygon(name: string, options: {
  52718. shape: Vector3[];
  52719. holes?: Vector3[][];
  52720. depth?: number;
  52721. faceUV?: Vector4[];
  52722. faceColors?: Color4[];
  52723. updatable?: boolean;
  52724. sideOrientation?: number;
  52725. frontUVs?: Vector4;
  52726. backUVs?: Vector4;
  52727. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52728. /**
  52729. * Creates a tube mesh.
  52730. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52731. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  52732. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  52733. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  52734. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  52735. * * 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)
  52736. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  52737. * * 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
  52738. * * 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
  52739. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52740. * * 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
  52741. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52742. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52743. * @param name defines the name of the mesh
  52744. * @param options defines the options used to create the mesh
  52745. * @param scene defines the hosting scene
  52746. * @returns the tube mesh
  52747. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52748. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  52749. */
  52750. static CreateTube(name: string, options: {
  52751. path: Vector3[];
  52752. radius?: number;
  52753. tessellation?: number;
  52754. radiusFunction?: {
  52755. (i: number, distance: number): number;
  52756. };
  52757. cap?: number;
  52758. arc?: number;
  52759. updatable?: boolean;
  52760. sideOrientation?: number;
  52761. frontUVs?: Vector4;
  52762. backUVs?: Vector4;
  52763. instance?: Mesh;
  52764. invertUV?: boolean;
  52765. }, scene?: Nullable<Scene>): Mesh;
  52766. /**
  52767. * Creates a polyhedron mesh
  52768. * * 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
  52769. * * The parameter `size` (positive float, default 1) sets the polygon size
  52770. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  52771. * * 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`
  52772. * * 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
  52773. * * 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)`)
  52774. * * 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
  52775. * * 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
  52776. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52777. * * 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
  52778. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52779. * @param name defines the name of the mesh
  52780. * @param options defines the options used to create the mesh
  52781. * @param scene defines the hosting scene
  52782. * @returns the polyhedron mesh
  52783. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  52784. */
  52785. static CreatePolyhedron(name: string, options: {
  52786. type?: number;
  52787. size?: number;
  52788. sizeX?: number;
  52789. sizeY?: number;
  52790. sizeZ?: number;
  52791. custom?: any;
  52792. faceUV?: Vector4[];
  52793. faceColors?: Color4[];
  52794. flat?: boolean;
  52795. updatable?: boolean;
  52796. sideOrientation?: number;
  52797. frontUVs?: Vector4;
  52798. backUVs?: Vector4;
  52799. }, scene?: Nullable<Scene>): Mesh;
  52800. /**
  52801. * Creates a decal mesh.
  52802. * 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
  52803. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  52804. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  52805. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  52806. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  52807. * @param name defines the name of the mesh
  52808. * @param sourceMesh defines the mesh where the decal must be applied
  52809. * @param options defines the options used to create the mesh
  52810. * @param scene defines the hosting scene
  52811. * @returns the decal mesh
  52812. * @see https://doc.babylonjs.com/how_to/decals
  52813. */
  52814. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  52815. position?: Vector3;
  52816. normal?: Vector3;
  52817. size?: Vector3;
  52818. angle?: number;
  52819. }): Mesh;
  52820. }
  52821. }
  52822. declare module BABYLON {
  52823. /**
  52824. * A simplifier interface for future simplification implementations
  52825. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52826. */
  52827. export interface ISimplifier {
  52828. /**
  52829. * Simplification of a given mesh according to the given settings.
  52830. * Since this requires computation, it is assumed that the function runs async.
  52831. * @param settings The settings of the simplification, including quality and distance
  52832. * @param successCallback A callback that will be called after the mesh was simplified.
  52833. * @param errorCallback in case of an error, this callback will be called. optional.
  52834. */
  52835. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  52836. }
  52837. /**
  52838. * Expected simplification settings.
  52839. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  52840. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52841. */
  52842. export interface ISimplificationSettings {
  52843. /**
  52844. * Gets or sets the expected quality
  52845. */
  52846. quality: number;
  52847. /**
  52848. * Gets or sets the distance when this optimized version should be used
  52849. */
  52850. distance: number;
  52851. /**
  52852. * Gets an already optimized mesh
  52853. */
  52854. optimizeMesh?: boolean;
  52855. }
  52856. /**
  52857. * Class used to specify simplification options
  52858. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52859. */
  52860. export class SimplificationSettings implements ISimplificationSettings {
  52861. /** expected quality */
  52862. quality: number;
  52863. /** distance when this optimized version should be used */
  52864. distance: number;
  52865. /** already optimized mesh */
  52866. optimizeMesh?: boolean | undefined;
  52867. /**
  52868. * Creates a SimplificationSettings
  52869. * @param quality expected quality
  52870. * @param distance distance when this optimized version should be used
  52871. * @param optimizeMesh already optimized mesh
  52872. */
  52873. constructor(
  52874. /** expected quality */
  52875. quality: number,
  52876. /** distance when this optimized version should be used */
  52877. distance: number,
  52878. /** already optimized mesh */
  52879. optimizeMesh?: boolean | undefined);
  52880. }
  52881. /**
  52882. * Interface used to define a simplification task
  52883. */
  52884. export interface ISimplificationTask {
  52885. /**
  52886. * Array of settings
  52887. */
  52888. settings: Array<ISimplificationSettings>;
  52889. /**
  52890. * Simplification type
  52891. */
  52892. simplificationType: SimplificationType;
  52893. /**
  52894. * Mesh to simplify
  52895. */
  52896. mesh: Mesh;
  52897. /**
  52898. * Callback called on success
  52899. */
  52900. successCallback?: () => void;
  52901. /**
  52902. * Defines if parallel processing can be used
  52903. */
  52904. parallelProcessing: boolean;
  52905. }
  52906. /**
  52907. * Queue used to order the simplification tasks
  52908. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52909. */
  52910. export class SimplificationQueue {
  52911. private _simplificationArray;
  52912. /**
  52913. * Gets a boolean indicating that the process is still running
  52914. */
  52915. running: boolean;
  52916. /**
  52917. * Creates a new queue
  52918. */
  52919. constructor();
  52920. /**
  52921. * Adds a new simplification task
  52922. * @param task defines a task to add
  52923. */
  52924. addTask(task: ISimplificationTask): void;
  52925. /**
  52926. * Execute next task
  52927. */
  52928. executeNext(): void;
  52929. /**
  52930. * Execute a simplification task
  52931. * @param task defines the task to run
  52932. */
  52933. runSimplification(task: ISimplificationTask): void;
  52934. private getSimplifier;
  52935. }
  52936. /**
  52937. * The implemented types of simplification
  52938. * At the moment only Quadratic Error Decimation is implemented
  52939. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52940. */
  52941. export enum SimplificationType {
  52942. /** Quadratic error decimation */
  52943. QUADRATIC = 0
  52944. }
  52945. }
  52946. declare module BABYLON {
  52947. interface Scene {
  52948. /** @hidden (Backing field) */
  52949. _simplificationQueue: SimplificationQueue;
  52950. /**
  52951. * Gets or sets the simplification queue attached to the scene
  52952. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52953. */
  52954. simplificationQueue: SimplificationQueue;
  52955. }
  52956. interface Mesh {
  52957. /**
  52958. * Simplify the mesh according to the given array of settings.
  52959. * Function will return immediately and will simplify async
  52960. * @param settings a collection of simplification settings
  52961. * @param parallelProcessing should all levels calculate parallel or one after the other
  52962. * @param simplificationType the type of simplification to run
  52963. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  52964. * @returns the current mesh
  52965. */
  52966. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  52967. }
  52968. /**
  52969. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  52970. * created in a scene
  52971. */
  52972. export class SimplicationQueueSceneComponent implements ISceneComponent {
  52973. /**
  52974. * The component name helpfull to identify the component in the list of scene components.
  52975. */
  52976. readonly name: string;
  52977. /**
  52978. * The scene the component belongs to.
  52979. */
  52980. scene: Scene;
  52981. /**
  52982. * Creates a new instance of the component for the given scene
  52983. * @param scene Defines the scene to register the component in
  52984. */
  52985. constructor(scene: Scene);
  52986. /**
  52987. * Registers the component in a given scene
  52988. */
  52989. register(): void;
  52990. /**
  52991. * Rebuilds the elements related to this component in case of
  52992. * context lost for instance.
  52993. */
  52994. rebuild(): void;
  52995. /**
  52996. * Disposes the component and the associated ressources
  52997. */
  52998. dispose(): void;
  52999. private _beforeCameraUpdate;
  53000. }
  53001. }
  53002. declare module BABYLON {
  53003. /**
  53004. * Class used to enable access to IndexedDB
  53005. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  53006. */
  53007. export class Database implements IOfflineProvider {
  53008. private _callbackManifestChecked;
  53009. private _currentSceneUrl;
  53010. private _db;
  53011. private _enableSceneOffline;
  53012. private _enableTexturesOffline;
  53013. private _manifestVersionFound;
  53014. private _mustUpdateRessources;
  53015. private _hasReachedQuota;
  53016. private _isSupported;
  53017. private _idbFactory;
  53018. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  53019. private static IsUASupportingBlobStorage;
  53020. /**
  53021. * Gets a boolean indicating if Database storate is enabled (off by default)
  53022. */
  53023. static IDBStorageEnabled: boolean;
  53024. /**
  53025. * Gets a boolean indicating if scene must be saved in the database
  53026. */
  53027. readonly enableSceneOffline: boolean;
  53028. /**
  53029. * Gets a boolean indicating if textures must be saved in the database
  53030. */
  53031. readonly enableTexturesOffline: boolean;
  53032. /**
  53033. * Creates a new Database
  53034. * @param urlToScene defines the url to load the scene
  53035. * @param callbackManifestChecked defines the callback to use when manifest is checked
  53036. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  53037. */
  53038. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  53039. private static _ParseURL;
  53040. private static _ReturnFullUrlLocation;
  53041. private _checkManifestFile;
  53042. /**
  53043. * Open the database and make it available
  53044. * @param successCallback defines the callback to call on success
  53045. * @param errorCallback defines the callback to call on error
  53046. */
  53047. open(successCallback: () => void, errorCallback: () => void): void;
  53048. /**
  53049. * Loads an image from the database
  53050. * @param url defines the url to load from
  53051. * @param image defines the target DOM image
  53052. */
  53053. loadImage(url: string, image: HTMLImageElement): void;
  53054. private _loadImageFromDBAsync;
  53055. private _saveImageIntoDBAsync;
  53056. private _checkVersionFromDB;
  53057. private _loadVersionFromDBAsync;
  53058. private _saveVersionIntoDBAsync;
  53059. /**
  53060. * Loads a file from database
  53061. * @param url defines the URL to load from
  53062. * @param sceneLoaded defines a callback to call on success
  53063. * @param progressCallBack defines a callback to call when progress changed
  53064. * @param errorCallback defines a callback to call on error
  53065. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  53066. */
  53067. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  53068. private _loadFileAsync;
  53069. private _saveFileAsync;
  53070. /**
  53071. * Validates if xhr data is correct
  53072. * @param xhr defines the request to validate
  53073. * @param dataType defines the expected data type
  53074. * @returns true if data is correct
  53075. */
  53076. private static _ValidateXHRData;
  53077. }
  53078. }
  53079. declare module BABYLON {
  53080. /** @hidden */
  53081. export var gpuUpdateParticlesPixelShader: {
  53082. name: string;
  53083. shader: string;
  53084. };
  53085. }
  53086. declare module BABYLON {
  53087. /** @hidden */
  53088. export var gpuUpdateParticlesVertexShader: {
  53089. name: string;
  53090. shader: string;
  53091. };
  53092. }
  53093. declare module BABYLON {
  53094. /** @hidden */
  53095. export var clipPlaneFragmentDeclaration2: {
  53096. name: string;
  53097. shader: string;
  53098. };
  53099. }
  53100. declare module BABYLON {
  53101. /** @hidden */
  53102. export var gpuRenderParticlesPixelShader: {
  53103. name: string;
  53104. shader: string;
  53105. };
  53106. }
  53107. declare module BABYLON {
  53108. /** @hidden */
  53109. export var clipPlaneVertexDeclaration2: {
  53110. name: string;
  53111. shader: string;
  53112. };
  53113. }
  53114. declare module BABYLON {
  53115. /** @hidden */
  53116. export var gpuRenderParticlesVertexShader: {
  53117. name: string;
  53118. shader: string;
  53119. };
  53120. }
  53121. declare module BABYLON {
  53122. /**
  53123. * This represents a GPU particle system in Babylon
  53124. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  53125. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  53126. */
  53127. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  53128. /**
  53129. * The layer mask we are rendering the particles through.
  53130. */
  53131. layerMask: number;
  53132. private _capacity;
  53133. private _activeCount;
  53134. private _currentActiveCount;
  53135. private _accumulatedCount;
  53136. private _renderEffect;
  53137. private _updateEffect;
  53138. private _buffer0;
  53139. private _buffer1;
  53140. private _spriteBuffer;
  53141. private _updateVAO;
  53142. private _renderVAO;
  53143. private _targetIndex;
  53144. private _sourceBuffer;
  53145. private _targetBuffer;
  53146. private _engine;
  53147. private _currentRenderId;
  53148. private _started;
  53149. private _stopped;
  53150. private _timeDelta;
  53151. private _randomTexture;
  53152. private _randomTexture2;
  53153. private _attributesStrideSize;
  53154. private _updateEffectOptions;
  53155. private _randomTextureSize;
  53156. private _actualFrame;
  53157. private readonly _rawTextureWidth;
  53158. /**
  53159. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  53160. */
  53161. static readonly IsSupported: boolean;
  53162. /**
  53163. * An event triggered when the system is disposed.
  53164. */
  53165. onDisposeObservable: Observable<GPUParticleSystem>;
  53166. /**
  53167. * Gets the maximum number of particles active at the same time.
  53168. * @returns The max number of active particles.
  53169. */
  53170. getCapacity(): number;
  53171. /**
  53172. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  53173. * to override the particles.
  53174. */
  53175. forceDepthWrite: boolean;
  53176. /**
  53177. * Gets or set the number of active particles
  53178. */
  53179. activeParticleCount: number;
  53180. private _preWarmDone;
  53181. /**
  53182. * Is this system ready to be used/rendered
  53183. * @return true if the system is ready
  53184. */
  53185. isReady(): boolean;
  53186. /**
  53187. * Gets if the system has been started. (Note: this will still be true after stop is called)
  53188. * @returns True if it has been started, otherwise false.
  53189. */
  53190. isStarted(): boolean;
  53191. /**
  53192. * Starts the particle system and begins to emit
  53193. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  53194. */
  53195. start(delay?: number): void;
  53196. /**
  53197. * Stops the particle system.
  53198. */
  53199. stop(): void;
  53200. /**
  53201. * Remove all active particles
  53202. */
  53203. reset(): void;
  53204. /**
  53205. * Returns the string "GPUParticleSystem"
  53206. * @returns a string containing the class name
  53207. */
  53208. getClassName(): string;
  53209. private _colorGradientsTexture;
  53210. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  53211. /**
  53212. * Adds a new color gradient
  53213. * @param gradient defines the gradient to use (between 0 and 1)
  53214. * @param color1 defines the color to affect to the specified gradient
  53215. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  53216. * @returns the current particle system
  53217. */
  53218. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  53219. /**
  53220. * Remove a specific color gradient
  53221. * @param gradient defines the gradient to remove
  53222. * @returns the current particle system
  53223. */
  53224. removeColorGradient(gradient: number): GPUParticleSystem;
  53225. private _angularSpeedGradientsTexture;
  53226. private _sizeGradientsTexture;
  53227. private _velocityGradientsTexture;
  53228. private _limitVelocityGradientsTexture;
  53229. private _dragGradientsTexture;
  53230. private _addFactorGradient;
  53231. /**
  53232. * Adds a new size gradient
  53233. * @param gradient defines the gradient to use (between 0 and 1)
  53234. * @param factor defines the size factor to affect to the specified gradient
  53235. * @returns the current particle system
  53236. */
  53237. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  53238. /**
  53239. * Remove a specific size gradient
  53240. * @param gradient defines the gradient to remove
  53241. * @returns the current particle system
  53242. */
  53243. removeSizeGradient(gradient: number): GPUParticleSystem;
  53244. /**
  53245. * Adds a new angular speed gradient
  53246. * @param gradient defines the gradient to use (between 0 and 1)
  53247. * @param factor defines the angular speed to affect to the specified gradient
  53248. * @returns the current particle system
  53249. */
  53250. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  53251. /**
  53252. * Remove a specific angular speed gradient
  53253. * @param gradient defines the gradient to remove
  53254. * @returns the current particle system
  53255. */
  53256. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  53257. /**
  53258. * Adds a new velocity gradient
  53259. * @param gradient defines the gradient to use (between 0 and 1)
  53260. * @param factor defines the velocity to affect to the specified gradient
  53261. * @returns the current particle system
  53262. */
  53263. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  53264. /**
  53265. * Remove a specific velocity gradient
  53266. * @param gradient defines the gradient to remove
  53267. * @returns the current particle system
  53268. */
  53269. removeVelocityGradient(gradient: number): GPUParticleSystem;
  53270. /**
  53271. * Adds a new limit velocity gradient
  53272. * @param gradient defines the gradient to use (between 0 and 1)
  53273. * @param factor defines the limit velocity value to affect to the specified gradient
  53274. * @returns the current particle system
  53275. */
  53276. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  53277. /**
  53278. * Remove a specific limit velocity gradient
  53279. * @param gradient defines the gradient to remove
  53280. * @returns the current particle system
  53281. */
  53282. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  53283. /**
  53284. * Adds a new drag gradient
  53285. * @param gradient defines the gradient to use (between 0 and 1)
  53286. * @param factor defines the drag value to affect to the specified gradient
  53287. * @returns the current particle system
  53288. */
  53289. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  53290. /**
  53291. * Remove a specific drag gradient
  53292. * @param gradient defines the gradient to remove
  53293. * @returns the current particle system
  53294. */
  53295. removeDragGradient(gradient: number): GPUParticleSystem;
  53296. /**
  53297. * Not supported by GPUParticleSystem
  53298. * @param gradient defines the gradient to use (between 0 and 1)
  53299. * @param factor defines the emit rate value to affect to the specified gradient
  53300. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53301. * @returns the current particle system
  53302. */
  53303. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53304. /**
  53305. * Not supported by GPUParticleSystem
  53306. * @param gradient defines the gradient to remove
  53307. * @returns the current particle system
  53308. */
  53309. removeEmitRateGradient(gradient: number): IParticleSystem;
  53310. /**
  53311. * Not supported by GPUParticleSystem
  53312. * @param gradient defines the gradient to use (between 0 and 1)
  53313. * @param factor defines the start size value to affect to the specified gradient
  53314. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53315. * @returns the current particle system
  53316. */
  53317. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53318. /**
  53319. * Not supported by GPUParticleSystem
  53320. * @param gradient defines the gradient to remove
  53321. * @returns the current particle system
  53322. */
  53323. removeStartSizeGradient(gradient: number): IParticleSystem;
  53324. /**
  53325. * Not supported by GPUParticleSystem
  53326. * @param gradient defines the gradient to use (between 0 and 1)
  53327. * @param min defines the color remap minimal range
  53328. * @param max defines the color remap maximal range
  53329. * @returns the current particle system
  53330. */
  53331. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  53332. /**
  53333. * Not supported by GPUParticleSystem
  53334. * @param gradient defines the gradient to remove
  53335. * @returns the current particle system
  53336. */
  53337. removeColorRemapGradient(): IParticleSystem;
  53338. /**
  53339. * Not supported by GPUParticleSystem
  53340. * @param gradient defines the gradient to use (between 0 and 1)
  53341. * @param min defines the alpha remap minimal range
  53342. * @param max defines the alpha remap maximal range
  53343. * @returns the current particle system
  53344. */
  53345. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  53346. /**
  53347. * Not supported by GPUParticleSystem
  53348. * @param gradient defines the gradient to remove
  53349. * @returns the current particle system
  53350. */
  53351. removeAlphaRemapGradient(): IParticleSystem;
  53352. /**
  53353. * Not supported by GPUParticleSystem
  53354. * @param gradient defines the gradient to use (between 0 and 1)
  53355. * @param color defines the color to affect to the specified gradient
  53356. * @returns the current particle system
  53357. */
  53358. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  53359. /**
  53360. * Not supported by GPUParticleSystem
  53361. * @param gradient defines the gradient to remove
  53362. * @returns the current particle system
  53363. */
  53364. removeRampGradient(): IParticleSystem;
  53365. /**
  53366. * Not supported by GPUParticleSystem
  53367. * @returns the list of ramp gradients
  53368. */
  53369. getRampGradients(): Nullable<Array<Color3Gradient>>;
  53370. /**
  53371. * Not supported by GPUParticleSystem
  53372. * Gets or sets a boolean indicating that ramp gradients must be used
  53373. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  53374. */
  53375. useRampGradients: boolean;
  53376. /**
  53377. * Not supported by GPUParticleSystem
  53378. * @param gradient defines the gradient to use (between 0 and 1)
  53379. * @param factor defines the life time factor to affect to the specified gradient
  53380. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53381. * @returns the current particle system
  53382. */
  53383. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53384. /**
  53385. * Not supported by GPUParticleSystem
  53386. * @param gradient defines the gradient to remove
  53387. * @returns the current particle system
  53388. */
  53389. removeLifeTimeGradient(gradient: number): IParticleSystem;
  53390. /**
  53391. * Instantiates a GPU particle system.
  53392. * 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.
  53393. * @param name The name of the particle system
  53394. * @param options The options used to create the system
  53395. * @param scene The scene the particle system belongs to
  53396. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  53397. */
  53398. constructor(name: string, options: Partial<{
  53399. capacity: number;
  53400. randomTextureSize: number;
  53401. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  53402. protected _reset(): void;
  53403. private _createUpdateVAO;
  53404. private _createRenderVAO;
  53405. private _initialize;
  53406. /** @hidden */
  53407. _recreateUpdateEffect(): void;
  53408. /** @hidden */
  53409. _recreateRenderEffect(): void;
  53410. /**
  53411. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  53412. * @param preWarm defines if we are in the pre-warmimg phase
  53413. */
  53414. animate(preWarm?: boolean): void;
  53415. private _createFactorGradientTexture;
  53416. private _createSizeGradientTexture;
  53417. private _createAngularSpeedGradientTexture;
  53418. private _createVelocityGradientTexture;
  53419. private _createLimitVelocityGradientTexture;
  53420. private _createDragGradientTexture;
  53421. private _createColorGradientTexture;
  53422. /**
  53423. * Renders the particle system in its current state
  53424. * @param preWarm defines if the system should only update the particles but not render them
  53425. * @returns the current number of particles
  53426. */
  53427. render(preWarm?: boolean): number;
  53428. /**
  53429. * Rebuilds the particle system
  53430. */
  53431. rebuild(): void;
  53432. private _releaseBuffers;
  53433. private _releaseVAOs;
  53434. /**
  53435. * Disposes the particle system and free the associated resources
  53436. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  53437. */
  53438. dispose(disposeTexture?: boolean): void;
  53439. /**
  53440. * Clones the particle system.
  53441. * @param name The name of the cloned object
  53442. * @param newEmitter The new emitter to use
  53443. * @returns the cloned particle system
  53444. */
  53445. clone(name: string, newEmitter: any): GPUParticleSystem;
  53446. /**
  53447. * Serializes the particle system to a JSON object.
  53448. * @returns the JSON object
  53449. */
  53450. serialize(): any;
  53451. /**
  53452. * Parses a JSON object to create a GPU particle system.
  53453. * @param parsedParticleSystem The JSON object to parse
  53454. * @param scene The scene to create the particle system in
  53455. * @param rootUrl The root url to use to load external dependencies like texture
  53456. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  53457. * @returns the parsed GPU particle system
  53458. */
  53459. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  53460. }
  53461. }
  53462. declare module BABYLON {
  53463. /**
  53464. * Represents a set of particle systems working together to create a specific effect
  53465. */
  53466. export class ParticleSystemSet implements IDisposable {
  53467. private _emitterCreationOptions;
  53468. private _emitterNode;
  53469. /**
  53470. * Gets the particle system list
  53471. */
  53472. systems: IParticleSystem[];
  53473. /**
  53474. * Gets the emitter node used with this set
  53475. */
  53476. readonly emitterNode: Nullable<TransformNode>;
  53477. /**
  53478. * Creates a new emitter mesh as a sphere
  53479. * @param options defines the options used to create the sphere
  53480. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  53481. * @param scene defines the hosting scene
  53482. */
  53483. setEmitterAsSphere(options: {
  53484. diameter: number;
  53485. segments: number;
  53486. color: Color3;
  53487. }, renderingGroupId: number, scene: Scene): void;
  53488. /**
  53489. * Starts all particle systems of the set
  53490. * @param emitter defines an optional mesh to use as emitter for the particle systems
  53491. */
  53492. start(emitter?: AbstractMesh): void;
  53493. /**
  53494. * Release all associated resources
  53495. */
  53496. dispose(): void;
  53497. /**
  53498. * Serialize the set into a JSON compatible object
  53499. * @returns a JSON compatible representation of the set
  53500. */
  53501. serialize(): any;
  53502. /**
  53503. * Parse a new ParticleSystemSet from a serialized source
  53504. * @param data defines a JSON compatible representation of the set
  53505. * @param scene defines the hosting scene
  53506. * @param gpu defines if we want GPU particles or CPU particles
  53507. * @returns a new ParticleSystemSet
  53508. */
  53509. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  53510. }
  53511. }
  53512. declare module BABYLON {
  53513. /**
  53514. * This class is made for on one-liner static method to help creating particle system set.
  53515. */
  53516. export class ParticleHelper {
  53517. /**
  53518. * Gets or sets base Assets URL
  53519. */
  53520. static BaseAssetsUrl: string;
  53521. /**
  53522. * Create a default particle system that you can tweak
  53523. * @param emitter defines the emitter to use
  53524. * @param capacity defines the system capacity (default is 500 particles)
  53525. * @param scene defines the hosting scene
  53526. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  53527. * @returns the new Particle system
  53528. */
  53529. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  53530. /**
  53531. * This is the main static method (one-liner) of this helper to create different particle systems
  53532. * @param type This string represents the type to the particle system to create
  53533. * @param scene The scene where the particle system should live
  53534. * @param gpu If the system will use gpu
  53535. * @returns the ParticleSystemSet created
  53536. */
  53537. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  53538. /**
  53539. * Static function used to export a particle system to a ParticleSystemSet variable.
  53540. * Please note that the emitter shape is not exported
  53541. * @param systems defines the particle systems to export
  53542. * @returns the created particle system set
  53543. */
  53544. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  53545. }
  53546. }
  53547. declare module BABYLON {
  53548. interface Engine {
  53549. /**
  53550. * Create an effect to use with particle systems.
  53551. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  53552. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  53553. * @param uniformsNames defines a list of attribute names
  53554. * @param samplers defines an array of string used to represent textures
  53555. * @param defines defines the string containing the defines to use to compile the shaders
  53556. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  53557. * @param onCompiled defines a function to call when the effect creation is successful
  53558. * @param onError defines a function to call when the effect creation has failed
  53559. * @returns the new Effect
  53560. */
  53561. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  53562. }
  53563. interface Mesh {
  53564. /**
  53565. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  53566. * @returns an array of IParticleSystem
  53567. */
  53568. getEmittedParticleSystems(): IParticleSystem[];
  53569. /**
  53570. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  53571. * @returns an array of IParticleSystem
  53572. */
  53573. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  53574. }
  53575. /**
  53576. * @hidden
  53577. */
  53578. export var _IDoNeedToBeInTheBuild: number;
  53579. }
  53580. declare module BABYLON {
  53581. interface Scene {
  53582. /** @hidden (Backing field) */
  53583. _physicsEngine: Nullable<IPhysicsEngine>;
  53584. /**
  53585. * Gets the current physics engine
  53586. * @returns a IPhysicsEngine or null if none attached
  53587. */
  53588. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  53589. /**
  53590. * Enables physics to the current scene
  53591. * @param gravity defines the scene's gravity for the physics engine
  53592. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  53593. * @return a boolean indicating if the physics engine was initialized
  53594. */
  53595. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  53596. /**
  53597. * Disables and disposes the physics engine associated with the scene
  53598. */
  53599. disablePhysicsEngine(): void;
  53600. /**
  53601. * Gets a boolean indicating if there is an active physics engine
  53602. * @returns a boolean indicating if there is an active physics engine
  53603. */
  53604. isPhysicsEnabled(): boolean;
  53605. /**
  53606. * Deletes a physics compound impostor
  53607. * @param compound defines the compound to delete
  53608. */
  53609. deleteCompoundImpostor(compound: any): void;
  53610. /**
  53611. * An event triggered when physic simulation is about to be run
  53612. */
  53613. onBeforePhysicsObservable: Observable<Scene>;
  53614. /**
  53615. * An event triggered when physic simulation has been done
  53616. */
  53617. onAfterPhysicsObservable: Observable<Scene>;
  53618. }
  53619. interface AbstractMesh {
  53620. /** @hidden */
  53621. _physicsImpostor: Nullable<PhysicsImpostor>;
  53622. /**
  53623. * Gets or sets impostor used for physic simulation
  53624. * @see http://doc.babylonjs.com/features/physics_engine
  53625. */
  53626. physicsImpostor: Nullable<PhysicsImpostor>;
  53627. /**
  53628. * Gets the current physics impostor
  53629. * @see http://doc.babylonjs.com/features/physics_engine
  53630. * @returns a physics impostor or null
  53631. */
  53632. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  53633. /** Apply a physic impulse to the mesh
  53634. * @param force defines the force to apply
  53635. * @param contactPoint defines where to apply the force
  53636. * @returns the current mesh
  53637. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  53638. */
  53639. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  53640. /**
  53641. * Creates a physic joint between two meshes
  53642. * @param otherMesh defines the other mesh to use
  53643. * @param pivot1 defines the pivot to use on this mesh
  53644. * @param pivot2 defines the pivot to use on the other mesh
  53645. * @param options defines additional options (can be plugin dependent)
  53646. * @returns the current mesh
  53647. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  53648. */
  53649. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  53650. /** @hidden */
  53651. _disposePhysicsObserver: Nullable<Observer<Node>>;
  53652. }
  53653. /**
  53654. * Defines the physics engine scene component responsible to manage a physics engine
  53655. */
  53656. export class PhysicsEngineSceneComponent implements ISceneComponent {
  53657. /**
  53658. * The component name helpful to identify the component in the list of scene components.
  53659. */
  53660. readonly name: string;
  53661. /**
  53662. * The scene the component belongs to.
  53663. */
  53664. scene: Scene;
  53665. /**
  53666. * Creates a new instance of the component for the given scene
  53667. * @param scene Defines the scene to register the component in
  53668. */
  53669. constructor(scene: Scene);
  53670. /**
  53671. * Registers the component in a given scene
  53672. */
  53673. register(): void;
  53674. /**
  53675. * Rebuilds the elements related to this component in case of
  53676. * context lost for instance.
  53677. */
  53678. rebuild(): void;
  53679. /**
  53680. * Disposes the component and the associated ressources
  53681. */
  53682. dispose(): void;
  53683. }
  53684. }
  53685. declare module BABYLON {
  53686. /**
  53687. * A helper for physics simulations
  53688. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53689. */
  53690. export class PhysicsHelper {
  53691. private _scene;
  53692. private _physicsEngine;
  53693. /**
  53694. * Initializes the Physics helper
  53695. * @param scene Babylon.js scene
  53696. */
  53697. constructor(scene: Scene);
  53698. /**
  53699. * Applies a radial explosion impulse
  53700. * @param origin the origin of the explosion
  53701. * @param radiusOrEventOptions the radius or the options of radial explosion
  53702. * @param strength the explosion strength
  53703. * @param falloff possible options: Constant & Linear. Defaults to Constant
  53704. * @returns A physics radial explosion event, or null
  53705. */
  53706. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  53707. /**
  53708. * Applies a radial explosion force
  53709. * @param origin the origin of the explosion
  53710. * @param radiusOrEventOptions the radius or the options of radial explosion
  53711. * @param strength the explosion strength
  53712. * @param falloff possible options: Constant & Linear. Defaults to Constant
  53713. * @returns A physics radial explosion event, or null
  53714. */
  53715. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  53716. /**
  53717. * Creates a gravitational field
  53718. * @param origin the origin of the explosion
  53719. * @param radiusOrEventOptions the radius or the options of radial explosion
  53720. * @param strength the explosion strength
  53721. * @param falloff possible options: Constant & Linear. Defaults to Constant
  53722. * @returns A physics gravitational field event, or null
  53723. */
  53724. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  53725. /**
  53726. * Creates a physics updraft event
  53727. * @param origin the origin of the updraft
  53728. * @param radiusOrEventOptions the radius or the options of the updraft
  53729. * @param strength the strength of the updraft
  53730. * @param height the height of the updraft
  53731. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  53732. * @returns A physics updraft event, or null
  53733. */
  53734. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  53735. /**
  53736. * Creates a physics vortex event
  53737. * @param origin the of the vortex
  53738. * @param radiusOrEventOptions the radius or the options of the vortex
  53739. * @param strength the strength of the vortex
  53740. * @param height the height of the vortex
  53741. * @returns a Physics vortex event, or null
  53742. * A physics vortex event or null
  53743. */
  53744. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  53745. }
  53746. /**
  53747. * Represents a physics radial explosion event
  53748. */
  53749. class PhysicsRadialExplosionEvent {
  53750. private _scene;
  53751. private _options;
  53752. private _sphere;
  53753. private _dataFetched;
  53754. /**
  53755. * Initializes a radial explosioin event
  53756. * @param _scene BabylonJS scene
  53757. * @param _options The options for the vortex event
  53758. */
  53759. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  53760. /**
  53761. * Returns the data related to the radial explosion event (sphere).
  53762. * @returns The radial explosion event data
  53763. */
  53764. getData(): PhysicsRadialExplosionEventData;
  53765. /**
  53766. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  53767. * @param impostor A physics imposter
  53768. * @param origin the origin of the explosion
  53769. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  53770. */
  53771. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  53772. /**
  53773. * Triggers affecterd impostors callbacks
  53774. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  53775. */
  53776. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  53777. /**
  53778. * Disposes the sphere.
  53779. * @param force Specifies if the sphere should be disposed by force
  53780. */
  53781. dispose(force?: boolean): void;
  53782. /*** Helpers ***/
  53783. private _prepareSphere;
  53784. private _intersectsWithSphere;
  53785. }
  53786. /**
  53787. * Represents a gravitational field event
  53788. */
  53789. class PhysicsGravitationalFieldEvent {
  53790. private _physicsHelper;
  53791. private _scene;
  53792. private _origin;
  53793. private _options;
  53794. private _tickCallback;
  53795. private _sphere;
  53796. private _dataFetched;
  53797. /**
  53798. * Initializes the physics gravitational field event
  53799. * @param _physicsHelper A physics helper
  53800. * @param _scene BabylonJS scene
  53801. * @param _origin The origin position of the gravitational field event
  53802. * @param _options The options for the vortex event
  53803. */
  53804. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  53805. /**
  53806. * Returns the data related to the gravitational field event (sphere).
  53807. * @returns A gravitational field event
  53808. */
  53809. getData(): PhysicsGravitationalFieldEventData;
  53810. /**
  53811. * Enables the gravitational field.
  53812. */
  53813. enable(): void;
  53814. /**
  53815. * Disables the gravitational field.
  53816. */
  53817. disable(): void;
  53818. /**
  53819. * Disposes the sphere.
  53820. * @param force The force to dispose from the gravitational field event
  53821. */
  53822. dispose(force?: boolean): void;
  53823. private _tick;
  53824. }
  53825. /**
  53826. * Represents a physics updraft event
  53827. */
  53828. class PhysicsUpdraftEvent {
  53829. private _scene;
  53830. private _origin;
  53831. private _options;
  53832. private _physicsEngine;
  53833. private _originTop;
  53834. private _originDirection;
  53835. private _tickCallback;
  53836. private _cylinder;
  53837. private _cylinderPosition;
  53838. private _dataFetched;
  53839. /**
  53840. * Initializes the physics updraft event
  53841. * @param _scene BabylonJS scene
  53842. * @param _origin The origin position of the updraft
  53843. * @param _options The options for the updraft event
  53844. */
  53845. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  53846. /**
  53847. * Returns the data related to the updraft event (cylinder).
  53848. * @returns A physics updraft event
  53849. */
  53850. getData(): PhysicsUpdraftEventData;
  53851. /**
  53852. * Enables the updraft.
  53853. */
  53854. enable(): void;
  53855. /**
  53856. * Disables the updraft.
  53857. */
  53858. disable(): void;
  53859. /**
  53860. * Disposes the cylinder.
  53861. * @param force Specifies if the updraft should be disposed by force
  53862. */
  53863. dispose(force?: boolean): void;
  53864. private getImpostorHitData;
  53865. private _tick;
  53866. /*** Helpers ***/
  53867. private _prepareCylinder;
  53868. private _intersectsWithCylinder;
  53869. }
  53870. /**
  53871. * Represents a physics vortex event
  53872. */
  53873. class PhysicsVortexEvent {
  53874. private _scene;
  53875. private _origin;
  53876. private _options;
  53877. private _physicsEngine;
  53878. private _originTop;
  53879. private _tickCallback;
  53880. private _cylinder;
  53881. private _cylinderPosition;
  53882. private _dataFetched;
  53883. /**
  53884. * Initializes the physics vortex event
  53885. * @param _scene The BabylonJS scene
  53886. * @param _origin The origin position of the vortex
  53887. * @param _options The options for the vortex event
  53888. */
  53889. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  53890. /**
  53891. * Returns the data related to the vortex event (cylinder).
  53892. * @returns The physics vortex event data
  53893. */
  53894. getData(): PhysicsVortexEventData;
  53895. /**
  53896. * Enables the vortex.
  53897. */
  53898. enable(): void;
  53899. /**
  53900. * Disables the cortex.
  53901. */
  53902. disable(): void;
  53903. /**
  53904. * Disposes the sphere.
  53905. * @param force
  53906. */
  53907. dispose(force?: boolean): void;
  53908. private getImpostorHitData;
  53909. private _tick;
  53910. /*** Helpers ***/
  53911. private _prepareCylinder;
  53912. private _intersectsWithCylinder;
  53913. }
  53914. /**
  53915. * Options fot the radial explosion event
  53916. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53917. */
  53918. export class PhysicsRadialExplosionEventOptions {
  53919. /**
  53920. * The radius of the sphere for the radial explosion.
  53921. */
  53922. radius: number;
  53923. /**
  53924. * The strenth of the explosion.
  53925. */
  53926. strength: number;
  53927. /**
  53928. * The strenght of the force in correspondence to the distance of the affected object
  53929. */
  53930. falloff: PhysicsRadialImpulseFalloff;
  53931. /**
  53932. * Sphere options for the radial explosion.
  53933. */
  53934. sphere: {
  53935. segments: number;
  53936. diameter: number;
  53937. };
  53938. /**
  53939. * Sphere options for the radial explosion.
  53940. */
  53941. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  53942. }
  53943. /**
  53944. * Options fot the updraft event
  53945. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53946. */
  53947. export class PhysicsUpdraftEventOptions {
  53948. /**
  53949. * The radius of the cylinder for the vortex
  53950. */
  53951. radius: number;
  53952. /**
  53953. * The strenth of the updraft.
  53954. */
  53955. strength: number;
  53956. /**
  53957. * The height of the cylinder for the updraft.
  53958. */
  53959. height: number;
  53960. /**
  53961. * The mode for the the updraft.
  53962. */
  53963. updraftMode: PhysicsUpdraftMode;
  53964. }
  53965. /**
  53966. * Options fot the vortex event
  53967. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53968. */
  53969. export class PhysicsVortexEventOptions {
  53970. /**
  53971. * The radius of the cylinder for the vortex
  53972. */
  53973. radius: number;
  53974. /**
  53975. * The strenth of the vortex.
  53976. */
  53977. strength: number;
  53978. /**
  53979. * The height of the cylinder for the vortex.
  53980. */
  53981. height: number;
  53982. /**
  53983. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  53984. */
  53985. centripetalForceThreshold: number;
  53986. /**
  53987. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  53988. */
  53989. centripetalForceMultiplier: number;
  53990. /**
  53991. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  53992. */
  53993. centrifugalForceMultiplier: number;
  53994. /**
  53995. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  53996. */
  53997. updraftForceMultiplier: number;
  53998. }
  53999. /**
  54000. * The strenght of the force in correspondence to the distance of the affected object
  54001. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54002. */
  54003. export enum PhysicsRadialImpulseFalloff {
  54004. /** Defines that impulse is constant in strength across it's whole radius */
  54005. Constant = 0,
  54006. /** Defines that impulse gets weaker if it's further from the origin */
  54007. Linear = 1
  54008. }
  54009. /**
  54010. * The strength of the force in correspondence to the distance of the affected object
  54011. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54012. */
  54013. export enum PhysicsUpdraftMode {
  54014. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  54015. Center = 0,
  54016. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  54017. Perpendicular = 1
  54018. }
  54019. /**
  54020. * Interface for a physics hit data
  54021. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54022. */
  54023. export interface PhysicsHitData {
  54024. /**
  54025. * The force applied at the contact point
  54026. */
  54027. force: Vector3;
  54028. /**
  54029. * The contact point
  54030. */
  54031. contactPoint: Vector3;
  54032. /**
  54033. * The distance from the origin to the contact point
  54034. */
  54035. distanceFromOrigin: number;
  54036. }
  54037. /**
  54038. * Interface for radial explosion event data
  54039. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54040. */
  54041. export interface PhysicsRadialExplosionEventData {
  54042. /**
  54043. * A sphere used for the radial explosion event
  54044. */
  54045. sphere: Mesh;
  54046. }
  54047. /**
  54048. * Interface for gravitational field event data
  54049. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54050. */
  54051. export interface PhysicsGravitationalFieldEventData {
  54052. /**
  54053. * A sphere mesh used for the gravitational field event
  54054. */
  54055. sphere: Mesh;
  54056. }
  54057. /**
  54058. * Interface for updraft event data
  54059. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54060. */
  54061. export interface PhysicsUpdraftEventData {
  54062. /**
  54063. * A cylinder used for the updraft event
  54064. */
  54065. cylinder: Mesh;
  54066. }
  54067. /**
  54068. * Interface for vortex event data
  54069. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54070. */
  54071. export interface PhysicsVortexEventData {
  54072. /**
  54073. * A cylinder used for the vortex event
  54074. */
  54075. cylinder: Mesh;
  54076. }
  54077. /**
  54078. * Interface for an affected physics impostor
  54079. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54080. */
  54081. export interface PhysicsAffectedImpostorWithData {
  54082. /**
  54083. * The impostor affected by the effect
  54084. */
  54085. impostor: PhysicsImpostor;
  54086. /**
  54087. * The data about the hit/horce from the explosion
  54088. */
  54089. hitData: PhysicsHitData;
  54090. }
  54091. }
  54092. declare module BABYLON {
  54093. /** @hidden */
  54094. export var blackAndWhitePixelShader: {
  54095. name: string;
  54096. shader: string;
  54097. };
  54098. }
  54099. declare module BABYLON {
  54100. /**
  54101. * Post process used to render in black and white
  54102. */
  54103. export class BlackAndWhitePostProcess extends PostProcess {
  54104. /**
  54105. * Linear about to convert he result to black and white (default: 1)
  54106. */
  54107. degree: number;
  54108. /**
  54109. * Creates a black and white post process
  54110. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  54111. * @param name The name of the effect.
  54112. * @param options The required width/height ratio to downsize to before computing the render pass.
  54113. * @param camera The camera to apply the render pass to.
  54114. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54115. * @param engine The engine which the post process will be applied. (default: current engine)
  54116. * @param reusable If the post process can be reused on the same frame. (default: false)
  54117. */
  54118. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54119. }
  54120. }
  54121. declare module BABYLON {
  54122. /**
  54123. * This represents a set of one or more post processes in Babylon.
  54124. * A post process can be used to apply a shader to a texture after it is rendered.
  54125. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54126. */
  54127. export class PostProcessRenderEffect {
  54128. private _postProcesses;
  54129. private _getPostProcesses;
  54130. private _singleInstance;
  54131. private _cameras;
  54132. private _indicesForCamera;
  54133. /**
  54134. * Name of the effect
  54135. * @hidden
  54136. */
  54137. _name: string;
  54138. /**
  54139. * Instantiates a post process render effect.
  54140. * A post process can be used to apply a shader to a texture after it is rendered.
  54141. * @param engine The engine the effect is tied to
  54142. * @param name The name of the effect
  54143. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  54144. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  54145. */
  54146. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  54147. /**
  54148. * Checks if all the post processes in the effect are supported.
  54149. */
  54150. readonly isSupported: boolean;
  54151. /**
  54152. * Updates the current state of the effect
  54153. * @hidden
  54154. */
  54155. _update(): void;
  54156. /**
  54157. * Attaches the effect on cameras
  54158. * @param cameras The camera to attach to.
  54159. * @hidden
  54160. */
  54161. _attachCameras(cameras: Camera): void;
  54162. /**
  54163. * Attaches the effect on cameras
  54164. * @param cameras The camera to attach to.
  54165. * @hidden
  54166. */
  54167. _attachCameras(cameras: Camera[]): void;
  54168. /**
  54169. * Detaches the effect on cameras
  54170. * @param cameras The camera to detatch from.
  54171. * @hidden
  54172. */
  54173. _detachCameras(cameras: Camera): void;
  54174. /**
  54175. * Detatches the effect on cameras
  54176. * @param cameras The camera to detatch from.
  54177. * @hidden
  54178. */
  54179. _detachCameras(cameras: Camera[]): void;
  54180. /**
  54181. * Enables the effect on given cameras
  54182. * @param cameras The camera to enable.
  54183. * @hidden
  54184. */
  54185. _enable(cameras: Camera): void;
  54186. /**
  54187. * Enables the effect on given cameras
  54188. * @param cameras The camera to enable.
  54189. * @hidden
  54190. */
  54191. _enable(cameras: Nullable<Camera[]>): void;
  54192. /**
  54193. * Disables the effect on the given cameras
  54194. * @param cameras The camera to disable.
  54195. * @hidden
  54196. */
  54197. _disable(cameras: Camera): void;
  54198. /**
  54199. * Disables the effect on the given cameras
  54200. * @param cameras The camera to disable.
  54201. * @hidden
  54202. */
  54203. _disable(cameras: Nullable<Camera[]>): void;
  54204. /**
  54205. * Gets a list of the post processes contained in the effect.
  54206. * @param camera The camera to get the post processes on.
  54207. * @returns The list of the post processes in the effect.
  54208. */
  54209. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  54210. }
  54211. }
  54212. declare module BABYLON {
  54213. /** @hidden */
  54214. export var extractHighlightsPixelShader: {
  54215. name: string;
  54216. shader: string;
  54217. };
  54218. }
  54219. declare module BABYLON {
  54220. /**
  54221. * 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.
  54222. */
  54223. export class ExtractHighlightsPostProcess extends PostProcess {
  54224. /**
  54225. * The luminance threshold, pixels below this value will be set to black.
  54226. */
  54227. threshold: number;
  54228. /** @hidden */
  54229. _exposure: number;
  54230. /**
  54231. * Post process which has the input texture to be used when performing highlight extraction
  54232. * @hidden
  54233. */
  54234. _inputPostProcess: Nullable<PostProcess>;
  54235. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54236. }
  54237. }
  54238. declare module BABYLON {
  54239. /** @hidden */
  54240. export var bloomMergePixelShader: {
  54241. name: string;
  54242. shader: string;
  54243. };
  54244. }
  54245. declare module BABYLON {
  54246. /**
  54247. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  54248. */
  54249. export class BloomMergePostProcess extends PostProcess {
  54250. /** Weight of the bloom to be added to the original input. */
  54251. weight: number;
  54252. /**
  54253. * Creates a new instance of @see BloomMergePostProcess
  54254. * @param name The name of the effect.
  54255. * @param originalFromInput Post process which's input will be used for the merge.
  54256. * @param blurred Blurred highlights post process which's output will be used.
  54257. * @param weight Weight of the bloom to be added to the original input.
  54258. * @param options The required width/height ratio to downsize to before computing the render pass.
  54259. * @param camera The camera to apply the render pass to.
  54260. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54261. * @param engine The engine which the post process will be applied. (default: current engine)
  54262. * @param reusable If the post process can be reused on the same frame. (default: false)
  54263. * @param textureType Type of textures used when performing the post process. (default: 0)
  54264. * @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)
  54265. */
  54266. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  54267. /** Weight of the bloom to be added to the original input. */
  54268. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54269. }
  54270. }
  54271. declare module BABYLON {
  54272. /**
  54273. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  54274. */
  54275. export class BloomEffect extends PostProcessRenderEffect {
  54276. private bloomScale;
  54277. /**
  54278. * @hidden Internal
  54279. */
  54280. _effects: Array<PostProcess>;
  54281. /**
  54282. * @hidden Internal
  54283. */
  54284. _downscale: ExtractHighlightsPostProcess;
  54285. private _blurX;
  54286. private _blurY;
  54287. private _merge;
  54288. /**
  54289. * The luminance threshold to find bright areas of the image to bloom.
  54290. */
  54291. threshold: number;
  54292. /**
  54293. * The strength of the bloom.
  54294. */
  54295. weight: number;
  54296. /**
  54297. * Specifies the size of the bloom blur kernel, relative to the final output size
  54298. */
  54299. kernel: number;
  54300. /**
  54301. * Creates a new instance of @see BloomEffect
  54302. * @param scene The scene the effect belongs to.
  54303. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  54304. * @param bloomKernel The size of the kernel to be used when applying the blur.
  54305. * @param bloomWeight The the strength of bloom.
  54306. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  54307. * @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)
  54308. */
  54309. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  54310. /**
  54311. * Disposes each of the internal effects for a given camera.
  54312. * @param camera The camera to dispose the effect on.
  54313. */
  54314. disposeEffects(camera: Camera): void;
  54315. /**
  54316. * @hidden Internal
  54317. */
  54318. _updateEffects(): void;
  54319. /**
  54320. * Internal
  54321. * @returns if all the contained post processes are ready.
  54322. * @hidden
  54323. */
  54324. _isReady(): boolean;
  54325. }
  54326. }
  54327. declare module BABYLON {
  54328. /** @hidden */
  54329. export var chromaticAberrationPixelShader: {
  54330. name: string;
  54331. shader: string;
  54332. };
  54333. }
  54334. declare module BABYLON {
  54335. /**
  54336. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  54337. */
  54338. export class ChromaticAberrationPostProcess extends PostProcess {
  54339. /**
  54340. * The amount of seperation of rgb channels (default: 30)
  54341. */
  54342. aberrationAmount: number;
  54343. /**
  54344. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  54345. */
  54346. radialIntensity: number;
  54347. /**
  54348. * 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))
  54349. */
  54350. direction: Vector2;
  54351. /**
  54352. * 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))
  54353. */
  54354. centerPosition: Vector2;
  54355. /**
  54356. * Creates a new instance ChromaticAberrationPostProcess
  54357. * @param name The name of the effect.
  54358. * @param screenWidth The width of the screen to apply the effect on.
  54359. * @param screenHeight The height of the screen to apply the effect on.
  54360. * @param options The required width/height ratio to downsize to before computing the render pass.
  54361. * @param camera The camera to apply the render pass to.
  54362. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54363. * @param engine The engine which the post process will be applied. (default: current engine)
  54364. * @param reusable If the post process can be reused on the same frame. (default: false)
  54365. * @param textureType Type of textures used when performing the post process. (default: 0)
  54366. * @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)
  54367. */
  54368. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54369. }
  54370. }
  54371. declare module BABYLON {
  54372. /** @hidden */
  54373. export var circleOfConfusionPixelShader: {
  54374. name: string;
  54375. shader: string;
  54376. };
  54377. }
  54378. declare module BABYLON {
  54379. /**
  54380. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  54381. */
  54382. export class CircleOfConfusionPostProcess extends PostProcess {
  54383. /**
  54384. * 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.
  54385. */
  54386. lensSize: number;
  54387. /**
  54388. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  54389. */
  54390. fStop: number;
  54391. /**
  54392. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  54393. */
  54394. focusDistance: number;
  54395. /**
  54396. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  54397. */
  54398. focalLength: number;
  54399. private _depthTexture;
  54400. /**
  54401. * Creates a new instance CircleOfConfusionPostProcess
  54402. * @param name The name of the effect.
  54403. * @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.
  54404. * @param options The required width/height ratio to downsize to before computing the render pass.
  54405. * @param camera The camera to apply the render pass to.
  54406. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54407. * @param engine The engine which the post process will be applied. (default: current engine)
  54408. * @param reusable If the post process can be reused on the same frame. (default: false)
  54409. * @param textureType Type of textures used when performing the post process. (default: 0)
  54410. * @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)
  54411. */
  54412. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54413. /**
  54414. * 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.
  54415. */
  54416. depthTexture: RenderTargetTexture;
  54417. }
  54418. }
  54419. declare module BABYLON {
  54420. /** @hidden */
  54421. export var colorCorrectionPixelShader: {
  54422. name: string;
  54423. shader: string;
  54424. };
  54425. }
  54426. declare module BABYLON {
  54427. /**
  54428. *
  54429. * This post-process allows the modification of rendered colors by using
  54430. * a 'look-up table' (LUT). This effect is also called Color Grading.
  54431. *
  54432. * The object needs to be provided an url to a texture containing the color
  54433. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  54434. * Use an image editing software to tweak the LUT to match your needs.
  54435. *
  54436. * For an example of a color LUT, see here:
  54437. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  54438. * For explanations on color grading, see here:
  54439. * @see http://udn.epicgames.com/Three/ColorGrading.html
  54440. *
  54441. */
  54442. export class ColorCorrectionPostProcess extends PostProcess {
  54443. private _colorTableTexture;
  54444. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54445. }
  54446. }
  54447. declare module BABYLON {
  54448. /** @hidden */
  54449. export var convolutionPixelShader: {
  54450. name: string;
  54451. shader: string;
  54452. };
  54453. }
  54454. declare module BABYLON {
  54455. /**
  54456. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  54457. * input texture to perform effects such as edge detection or sharpening
  54458. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  54459. */
  54460. export class ConvolutionPostProcess extends PostProcess {
  54461. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  54462. kernel: number[];
  54463. /**
  54464. * Creates a new instance ConvolutionPostProcess
  54465. * @param name The name of the effect.
  54466. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  54467. * @param options The required width/height ratio to downsize to before computing the render pass.
  54468. * @param camera The camera to apply the render pass to.
  54469. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54470. * @param engine The engine which the post process will be applied. (default: current engine)
  54471. * @param reusable If the post process can be reused on the same frame. (default: false)
  54472. * @param textureType Type of textures used when performing the post process. (default: 0)
  54473. */
  54474. constructor(name: string,
  54475. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  54476. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  54477. /**
  54478. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54479. */
  54480. static EdgeDetect0Kernel: number[];
  54481. /**
  54482. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54483. */
  54484. static EdgeDetect1Kernel: number[];
  54485. /**
  54486. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54487. */
  54488. static EdgeDetect2Kernel: number[];
  54489. /**
  54490. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54491. */
  54492. static SharpenKernel: number[];
  54493. /**
  54494. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54495. */
  54496. static EmbossKernel: number[];
  54497. /**
  54498. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54499. */
  54500. static GaussianKernel: number[];
  54501. }
  54502. }
  54503. declare module BABYLON {
  54504. /**
  54505. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  54506. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  54507. * based on samples that have a large difference in distance than the center pixel.
  54508. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  54509. */
  54510. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  54511. direction: Vector2;
  54512. /**
  54513. * Creates a new instance CircleOfConfusionPostProcess
  54514. * @param name The name of the effect.
  54515. * @param scene The scene the effect belongs to.
  54516. * @param direction The direction the blur should be applied.
  54517. * @param kernel The size of the kernel used to blur.
  54518. * @param options The required width/height ratio to downsize to before computing the render pass.
  54519. * @param camera The camera to apply the render pass to.
  54520. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  54521. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  54522. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54523. * @param engine The engine which the post process will be applied. (default: current engine)
  54524. * @param reusable If the post process can be reused on the same frame. (default: false)
  54525. * @param textureType Type of textures used when performing the post process. (default: 0)
  54526. * @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)
  54527. */
  54528. 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);
  54529. }
  54530. }
  54531. declare module BABYLON {
  54532. /** @hidden */
  54533. export var depthOfFieldMergePixelShader: {
  54534. name: string;
  54535. shader: string;
  54536. };
  54537. }
  54538. declare module BABYLON {
  54539. /**
  54540. * Options to be set when merging outputs from the default pipeline.
  54541. */
  54542. export class DepthOfFieldMergePostProcessOptions {
  54543. /**
  54544. * The original image to merge on top of
  54545. */
  54546. originalFromInput: PostProcess;
  54547. /**
  54548. * Parameters to perform the merge of the depth of field effect
  54549. */
  54550. depthOfField?: {
  54551. circleOfConfusion: PostProcess;
  54552. blurSteps: Array<PostProcess>;
  54553. };
  54554. /**
  54555. * Parameters to perform the merge of bloom effect
  54556. */
  54557. bloom?: {
  54558. blurred: PostProcess;
  54559. weight: number;
  54560. };
  54561. }
  54562. /**
  54563. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  54564. */
  54565. export class DepthOfFieldMergePostProcess extends PostProcess {
  54566. private blurSteps;
  54567. /**
  54568. * Creates a new instance of DepthOfFieldMergePostProcess
  54569. * @param name The name of the effect.
  54570. * @param originalFromInput Post process which's input will be used for the merge.
  54571. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  54572. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  54573. * @param options The required width/height ratio to downsize to before computing the render pass.
  54574. * @param camera The camera to apply the render pass to.
  54575. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54576. * @param engine The engine which the post process will be applied. (default: current engine)
  54577. * @param reusable If the post process can be reused on the same frame. (default: false)
  54578. * @param textureType Type of textures used when performing the post process. (default: 0)
  54579. * @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)
  54580. */
  54581. 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);
  54582. /**
  54583. * Updates the effect with the current post process compile time values and recompiles the shader.
  54584. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  54585. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  54586. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  54587. * @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
  54588. * @param onCompiled Called when the shader has been compiled.
  54589. * @param onError Called if there is an error when compiling a shader.
  54590. */
  54591. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  54592. }
  54593. }
  54594. declare module BABYLON {
  54595. /**
  54596. * Specifies the level of max blur that should be applied when using the depth of field effect
  54597. */
  54598. export enum DepthOfFieldEffectBlurLevel {
  54599. /**
  54600. * Subtle blur
  54601. */
  54602. Low = 0,
  54603. /**
  54604. * Medium blur
  54605. */
  54606. Medium = 1,
  54607. /**
  54608. * Large blur
  54609. */
  54610. High = 2
  54611. }
  54612. /**
  54613. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  54614. */
  54615. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  54616. private _circleOfConfusion;
  54617. /**
  54618. * @hidden Internal, blurs from high to low
  54619. */
  54620. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  54621. private _depthOfFieldBlurY;
  54622. private _dofMerge;
  54623. /**
  54624. * @hidden Internal post processes in depth of field effect
  54625. */
  54626. _effects: Array<PostProcess>;
  54627. /**
  54628. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  54629. */
  54630. focalLength: number;
  54631. /**
  54632. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  54633. */
  54634. fStop: number;
  54635. /**
  54636. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  54637. */
  54638. focusDistance: number;
  54639. /**
  54640. * 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.
  54641. */
  54642. lensSize: number;
  54643. /**
  54644. * Creates a new instance DepthOfFieldEffect
  54645. * @param scene The scene the effect belongs to.
  54646. * @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.
  54647. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  54648. * @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)
  54649. */
  54650. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  54651. /**
  54652. * Get the current class name of the current effet
  54653. * @returns "DepthOfFieldEffect"
  54654. */
  54655. getClassName(): string;
  54656. /**
  54657. * 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.
  54658. */
  54659. depthTexture: RenderTargetTexture;
  54660. /**
  54661. * Disposes each of the internal effects for a given camera.
  54662. * @param camera The camera to dispose the effect on.
  54663. */
  54664. disposeEffects(camera: Camera): void;
  54665. /**
  54666. * @hidden Internal
  54667. */
  54668. _updateEffects(): void;
  54669. /**
  54670. * Internal
  54671. * @returns if all the contained post processes are ready.
  54672. * @hidden
  54673. */
  54674. _isReady(): boolean;
  54675. }
  54676. }
  54677. declare module BABYLON {
  54678. /** @hidden */
  54679. export var displayPassPixelShader: {
  54680. name: string;
  54681. shader: string;
  54682. };
  54683. }
  54684. declare module BABYLON {
  54685. /**
  54686. * DisplayPassPostProcess which produces an output the same as it's input
  54687. */
  54688. export class DisplayPassPostProcess extends PostProcess {
  54689. /**
  54690. * Creates the DisplayPassPostProcess
  54691. * @param name The name of the effect.
  54692. * @param options The required width/height ratio to downsize to before computing the render pass.
  54693. * @param camera The camera to apply the render pass to.
  54694. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54695. * @param engine The engine which the post process will be applied. (default: current engine)
  54696. * @param reusable If the post process can be reused on the same frame. (default: false)
  54697. */
  54698. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54699. }
  54700. }
  54701. declare module BABYLON {
  54702. /** @hidden */
  54703. export var filterPixelShader: {
  54704. name: string;
  54705. shader: string;
  54706. };
  54707. }
  54708. declare module BABYLON {
  54709. /**
  54710. * Applies a kernel filter to the image
  54711. */
  54712. export class FilterPostProcess extends PostProcess {
  54713. /** The matrix to be applied to the image */
  54714. kernelMatrix: Matrix;
  54715. /**
  54716. *
  54717. * @param name The name of the effect.
  54718. * @param kernelMatrix The matrix to be applied to the image
  54719. * @param options The required width/height ratio to downsize to before computing the render pass.
  54720. * @param camera The camera to apply the render pass to.
  54721. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54722. * @param engine The engine which the post process will be applied. (default: current engine)
  54723. * @param reusable If the post process can be reused on the same frame. (default: false)
  54724. */
  54725. constructor(name: string,
  54726. /** The matrix to be applied to the image */
  54727. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54728. }
  54729. }
  54730. declare module BABYLON {
  54731. /** @hidden */
  54732. export var fxaaPixelShader: {
  54733. name: string;
  54734. shader: string;
  54735. };
  54736. }
  54737. declare module BABYLON {
  54738. /** @hidden */
  54739. export var fxaaVertexShader: {
  54740. name: string;
  54741. shader: string;
  54742. };
  54743. }
  54744. declare module BABYLON {
  54745. /**
  54746. * Fxaa post process
  54747. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  54748. */
  54749. export class FxaaPostProcess extends PostProcess {
  54750. /** @hidden */
  54751. texelWidth: number;
  54752. /** @hidden */
  54753. texelHeight: number;
  54754. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  54755. private _getDefines;
  54756. }
  54757. }
  54758. declare module BABYLON {
  54759. /** @hidden */
  54760. export var grainPixelShader: {
  54761. name: string;
  54762. shader: string;
  54763. };
  54764. }
  54765. declare module BABYLON {
  54766. /**
  54767. * The GrainPostProcess adds noise to the image at mid luminance levels
  54768. */
  54769. export class GrainPostProcess extends PostProcess {
  54770. /**
  54771. * The intensity of the grain added (default: 30)
  54772. */
  54773. intensity: number;
  54774. /**
  54775. * If the grain should be randomized on every frame
  54776. */
  54777. animated: boolean;
  54778. /**
  54779. * Creates a new instance of @see GrainPostProcess
  54780. * @param name The name of the effect.
  54781. * @param options The required width/height ratio to downsize to before computing the render pass.
  54782. * @param camera The camera to apply the render pass to.
  54783. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54784. * @param engine The engine which the post process will be applied. (default: current engine)
  54785. * @param reusable If the post process can be reused on the same frame. (default: false)
  54786. * @param textureType Type of textures used when performing the post process. (default: 0)
  54787. * @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)
  54788. */
  54789. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54790. }
  54791. }
  54792. declare module BABYLON {
  54793. /** @hidden */
  54794. export var highlightsPixelShader: {
  54795. name: string;
  54796. shader: string;
  54797. };
  54798. }
  54799. declare module BABYLON {
  54800. /**
  54801. * Extracts highlights from the image
  54802. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  54803. */
  54804. export class HighlightsPostProcess extends PostProcess {
  54805. /**
  54806. * Extracts highlights from the image
  54807. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  54808. * @param name The name of the effect.
  54809. * @param options The required width/height ratio to downsize to before computing the render pass.
  54810. * @param camera The camera to apply the render pass to.
  54811. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54812. * @param engine The engine which the post process will be applied. (default: current engine)
  54813. * @param reusable If the post process can be reused on the same frame. (default: false)
  54814. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  54815. */
  54816. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  54817. }
  54818. }
  54819. declare module BABYLON {
  54820. /** @hidden */
  54821. export var mrtFragmentDeclaration: {
  54822. name: string;
  54823. shader: string;
  54824. };
  54825. }
  54826. declare module BABYLON {
  54827. /** @hidden */
  54828. export var geometryPixelShader: {
  54829. name: string;
  54830. shader: string;
  54831. };
  54832. }
  54833. declare module BABYLON {
  54834. /** @hidden */
  54835. export var geometryVertexShader: {
  54836. name: string;
  54837. shader: string;
  54838. };
  54839. }
  54840. declare module BABYLON {
  54841. /** @hidden */
  54842. interface ISavedTransformationMatrix {
  54843. world: Matrix;
  54844. viewProjection: Matrix;
  54845. }
  54846. /**
  54847. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  54848. */
  54849. export class GeometryBufferRenderer {
  54850. /**
  54851. * Constant used to retrieve the position texture index in the G-Buffer textures array
  54852. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  54853. */
  54854. static readonly POSITION_TEXTURE_TYPE: number;
  54855. /**
  54856. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  54857. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  54858. */
  54859. static readonly VELOCITY_TEXTURE_TYPE: number;
  54860. /**
  54861. * Dictionary used to store the previous transformation matrices of each rendered mesh
  54862. * in order to compute objects velocities when enableVelocity is set to "true"
  54863. * @hidden
  54864. */
  54865. _previousTransformationMatrices: {
  54866. [index: number]: ISavedTransformationMatrix;
  54867. };
  54868. /**
  54869. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  54870. * in order to compute objects velocities when enableVelocity is set to "true"
  54871. * @hidden
  54872. */
  54873. _previousBonesTransformationMatrices: {
  54874. [index: number]: Float32Array;
  54875. };
  54876. /**
  54877. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  54878. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  54879. */
  54880. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  54881. private _scene;
  54882. private _multiRenderTarget;
  54883. private _ratio;
  54884. private _enablePosition;
  54885. private _enableVelocity;
  54886. private _positionIndex;
  54887. private _velocityIndex;
  54888. protected _effect: Effect;
  54889. protected _cachedDefines: string;
  54890. /**
  54891. * Set the render list (meshes to be rendered) used in the G buffer.
  54892. */
  54893. renderList: Mesh[];
  54894. /**
  54895. * Gets wether or not G buffer are supported by the running hardware.
  54896. * This requires draw buffer supports
  54897. */
  54898. readonly isSupported: boolean;
  54899. /**
  54900. * Returns the index of the given texture type in the G-Buffer textures array
  54901. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  54902. * @returns the index of the given texture type in the G-Buffer textures array
  54903. */
  54904. getTextureIndex(textureType: number): number;
  54905. /**
  54906. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  54907. */
  54908. /**
  54909. * Sets whether or not objects positions are enabled for the G buffer.
  54910. */
  54911. enablePosition: boolean;
  54912. /**
  54913. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  54914. */
  54915. /**
  54916. * Sets wether or not objects velocities are enabled for the G buffer.
  54917. */
  54918. enableVelocity: boolean;
  54919. /**
  54920. * Gets the scene associated with the buffer.
  54921. */
  54922. readonly scene: Scene;
  54923. /**
  54924. * Gets the ratio used by the buffer during its creation.
  54925. * How big is the buffer related to the main canvas.
  54926. */
  54927. readonly ratio: number;
  54928. /** @hidden */
  54929. static _SceneComponentInitialization: (scene: Scene) => void;
  54930. /**
  54931. * Creates a new G Buffer for the scene
  54932. * @param scene The scene the buffer belongs to
  54933. * @param ratio How big is the buffer related to the main canvas.
  54934. */
  54935. constructor(scene: Scene, ratio?: number);
  54936. /**
  54937. * Checks wether everything is ready to render a submesh to the G buffer.
  54938. * @param subMesh the submesh to check readiness for
  54939. * @param useInstances is the mesh drawn using instance or not
  54940. * @returns true if ready otherwise false
  54941. */
  54942. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54943. /**
  54944. * Gets the current underlying G Buffer.
  54945. * @returns the buffer
  54946. */
  54947. getGBuffer(): MultiRenderTarget;
  54948. /**
  54949. * Gets the number of samples used to render the buffer (anti aliasing).
  54950. */
  54951. /**
  54952. * Sets the number of samples used to render the buffer (anti aliasing).
  54953. */
  54954. samples: number;
  54955. /**
  54956. * Disposes the renderer and frees up associated resources.
  54957. */
  54958. dispose(): void;
  54959. protected _createRenderTargets(): void;
  54960. private _copyBonesTransformationMatrices;
  54961. }
  54962. }
  54963. declare module BABYLON {
  54964. interface Scene {
  54965. /** @hidden (Backing field) */
  54966. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  54967. /**
  54968. * Gets or Sets the current geometry buffer associated to the scene.
  54969. */
  54970. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  54971. /**
  54972. * Enables a GeometryBufferRender and associates it with the scene
  54973. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  54974. * @returns the GeometryBufferRenderer
  54975. */
  54976. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  54977. /**
  54978. * Disables the GeometryBufferRender associated with the scene
  54979. */
  54980. disableGeometryBufferRenderer(): void;
  54981. }
  54982. /**
  54983. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  54984. * in several rendering techniques.
  54985. */
  54986. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  54987. /**
  54988. * The component name helpful to identify the component in the list of scene components.
  54989. */
  54990. readonly name: string;
  54991. /**
  54992. * The scene the component belongs to.
  54993. */
  54994. scene: Scene;
  54995. /**
  54996. * Creates a new instance of the component for the given scene
  54997. * @param scene Defines the scene to register the component in
  54998. */
  54999. constructor(scene: Scene);
  55000. /**
  55001. * Registers the component in a given scene
  55002. */
  55003. register(): void;
  55004. /**
  55005. * Rebuilds the elements related to this component in case of
  55006. * context lost for instance.
  55007. */
  55008. rebuild(): void;
  55009. /**
  55010. * Disposes the component and the associated ressources
  55011. */
  55012. dispose(): void;
  55013. private _gatherRenderTargets;
  55014. }
  55015. }
  55016. declare module BABYLON {
  55017. /** @hidden */
  55018. export var motionBlurPixelShader: {
  55019. name: string;
  55020. shader: string;
  55021. };
  55022. }
  55023. declare module BABYLON {
  55024. /**
  55025. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  55026. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  55027. * As an example, all you have to do is to create the post-process:
  55028. * var mb = new BABYLON.MotionBlurPostProcess(
  55029. * 'mb', // The name of the effect.
  55030. * scene, // The scene containing the objects to blur according to their velocity.
  55031. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  55032. * camera // The camera to apply the render pass to.
  55033. * );
  55034. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  55035. */
  55036. export class MotionBlurPostProcess extends PostProcess {
  55037. /**
  55038. * Defines how much the image is blurred by the movement. Default value is equal to 1
  55039. */
  55040. motionStrength: number;
  55041. /**
  55042. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  55043. */
  55044. /**
  55045. * Sets the number of iterations to be used for motion blur quality
  55046. */
  55047. motionBlurSamples: number;
  55048. private _motionBlurSamples;
  55049. private _geometryBufferRenderer;
  55050. /**
  55051. * Creates a new instance MotionBlurPostProcess
  55052. * @param name The name of the effect.
  55053. * @param scene The scene containing the objects to blur according to their velocity.
  55054. * @param options The required width/height ratio to downsize to before computing the render pass.
  55055. * @param camera The camera to apply the render pass to.
  55056. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55057. * @param engine The engine which the post process will be applied. (default: current engine)
  55058. * @param reusable If the post process can be reused on the same frame. (default: false)
  55059. * @param textureType Type of textures used when performing the post process. (default: 0)
  55060. * @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)
  55061. */
  55062. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55063. /**
  55064. * Excludes the given skinned mesh from computing bones velocities.
  55065. * 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.
  55066. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  55067. */
  55068. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  55069. /**
  55070. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  55071. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  55072. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  55073. */
  55074. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  55075. /**
  55076. * Disposes the post process.
  55077. * @param camera The camera to dispose the post process on.
  55078. */
  55079. dispose(camera?: Camera): void;
  55080. }
  55081. }
  55082. declare module BABYLON {
  55083. /** @hidden */
  55084. export var refractionPixelShader: {
  55085. name: string;
  55086. shader: string;
  55087. };
  55088. }
  55089. declare module BABYLON {
  55090. /**
  55091. * Post process which applies a refractin texture
  55092. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  55093. */
  55094. export class RefractionPostProcess extends PostProcess {
  55095. /** the base color of the refraction (used to taint the rendering) */
  55096. color: Color3;
  55097. /** simulated refraction depth */
  55098. depth: number;
  55099. /** the coefficient of the base color (0 to remove base color tainting) */
  55100. colorLevel: number;
  55101. private _refTexture;
  55102. private _ownRefractionTexture;
  55103. /**
  55104. * Gets or sets the refraction texture
  55105. * Please note that you are responsible for disposing the texture if you set it manually
  55106. */
  55107. refractionTexture: Texture;
  55108. /**
  55109. * Initializes the RefractionPostProcess
  55110. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  55111. * @param name The name of the effect.
  55112. * @param refractionTextureUrl Url of the refraction texture to use
  55113. * @param color the base color of the refraction (used to taint the rendering)
  55114. * @param depth simulated refraction depth
  55115. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  55116. * @param camera The camera to apply the render pass to.
  55117. * @param options The required width/height ratio to downsize to before computing the render pass.
  55118. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55119. * @param engine The engine which the post process will be applied. (default: current engine)
  55120. * @param reusable If the post process can be reused on the same frame. (default: false)
  55121. */
  55122. constructor(name: string, refractionTextureUrl: string,
  55123. /** the base color of the refraction (used to taint the rendering) */
  55124. color: Color3,
  55125. /** simulated refraction depth */
  55126. depth: number,
  55127. /** the coefficient of the base color (0 to remove base color tainting) */
  55128. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55129. /**
  55130. * Disposes of the post process
  55131. * @param camera Camera to dispose post process on
  55132. */
  55133. dispose(camera: Camera): void;
  55134. }
  55135. }
  55136. declare module BABYLON {
  55137. /** @hidden */
  55138. export var sharpenPixelShader: {
  55139. name: string;
  55140. shader: string;
  55141. };
  55142. }
  55143. declare module BABYLON {
  55144. /**
  55145. * The SharpenPostProcess applies a sharpen kernel to every pixel
  55146. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  55147. */
  55148. export class SharpenPostProcess extends PostProcess {
  55149. /**
  55150. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  55151. */
  55152. colorAmount: number;
  55153. /**
  55154. * How much sharpness should be applied (default: 0.3)
  55155. */
  55156. edgeAmount: number;
  55157. /**
  55158. * Creates a new instance ConvolutionPostProcess
  55159. * @param name The name of the effect.
  55160. * @param options The required width/height ratio to downsize to before computing the render pass.
  55161. * @param camera The camera to apply the render pass to.
  55162. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55163. * @param engine The engine which the post process will be applied. (default: current engine)
  55164. * @param reusable If the post process can be reused on the same frame. (default: false)
  55165. * @param textureType Type of textures used when performing the post process. (default: 0)
  55166. * @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)
  55167. */
  55168. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55169. }
  55170. }
  55171. declare module BABYLON {
  55172. /**
  55173. * PostProcessRenderPipeline
  55174. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55175. */
  55176. export class PostProcessRenderPipeline {
  55177. private engine;
  55178. private _renderEffects;
  55179. private _renderEffectsForIsolatedPass;
  55180. /**
  55181. * List of inspectable custom properties (used by the Inspector)
  55182. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  55183. */
  55184. inspectableCustomProperties: IInspectable[];
  55185. /**
  55186. * @hidden
  55187. */
  55188. protected _cameras: Camera[];
  55189. /** @hidden */
  55190. _name: string;
  55191. /**
  55192. * Gets pipeline name
  55193. */
  55194. readonly name: string;
  55195. /**
  55196. * Initializes a PostProcessRenderPipeline
  55197. * @param engine engine to add the pipeline to
  55198. * @param name name of the pipeline
  55199. */
  55200. constructor(engine: Engine, name: string);
  55201. /**
  55202. * Gets the class name
  55203. * @returns "PostProcessRenderPipeline"
  55204. */
  55205. getClassName(): string;
  55206. /**
  55207. * If all the render effects in the pipeline are supported
  55208. */
  55209. readonly isSupported: boolean;
  55210. /**
  55211. * Adds an effect to the pipeline
  55212. * @param renderEffect the effect to add
  55213. */
  55214. addEffect(renderEffect: PostProcessRenderEffect): void;
  55215. /** @hidden */
  55216. _rebuild(): void;
  55217. /** @hidden */
  55218. _enableEffect(renderEffectName: string, cameras: Camera): void;
  55219. /** @hidden */
  55220. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  55221. /** @hidden */
  55222. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  55223. /** @hidden */
  55224. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  55225. /** @hidden */
  55226. _attachCameras(cameras: Camera, unique: boolean): void;
  55227. /** @hidden */
  55228. _attachCameras(cameras: Camera[], unique: boolean): void;
  55229. /** @hidden */
  55230. _detachCameras(cameras: Camera): void;
  55231. /** @hidden */
  55232. _detachCameras(cameras: Nullable<Camera[]>): void;
  55233. /** @hidden */
  55234. _update(): void;
  55235. /** @hidden */
  55236. _reset(): void;
  55237. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  55238. /**
  55239. * Disposes of the pipeline
  55240. */
  55241. dispose(): void;
  55242. }
  55243. }
  55244. declare module BABYLON {
  55245. /**
  55246. * PostProcessRenderPipelineManager class
  55247. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55248. */
  55249. export class PostProcessRenderPipelineManager {
  55250. private _renderPipelines;
  55251. /**
  55252. * Initializes a PostProcessRenderPipelineManager
  55253. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55254. */
  55255. constructor();
  55256. /**
  55257. * Gets the list of supported render pipelines
  55258. */
  55259. readonly supportedPipelines: PostProcessRenderPipeline[];
  55260. /**
  55261. * Adds a pipeline to the manager
  55262. * @param renderPipeline The pipeline to add
  55263. */
  55264. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  55265. /**
  55266. * Attaches a camera to the pipeline
  55267. * @param renderPipelineName The name of the pipeline to attach to
  55268. * @param cameras the camera to attach
  55269. * @param unique if the camera can be attached multiple times to the pipeline
  55270. */
  55271. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  55272. /**
  55273. * Detaches a camera from the pipeline
  55274. * @param renderPipelineName The name of the pipeline to detach from
  55275. * @param cameras the camera to detach
  55276. */
  55277. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  55278. /**
  55279. * Enables an effect by name on a pipeline
  55280. * @param renderPipelineName the name of the pipeline to enable the effect in
  55281. * @param renderEffectName the name of the effect to enable
  55282. * @param cameras the cameras that the effect should be enabled on
  55283. */
  55284. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  55285. /**
  55286. * Disables an effect by name on a pipeline
  55287. * @param renderPipelineName the name of the pipeline to disable the effect in
  55288. * @param renderEffectName the name of the effect to disable
  55289. * @param cameras the cameras that the effect should be disabled on
  55290. */
  55291. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  55292. /**
  55293. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  55294. */
  55295. update(): void;
  55296. /** @hidden */
  55297. _rebuild(): void;
  55298. /**
  55299. * Disposes of the manager and pipelines
  55300. */
  55301. dispose(): void;
  55302. }
  55303. }
  55304. declare module BABYLON {
  55305. interface Scene {
  55306. /** @hidden (Backing field) */
  55307. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  55308. /**
  55309. * Gets the postprocess render pipeline manager
  55310. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55311. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  55312. */
  55313. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  55314. }
  55315. /**
  55316. * Defines the Render Pipeline scene component responsible to rendering pipelines
  55317. */
  55318. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  55319. /**
  55320. * The component name helpfull to identify the component in the list of scene components.
  55321. */
  55322. readonly name: string;
  55323. /**
  55324. * The scene the component belongs to.
  55325. */
  55326. scene: Scene;
  55327. /**
  55328. * Creates a new instance of the component for the given scene
  55329. * @param scene Defines the scene to register the component in
  55330. */
  55331. constructor(scene: Scene);
  55332. /**
  55333. * Registers the component in a given scene
  55334. */
  55335. register(): void;
  55336. /**
  55337. * Rebuilds the elements related to this component in case of
  55338. * context lost for instance.
  55339. */
  55340. rebuild(): void;
  55341. /**
  55342. * Disposes the component and the associated ressources
  55343. */
  55344. dispose(): void;
  55345. private _gatherRenderTargets;
  55346. }
  55347. }
  55348. declare module BABYLON {
  55349. /**
  55350. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  55351. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  55352. */
  55353. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  55354. private _scene;
  55355. private _camerasToBeAttached;
  55356. /**
  55357. * ID of the sharpen post process,
  55358. */
  55359. private readonly SharpenPostProcessId;
  55360. /**
  55361. * @ignore
  55362. * ID of the image processing post process;
  55363. */
  55364. readonly ImageProcessingPostProcessId: string;
  55365. /**
  55366. * @ignore
  55367. * ID of the Fast Approximate Anti-Aliasing post process;
  55368. */
  55369. readonly FxaaPostProcessId: string;
  55370. /**
  55371. * ID of the chromatic aberration post process,
  55372. */
  55373. private readonly ChromaticAberrationPostProcessId;
  55374. /**
  55375. * ID of the grain post process
  55376. */
  55377. private readonly GrainPostProcessId;
  55378. /**
  55379. * Sharpen post process which will apply a sharpen convolution to enhance edges
  55380. */
  55381. sharpen: SharpenPostProcess;
  55382. private _sharpenEffect;
  55383. private bloom;
  55384. /**
  55385. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  55386. */
  55387. depthOfField: DepthOfFieldEffect;
  55388. /**
  55389. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  55390. */
  55391. fxaa: FxaaPostProcess;
  55392. /**
  55393. * Image post processing pass used to perform operations such as tone mapping or color grading.
  55394. */
  55395. imageProcessing: ImageProcessingPostProcess;
  55396. /**
  55397. * Chromatic aberration post process which will shift rgb colors in the image
  55398. */
  55399. chromaticAberration: ChromaticAberrationPostProcess;
  55400. private _chromaticAberrationEffect;
  55401. /**
  55402. * Grain post process which add noise to the image
  55403. */
  55404. grain: GrainPostProcess;
  55405. private _grainEffect;
  55406. /**
  55407. * Glow post process which adds a glow to emissive areas of the image
  55408. */
  55409. private _glowLayer;
  55410. /**
  55411. * Animations which can be used to tweak settings over a period of time
  55412. */
  55413. animations: Animation[];
  55414. private _imageProcessingConfigurationObserver;
  55415. private _sharpenEnabled;
  55416. private _bloomEnabled;
  55417. private _depthOfFieldEnabled;
  55418. private _depthOfFieldBlurLevel;
  55419. private _fxaaEnabled;
  55420. private _imageProcessingEnabled;
  55421. private _defaultPipelineTextureType;
  55422. private _bloomScale;
  55423. private _chromaticAberrationEnabled;
  55424. private _grainEnabled;
  55425. private _buildAllowed;
  55426. /**
  55427. * Gets active scene
  55428. */
  55429. readonly scene: Scene;
  55430. /**
  55431. * Enable or disable the sharpen process from the pipeline
  55432. */
  55433. sharpenEnabled: boolean;
  55434. private _resizeObserver;
  55435. private _hardwareScaleLevel;
  55436. private _bloomKernel;
  55437. /**
  55438. * Specifies the size of the bloom blur kernel, relative to the final output size
  55439. */
  55440. bloomKernel: number;
  55441. /**
  55442. * Specifies the weight of the bloom in the final rendering
  55443. */
  55444. private _bloomWeight;
  55445. /**
  55446. * Specifies the luma threshold for the area that will be blurred by the bloom
  55447. */
  55448. private _bloomThreshold;
  55449. private _hdr;
  55450. /**
  55451. * The strength of the bloom.
  55452. */
  55453. bloomWeight: number;
  55454. /**
  55455. * The strength of the bloom.
  55456. */
  55457. bloomThreshold: number;
  55458. /**
  55459. * The scale of the bloom, lower value will provide better performance.
  55460. */
  55461. bloomScale: number;
  55462. /**
  55463. * Enable or disable the bloom from the pipeline
  55464. */
  55465. bloomEnabled: boolean;
  55466. private _rebuildBloom;
  55467. /**
  55468. * If the depth of field is enabled.
  55469. */
  55470. depthOfFieldEnabled: boolean;
  55471. /**
  55472. * Blur level of the depth of field effect. (Higher blur will effect performance)
  55473. */
  55474. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  55475. /**
  55476. * If the anti aliasing is enabled.
  55477. */
  55478. fxaaEnabled: boolean;
  55479. private _samples;
  55480. /**
  55481. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  55482. */
  55483. samples: number;
  55484. /**
  55485. * If image processing is enabled.
  55486. */
  55487. imageProcessingEnabled: boolean;
  55488. /**
  55489. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  55490. */
  55491. glowLayerEnabled: boolean;
  55492. /**
  55493. * Gets the glow layer (or null if not defined)
  55494. */
  55495. readonly glowLayer: Nullable<GlowLayer>;
  55496. /**
  55497. * Enable or disable the chromaticAberration process from the pipeline
  55498. */
  55499. chromaticAberrationEnabled: boolean;
  55500. /**
  55501. * Enable or disable the grain process from the pipeline
  55502. */
  55503. grainEnabled: boolean;
  55504. /**
  55505. * @constructor
  55506. * @param name - The rendering pipeline name (default: "")
  55507. * @param hdr - If high dynamic range textures should be used (default: true)
  55508. * @param scene - The scene linked to this pipeline (default: the last created scene)
  55509. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  55510. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  55511. */
  55512. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  55513. /**
  55514. * Get the class name
  55515. * @returns "DefaultRenderingPipeline"
  55516. */
  55517. getClassName(): string;
  55518. /**
  55519. * Force the compilation of the entire pipeline.
  55520. */
  55521. prepare(): void;
  55522. private _hasCleared;
  55523. private _prevPostProcess;
  55524. private _prevPrevPostProcess;
  55525. private _setAutoClearAndTextureSharing;
  55526. private _depthOfFieldSceneObserver;
  55527. private _buildPipeline;
  55528. private _disposePostProcesses;
  55529. /**
  55530. * Adds a camera to the pipeline
  55531. * @param camera the camera to be added
  55532. */
  55533. addCamera(camera: Camera): void;
  55534. /**
  55535. * Removes a camera from the pipeline
  55536. * @param camera the camera to remove
  55537. */
  55538. removeCamera(camera: Camera): void;
  55539. /**
  55540. * Dispose of the pipeline and stop all post processes
  55541. */
  55542. dispose(): void;
  55543. /**
  55544. * Serialize the rendering pipeline (Used when exporting)
  55545. * @returns the serialized object
  55546. */
  55547. serialize(): any;
  55548. /**
  55549. * Parse the serialized pipeline
  55550. * @param source Source pipeline.
  55551. * @param scene The scene to load the pipeline to.
  55552. * @param rootUrl The URL of the serialized pipeline.
  55553. * @returns An instantiated pipeline from the serialized object.
  55554. */
  55555. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  55556. }
  55557. }
  55558. declare module BABYLON {
  55559. /** @hidden */
  55560. export var lensHighlightsPixelShader: {
  55561. name: string;
  55562. shader: string;
  55563. };
  55564. }
  55565. declare module BABYLON {
  55566. /** @hidden */
  55567. export var depthOfFieldPixelShader: {
  55568. name: string;
  55569. shader: string;
  55570. };
  55571. }
  55572. declare module BABYLON {
  55573. /**
  55574. * BABYLON.JS Chromatic Aberration GLSL Shader
  55575. * Author: Olivier Guyot
  55576. * Separates very slightly R, G and B colors on the edges of the screen
  55577. * Inspired by Francois Tarlier & Martins Upitis
  55578. */
  55579. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  55580. /**
  55581. * @ignore
  55582. * The chromatic aberration PostProcess id in the pipeline
  55583. */
  55584. LensChromaticAberrationEffect: string;
  55585. /**
  55586. * @ignore
  55587. * The highlights enhancing PostProcess id in the pipeline
  55588. */
  55589. HighlightsEnhancingEffect: string;
  55590. /**
  55591. * @ignore
  55592. * The depth-of-field PostProcess id in the pipeline
  55593. */
  55594. LensDepthOfFieldEffect: string;
  55595. private _scene;
  55596. private _depthTexture;
  55597. private _grainTexture;
  55598. private _chromaticAberrationPostProcess;
  55599. private _highlightsPostProcess;
  55600. private _depthOfFieldPostProcess;
  55601. private _edgeBlur;
  55602. private _grainAmount;
  55603. private _chromaticAberration;
  55604. private _distortion;
  55605. private _highlightsGain;
  55606. private _highlightsThreshold;
  55607. private _dofDistance;
  55608. private _dofAperture;
  55609. private _dofDarken;
  55610. private _dofPentagon;
  55611. private _blurNoise;
  55612. /**
  55613. * @constructor
  55614. *
  55615. * Effect parameters are as follow:
  55616. * {
  55617. * chromatic_aberration: number; // from 0 to x (1 for realism)
  55618. * edge_blur: number; // from 0 to x (1 for realism)
  55619. * distortion: number; // from 0 to x (1 for realism)
  55620. * grain_amount: number; // from 0 to 1
  55621. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  55622. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  55623. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  55624. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  55625. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  55626. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  55627. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  55628. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  55629. * }
  55630. * Note: if an effect parameter is unset, effect is disabled
  55631. *
  55632. * @param name The rendering pipeline name
  55633. * @param parameters - An object containing all parameters (see above)
  55634. * @param scene The scene linked to this pipeline
  55635. * @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)
  55636. * @param cameras The array of cameras that the rendering pipeline will be attached to
  55637. */
  55638. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  55639. /**
  55640. * Get the class name
  55641. * @returns "LensRenderingPipeline"
  55642. */
  55643. getClassName(): string;
  55644. /**
  55645. * Gets associated scene
  55646. */
  55647. readonly scene: Scene;
  55648. /**
  55649. * Gets or sets the edge blur
  55650. */
  55651. edgeBlur: number;
  55652. /**
  55653. * Gets or sets the grain amount
  55654. */
  55655. grainAmount: number;
  55656. /**
  55657. * Gets or sets the chromatic aberration amount
  55658. */
  55659. chromaticAberration: number;
  55660. /**
  55661. * Gets or sets the depth of field aperture
  55662. */
  55663. dofAperture: number;
  55664. /**
  55665. * Gets or sets the edge distortion
  55666. */
  55667. edgeDistortion: number;
  55668. /**
  55669. * Gets or sets the depth of field distortion
  55670. */
  55671. dofDistortion: number;
  55672. /**
  55673. * Gets or sets the darken out of focus amount
  55674. */
  55675. darkenOutOfFocus: number;
  55676. /**
  55677. * Gets or sets a boolean indicating if blur noise is enabled
  55678. */
  55679. blurNoise: boolean;
  55680. /**
  55681. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  55682. */
  55683. pentagonBokeh: boolean;
  55684. /**
  55685. * Gets or sets the highlight grain amount
  55686. */
  55687. highlightsGain: number;
  55688. /**
  55689. * Gets or sets the highlight threshold
  55690. */
  55691. highlightsThreshold: number;
  55692. /**
  55693. * Sets the amount of blur at the edges
  55694. * @param amount blur amount
  55695. */
  55696. setEdgeBlur(amount: number): void;
  55697. /**
  55698. * Sets edge blur to 0
  55699. */
  55700. disableEdgeBlur(): void;
  55701. /**
  55702. * Sets the amout of grain
  55703. * @param amount Amount of grain
  55704. */
  55705. setGrainAmount(amount: number): void;
  55706. /**
  55707. * Set grain amount to 0
  55708. */
  55709. disableGrain(): void;
  55710. /**
  55711. * Sets the chromatic aberration amount
  55712. * @param amount amount of chromatic aberration
  55713. */
  55714. setChromaticAberration(amount: number): void;
  55715. /**
  55716. * Sets chromatic aberration amount to 0
  55717. */
  55718. disableChromaticAberration(): void;
  55719. /**
  55720. * Sets the EdgeDistortion amount
  55721. * @param amount amount of EdgeDistortion
  55722. */
  55723. setEdgeDistortion(amount: number): void;
  55724. /**
  55725. * Sets edge distortion to 0
  55726. */
  55727. disableEdgeDistortion(): void;
  55728. /**
  55729. * Sets the FocusDistance amount
  55730. * @param amount amount of FocusDistance
  55731. */
  55732. setFocusDistance(amount: number): void;
  55733. /**
  55734. * Disables depth of field
  55735. */
  55736. disableDepthOfField(): void;
  55737. /**
  55738. * Sets the Aperture amount
  55739. * @param amount amount of Aperture
  55740. */
  55741. setAperture(amount: number): void;
  55742. /**
  55743. * Sets the DarkenOutOfFocus amount
  55744. * @param amount amount of DarkenOutOfFocus
  55745. */
  55746. setDarkenOutOfFocus(amount: number): void;
  55747. private _pentagonBokehIsEnabled;
  55748. /**
  55749. * Creates a pentagon bokeh effect
  55750. */
  55751. enablePentagonBokeh(): void;
  55752. /**
  55753. * Disables the pentagon bokeh effect
  55754. */
  55755. disablePentagonBokeh(): void;
  55756. /**
  55757. * Enables noise blur
  55758. */
  55759. enableNoiseBlur(): void;
  55760. /**
  55761. * Disables noise blur
  55762. */
  55763. disableNoiseBlur(): void;
  55764. /**
  55765. * Sets the HighlightsGain amount
  55766. * @param amount amount of HighlightsGain
  55767. */
  55768. setHighlightsGain(amount: number): void;
  55769. /**
  55770. * Sets the HighlightsThreshold amount
  55771. * @param amount amount of HighlightsThreshold
  55772. */
  55773. setHighlightsThreshold(amount: number): void;
  55774. /**
  55775. * Disables highlights
  55776. */
  55777. disableHighlights(): void;
  55778. /**
  55779. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  55780. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  55781. */
  55782. dispose(disableDepthRender?: boolean): void;
  55783. private _createChromaticAberrationPostProcess;
  55784. private _createHighlightsPostProcess;
  55785. private _createDepthOfFieldPostProcess;
  55786. private _createGrainTexture;
  55787. }
  55788. }
  55789. declare module BABYLON {
  55790. /** @hidden */
  55791. export var ssao2PixelShader: {
  55792. name: string;
  55793. shader: string;
  55794. };
  55795. }
  55796. declare module BABYLON {
  55797. /** @hidden */
  55798. export var ssaoCombinePixelShader: {
  55799. name: string;
  55800. shader: string;
  55801. };
  55802. }
  55803. declare module BABYLON {
  55804. /**
  55805. * Render pipeline to produce ssao effect
  55806. */
  55807. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  55808. /**
  55809. * @ignore
  55810. * The PassPostProcess id in the pipeline that contains the original scene color
  55811. */
  55812. SSAOOriginalSceneColorEffect: string;
  55813. /**
  55814. * @ignore
  55815. * The SSAO PostProcess id in the pipeline
  55816. */
  55817. SSAORenderEffect: string;
  55818. /**
  55819. * @ignore
  55820. * The horizontal blur PostProcess id in the pipeline
  55821. */
  55822. SSAOBlurHRenderEffect: string;
  55823. /**
  55824. * @ignore
  55825. * The vertical blur PostProcess id in the pipeline
  55826. */
  55827. SSAOBlurVRenderEffect: string;
  55828. /**
  55829. * @ignore
  55830. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  55831. */
  55832. SSAOCombineRenderEffect: string;
  55833. /**
  55834. * The output strength of the SSAO post-process. Default value is 1.0.
  55835. */
  55836. totalStrength: number;
  55837. /**
  55838. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  55839. */
  55840. maxZ: number;
  55841. /**
  55842. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  55843. */
  55844. minZAspect: number;
  55845. private _samples;
  55846. /**
  55847. * Number of samples used for the SSAO calculations. Default value is 8
  55848. */
  55849. samples: number;
  55850. private _textureSamples;
  55851. /**
  55852. * Number of samples to use for antialiasing
  55853. */
  55854. textureSamples: number;
  55855. /**
  55856. * Ratio object used for SSAO ratio and blur ratio
  55857. */
  55858. private _ratio;
  55859. /**
  55860. * Dynamically generated sphere sampler.
  55861. */
  55862. private _sampleSphere;
  55863. /**
  55864. * Blur filter offsets
  55865. */
  55866. private _samplerOffsets;
  55867. private _expensiveBlur;
  55868. /**
  55869. * If bilateral blur should be used
  55870. */
  55871. expensiveBlur: boolean;
  55872. /**
  55873. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  55874. */
  55875. radius: number;
  55876. /**
  55877. * The base color of the SSAO post-process
  55878. * The final result is "base + ssao" between [0, 1]
  55879. */
  55880. base: number;
  55881. /**
  55882. * Support test.
  55883. */
  55884. static readonly IsSupported: boolean;
  55885. private _scene;
  55886. private _depthTexture;
  55887. private _normalTexture;
  55888. private _randomTexture;
  55889. private _originalColorPostProcess;
  55890. private _ssaoPostProcess;
  55891. private _blurHPostProcess;
  55892. private _blurVPostProcess;
  55893. private _ssaoCombinePostProcess;
  55894. private _firstUpdate;
  55895. /**
  55896. * Gets active scene
  55897. */
  55898. readonly scene: Scene;
  55899. /**
  55900. * @constructor
  55901. * @param name The rendering pipeline name
  55902. * @param scene The scene linked to this pipeline
  55903. * @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 }
  55904. * @param cameras The array of cameras that the rendering pipeline will be attached to
  55905. */
  55906. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  55907. /**
  55908. * Get the class name
  55909. * @returns "SSAO2RenderingPipeline"
  55910. */
  55911. getClassName(): string;
  55912. /**
  55913. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  55914. */
  55915. dispose(disableGeometryBufferRenderer?: boolean): void;
  55916. private _createBlurPostProcess;
  55917. /** @hidden */
  55918. _rebuild(): void;
  55919. private _bits;
  55920. private _radicalInverse_VdC;
  55921. private _hammersley;
  55922. private _hemisphereSample_uniform;
  55923. private _generateHemisphere;
  55924. private _createSSAOPostProcess;
  55925. private _createSSAOCombinePostProcess;
  55926. private _createRandomTexture;
  55927. /**
  55928. * Serialize the rendering pipeline (Used when exporting)
  55929. * @returns the serialized object
  55930. */
  55931. serialize(): any;
  55932. /**
  55933. * Parse the serialized pipeline
  55934. * @param source Source pipeline.
  55935. * @param scene The scene to load the pipeline to.
  55936. * @param rootUrl The URL of the serialized pipeline.
  55937. * @returns An instantiated pipeline from the serialized object.
  55938. */
  55939. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  55940. }
  55941. }
  55942. declare module BABYLON {
  55943. /** @hidden */
  55944. export var ssaoPixelShader: {
  55945. name: string;
  55946. shader: string;
  55947. };
  55948. }
  55949. declare module BABYLON {
  55950. /**
  55951. * Render pipeline to produce ssao effect
  55952. */
  55953. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  55954. /**
  55955. * @ignore
  55956. * The PassPostProcess id in the pipeline that contains the original scene color
  55957. */
  55958. SSAOOriginalSceneColorEffect: string;
  55959. /**
  55960. * @ignore
  55961. * The SSAO PostProcess id in the pipeline
  55962. */
  55963. SSAORenderEffect: string;
  55964. /**
  55965. * @ignore
  55966. * The horizontal blur PostProcess id in the pipeline
  55967. */
  55968. SSAOBlurHRenderEffect: string;
  55969. /**
  55970. * @ignore
  55971. * The vertical blur PostProcess id in the pipeline
  55972. */
  55973. SSAOBlurVRenderEffect: string;
  55974. /**
  55975. * @ignore
  55976. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  55977. */
  55978. SSAOCombineRenderEffect: string;
  55979. /**
  55980. * The output strength of the SSAO post-process. Default value is 1.0.
  55981. */
  55982. totalStrength: number;
  55983. /**
  55984. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  55985. */
  55986. radius: number;
  55987. /**
  55988. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  55989. * Must not be equal to fallOff and superior to fallOff.
  55990. * Default value is 0.0075
  55991. */
  55992. area: number;
  55993. /**
  55994. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  55995. * Must not be equal to area and inferior to area.
  55996. * Default value is 0.000001
  55997. */
  55998. fallOff: number;
  55999. /**
  56000. * The base color of the SSAO post-process
  56001. * The final result is "base + ssao" between [0, 1]
  56002. */
  56003. base: number;
  56004. private _scene;
  56005. private _depthTexture;
  56006. private _randomTexture;
  56007. private _originalColorPostProcess;
  56008. private _ssaoPostProcess;
  56009. private _blurHPostProcess;
  56010. private _blurVPostProcess;
  56011. private _ssaoCombinePostProcess;
  56012. private _firstUpdate;
  56013. /**
  56014. * Gets active scene
  56015. */
  56016. readonly scene: Scene;
  56017. /**
  56018. * @constructor
  56019. * @param name - The rendering pipeline name
  56020. * @param scene - The scene linked to this pipeline
  56021. * @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 }
  56022. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  56023. */
  56024. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  56025. /**
  56026. * Get the class name
  56027. * @returns "SSAORenderingPipeline"
  56028. */
  56029. getClassName(): string;
  56030. /**
  56031. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  56032. */
  56033. dispose(disableDepthRender?: boolean): void;
  56034. private _createBlurPostProcess;
  56035. /** @hidden */
  56036. _rebuild(): void;
  56037. private _createSSAOPostProcess;
  56038. private _createSSAOCombinePostProcess;
  56039. private _createRandomTexture;
  56040. }
  56041. }
  56042. declare module BABYLON {
  56043. /** @hidden */
  56044. export var standardPixelShader: {
  56045. name: string;
  56046. shader: string;
  56047. };
  56048. }
  56049. declare module BABYLON {
  56050. /**
  56051. * Standard rendering pipeline
  56052. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  56053. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  56054. */
  56055. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  56056. /**
  56057. * Public members
  56058. */
  56059. /**
  56060. * Post-process which contains the original scene color before the pipeline applies all the effects
  56061. */
  56062. originalPostProcess: Nullable<PostProcess>;
  56063. /**
  56064. * Post-process used to down scale an image x4
  56065. */
  56066. downSampleX4PostProcess: Nullable<PostProcess>;
  56067. /**
  56068. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  56069. */
  56070. brightPassPostProcess: Nullable<PostProcess>;
  56071. /**
  56072. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  56073. */
  56074. blurHPostProcesses: PostProcess[];
  56075. /**
  56076. * Post-process array storing all the vertical blur post-processes used by the pipeline
  56077. */
  56078. blurVPostProcesses: PostProcess[];
  56079. /**
  56080. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  56081. */
  56082. textureAdderPostProcess: Nullable<PostProcess>;
  56083. /**
  56084. * Post-process used to create volumetric lighting effect
  56085. */
  56086. volumetricLightPostProcess: Nullable<PostProcess>;
  56087. /**
  56088. * Post-process used to smooth the previous volumetric light post-process on the X axis
  56089. */
  56090. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  56091. /**
  56092. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  56093. */
  56094. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  56095. /**
  56096. * Post-process used to merge the volumetric light effect and the real scene color
  56097. */
  56098. volumetricLightMergePostProces: Nullable<PostProcess>;
  56099. /**
  56100. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  56101. */
  56102. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  56103. /**
  56104. * Base post-process used to calculate the average luminance of the final image for HDR
  56105. */
  56106. luminancePostProcess: Nullable<PostProcess>;
  56107. /**
  56108. * Post-processes used to create down sample post-processes in order to get
  56109. * the average luminance of the final image for HDR
  56110. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  56111. */
  56112. luminanceDownSamplePostProcesses: PostProcess[];
  56113. /**
  56114. * Post-process used to create a HDR effect (light adaptation)
  56115. */
  56116. hdrPostProcess: Nullable<PostProcess>;
  56117. /**
  56118. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  56119. */
  56120. textureAdderFinalPostProcess: Nullable<PostProcess>;
  56121. /**
  56122. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  56123. */
  56124. lensFlareFinalPostProcess: Nullable<PostProcess>;
  56125. /**
  56126. * Post-process used to merge the final HDR post-process and the real scene color
  56127. */
  56128. hdrFinalPostProcess: Nullable<PostProcess>;
  56129. /**
  56130. * Post-process used to create a lens flare effect
  56131. */
  56132. lensFlarePostProcess: Nullable<PostProcess>;
  56133. /**
  56134. * Post-process that merges the result of the lens flare post-process and the real scene color
  56135. */
  56136. lensFlareComposePostProcess: Nullable<PostProcess>;
  56137. /**
  56138. * Post-process used to create a motion blur effect
  56139. */
  56140. motionBlurPostProcess: Nullable<PostProcess>;
  56141. /**
  56142. * Post-process used to create a depth of field effect
  56143. */
  56144. depthOfFieldPostProcess: Nullable<PostProcess>;
  56145. /**
  56146. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  56147. */
  56148. fxaaPostProcess: Nullable<FxaaPostProcess>;
  56149. /**
  56150. * Represents the brightness threshold in order to configure the illuminated surfaces
  56151. */
  56152. brightThreshold: number;
  56153. /**
  56154. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  56155. */
  56156. blurWidth: number;
  56157. /**
  56158. * Sets if the blur for highlighted surfaces must be only horizontal
  56159. */
  56160. horizontalBlur: boolean;
  56161. /**
  56162. * Gets the overall exposure used by the pipeline
  56163. */
  56164. /**
  56165. * Sets the overall exposure used by the pipeline
  56166. */
  56167. exposure: number;
  56168. /**
  56169. * Texture used typically to simulate "dirty" on camera lens
  56170. */
  56171. lensTexture: Nullable<Texture>;
  56172. /**
  56173. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  56174. */
  56175. volumetricLightCoefficient: number;
  56176. /**
  56177. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  56178. */
  56179. volumetricLightPower: number;
  56180. /**
  56181. * Used the set the blur intensity to smooth the volumetric lights
  56182. */
  56183. volumetricLightBlurScale: number;
  56184. /**
  56185. * Light (spot or directional) used to generate the volumetric lights rays
  56186. * The source light must have a shadow generate so the pipeline can get its
  56187. * depth map
  56188. */
  56189. sourceLight: Nullable<SpotLight | DirectionalLight>;
  56190. /**
  56191. * For eye adaptation, represents the minimum luminance the eye can see
  56192. */
  56193. hdrMinimumLuminance: number;
  56194. /**
  56195. * For eye adaptation, represents the decrease luminance speed
  56196. */
  56197. hdrDecreaseRate: number;
  56198. /**
  56199. * For eye adaptation, represents the increase luminance speed
  56200. */
  56201. hdrIncreaseRate: number;
  56202. /**
  56203. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  56204. */
  56205. /**
  56206. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  56207. */
  56208. hdrAutoExposure: boolean;
  56209. /**
  56210. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  56211. */
  56212. lensColorTexture: Nullable<Texture>;
  56213. /**
  56214. * The overall strengh for the lens flare effect
  56215. */
  56216. lensFlareStrength: number;
  56217. /**
  56218. * Dispersion coefficient for lens flare ghosts
  56219. */
  56220. lensFlareGhostDispersal: number;
  56221. /**
  56222. * Main lens flare halo width
  56223. */
  56224. lensFlareHaloWidth: number;
  56225. /**
  56226. * Based on the lens distortion effect, defines how much the lens flare result
  56227. * is distorted
  56228. */
  56229. lensFlareDistortionStrength: number;
  56230. /**
  56231. * Lens star texture must be used to simulate rays on the flares and is available
  56232. * in the documentation
  56233. */
  56234. lensStarTexture: Nullable<Texture>;
  56235. /**
  56236. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  56237. * flare effect by taking account of the dirt texture
  56238. */
  56239. lensFlareDirtTexture: Nullable<Texture>;
  56240. /**
  56241. * Represents the focal length for the depth of field effect
  56242. */
  56243. depthOfFieldDistance: number;
  56244. /**
  56245. * Represents the blur intensity for the blurred part of the depth of field effect
  56246. */
  56247. depthOfFieldBlurWidth: number;
  56248. /**
  56249. * Gets how much the image is blurred by the movement while using the motion blur post-process
  56250. */
  56251. /**
  56252. * Sets how much the image is blurred by the movement while using the motion blur post-process
  56253. */
  56254. motionStrength: number;
  56255. /**
  56256. * Gets wether or not the motion blur post-process is object based or screen based.
  56257. */
  56258. /**
  56259. * Sets wether or not the motion blur post-process should be object based or screen based
  56260. */
  56261. objectBasedMotionBlur: boolean;
  56262. /**
  56263. * List of animations for the pipeline (IAnimatable implementation)
  56264. */
  56265. animations: Animation[];
  56266. /**
  56267. * Private members
  56268. */
  56269. private _scene;
  56270. private _currentDepthOfFieldSource;
  56271. private _basePostProcess;
  56272. private _fixedExposure;
  56273. private _currentExposure;
  56274. private _hdrAutoExposure;
  56275. private _hdrCurrentLuminance;
  56276. private _motionStrength;
  56277. private _isObjectBasedMotionBlur;
  56278. private _floatTextureType;
  56279. private _ratio;
  56280. private _bloomEnabled;
  56281. private _depthOfFieldEnabled;
  56282. private _vlsEnabled;
  56283. private _lensFlareEnabled;
  56284. private _hdrEnabled;
  56285. private _motionBlurEnabled;
  56286. private _fxaaEnabled;
  56287. private _motionBlurSamples;
  56288. private _volumetricLightStepsCount;
  56289. private _samples;
  56290. /**
  56291. * @ignore
  56292. * Specifies if the bloom pipeline is enabled
  56293. */
  56294. BloomEnabled: boolean;
  56295. /**
  56296. * @ignore
  56297. * Specifies if the depth of field pipeline is enabed
  56298. */
  56299. DepthOfFieldEnabled: boolean;
  56300. /**
  56301. * @ignore
  56302. * Specifies if the lens flare pipeline is enabed
  56303. */
  56304. LensFlareEnabled: boolean;
  56305. /**
  56306. * @ignore
  56307. * Specifies if the HDR pipeline is enabled
  56308. */
  56309. HDREnabled: boolean;
  56310. /**
  56311. * @ignore
  56312. * Specifies if the volumetric lights scattering effect is enabled
  56313. */
  56314. VLSEnabled: boolean;
  56315. /**
  56316. * @ignore
  56317. * Specifies if the motion blur effect is enabled
  56318. */
  56319. MotionBlurEnabled: boolean;
  56320. /**
  56321. * Specifies if anti-aliasing is enabled
  56322. */
  56323. fxaaEnabled: boolean;
  56324. /**
  56325. * Specifies the number of steps used to calculate the volumetric lights
  56326. * Typically in interval [50, 200]
  56327. */
  56328. volumetricLightStepsCount: number;
  56329. /**
  56330. * Specifies the number of samples used for the motion blur effect
  56331. * Typically in interval [16, 64]
  56332. */
  56333. motionBlurSamples: number;
  56334. /**
  56335. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  56336. */
  56337. samples: number;
  56338. /**
  56339. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  56340. * @constructor
  56341. * @param name The rendering pipeline name
  56342. * @param scene The scene linked to this pipeline
  56343. * @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)
  56344. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  56345. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56346. */
  56347. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  56348. private _buildPipeline;
  56349. private _createDownSampleX4PostProcess;
  56350. private _createBrightPassPostProcess;
  56351. private _createBlurPostProcesses;
  56352. private _createTextureAdderPostProcess;
  56353. private _createVolumetricLightPostProcess;
  56354. private _createLuminancePostProcesses;
  56355. private _createHdrPostProcess;
  56356. private _createLensFlarePostProcess;
  56357. private _createDepthOfFieldPostProcess;
  56358. private _createMotionBlurPostProcess;
  56359. private _getDepthTexture;
  56360. private _disposePostProcesses;
  56361. /**
  56362. * Dispose of the pipeline and stop all post processes
  56363. */
  56364. dispose(): void;
  56365. /**
  56366. * Serialize the rendering pipeline (Used when exporting)
  56367. * @returns the serialized object
  56368. */
  56369. serialize(): any;
  56370. /**
  56371. * Parse the serialized pipeline
  56372. * @param source Source pipeline.
  56373. * @param scene The scene to load the pipeline to.
  56374. * @param rootUrl The URL of the serialized pipeline.
  56375. * @returns An instantiated pipeline from the serialized object.
  56376. */
  56377. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  56378. /**
  56379. * Luminance steps
  56380. */
  56381. static LuminanceSteps: number;
  56382. }
  56383. }
  56384. declare module BABYLON {
  56385. /** @hidden */
  56386. export var tonemapPixelShader: {
  56387. name: string;
  56388. shader: string;
  56389. };
  56390. }
  56391. declare module BABYLON {
  56392. /** Defines operator used for tonemapping */
  56393. export enum TonemappingOperator {
  56394. /** Hable */
  56395. Hable = 0,
  56396. /** Reinhard */
  56397. Reinhard = 1,
  56398. /** HejiDawson */
  56399. HejiDawson = 2,
  56400. /** Photographic */
  56401. Photographic = 3
  56402. }
  56403. /**
  56404. * Defines a post process to apply tone mapping
  56405. */
  56406. export class TonemapPostProcess extends PostProcess {
  56407. private _operator;
  56408. /** Defines the required exposure adjustement */
  56409. exposureAdjustment: number;
  56410. /**
  56411. * Creates a new TonemapPostProcess
  56412. * @param name defines the name of the postprocess
  56413. * @param _operator defines the operator to use
  56414. * @param exposureAdjustment defines the required exposure adjustement
  56415. * @param camera defines the camera to use (can be null)
  56416. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  56417. * @param engine defines the hosting engine (can be ignore if camera is set)
  56418. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  56419. */
  56420. constructor(name: string, _operator: TonemappingOperator,
  56421. /** Defines the required exposure adjustement */
  56422. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  56423. }
  56424. }
  56425. declare module BABYLON {
  56426. /** @hidden */
  56427. export var depthVertexShader: {
  56428. name: string;
  56429. shader: string;
  56430. };
  56431. }
  56432. declare module BABYLON {
  56433. /** @hidden */
  56434. export var volumetricLightScatteringPixelShader: {
  56435. name: string;
  56436. shader: string;
  56437. };
  56438. }
  56439. declare module BABYLON {
  56440. /** @hidden */
  56441. export var volumetricLightScatteringPassPixelShader: {
  56442. name: string;
  56443. shader: string;
  56444. };
  56445. }
  56446. declare module BABYLON {
  56447. /**
  56448. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  56449. */
  56450. export class VolumetricLightScatteringPostProcess extends PostProcess {
  56451. private _volumetricLightScatteringPass;
  56452. private _volumetricLightScatteringRTT;
  56453. private _viewPort;
  56454. private _screenCoordinates;
  56455. private _cachedDefines;
  56456. /**
  56457. * If not undefined, the mesh position is computed from the attached node position
  56458. */
  56459. attachedNode: {
  56460. position: Vector3;
  56461. };
  56462. /**
  56463. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  56464. */
  56465. customMeshPosition: Vector3;
  56466. /**
  56467. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  56468. */
  56469. useCustomMeshPosition: boolean;
  56470. /**
  56471. * If the post-process should inverse the light scattering direction
  56472. */
  56473. invert: boolean;
  56474. /**
  56475. * The internal mesh used by the post-process
  56476. */
  56477. mesh: Mesh;
  56478. /**
  56479. * @hidden
  56480. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  56481. */
  56482. useDiffuseColor: boolean;
  56483. /**
  56484. * Array containing the excluded meshes not rendered in the internal pass
  56485. */
  56486. excludedMeshes: AbstractMesh[];
  56487. /**
  56488. * Controls the overall intensity of the post-process
  56489. */
  56490. exposure: number;
  56491. /**
  56492. * Dissipates each sample's contribution in range [0, 1]
  56493. */
  56494. decay: number;
  56495. /**
  56496. * Controls the overall intensity of each sample
  56497. */
  56498. weight: number;
  56499. /**
  56500. * Controls the density of each sample
  56501. */
  56502. density: number;
  56503. /**
  56504. * @constructor
  56505. * @param name The post-process name
  56506. * @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)
  56507. * @param camera The camera that the post-process will be attached to
  56508. * @param mesh The mesh used to create the light scattering
  56509. * @param samples The post-process quality, default 100
  56510. * @param samplingModeThe post-process filtering mode
  56511. * @param engine The babylon engine
  56512. * @param reusable If the post-process is reusable
  56513. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  56514. */
  56515. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  56516. /**
  56517. * Returns the string "VolumetricLightScatteringPostProcess"
  56518. * @returns "VolumetricLightScatteringPostProcess"
  56519. */
  56520. getClassName(): string;
  56521. private _isReady;
  56522. /**
  56523. * Sets the new light position for light scattering effect
  56524. * @param position The new custom light position
  56525. */
  56526. setCustomMeshPosition(position: Vector3): void;
  56527. /**
  56528. * Returns the light position for light scattering effect
  56529. * @return Vector3 The custom light position
  56530. */
  56531. getCustomMeshPosition(): Vector3;
  56532. /**
  56533. * Disposes the internal assets and detaches the post-process from the camera
  56534. */
  56535. dispose(camera: Camera): void;
  56536. /**
  56537. * Returns the render target texture used by the post-process
  56538. * @return the render target texture used by the post-process
  56539. */
  56540. getPass(): RenderTargetTexture;
  56541. private _meshExcluded;
  56542. private _createPass;
  56543. private _updateMeshScreenCoordinates;
  56544. /**
  56545. * Creates a default mesh for the Volumeric Light Scattering post-process
  56546. * @param name The mesh name
  56547. * @param scene The scene where to create the mesh
  56548. * @return the default mesh
  56549. */
  56550. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  56551. }
  56552. }
  56553. declare module BABYLON {
  56554. interface Scene {
  56555. /** @hidden (Backing field) */
  56556. _boundingBoxRenderer: BoundingBoxRenderer;
  56557. /** @hidden (Backing field) */
  56558. _forceShowBoundingBoxes: boolean;
  56559. /**
  56560. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  56561. */
  56562. forceShowBoundingBoxes: boolean;
  56563. /**
  56564. * Gets the bounding box renderer associated with the scene
  56565. * @returns a BoundingBoxRenderer
  56566. */
  56567. getBoundingBoxRenderer(): BoundingBoxRenderer;
  56568. }
  56569. interface AbstractMesh {
  56570. /** @hidden (Backing field) */
  56571. _showBoundingBox: boolean;
  56572. /**
  56573. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  56574. */
  56575. showBoundingBox: boolean;
  56576. }
  56577. /**
  56578. * Component responsible of rendering the bounding box of the meshes in a scene.
  56579. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  56580. */
  56581. export class BoundingBoxRenderer implements ISceneComponent {
  56582. /**
  56583. * The component name helpfull to identify the component in the list of scene components.
  56584. */
  56585. readonly name: string;
  56586. /**
  56587. * The scene the component belongs to.
  56588. */
  56589. scene: Scene;
  56590. /**
  56591. * Color of the bounding box lines placed in front of an object
  56592. */
  56593. frontColor: Color3;
  56594. /**
  56595. * Color of the bounding box lines placed behind an object
  56596. */
  56597. backColor: Color3;
  56598. /**
  56599. * Defines if the renderer should show the back lines or not
  56600. */
  56601. showBackLines: boolean;
  56602. /**
  56603. * @hidden
  56604. */
  56605. renderList: SmartArray<BoundingBox>;
  56606. private _colorShader;
  56607. private _vertexBuffers;
  56608. private _indexBuffer;
  56609. /**
  56610. * Instantiates a new bounding box renderer in a scene.
  56611. * @param scene the scene the renderer renders in
  56612. */
  56613. constructor(scene: Scene);
  56614. /**
  56615. * Registers the component in a given scene
  56616. */
  56617. register(): void;
  56618. private _evaluateSubMesh;
  56619. private _activeMesh;
  56620. private _prepareRessources;
  56621. private _createIndexBuffer;
  56622. /**
  56623. * Rebuilds the elements related to this component in case of
  56624. * context lost for instance.
  56625. */
  56626. rebuild(): void;
  56627. /**
  56628. * @hidden
  56629. */
  56630. reset(): void;
  56631. /**
  56632. * Render the bounding boxes of a specific rendering group
  56633. * @param renderingGroupId defines the rendering group to render
  56634. */
  56635. render(renderingGroupId: number): void;
  56636. /**
  56637. * In case of occlusion queries, we can render the occlusion bounding box through this method
  56638. * @param mesh Define the mesh to render the occlusion bounding box for
  56639. */
  56640. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  56641. /**
  56642. * Dispose and release the resources attached to this renderer.
  56643. */
  56644. dispose(): void;
  56645. }
  56646. }
  56647. declare module BABYLON {
  56648. /** @hidden */
  56649. export var depthPixelShader: {
  56650. name: string;
  56651. shader: string;
  56652. };
  56653. }
  56654. declare module BABYLON {
  56655. /**
  56656. * This represents a depth renderer in Babylon.
  56657. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  56658. */
  56659. export class DepthRenderer {
  56660. private _scene;
  56661. private _depthMap;
  56662. private _effect;
  56663. private _cachedDefines;
  56664. private _camera;
  56665. /**
  56666. * Specifiess that the depth renderer will only be used within
  56667. * the camera it is created for.
  56668. * This can help forcing its rendering during the camera processing.
  56669. */
  56670. useOnlyInActiveCamera: boolean;
  56671. /** @hidden */
  56672. static _SceneComponentInitialization: (scene: Scene) => void;
  56673. /**
  56674. * Instantiates a depth renderer
  56675. * @param scene The scene the renderer belongs to
  56676. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  56677. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  56678. */
  56679. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  56680. /**
  56681. * Creates the depth rendering effect and checks if the effect is ready.
  56682. * @param subMesh The submesh to be used to render the depth map of
  56683. * @param useInstances If multiple world instances should be used
  56684. * @returns if the depth renderer is ready to render the depth map
  56685. */
  56686. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56687. /**
  56688. * Gets the texture which the depth map will be written to.
  56689. * @returns The depth map texture
  56690. */
  56691. getDepthMap(): RenderTargetTexture;
  56692. /**
  56693. * Disposes of the depth renderer.
  56694. */
  56695. dispose(): void;
  56696. }
  56697. }
  56698. declare module BABYLON {
  56699. interface Scene {
  56700. /** @hidden (Backing field) */
  56701. _depthRenderer: {
  56702. [id: string]: DepthRenderer;
  56703. };
  56704. /**
  56705. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  56706. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  56707. * @returns the created depth renderer
  56708. */
  56709. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  56710. /**
  56711. * Disables a depth renderer for a given camera
  56712. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  56713. */
  56714. disableDepthRenderer(camera?: Nullable<Camera>): void;
  56715. }
  56716. /**
  56717. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  56718. * in several rendering techniques.
  56719. */
  56720. export class DepthRendererSceneComponent implements ISceneComponent {
  56721. /**
  56722. * The component name helpfull to identify the component in the list of scene components.
  56723. */
  56724. readonly name: string;
  56725. /**
  56726. * The scene the component belongs to.
  56727. */
  56728. scene: Scene;
  56729. /**
  56730. * Creates a new instance of the component for the given scene
  56731. * @param scene Defines the scene to register the component in
  56732. */
  56733. constructor(scene: Scene);
  56734. /**
  56735. * Registers the component in a given scene
  56736. */
  56737. register(): void;
  56738. /**
  56739. * Rebuilds the elements related to this component in case of
  56740. * context lost for instance.
  56741. */
  56742. rebuild(): void;
  56743. /**
  56744. * Disposes the component and the associated ressources
  56745. */
  56746. dispose(): void;
  56747. private _gatherRenderTargets;
  56748. private _gatherActiveCameraRenderTargets;
  56749. }
  56750. }
  56751. declare module BABYLON {
  56752. /** @hidden */
  56753. export var outlinePixelShader: {
  56754. name: string;
  56755. shader: string;
  56756. };
  56757. }
  56758. declare module BABYLON {
  56759. /** @hidden */
  56760. export var outlineVertexShader: {
  56761. name: string;
  56762. shader: string;
  56763. };
  56764. }
  56765. declare module BABYLON {
  56766. interface Scene {
  56767. /** @hidden */
  56768. _outlineRenderer: OutlineRenderer;
  56769. /**
  56770. * Gets the outline renderer associated with the scene
  56771. * @returns a OutlineRenderer
  56772. */
  56773. getOutlineRenderer(): OutlineRenderer;
  56774. }
  56775. interface AbstractMesh {
  56776. /** @hidden (Backing field) */
  56777. _renderOutline: boolean;
  56778. /**
  56779. * Gets or sets a boolean indicating if the outline must be rendered as well
  56780. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  56781. */
  56782. renderOutline: boolean;
  56783. /** @hidden (Backing field) */
  56784. _renderOverlay: boolean;
  56785. /**
  56786. * Gets or sets a boolean indicating if the overlay must be rendered as well
  56787. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  56788. */
  56789. renderOverlay: boolean;
  56790. }
  56791. /**
  56792. * This class is responsible to draw bothe outline/overlay of meshes.
  56793. * It should not be used directly but through the available method on mesh.
  56794. */
  56795. export class OutlineRenderer implements ISceneComponent {
  56796. /**
  56797. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  56798. */
  56799. private static _StencilReference;
  56800. /**
  56801. * The name of the component. Each component must have a unique name.
  56802. */
  56803. name: string;
  56804. /**
  56805. * The scene the component belongs to.
  56806. */
  56807. scene: Scene;
  56808. /**
  56809. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  56810. */
  56811. zOffset: number;
  56812. private _engine;
  56813. private _effect;
  56814. private _cachedDefines;
  56815. private _savedDepthWrite;
  56816. /**
  56817. * Instantiates a new outline renderer. (There could be only one per scene).
  56818. * @param scene Defines the scene it belongs to
  56819. */
  56820. constructor(scene: Scene);
  56821. /**
  56822. * Register the component to one instance of a scene.
  56823. */
  56824. register(): void;
  56825. /**
  56826. * Rebuilds the elements related to this component in case of
  56827. * context lost for instance.
  56828. */
  56829. rebuild(): void;
  56830. /**
  56831. * Disposes the component and the associated ressources.
  56832. */
  56833. dispose(): void;
  56834. /**
  56835. * Renders the outline in the canvas.
  56836. * @param subMesh Defines the sumesh to render
  56837. * @param batch Defines the batch of meshes in case of instances
  56838. * @param useOverlay Defines if the rendering is for the overlay or the outline
  56839. */
  56840. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  56841. /**
  56842. * Returns whether or not the outline renderer is ready for a given submesh.
  56843. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  56844. * @param subMesh Defines the submesh to check readyness for
  56845. * @param useInstances Defines wheter wee are trying to render instances or not
  56846. * @returns true if ready otherwise false
  56847. */
  56848. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56849. private _beforeRenderingMesh;
  56850. private _afterRenderingMesh;
  56851. }
  56852. }
  56853. declare module BABYLON {
  56854. /**
  56855. * Defines the list of states available for a task inside a AssetsManager
  56856. */
  56857. export enum AssetTaskState {
  56858. /**
  56859. * Initialization
  56860. */
  56861. INIT = 0,
  56862. /**
  56863. * Running
  56864. */
  56865. RUNNING = 1,
  56866. /**
  56867. * Done
  56868. */
  56869. DONE = 2,
  56870. /**
  56871. * Error
  56872. */
  56873. ERROR = 3
  56874. }
  56875. /**
  56876. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  56877. */
  56878. export abstract class AbstractAssetTask {
  56879. /**
  56880. * Task name
  56881. */ name: string;
  56882. /**
  56883. * Callback called when the task is successful
  56884. */
  56885. onSuccess: (task: any) => void;
  56886. /**
  56887. * Callback called when the task is not successful
  56888. */
  56889. onError: (task: any, message?: string, exception?: any) => void;
  56890. /**
  56891. * Creates a new AssetsManager
  56892. * @param name defines the name of the task
  56893. */
  56894. constructor(
  56895. /**
  56896. * Task name
  56897. */ name: string);
  56898. private _isCompleted;
  56899. private _taskState;
  56900. private _errorObject;
  56901. /**
  56902. * Get if the task is completed
  56903. */
  56904. readonly isCompleted: boolean;
  56905. /**
  56906. * Gets the current state of the task
  56907. */
  56908. readonly taskState: AssetTaskState;
  56909. /**
  56910. * Gets the current error object (if task is in error)
  56911. */
  56912. readonly errorObject: {
  56913. message?: string;
  56914. exception?: any;
  56915. };
  56916. /**
  56917. * Internal only
  56918. * @hidden
  56919. */
  56920. _setErrorObject(message?: string, exception?: any): void;
  56921. /**
  56922. * Execute the current task
  56923. * @param scene defines the scene where you want your assets to be loaded
  56924. * @param onSuccess is a callback called when the task is successfully executed
  56925. * @param onError is a callback called if an error occurs
  56926. */
  56927. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56928. /**
  56929. * Execute the current task
  56930. * @param scene defines the scene where you want your assets to be loaded
  56931. * @param onSuccess is a callback called when the task is successfully executed
  56932. * @param onError is a callback called if an error occurs
  56933. */
  56934. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56935. /**
  56936. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  56937. * This can be used with failed tasks that have the reason for failure fixed.
  56938. */
  56939. reset(): void;
  56940. private onErrorCallback;
  56941. private onDoneCallback;
  56942. }
  56943. /**
  56944. * Define the interface used by progress events raised during assets loading
  56945. */
  56946. export interface IAssetsProgressEvent {
  56947. /**
  56948. * Defines the number of remaining tasks to process
  56949. */
  56950. remainingCount: number;
  56951. /**
  56952. * Defines the total number of tasks
  56953. */
  56954. totalCount: number;
  56955. /**
  56956. * Defines the task that was just processed
  56957. */
  56958. task: AbstractAssetTask;
  56959. }
  56960. /**
  56961. * Class used to share progress information about assets loading
  56962. */
  56963. export class AssetsProgressEvent implements IAssetsProgressEvent {
  56964. /**
  56965. * Defines the number of remaining tasks to process
  56966. */
  56967. remainingCount: number;
  56968. /**
  56969. * Defines the total number of tasks
  56970. */
  56971. totalCount: number;
  56972. /**
  56973. * Defines the task that was just processed
  56974. */
  56975. task: AbstractAssetTask;
  56976. /**
  56977. * Creates a AssetsProgressEvent
  56978. * @param remainingCount defines the number of remaining tasks to process
  56979. * @param totalCount defines the total number of tasks
  56980. * @param task defines the task that was just processed
  56981. */
  56982. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  56983. }
  56984. /**
  56985. * Define a task used by AssetsManager to load meshes
  56986. */
  56987. export class MeshAssetTask extends AbstractAssetTask {
  56988. /**
  56989. * Defines the name of the task
  56990. */
  56991. name: string;
  56992. /**
  56993. * Defines the list of mesh's names you want to load
  56994. */
  56995. meshesNames: any;
  56996. /**
  56997. * Defines the root url to use as a base to load your meshes and associated resources
  56998. */
  56999. rootUrl: string;
  57000. /**
  57001. * Defines the filename of the scene to load from
  57002. */
  57003. sceneFilename: string;
  57004. /**
  57005. * Gets the list of loaded meshes
  57006. */
  57007. loadedMeshes: Array<AbstractMesh>;
  57008. /**
  57009. * Gets the list of loaded particle systems
  57010. */
  57011. loadedParticleSystems: Array<IParticleSystem>;
  57012. /**
  57013. * Gets the list of loaded skeletons
  57014. */
  57015. loadedSkeletons: Array<Skeleton>;
  57016. /**
  57017. * Gets the list of loaded animation groups
  57018. */
  57019. loadedAnimationGroups: Array<AnimationGroup>;
  57020. /**
  57021. * Callback called when the task is successful
  57022. */
  57023. onSuccess: (task: MeshAssetTask) => void;
  57024. /**
  57025. * Callback called when the task is successful
  57026. */
  57027. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  57028. /**
  57029. * Creates a new MeshAssetTask
  57030. * @param name defines the name of the task
  57031. * @param meshesNames defines the list of mesh's names you want to load
  57032. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  57033. * @param sceneFilename defines the filename of the scene to load from
  57034. */
  57035. constructor(
  57036. /**
  57037. * Defines the name of the task
  57038. */
  57039. name: string,
  57040. /**
  57041. * Defines the list of mesh's names you want to load
  57042. */
  57043. meshesNames: any,
  57044. /**
  57045. * Defines the root url to use as a base to load your meshes and associated resources
  57046. */
  57047. rootUrl: string,
  57048. /**
  57049. * Defines the filename of the scene to load from
  57050. */
  57051. sceneFilename: string);
  57052. /**
  57053. * Execute the current task
  57054. * @param scene defines the scene where you want your assets to be loaded
  57055. * @param onSuccess is a callback called when the task is successfully executed
  57056. * @param onError is a callback called if an error occurs
  57057. */
  57058. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57059. }
  57060. /**
  57061. * Define a task used by AssetsManager to load text content
  57062. */
  57063. export class TextFileAssetTask extends AbstractAssetTask {
  57064. /**
  57065. * Defines the name of the task
  57066. */
  57067. name: string;
  57068. /**
  57069. * Defines the location of the file to load
  57070. */
  57071. url: string;
  57072. /**
  57073. * Gets the loaded text string
  57074. */
  57075. text: string;
  57076. /**
  57077. * Callback called when the task is successful
  57078. */
  57079. onSuccess: (task: TextFileAssetTask) => void;
  57080. /**
  57081. * Callback called when the task is successful
  57082. */
  57083. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  57084. /**
  57085. * Creates a new TextFileAssetTask object
  57086. * @param name defines the name of the task
  57087. * @param url defines the location of the file to load
  57088. */
  57089. constructor(
  57090. /**
  57091. * Defines the name of the task
  57092. */
  57093. name: string,
  57094. /**
  57095. * Defines the location of the file to load
  57096. */
  57097. url: string);
  57098. /**
  57099. * Execute the current task
  57100. * @param scene defines the scene where you want your assets to be loaded
  57101. * @param onSuccess is a callback called when the task is successfully executed
  57102. * @param onError is a callback called if an error occurs
  57103. */
  57104. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57105. }
  57106. /**
  57107. * Define a task used by AssetsManager to load binary data
  57108. */
  57109. export class BinaryFileAssetTask extends AbstractAssetTask {
  57110. /**
  57111. * Defines the name of the task
  57112. */
  57113. name: string;
  57114. /**
  57115. * Defines the location of the file to load
  57116. */
  57117. url: string;
  57118. /**
  57119. * Gets the lodaded data (as an array buffer)
  57120. */
  57121. data: ArrayBuffer;
  57122. /**
  57123. * Callback called when the task is successful
  57124. */
  57125. onSuccess: (task: BinaryFileAssetTask) => void;
  57126. /**
  57127. * Callback called when the task is successful
  57128. */
  57129. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  57130. /**
  57131. * Creates a new BinaryFileAssetTask object
  57132. * @param name defines the name of the new task
  57133. * @param url defines the location of the file to load
  57134. */
  57135. constructor(
  57136. /**
  57137. * Defines the name of the task
  57138. */
  57139. name: string,
  57140. /**
  57141. * Defines the location of the file to load
  57142. */
  57143. url: string);
  57144. /**
  57145. * Execute the current task
  57146. * @param scene defines the scene where you want your assets to be loaded
  57147. * @param onSuccess is a callback called when the task is successfully executed
  57148. * @param onError is a callback called if an error occurs
  57149. */
  57150. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57151. }
  57152. /**
  57153. * Define a task used by AssetsManager to load images
  57154. */
  57155. export class ImageAssetTask extends AbstractAssetTask {
  57156. /**
  57157. * Defines the name of the task
  57158. */
  57159. name: string;
  57160. /**
  57161. * Defines the location of the image to load
  57162. */
  57163. url: string;
  57164. /**
  57165. * Gets the loaded images
  57166. */
  57167. image: HTMLImageElement;
  57168. /**
  57169. * Callback called when the task is successful
  57170. */
  57171. onSuccess: (task: ImageAssetTask) => void;
  57172. /**
  57173. * Callback called when the task is successful
  57174. */
  57175. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  57176. /**
  57177. * Creates a new ImageAssetTask
  57178. * @param name defines the name of the task
  57179. * @param url defines the location of the image to load
  57180. */
  57181. constructor(
  57182. /**
  57183. * Defines the name of the task
  57184. */
  57185. name: string,
  57186. /**
  57187. * Defines the location of the image to load
  57188. */
  57189. url: string);
  57190. /**
  57191. * Execute the current task
  57192. * @param scene defines the scene where you want your assets to be loaded
  57193. * @param onSuccess is a callback called when the task is successfully executed
  57194. * @param onError is a callback called if an error occurs
  57195. */
  57196. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57197. }
  57198. /**
  57199. * Defines the interface used by texture loading tasks
  57200. */
  57201. export interface ITextureAssetTask<TEX extends BaseTexture> {
  57202. /**
  57203. * Gets the loaded texture
  57204. */
  57205. texture: TEX;
  57206. }
  57207. /**
  57208. * Define a task used by AssetsManager to load 2D textures
  57209. */
  57210. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  57211. /**
  57212. * Defines the name of the task
  57213. */
  57214. name: string;
  57215. /**
  57216. * Defines the location of the file to load
  57217. */
  57218. url: string;
  57219. /**
  57220. * Defines if mipmap should not be generated (default is false)
  57221. */
  57222. noMipmap?: boolean | undefined;
  57223. /**
  57224. * Defines if texture must be inverted on Y axis (default is false)
  57225. */
  57226. invertY?: boolean | undefined;
  57227. /**
  57228. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  57229. */
  57230. samplingMode: number;
  57231. /**
  57232. * Gets the loaded texture
  57233. */
  57234. texture: Texture;
  57235. /**
  57236. * Callback called when the task is successful
  57237. */
  57238. onSuccess: (task: TextureAssetTask) => void;
  57239. /**
  57240. * Callback called when the task is successful
  57241. */
  57242. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  57243. /**
  57244. * Creates a new TextureAssetTask object
  57245. * @param name defines the name of the task
  57246. * @param url defines the location of the file to load
  57247. * @param noMipmap defines if mipmap should not be generated (default is false)
  57248. * @param invertY defines if texture must be inverted on Y axis (default is false)
  57249. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  57250. */
  57251. constructor(
  57252. /**
  57253. * Defines the name of the task
  57254. */
  57255. name: string,
  57256. /**
  57257. * Defines the location of the file to load
  57258. */
  57259. url: string,
  57260. /**
  57261. * Defines if mipmap should not be generated (default is false)
  57262. */
  57263. noMipmap?: boolean | undefined,
  57264. /**
  57265. * Defines if texture must be inverted on Y axis (default is false)
  57266. */
  57267. invertY?: boolean | undefined,
  57268. /**
  57269. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  57270. */
  57271. samplingMode?: number);
  57272. /**
  57273. * Execute the current task
  57274. * @param scene defines the scene where you want your assets to be loaded
  57275. * @param onSuccess is a callback called when the task is successfully executed
  57276. * @param onError is a callback called if an error occurs
  57277. */
  57278. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57279. }
  57280. /**
  57281. * Define a task used by AssetsManager to load cube textures
  57282. */
  57283. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  57284. /**
  57285. * Defines the name of the task
  57286. */
  57287. name: string;
  57288. /**
  57289. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  57290. */
  57291. url: string;
  57292. /**
  57293. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  57294. */
  57295. extensions?: string[] | undefined;
  57296. /**
  57297. * Defines if mipmaps should not be generated (default is false)
  57298. */
  57299. noMipmap?: boolean | undefined;
  57300. /**
  57301. * Defines the explicit list of files (undefined by default)
  57302. */
  57303. files?: string[] | undefined;
  57304. /**
  57305. * Gets the loaded texture
  57306. */
  57307. texture: CubeTexture;
  57308. /**
  57309. * Callback called when the task is successful
  57310. */
  57311. onSuccess: (task: CubeTextureAssetTask) => void;
  57312. /**
  57313. * Callback called when the task is successful
  57314. */
  57315. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  57316. /**
  57317. * Creates a new CubeTextureAssetTask
  57318. * @param name defines the name of the task
  57319. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  57320. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  57321. * @param noMipmap defines if mipmaps should not be generated (default is false)
  57322. * @param files defines the explicit list of files (undefined by default)
  57323. */
  57324. constructor(
  57325. /**
  57326. * Defines the name of the task
  57327. */
  57328. name: string,
  57329. /**
  57330. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  57331. */
  57332. url: string,
  57333. /**
  57334. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  57335. */
  57336. extensions?: string[] | undefined,
  57337. /**
  57338. * Defines if mipmaps should not be generated (default is false)
  57339. */
  57340. noMipmap?: boolean | undefined,
  57341. /**
  57342. * Defines the explicit list of files (undefined by default)
  57343. */
  57344. files?: string[] | undefined);
  57345. /**
  57346. * Execute the current task
  57347. * @param scene defines the scene where you want your assets to be loaded
  57348. * @param onSuccess is a callback called when the task is successfully executed
  57349. * @param onError is a callback called if an error occurs
  57350. */
  57351. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57352. }
  57353. /**
  57354. * Define a task used by AssetsManager to load HDR cube textures
  57355. */
  57356. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  57357. /**
  57358. * Defines the name of the task
  57359. */
  57360. name: string;
  57361. /**
  57362. * Defines the location of the file to load
  57363. */
  57364. url: string;
  57365. /**
  57366. * Defines the desired size (the more it increases the longer the generation will be)
  57367. */
  57368. size: number;
  57369. /**
  57370. * Defines if mipmaps should not be generated (default is false)
  57371. */
  57372. noMipmap: boolean;
  57373. /**
  57374. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  57375. */
  57376. generateHarmonics: boolean;
  57377. /**
  57378. * 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)
  57379. */
  57380. gammaSpace: boolean;
  57381. /**
  57382. * Internal Use Only
  57383. */
  57384. reserved: boolean;
  57385. /**
  57386. * Gets the loaded texture
  57387. */
  57388. texture: HDRCubeTexture;
  57389. /**
  57390. * Callback called when the task is successful
  57391. */
  57392. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  57393. /**
  57394. * Callback called when the task is successful
  57395. */
  57396. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  57397. /**
  57398. * Creates a new HDRCubeTextureAssetTask object
  57399. * @param name defines the name of the task
  57400. * @param url defines the location of the file to load
  57401. * @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.
  57402. * @param noMipmap defines if mipmaps should not be generated (default is false)
  57403. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  57404. * @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)
  57405. * @param reserved Internal use only
  57406. */
  57407. constructor(
  57408. /**
  57409. * Defines the name of the task
  57410. */
  57411. name: string,
  57412. /**
  57413. * Defines the location of the file to load
  57414. */
  57415. url: string,
  57416. /**
  57417. * Defines the desired size (the more it increases the longer the generation will be)
  57418. */
  57419. size: number,
  57420. /**
  57421. * Defines if mipmaps should not be generated (default is false)
  57422. */
  57423. noMipmap?: boolean,
  57424. /**
  57425. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  57426. */
  57427. generateHarmonics?: boolean,
  57428. /**
  57429. * 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)
  57430. */
  57431. gammaSpace?: boolean,
  57432. /**
  57433. * Internal Use Only
  57434. */
  57435. reserved?: boolean);
  57436. /**
  57437. * Execute the current task
  57438. * @param scene defines the scene where you want your assets to be loaded
  57439. * @param onSuccess is a callback called when the task is successfully executed
  57440. * @param onError is a callback called if an error occurs
  57441. */
  57442. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57443. }
  57444. /**
  57445. * Define a task used by AssetsManager to load Equirectangular cube textures
  57446. */
  57447. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  57448. /**
  57449. * Defines the name of the task
  57450. */
  57451. name: string;
  57452. /**
  57453. * Defines the location of the file to load
  57454. */
  57455. url: string;
  57456. /**
  57457. * Defines the desired size (the more it increases the longer the generation will be)
  57458. */
  57459. size: number;
  57460. /**
  57461. * Defines if mipmaps should not be generated (default is false)
  57462. */
  57463. noMipmap: boolean;
  57464. /**
  57465. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  57466. * but the standard material would require them in Gamma space) (default is true)
  57467. */
  57468. gammaSpace: boolean;
  57469. /**
  57470. * Gets the loaded texture
  57471. */
  57472. texture: EquiRectangularCubeTexture;
  57473. /**
  57474. * Callback called when the task is successful
  57475. */
  57476. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  57477. /**
  57478. * Callback called when the task is successful
  57479. */
  57480. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  57481. /**
  57482. * Creates a new EquiRectangularCubeTextureAssetTask object
  57483. * @param name defines the name of the task
  57484. * @param url defines the location of the file to load
  57485. * @param size defines the desired size (the more it increases the longer the generation will be)
  57486. * If the size is omitted this implies you are using a preprocessed cubemap.
  57487. * @param noMipmap defines if mipmaps should not be generated (default is false)
  57488. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  57489. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  57490. * (default is true)
  57491. */
  57492. constructor(
  57493. /**
  57494. * Defines the name of the task
  57495. */
  57496. name: string,
  57497. /**
  57498. * Defines the location of the file to load
  57499. */
  57500. url: string,
  57501. /**
  57502. * Defines the desired size (the more it increases the longer the generation will be)
  57503. */
  57504. size: number,
  57505. /**
  57506. * Defines if mipmaps should not be generated (default is false)
  57507. */
  57508. noMipmap?: boolean,
  57509. /**
  57510. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  57511. * but the standard material would require them in Gamma space) (default is true)
  57512. */
  57513. gammaSpace?: boolean);
  57514. /**
  57515. * Execute the current task
  57516. * @param scene defines the scene where you want your assets to be loaded
  57517. * @param onSuccess is a callback called when the task is successfully executed
  57518. * @param onError is a callback called if an error occurs
  57519. */
  57520. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57521. }
  57522. /**
  57523. * This class can be used to easily import assets into a scene
  57524. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  57525. */
  57526. export class AssetsManager {
  57527. private _scene;
  57528. private _isLoading;
  57529. protected _tasks: AbstractAssetTask[];
  57530. protected _waitingTasksCount: number;
  57531. protected _totalTasksCount: number;
  57532. /**
  57533. * Callback called when all tasks are processed
  57534. */
  57535. onFinish: (tasks: AbstractAssetTask[]) => void;
  57536. /**
  57537. * Callback called when a task is successful
  57538. */
  57539. onTaskSuccess: (task: AbstractAssetTask) => void;
  57540. /**
  57541. * Callback called when a task had an error
  57542. */
  57543. onTaskError: (task: AbstractAssetTask) => void;
  57544. /**
  57545. * Callback called when a task is done (whatever the result is)
  57546. */
  57547. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  57548. /**
  57549. * Observable called when all tasks are processed
  57550. */
  57551. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  57552. /**
  57553. * Observable called when a task had an error
  57554. */
  57555. onTaskErrorObservable: Observable<AbstractAssetTask>;
  57556. /**
  57557. * Observable called when all tasks were executed
  57558. */
  57559. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  57560. /**
  57561. * Observable called when a task is done (whatever the result is)
  57562. */
  57563. onProgressObservable: Observable<IAssetsProgressEvent>;
  57564. /**
  57565. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  57566. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  57567. */
  57568. useDefaultLoadingScreen: boolean;
  57569. /**
  57570. * Creates a new AssetsManager
  57571. * @param scene defines the scene to work on
  57572. */
  57573. constructor(scene: Scene);
  57574. /**
  57575. * Add a MeshAssetTask to the list of active tasks
  57576. * @param taskName defines the name of the new task
  57577. * @param meshesNames defines the name of meshes to load
  57578. * @param rootUrl defines the root url to use to locate files
  57579. * @param sceneFilename defines the filename of the scene file
  57580. * @returns a new MeshAssetTask object
  57581. */
  57582. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  57583. /**
  57584. * Add a TextFileAssetTask to the list of active tasks
  57585. * @param taskName defines the name of the new task
  57586. * @param url defines the url of the file to load
  57587. * @returns a new TextFileAssetTask object
  57588. */
  57589. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  57590. /**
  57591. * Add a BinaryFileAssetTask to the list of active tasks
  57592. * @param taskName defines the name of the new task
  57593. * @param url defines the url of the file to load
  57594. * @returns a new BinaryFileAssetTask object
  57595. */
  57596. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  57597. /**
  57598. * Add a ImageAssetTask to the list of active tasks
  57599. * @param taskName defines the name of the new task
  57600. * @param url defines the url of the file to load
  57601. * @returns a new ImageAssetTask object
  57602. */
  57603. addImageTask(taskName: string, url: string): ImageAssetTask;
  57604. /**
  57605. * Add a TextureAssetTask to the list of active tasks
  57606. * @param taskName defines the name of the new task
  57607. * @param url defines the url of the file to load
  57608. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57609. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  57610. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  57611. * @returns a new TextureAssetTask object
  57612. */
  57613. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  57614. /**
  57615. * Add a CubeTextureAssetTask to the list of active tasks
  57616. * @param taskName defines the name of the new task
  57617. * @param url defines the url of the file to load
  57618. * @param extensions defines the extension to use to load the cube map (can be null)
  57619. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57620. * @param files defines the list of files to load (can be null)
  57621. * @returns a new CubeTextureAssetTask object
  57622. */
  57623. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  57624. /**
  57625. *
  57626. * Add a HDRCubeTextureAssetTask to the list of active tasks
  57627. * @param taskName defines the name of the new task
  57628. * @param url defines the url of the file to load
  57629. * @param size defines the size you want for the cubemap (can be null)
  57630. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57631. * @param generateHarmonics defines if you want to automatically generate (true by default)
  57632. * @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)
  57633. * @param reserved Internal use only
  57634. * @returns a new HDRCubeTextureAssetTask object
  57635. */
  57636. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  57637. /**
  57638. *
  57639. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  57640. * @param taskName defines the name of the new task
  57641. * @param url defines the url of the file to load
  57642. * @param size defines the size you want for the cubemap (can be null)
  57643. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57644. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  57645. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  57646. * @returns a new EquiRectangularCubeTextureAssetTask object
  57647. */
  57648. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  57649. /**
  57650. * Remove a task from the assets manager.
  57651. * @param task the task to remove
  57652. */
  57653. removeTask(task: AbstractAssetTask): void;
  57654. private _decreaseWaitingTasksCount;
  57655. private _runTask;
  57656. /**
  57657. * Reset the AssetsManager and remove all tasks
  57658. * @return the current instance of the AssetsManager
  57659. */
  57660. reset(): AssetsManager;
  57661. /**
  57662. * Start the loading process
  57663. * @return the current instance of the AssetsManager
  57664. */
  57665. load(): AssetsManager;
  57666. /**
  57667. * Start the loading process as an async operation
  57668. * @return a promise returning the list of failed tasks
  57669. */
  57670. loadAsync(): Promise<void>;
  57671. }
  57672. }
  57673. declare module BABYLON {
  57674. /**
  57675. * Wrapper class for promise with external resolve and reject.
  57676. */
  57677. export class Deferred<T> {
  57678. /**
  57679. * The promise associated with this deferred object.
  57680. */
  57681. readonly promise: Promise<T>;
  57682. private _resolve;
  57683. private _reject;
  57684. /**
  57685. * The resolve method of the promise associated with this deferred object.
  57686. */
  57687. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  57688. /**
  57689. * The reject method of the promise associated with this deferred object.
  57690. */
  57691. readonly reject: (reason?: any) => void;
  57692. /**
  57693. * Constructor for this deferred object.
  57694. */
  57695. constructor();
  57696. }
  57697. }
  57698. declare module BABYLON {
  57699. /**
  57700. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  57701. */
  57702. export class MeshExploder {
  57703. private _centerMesh;
  57704. private _meshes;
  57705. private _meshesOrigins;
  57706. private _toCenterVectors;
  57707. private _scaledDirection;
  57708. private _newPosition;
  57709. private _centerPosition;
  57710. /**
  57711. * Explodes meshes from a center mesh.
  57712. * @param meshes The meshes to explode.
  57713. * @param centerMesh The mesh to be center of explosion.
  57714. */
  57715. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  57716. private _setCenterMesh;
  57717. /**
  57718. * Get class name
  57719. * @returns "MeshExploder"
  57720. */
  57721. getClassName(): string;
  57722. /**
  57723. * "Exploded meshes"
  57724. * @returns Array of meshes with the centerMesh at index 0.
  57725. */
  57726. getMeshes(): Array<Mesh>;
  57727. /**
  57728. * Explodes meshes giving a specific direction
  57729. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  57730. */
  57731. explode(direction?: number): void;
  57732. }
  57733. }
  57734. declare module BABYLON {
  57735. /**
  57736. * Class used to help managing file picking and drag'n'drop
  57737. */
  57738. export class FilesInput {
  57739. /**
  57740. * List of files ready to be loaded
  57741. */
  57742. static readonly FilesToLoad: {
  57743. [key: string]: File;
  57744. };
  57745. /**
  57746. * Callback called when a file is processed
  57747. */
  57748. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  57749. private _engine;
  57750. private _currentScene;
  57751. private _sceneLoadedCallback;
  57752. private _progressCallback;
  57753. private _additionalRenderLoopLogicCallback;
  57754. private _textureLoadingCallback;
  57755. private _startingProcessingFilesCallback;
  57756. private _onReloadCallback;
  57757. private _errorCallback;
  57758. private _elementToMonitor;
  57759. private _sceneFileToLoad;
  57760. private _filesToLoad;
  57761. /**
  57762. * Creates a new FilesInput
  57763. * @param engine defines the rendering engine
  57764. * @param scene defines the hosting scene
  57765. * @param sceneLoadedCallback callback called when scene is loaded
  57766. * @param progressCallback callback called to track progress
  57767. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  57768. * @param textureLoadingCallback callback called when a texture is loading
  57769. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  57770. * @param onReloadCallback callback called when a reload is requested
  57771. * @param errorCallback callback call if an error occurs
  57772. */
  57773. 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);
  57774. private _dragEnterHandler;
  57775. private _dragOverHandler;
  57776. private _dropHandler;
  57777. /**
  57778. * Calls this function to listen to drag'n'drop events on a specific DOM element
  57779. * @param elementToMonitor defines the DOM element to track
  57780. */
  57781. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  57782. /**
  57783. * Release all associated resources
  57784. */
  57785. dispose(): void;
  57786. private renderFunction;
  57787. private drag;
  57788. private drop;
  57789. private _traverseFolder;
  57790. private _processFiles;
  57791. /**
  57792. * Load files from a drop event
  57793. * @param event defines the drop event to use as source
  57794. */
  57795. loadFiles(event: any): void;
  57796. private _processReload;
  57797. /**
  57798. * Reload the current scene from the loaded files
  57799. */
  57800. reload(): void;
  57801. }
  57802. }
  57803. declare module BABYLON {
  57804. /**
  57805. * Defines the root class used to create scene optimization to use with SceneOptimizer
  57806. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57807. */
  57808. export class SceneOptimization {
  57809. /**
  57810. * Defines the priority of this optimization (0 by default which means first in the list)
  57811. */
  57812. priority: number;
  57813. /**
  57814. * Gets a string describing the action executed by the current optimization
  57815. * @returns description string
  57816. */
  57817. getDescription(): string;
  57818. /**
  57819. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57820. * @param scene defines the current scene where to apply this optimization
  57821. * @param optimizer defines the current optimizer
  57822. * @returns true if everything that can be done was applied
  57823. */
  57824. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57825. /**
  57826. * Creates the SceneOptimization object
  57827. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  57828. * @param desc defines the description associated with the optimization
  57829. */
  57830. constructor(
  57831. /**
  57832. * Defines the priority of this optimization (0 by default which means first in the list)
  57833. */
  57834. priority?: number);
  57835. }
  57836. /**
  57837. * Defines an optimization used to reduce the size of render target textures
  57838. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57839. */
  57840. export class TextureOptimization extends SceneOptimization {
  57841. /**
  57842. * Defines the priority of this optimization (0 by default which means first in the list)
  57843. */
  57844. priority: number;
  57845. /**
  57846. * 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
  57847. */
  57848. maximumSize: number;
  57849. /**
  57850. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  57851. */
  57852. step: number;
  57853. /**
  57854. * Gets a string describing the action executed by the current optimization
  57855. * @returns description string
  57856. */
  57857. getDescription(): string;
  57858. /**
  57859. * Creates the TextureOptimization object
  57860. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  57861. * @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
  57862. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  57863. */
  57864. constructor(
  57865. /**
  57866. * Defines the priority of this optimization (0 by default which means first in the list)
  57867. */
  57868. priority?: number,
  57869. /**
  57870. * 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
  57871. */
  57872. maximumSize?: number,
  57873. /**
  57874. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  57875. */
  57876. step?: number);
  57877. /**
  57878. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57879. * @param scene defines the current scene where to apply this optimization
  57880. * @param optimizer defines the current optimizer
  57881. * @returns true if everything that can be done was applied
  57882. */
  57883. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57884. }
  57885. /**
  57886. * Defines an optimization used to increase or decrease the rendering resolution
  57887. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57888. */
  57889. export class HardwareScalingOptimization extends SceneOptimization {
  57890. /**
  57891. * Defines the priority of this optimization (0 by default which means first in the list)
  57892. */
  57893. priority: number;
  57894. /**
  57895. * Defines the maximum scale to use (2 by default)
  57896. */
  57897. maximumScale: number;
  57898. /**
  57899. * Defines the step to use between two passes (0.5 by default)
  57900. */
  57901. step: number;
  57902. private _currentScale;
  57903. private _directionOffset;
  57904. /**
  57905. * Gets a string describing the action executed by the current optimization
  57906. * @return description string
  57907. */
  57908. getDescription(): string;
  57909. /**
  57910. * Creates the HardwareScalingOptimization object
  57911. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  57912. * @param maximumScale defines the maximum scale to use (2 by default)
  57913. * @param step defines the step to use between two passes (0.5 by default)
  57914. */
  57915. constructor(
  57916. /**
  57917. * Defines the priority of this optimization (0 by default which means first in the list)
  57918. */
  57919. priority?: number,
  57920. /**
  57921. * Defines the maximum scale to use (2 by default)
  57922. */
  57923. maximumScale?: number,
  57924. /**
  57925. * Defines the step to use between two passes (0.5 by default)
  57926. */
  57927. step?: number);
  57928. /**
  57929. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57930. * @param scene defines the current scene where to apply this optimization
  57931. * @param optimizer defines the current optimizer
  57932. * @returns true if everything that can be done was applied
  57933. */
  57934. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57935. }
  57936. /**
  57937. * Defines an optimization used to remove shadows
  57938. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57939. */
  57940. export class ShadowsOptimization extends SceneOptimization {
  57941. /**
  57942. * Gets a string describing the action executed by the current optimization
  57943. * @return description string
  57944. */
  57945. getDescription(): string;
  57946. /**
  57947. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57948. * @param scene defines the current scene where to apply this optimization
  57949. * @param optimizer defines the current optimizer
  57950. * @returns true if everything that can be done was applied
  57951. */
  57952. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57953. }
  57954. /**
  57955. * Defines an optimization used to turn post-processes off
  57956. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57957. */
  57958. export class PostProcessesOptimization extends SceneOptimization {
  57959. /**
  57960. * Gets a string describing the action executed by the current optimization
  57961. * @return description string
  57962. */
  57963. getDescription(): string;
  57964. /**
  57965. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57966. * @param scene defines the current scene where to apply this optimization
  57967. * @param optimizer defines the current optimizer
  57968. * @returns true if everything that can be done was applied
  57969. */
  57970. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57971. }
  57972. /**
  57973. * Defines an optimization used to turn lens flares off
  57974. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57975. */
  57976. export class LensFlaresOptimization extends SceneOptimization {
  57977. /**
  57978. * Gets a string describing the action executed by the current optimization
  57979. * @return description string
  57980. */
  57981. getDescription(): string;
  57982. /**
  57983. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57984. * @param scene defines the current scene where to apply this optimization
  57985. * @param optimizer defines the current optimizer
  57986. * @returns true if everything that can be done was applied
  57987. */
  57988. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57989. }
  57990. /**
  57991. * Defines an optimization based on user defined callback.
  57992. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57993. */
  57994. export class CustomOptimization extends SceneOptimization {
  57995. /**
  57996. * Callback called to apply the custom optimization.
  57997. */
  57998. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  57999. /**
  58000. * Callback called to get custom description
  58001. */
  58002. onGetDescription: () => string;
  58003. /**
  58004. * Gets a string describing the action executed by the current optimization
  58005. * @returns description string
  58006. */
  58007. getDescription(): string;
  58008. /**
  58009. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58010. * @param scene defines the current scene where to apply this optimization
  58011. * @param optimizer defines the current optimizer
  58012. * @returns true if everything that can be done was applied
  58013. */
  58014. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58015. }
  58016. /**
  58017. * Defines an optimization used to turn particles off
  58018. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58019. */
  58020. export class ParticlesOptimization extends SceneOptimization {
  58021. /**
  58022. * Gets a string describing the action executed by the current optimization
  58023. * @return description string
  58024. */
  58025. getDescription(): string;
  58026. /**
  58027. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58028. * @param scene defines the current scene where to apply this optimization
  58029. * @param optimizer defines the current optimizer
  58030. * @returns true if everything that can be done was applied
  58031. */
  58032. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58033. }
  58034. /**
  58035. * Defines an optimization used to turn render targets off
  58036. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58037. */
  58038. export class RenderTargetsOptimization extends SceneOptimization {
  58039. /**
  58040. * Gets a string describing the action executed by the current optimization
  58041. * @return description string
  58042. */
  58043. getDescription(): string;
  58044. /**
  58045. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58046. * @param scene defines the current scene where to apply this optimization
  58047. * @param optimizer defines the current optimizer
  58048. * @returns true if everything that can be done was applied
  58049. */
  58050. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58051. }
  58052. /**
  58053. * Defines an optimization used to merge meshes with compatible materials
  58054. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58055. */
  58056. export class MergeMeshesOptimization extends SceneOptimization {
  58057. private static _UpdateSelectionTree;
  58058. /**
  58059. * Gets or sets a boolean which defines if optimization octree has to be updated
  58060. */
  58061. /**
  58062. * Gets or sets a boolean which defines if optimization octree has to be updated
  58063. */
  58064. static UpdateSelectionTree: boolean;
  58065. /**
  58066. * Gets a string describing the action executed by the current optimization
  58067. * @return description string
  58068. */
  58069. getDescription(): string;
  58070. private _canBeMerged;
  58071. /**
  58072. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58073. * @param scene defines the current scene where to apply this optimization
  58074. * @param optimizer defines the current optimizer
  58075. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  58076. * @returns true if everything that can be done was applied
  58077. */
  58078. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  58079. }
  58080. /**
  58081. * Defines a list of options used by SceneOptimizer
  58082. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58083. */
  58084. export class SceneOptimizerOptions {
  58085. /**
  58086. * Defines the target frame rate to reach (60 by default)
  58087. */
  58088. targetFrameRate: number;
  58089. /**
  58090. * Defines the interval between two checkes (2000ms by default)
  58091. */
  58092. trackerDuration: number;
  58093. /**
  58094. * Gets the list of optimizations to apply
  58095. */
  58096. optimizations: SceneOptimization[];
  58097. /**
  58098. * Creates a new list of options used by SceneOptimizer
  58099. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  58100. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  58101. */
  58102. constructor(
  58103. /**
  58104. * Defines the target frame rate to reach (60 by default)
  58105. */
  58106. targetFrameRate?: number,
  58107. /**
  58108. * Defines the interval between two checkes (2000ms by default)
  58109. */
  58110. trackerDuration?: number);
  58111. /**
  58112. * Add a new optimization
  58113. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  58114. * @returns the current SceneOptimizerOptions
  58115. */
  58116. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  58117. /**
  58118. * Add a new custom optimization
  58119. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  58120. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  58121. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58122. * @returns the current SceneOptimizerOptions
  58123. */
  58124. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  58125. /**
  58126. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  58127. * @param targetFrameRate defines the target frame rate (60 by default)
  58128. * @returns a SceneOptimizerOptions object
  58129. */
  58130. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  58131. /**
  58132. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  58133. * @param targetFrameRate defines the target frame rate (60 by default)
  58134. * @returns a SceneOptimizerOptions object
  58135. */
  58136. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  58137. /**
  58138. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  58139. * @param targetFrameRate defines the target frame rate (60 by default)
  58140. * @returns a SceneOptimizerOptions object
  58141. */
  58142. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  58143. }
  58144. /**
  58145. * Class used to run optimizations in order to reach a target frame rate
  58146. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58147. */
  58148. export class SceneOptimizer implements IDisposable {
  58149. private _isRunning;
  58150. private _options;
  58151. private _scene;
  58152. private _currentPriorityLevel;
  58153. private _targetFrameRate;
  58154. private _trackerDuration;
  58155. private _currentFrameRate;
  58156. private _sceneDisposeObserver;
  58157. private _improvementMode;
  58158. /**
  58159. * Defines an observable called when the optimizer reaches the target frame rate
  58160. */
  58161. onSuccessObservable: Observable<SceneOptimizer>;
  58162. /**
  58163. * Defines an observable called when the optimizer enables an optimization
  58164. */
  58165. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  58166. /**
  58167. * Defines an observable called when the optimizer is not able to reach the target frame rate
  58168. */
  58169. onFailureObservable: Observable<SceneOptimizer>;
  58170. /**
  58171. * Gets a boolean indicating if the optimizer is in improvement mode
  58172. */
  58173. readonly isInImprovementMode: boolean;
  58174. /**
  58175. * Gets the current priority level (0 at start)
  58176. */
  58177. readonly currentPriorityLevel: number;
  58178. /**
  58179. * Gets the current frame rate checked by the SceneOptimizer
  58180. */
  58181. readonly currentFrameRate: number;
  58182. /**
  58183. * Gets or sets the current target frame rate (60 by default)
  58184. */
  58185. /**
  58186. * Gets or sets the current target frame rate (60 by default)
  58187. */
  58188. targetFrameRate: number;
  58189. /**
  58190. * Gets or sets the current interval between two checks (every 2000ms by default)
  58191. */
  58192. /**
  58193. * Gets or sets the current interval between two checks (every 2000ms by default)
  58194. */
  58195. trackerDuration: number;
  58196. /**
  58197. * Gets the list of active optimizations
  58198. */
  58199. readonly optimizations: SceneOptimization[];
  58200. /**
  58201. * Creates a new SceneOptimizer
  58202. * @param scene defines the scene to work on
  58203. * @param options defines the options to use with the SceneOptimizer
  58204. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  58205. * @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)
  58206. */
  58207. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  58208. /**
  58209. * Stops the current optimizer
  58210. */
  58211. stop(): void;
  58212. /**
  58213. * Reset the optimizer to initial step (current priority level = 0)
  58214. */
  58215. reset(): void;
  58216. /**
  58217. * Start the optimizer. By default it will try to reach a specific framerate
  58218. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  58219. */
  58220. start(): void;
  58221. private _checkCurrentState;
  58222. /**
  58223. * Release all resources
  58224. */
  58225. dispose(): void;
  58226. /**
  58227. * Helper function to create a SceneOptimizer with one single line of code
  58228. * @param scene defines the scene to work on
  58229. * @param options defines the options to use with the SceneOptimizer
  58230. * @param onSuccess defines a callback to call on success
  58231. * @param onFailure defines a callback to call on failure
  58232. * @returns the new SceneOptimizer object
  58233. */
  58234. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  58235. }
  58236. }
  58237. declare module BABYLON {
  58238. /**
  58239. * Class used to serialize a scene into a string
  58240. */
  58241. export class SceneSerializer {
  58242. /**
  58243. * Clear cache used by a previous serialization
  58244. */
  58245. static ClearCache(): void;
  58246. /**
  58247. * Serialize a scene into a JSON compatible object
  58248. * @param scene defines the scene to serialize
  58249. * @returns a JSON compatible object
  58250. */
  58251. static Serialize(scene: Scene): any;
  58252. /**
  58253. * Serialize a mesh into a JSON compatible object
  58254. * @param toSerialize defines the mesh to serialize
  58255. * @param withParents defines if parents must be serialized as well
  58256. * @param withChildren defines if children must be serialized as well
  58257. * @returns a JSON compatible object
  58258. */
  58259. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  58260. }
  58261. }
  58262. declare module BABYLON {
  58263. /**
  58264. * Class used to host texture specific utilities
  58265. */
  58266. export class TextureTools {
  58267. /**
  58268. * Uses the GPU to create a copy texture rescaled at a given size
  58269. * @param texture Texture to copy from
  58270. * @param width defines the desired width
  58271. * @param height defines the desired height
  58272. * @param useBilinearMode defines if bilinear mode has to be used
  58273. * @return the generated texture
  58274. */
  58275. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  58276. }
  58277. }
  58278. declare module BABYLON {
  58279. /**
  58280. * This represents the different options avilable for the video capture.
  58281. */
  58282. export interface VideoRecorderOptions {
  58283. /** Defines the mime type of the video */
  58284. mimeType: string;
  58285. /** Defines the video the video should be recorded at */
  58286. fps: number;
  58287. /** Defines the chunk size for the recording data */
  58288. recordChunckSize: number;
  58289. /** The audio tracks to attach to the record */
  58290. audioTracks?: MediaStreamTrack[];
  58291. }
  58292. /**
  58293. * This can helps recording videos from BabylonJS.
  58294. * This is based on the available WebRTC functionalities of the browser.
  58295. *
  58296. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  58297. */
  58298. export class VideoRecorder {
  58299. private static readonly _defaultOptions;
  58300. /**
  58301. * Returns wehther or not the VideoRecorder is available in your browser.
  58302. * @param engine Defines the Babylon Engine to check the support for
  58303. * @returns true if supported otherwise false
  58304. */
  58305. static IsSupported(engine: Engine): boolean;
  58306. private readonly _options;
  58307. private _canvas;
  58308. private _mediaRecorder;
  58309. private _recordedChunks;
  58310. private _fileName;
  58311. private _resolve;
  58312. private _reject;
  58313. /**
  58314. * True wether a recording is already in progress.
  58315. */
  58316. readonly isRecording: boolean;
  58317. /**
  58318. * Create a new VideoCapture object which can help converting what you see in Babylon to
  58319. * a video file.
  58320. * @param engine Defines the BabylonJS Engine you wish to record
  58321. * @param options Defines options that can be used to customized the capture
  58322. */
  58323. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  58324. /**
  58325. * Stops the current recording before the default capture timeout passed in the startRecording
  58326. * functions.
  58327. */
  58328. stopRecording(): void;
  58329. /**
  58330. * Starts recording the canvas for a max duration specified in parameters.
  58331. * @param fileName Defines the name of the file to be downloaded when the recording stop. If null no automatic download will start and you can rely on the promise to get the data back.
  58332. * @param maxDuration Defines the maximum recording time in seconds.
  58333. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  58334. * @return a promise callback at the end of the recording with the video data in Blob.
  58335. */
  58336. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  58337. /**
  58338. * Releases internal resources used during the recording.
  58339. */
  58340. dispose(): void;
  58341. private _handleDataAvailable;
  58342. private _handleError;
  58343. private _handleStop;
  58344. }
  58345. }
  58346. declare module BABYLON {
  58347. /**
  58348. * Class containing a set of static utilities functions for screenshots
  58349. */
  58350. export class ScreenshotTools {
  58351. /**
  58352. * Captures a screenshot of the current rendering
  58353. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  58354. * @param engine defines the rendering engine
  58355. * @param camera defines the source camera
  58356. * @param size This parameter can be set to a single number or to an object with the
  58357. * following (optional) properties: precision, width, height. If a single number is passed,
  58358. * it will be used for both width and height. If an object is passed, the screenshot size
  58359. * will be derived from the parameters. The precision property is a multiplier allowing
  58360. * rendering at a higher or lower resolution
  58361. * @param successCallback defines the callback receives a single parameter which contains the
  58362. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  58363. * src parameter of an <img> to display it
  58364. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  58365. * Check your browser for supported MIME types
  58366. */
  58367. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  58368. /**
  58369. * Generates an image screenshot from the specified camera.
  58370. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  58371. * @param engine The engine to use for rendering
  58372. * @param camera The camera to use for rendering
  58373. * @param size This parameter can be set to a single number or to an object with the
  58374. * following (optional) properties: precision, width, height. If a single number is passed,
  58375. * it will be used for both width and height. If an object is passed, the screenshot size
  58376. * will be derived from the parameters. The precision property is a multiplier allowing
  58377. * rendering at a higher or lower resolution
  58378. * @param successCallback The callback receives a single parameter which contains the
  58379. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  58380. * src parameter of an <img> to display it
  58381. * @param mimeType The MIME type of the screenshot image (default: image/png).
  58382. * Check your browser for supported MIME types
  58383. * @param samples Texture samples (default: 1)
  58384. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  58385. * @param fileName A name for for the downloaded file.
  58386. */
  58387. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  58388. }
  58389. }
  58390. declare module BABYLON {
  58391. /**
  58392. * A cursor which tracks a point on a path
  58393. */
  58394. export class PathCursor {
  58395. private path;
  58396. /**
  58397. * Stores path cursor callbacks for when an onchange event is triggered
  58398. */
  58399. private _onchange;
  58400. /**
  58401. * The value of the path cursor
  58402. */
  58403. value: number;
  58404. /**
  58405. * The animation array of the path cursor
  58406. */
  58407. animations: Animation[];
  58408. /**
  58409. * Initializes the path cursor
  58410. * @param path The path to track
  58411. */
  58412. constructor(path: Path2);
  58413. /**
  58414. * Gets the cursor point on the path
  58415. * @returns A point on the path cursor at the cursor location
  58416. */
  58417. getPoint(): Vector3;
  58418. /**
  58419. * Moves the cursor ahead by the step amount
  58420. * @param step The amount to move the cursor forward
  58421. * @returns This path cursor
  58422. */
  58423. moveAhead(step?: number): PathCursor;
  58424. /**
  58425. * Moves the cursor behind by the step amount
  58426. * @param step The amount to move the cursor back
  58427. * @returns This path cursor
  58428. */
  58429. moveBack(step?: number): PathCursor;
  58430. /**
  58431. * Moves the cursor by the step amount
  58432. * If the step amount is greater than one, an exception is thrown
  58433. * @param step The amount to move the cursor
  58434. * @returns This path cursor
  58435. */
  58436. move(step: number): PathCursor;
  58437. /**
  58438. * Ensures that the value is limited between zero and one
  58439. * @returns This path cursor
  58440. */
  58441. private ensureLimits;
  58442. /**
  58443. * Runs onchange callbacks on change (used by the animation engine)
  58444. * @returns This path cursor
  58445. */
  58446. private raiseOnChange;
  58447. /**
  58448. * Executes a function on change
  58449. * @param f A path cursor onchange callback
  58450. * @returns This path cursor
  58451. */
  58452. onchange(f: (cursor: PathCursor) => void): PathCursor;
  58453. }
  58454. }
  58455. declare module BABYLON {
  58456. /** @hidden */
  58457. export var blurPixelShader: {
  58458. name: string;
  58459. shader: string;
  58460. };
  58461. }
  58462. declare module BABYLON {
  58463. /** @hidden */
  58464. export var bones300Declaration: {
  58465. name: string;
  58466. shader: string;
  58467. };
  58468. }
  58469. declare module BABYLON {
  58470. /** @hidden */
  58471. export var instances300Declaration: {
  58472. name: string;
  58473. shader: string;
  58474. };
  58475. }
  58476. declare module BABYLON {
  58477. /** @hidden */
  58478. export var pointCloudVertexDeclaration: {
  58479. name: string;
  58480. shader: string;
  58481. };
  58482. }
  58483. // Mixins
  58484. interface Window {
  58485. mozIndexedDB: IDBFactory;
  58486. webkitIndexedDB: IDBFactory;
  58487. msIndexedDB: IDBFactory;
  58488. webkitURL: typeof URL;
  58489. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  58490. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  58491. WebGLRenderingContext: WebGLRenderingContext;
  58492. MSGesture: MSGesture;
  58493. CANNON: any;
  58494. AudioContext: AudioContext;
  58495. webkitAudioContext: AudioContext;
  58496. PointerEvent: any;
  58497. Math: Math;
  58498. Uint8Array: Uint8ArrayConstructor;
  58499. Float32Array: Float32ArrayConstructor;
  58500. mozURL: typeof URL;
  58501. msURL: typeof URL;
  58502. VRFrameData: any; // WebVR, from specs 1.1
  58503. DracoDecoderModule: any;
  58504. setImmediate(handler: (...args: any[]) => void): number;
  58505. }
  58506. interface HTMLCanvasElement {
  58507. requestPointerLock(): void;
  58508. msRequestPointerLock?(): void;
  58509. mozRequestPointerLock?(): void;
  58510. webkitRequestPointerLock?(): void;
  58511. /** Track wether a record is in progress */
  58512. isRecording: boolean;
  58513. /** Capture Stream method defined by some browsers */
  58514. captureStream(fps?: number): MediaStream;
  58515. }
  58516. interface CanvasRenderingContext2D {
  58517. msImageSmoothingEnabled: boolean;
  58518. }
  58519. interface MouseEvent {
  58520. mozMovementX: number;
  58521. mozMovementY: number;
  58522. webkitMovementX: number;
  58523. webkitMovementY: number;
  58524. msMovementX: number;
  58525. msMovementY: number;
  58526. }
  58527. interface Navigator {
  58528. mozGetVRDevices: (any: any) => any;
  58529. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  58530. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  58531. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  58532. webkitGetGamepads(): Gamepad[];
  58533. msGetGamepads(): Gamepad[];
  58534. webkitGamepads(): Gamepad[];
  58535. }
  58536. interface HTMLVideoElement {
  58537. mozSrcObject: any;
  58538. }
  58539. interface Math {
  58540. fround(x: number): number;
  58541. imul(a: number, b: number): number;
  58542. }
  58543. interface WebGLRenderingContext {
  58544. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  58545. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  58546. vertexAttribDivisor(index: number, divisor: number): void;
  58547. createVertexArray(): any;
  58548. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  58549. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  58550. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  58551. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  58552. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  58553. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  58554. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  58555. // Queries
  58556. createQuery(): WebGLQuery;
  58557. deleteQuery(query: WebGLQuery): void;
  58558. beginQuery(target: number, query: WebGLQuery): void;
  58559. endQuery(target: number): void;
  58560. getQueryParameter(query: WebGLQuery, pname: number): any;
  58561. getQuery(target: number, pname: number): any;
  58562. MAX_SAMPLES: number;
  58563. RGBA8: number;
  58564. READ_FRAMEBUFFER: number;
  58565. DRAW_FRAMEBUFFER: number;
  58566. UNIFORM_BUFFER: number;
  58567. HALF_FLOAT_OES: number;
  58568. RGBA16F: number;
  58569. RGBA32F: number;
  58570. R32F: number;
  58571. RG32F: number;
  58572. RGB32F: number;
  58573. R16F: number;
  58574. RG16F: number;
  58575. RGB16F: number;
  58576. RED: number;
  58577. RG: number;
  58578. R8: number;
  58579. RG8: number;
  58580. UNSIGNED_INT_24_8: number;
  58581. DEPTH24_STENCIL8: number;
  58582. /* Multiple Render Targets */
  58583. drawBuffers(buffers: number[]): void;
  58584. readBuffer(src: number): void;
  58585. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  58586. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  58587. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  58588. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  58589. // Occlusion Query
  58590. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  58591. ANY_SAMPLES_PASSED: number;
  58592. QUERY_RESULT_AVAILABLE: number;
  58593. QUERY_RESULT: number;
  58594. }
  58595. interface WebGLProgram {
  58596. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  58597. }
  58598. interface EXT_disjoint_timer_query {
  58599. QUERY_COUNTER_BITS_EXT: number;
  58600. TIME_ELAPSED_EXT: number;
  58601. TIMESTAMP_EXT: number;
  58602. GPU_DISJOINT_EXT: number;
  58603. QUERY_RESULT_EXT: number;
  58604. QUERY_RESULT_AVAILABLE_EXT: number;
  58605. queryCounterEXT(query: WebGLQuery, target: number): void;
  58606. createQueryEXT(): WebGLQuery;
  58607. beginQueryEXT(target: number, query: WebGLQuery): void;
  58608. endQueryEXT(target: number): void;
  58609. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  58610. deleteQueryEXT(query: WebGLQuery): void;
  58611. }
  58612. interface WebGLUniformLocation {
  58613. _currentState: any;
  58614. }
  58615. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  58616. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  58617. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  58618. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  58619. interface WebGLRenderingContext {
  58620. readonly RASTERIZER_DISCARD: number;
  58621. readonly DEPTH_COMPONENT24: number;
  58622. readonly TEXTURE_3D: number;
  58623. readonly TEXTURE_2D_ARRAY: number;
  58624. readonly TEXTURE_COMPARE_FUNC: number;
  58625. readonly TEXTURE_COMPARE_MODE: number;
  58626. readonly COMPARE_REF_TO_TEXTURE: number;
  58627. readonly TEXTURE_WRAP_R: number;
  58628. readonly HALF_FLOAT: number;
  58629. readonly RGB8: number;
  58630. readonly RED_INTEGER: number;
  58631. readonly RG_INTEGER: number;
  58632. readonly RGB_INTEGER: number;
  58633. readonly RGBA_INTEGER: number;
  58634. readonly R8_SNORM: number;
  58635. readonly RG8_SNORM: number;
  58636. readonly RGB8_SNORM: number;
  58637. readonly RGBA8_SNORM: number;
  58638. readonly R8I: number;
  58639. readonly RG8I: number;
  58640. readonly RGB8I: number;
  58641. readonly RGBA8I: number;
  58642. readonly R8UI: number;
  58643. readonly RG8UI: number;
  58644. readonly RGB8UI: number;
  58645. readonly RGBA8UI: number;
  58646. readonly R16I: number;
  58647. readonly RG16I: number;
  58648. readonly RGB16I: number;
  58649. readonly RGBA16I: number;
  58650. readonly R16UI: number;
  58651. readonly RG16UI: number;
  58652. readonly RGB16UI: number;
  58653. readonly RGBA16UI: number;
  58654. readonly R32I: number;
  58655. readonly RG32I: number;
  58656. readonly RGB32I: number;
  58657. readonly RGBA32I: number;
  58658. readonly R32UI: number;
  58659. readonly RG32UI: number;
  58660. readonly RGB32UI: number;
  58661. readonly RGBA32UI: number;
  58662. readonly RGB10_A2UI: number;
  58663. readonly R11F_G11F_B10F: number;
  58664. readonly RGB9_E5: number;
  58665. readonly RGB10_A2: number;
  58666. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  58667. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  58668. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  58669. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  58670. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  58671. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  58672. 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;
  58673. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  58674. readonly TRANSFORM_FEEDBACK: number;
  58675. readonly INTERLEAVED_ATTRIBS: number;
  58676. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  58677. createTransformFeedback(): WebGLTransformFeedback;
  58678. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  58679. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  58680. beginTransformFeedback(primitiveMode: number): void;
  58681. endTransformFeedback(): void;
  58682. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  58683. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  58684. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  58685. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  58686. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  58687. }
  58688. interface ImageBitmap {
  58689. readonly width: number;
  58690. readonly height: number;
  58691. close(): void;
  58692. }
  58693. interface WebGLQuery extends WebGLObject {
  58694. }
  58695. declare var WebGLQuery: {
  58696. prototype: WebGLQuery;
  58697. new(): WebGLQuery;
  58698. };
  58699. interface WebGLSampler extends WebGLObject {
  58700. }
  58701. declare var WebGLSampler: {
  58702. prototype: WebGLSampler;
  58703. new(): WebGLSampler;
  58704. };
  58705. interface WebGLSync extends WebGLObject {
  58706. }
  58707. declare var WebGLSync: {
  58708. prototype: WebGLSync;
  58709. new(): WebGLSync;
  58710. };
  58711. interface WebGLTransformFeedback extends WebGLObject {
  58712. }
  58713. declare var WebGLTransformFeedback: {
  58714. prototype: WebGLTransformFeedback;
  58715. new(): WebGLTransformFeedback;
  58716. };
  58717. interface WebGLVertexArrayObject extends WebGLObject {
  58718. }
  58719. declare var WebGLVertexArrayObject: {
  58720. prototype: WebGLVertexArrayObject;
  58721. new(): WebGLVertexArrayObject;
  58722. };
  58723. // Type definitions for WebVR API
  58724. // Project: https://w3c.github.io/webvr/
  58725. // Definitions by: six a <https://github.com/lostfictions>
  58726. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  58727. interface VRDisplay extends EventTarget {
  58728. /**
  58729. * Dictionary of capabilities describing the VRDisplay.
  58730. */
  58731. readonly capabilities: VRDisplayCapabilities;
  58732. /**
  58733. * z-depth defining the far plane of the eye view frustum
  58734. * enables mapping of values in the render target depth
  58735. * attachment to scene coordinates. Initially set to 10000.0.
  58736. */
  58737. depthFar: number;
  58738. /**
  58739. * z-depth defining the near plane of the eye view frustum
  58740. * enables mapping of values in the render target depth
  58741. * attachment to scene coordinates. Initially set to 0.01.
  58742. */
  58743. depthNear: number;
  58744. /**
  58745. * An identifier for this distinct VRDisplay. Used as an
  58746. * association point in the Gamepad API.
  58747. */
  58748. readonly displayId: number;
  58749. /**
  58750. * A display name, a user-readable name identifying it.
  58751. */
  58752. readonly displayName: string;
  58753. readonly isConnected: boolean;
  58754. readonly isPresenting: boolean;
  58755. /**
  58756. * If this VRDisplay supports room-scale experiences, the optional
  58757. * stage attribute contains details on the room-scale parameters.
  58758. */
  58759. readonly stageParameters: VRStageParameters | null;
  58760. /**
  58761. * Passing the value returned by `requestAnimationFrame` to
  58762. * `cancelAnimationFrame` will unregister the callback.
  58763. * @param handle Define the hanle of the request to cancel
  58764. */
  58765. cancelAnimationFrame(handle: number): void;
  58766. /**
  58767. * Stops presenting to the VRDisplay.
  58768. * @returns a promise to know when it stopped
  58769. */
  58770. exitPresent(): Promise<void>;
  58771. /**
  58772. * Return the current VREyeParameters for the given eye.
  58773. * @param whichEye Define the eye we want the parameter for
  58774. * @returns the eye parameters
  58775. */
  58776. getEyeParameters(whichEye: string): VREyeParameters;
  58777. /**
  58778. * Populates the passed VRFrameData with the information required to render
  58779. * the current frame.
  58780. * @param frameData Define the data structure to populate
  58781. * @returns true if ok otherwise false
  58782. */
  58783. getFrameData(frameData: VRFrameData): boolean;
  58784. /**
  58785. * Get the layers currently being presented.
  58786. * @returns the list of VR layers
  58787. */
  58788. getLayers(): VRLayer[];
  58789. /**
  58790. * Return a VRPose containing the future predicted pose of the VRDisplay
  58791. * when the current frame will be presented. The value returned will not
  58792. * change until JavaScript has returned control to the browser.
  58793. *
  58794. * The VRPose will contain the position, orientation, velocity,
  58795. * and acceleration of each of these properties.
  58796. * @returns the pose object
  58797. */
  58798. getPose(): VRPose;
  58799. /**
  58800. * Return the current instantaneous pose of the VRDisplay, with no
  58801. * prediction applied.
  58802. * @returns the current instantaneous pose
  58803. */
  58804. getImmediatePose(): VRPose;
  58805. /**
  58806. * The callback passed to `requestAnimationFrame` will be called
  58807. * any time a new frame should be rendered. When the VRDisplay is
  58808. * presenting the callback will be called at the native refresh
  58809. * rate of the HMD. When not presenting this function acts
  58810. * identically to how window.requestAnimationFrame acts. Content should
  58811. * make no assumptions of frame rate or vsync behavior as the HMD runs
  58812. * asynchronously from other displays and at differing refresh rates.
  58813. * @param callback Define the eaction to run next frame
  58814. * @returns the request handle it
  58815. */
  58816. requestAnimationFrame(callback: FrameRequestCallback): number;
  58817. /**
  58818. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  58819. * Repeat calls while already presenting will update the VRLayers being displayed.
  58820. * @param layers Define the list of layer to present
  58821. * @returns a promise to know when the request has been fulfilled
  58822. */
  58823. requestPresent(layers: VRLayer[]): Promise<void>;
  58824. /**
  58825. * Reset the pose for this display, treating its current position and
  58826. * orientation as the "origin/zero" values. VRPose.position,
  58827. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  58828. * updated when calling resetPose(). This should be called in only
  58829. * sitting-space experiences.
  58830. */
  58831. resetPose(): void;
  58832. /**
  58833. * The VRLayer provided to the VRDisplay will be captured and presented
  58834. * in the HMD. Calling this function has the same effect on the source
  58835. * canvas as any other operation that uses its source image, and canvases
  58836. * created without preserveDrawingBuffer set to true will be cleared.
  58837. * @param pose Define the pose to submit
  58838. */
  58839. submitFrame(pose?: VRPose): void;
  58840. }
  58841. declare var VRDisplay: {
  58842. prototype: VRDisplay;
  58843. new(): VRDisplay;
  58844. };
  58845. interface VRLayer {
  58846. leftBounds?: number[] | Float32Array | null;
  58847. rightBounds?: number[] | Float32Array | null;
  58848. source?: HTMLCanvasElement | null;
  58849. }
  58850. interface VRDisplayCapabilities {
  58851. readonly canPresent: boolean;
  58852. readonly hasExternalDisplay: boolean;
  58853. readonly hasOrientation: boolean;
  58854. readonly hasPosition: boolean;
  58855. readonly maxLayers: number;
  58856. }
  58857. interface VREyeParameters {
  58858. /** @deprecated */
  58859. readonly fieldOfView: VRFieldOfView;
  58860. readonly offset: Float32Array;
  58861. readonly renderHeight: number;
  58862. readonly renderWidth: number;
  58863. }
  58864. interface VRFieldOfView {
  58865. readonly downDegrees: number;
  58866. readonly leftDegrees: number;
  58867. readonly rightDegrees: number;
  58868. readonly upDegrees: number;
  58869. }
  58870. interface VRFrameData {
  58871. readonly leftProjectionMatrix: Float32Array;
  58872. readonly leftViewMatrix: Float32Array;
  58873. readonly pose: VRPose;
  58874. readonly rightProjectionMatrix: Float32Array;
  58875. readonly rightViewMatrix: Float32Array;
  58876. readonly timestamp: number;
  58877. }
  58878. interface VRPose {
  58879. readonly angularAcceleration: Float32Array | null;
  58880. readonly angularVelocity: Float32Array | null;
  58881. readonly linearAcceleration: Float32Array | null;
  58882. readonly linearVelocity: Float32Array | null;
  58883. readonly orientation: Float32Array | null;
  58884. readonly position: Float32Array | null;
  58885. readonly timestamp: number;
  58886. }
  58887. interface VRStageParameters {
  58888. sittingToStandingTransform?: Float32Array;
  58889. sizeX?: number;
  58890. sizeY?: number;
  58891. }
  58892. interface Navigator {
  58893. getVRDisplays(): Promise<VRDisplay[]>;
  58894. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  58895. }
  58896. interface Window {
  58897. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  58898. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  58899. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  58900. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  58901. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  58902. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  58903. }
  58904. interface Gamepad {
  58905. readonly displayId: number;
  58906. }
  58907. interface XRDevice {
  58908. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  58909. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  58910. }
  58911. interface XRSession {
  58912. getInputSources(): Array<any>;
  58913. baseLayer: XRWebGLLayer;
  58914. requestFrameOfReference(type: string): Promise<void>;
  58915. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  58916. end(): Promise<void>;
  58917. requestAnimationFrame: Function;
  58918. addEventListener: Function;
  58919. }
  58920. interface XRSessionCreationOptions {
  58921. outputContext?: WebGLRenderingContext | null;
  58922. immersive?: boolean;
  58923. environmentIntegration?: boolean;
  58924. }
  58925. interface XRLayer {
  58926. getViewport: Function;
  58927. framebufferWidth: number;
  58928. framebufferHeight: number;
  58929. }
  58930. interface XRView {
  58931. projectionMatrix: Float32Array;
  58932. }
  58933. interface XRFrame {
  58934. getDevicePose: Function;
  58935. getInputPose: Function;
  58936. views: Array<XRView>;
  58937. baseLayer: XRLayer;
  58938. }
  58939. interface XRFrameOfReference {
  58940. }
  58941. interface XRWebGLLayer extends XRLayer {
  58942. framebuffer: WebGLFramebuffer;
  58943. }
  58944. declare var XRWebGLLayer: {
  58945. prototype: XRWebGLLayer;
  58946. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  58947. };
  58948. declare module BABYLON.GUI {
  58949. /**
  58950. * Class used to specific a value and its associated unit
  58951. */
  58952. export class ValueAndUnit {
  58953. /** defines the unit to store */
  58954. unit: number;
  58955. /** defines a boolean indicating if the value can be negative */
  58956. negativeValueAllowed: boolean;
  58957. private _value;
  58958. private _originalUnit;
  58959. /**
  58960. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  58961. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  58962. */
  58963. ignoreAdaptiveScaling: boolean;
  58964. /**
  58965. * Creates a new ValueAndUnit
  58966. * @param value defines the value to store
  58967. * @param unit defines the unit to store
  58968. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  58969. */
  58970. constructor(value: number,
  58971. /** defines the unit to store */
  58972. unit?: number,
  58973. /** defines a boolean indicating if the value can be negative */
  58974. negativeValueAllowed?: boolean);
  58975. /** Gets a boolean indicating if the value is a percentage */
  58976. readonly isPercentage: boolean;
  58977. /** Gets a boolean indicating if the value is store as pixel */
  58978. readonly isPixel: boolean;
  58979. /** Gets direct internal value */
  58980. readonly internalValue: number;
  58981. /**
  58982. * Gets value as pixel
  58983. * @param host defines the root host
  58984. * @param refValue defines the reference value for percentages
  58985. * @returns the value as pixel
  58986. */
  58987. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  58988. /**
  58989. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  58990. * @param value defines the value to store
  58991. * @param unit defines the unit to store
  58992. * @returns the current ValueAndUnit
  58993. */
  58994. updateInPlace(value: number, unit?: number): ValueAndUnit;
  58995. /**
  58996. * Gets the value accordingly to its unit
  58997. * @param host defines the root host
  58998. * @returns the value
  58999. */
  59000. getValue(host: AdvancedDynamicTexture): number;
  59001. /**
  59002. * Gets a string representation of the value
  59003. * @param host defines the root host
  59004. * @param decimals defines an optional number of decimals to display
  59005. * @returns a string
  59006. */
  59007. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  59008. /**
  59009. * Store a value parsed from a string
  59010. * @param source defines the source string
  59011. * @returns true if the value was successfully parsed
  59012. */
  59013. fromString(source: string | number): boolean;
  59014. private static _Regex;
  59015. private static _UNITMODE_PERCENTAGE;
  59016. private static _UNITMODE_PIXEL;
  59017. /** UNITMODE_PERCENTAGE */
  59018. static readonly UNITMODE_PERCENTAGE: number;
  59019. /** UNITMODE_PIXEL */
  59020. static readonly UNITMODE_PIXEL: number;
  59021. }
  59022. }
  59023. declare module BABYLON.GUI {
  59024. /**
  59025. * Define a style used by control to automatically setup properties based on a template.
  59026. * Only support font related properties so far
  59027. */
  59028. export class Style implements BABYLON.IDisposable {
  59029. private _fontFamily;
  59030. private _fontStyle;
  59031. private _fontWeight;
  59032. /** @hidden */
  59033. _host: AdvancedDynamicTexture;
  59034. /** @hidden */
  59035. _fontSize: ValueAndUnit;
  59036. /**
  59037. * BABYLON.Observable raised when the style values are changed
  59038. */
  59039. onChangedObservable: BABYLON.Observable<Style>;
  59040. /**
  59041. * Creates a new style object
  59042. * @param host defines the AdvancedDynamicTexture which hosts this style
  59043. */
  59044. constructor(host: AdvancedDynamicTexture);
  59045. /**
  59046. * Gets or sets the font size
  59047. */
  59048. fontSize: string | number;
  59049. /**
  59050. * Gets or sets the font family
  59051. */
  59052. fontFamily: string;
  59053. /**
  59054. * Gets or sets the font style
  59055. */
  59056. fontStyle: string;
  59057. /** Gets or sets font weight */
  59058. fontWeight: string;
  59059. /** Dispose all associated resources */
  59060. dispose(): void;
  59061. }
  59062. }
  59063. declare module BABYLON.GUI {
  59064. /**
  59065. * Class used to transport BABYLON.Vector2 information for pointer events
  59066. */
  59067. export class Vector2WithInfo extends BABYLON.Vector2 {
  59068. /** defines the current mouse button index */
  59069. buttonIndex: number;
  59070. /**
  59071. * Creates a new Vector2WithInfo
  59072. * @param source defines the vector2 data to transport
  59073. * @param buttonIndex defines the current mouse button index
  59074. */
  59075. constructor(source: BABYLON.Vector2,
  59076. /** defines the current mouse button index */
  59077. buttonIndex?: number);
  59078. }
  59079. /** Class used to provide 2D matrix features */
  59080. export class Matrix2D {
  59081. /** Gets the internal array of 6 floats used to store matrix data */
  59082. m: Float32Array;
  59083. /**
  59084. * Creates a new matrix
  59085. * @param m00 defines value for (0, 0)
  59086. * @param m01 defines value for (0, 1)
  59087. * @param m10 defines value for (1, 0)
  59088. * @param m11 defines value for (1, 1)
  59089. * @param m20 defines value for (2, 0)
  59090. * @param m21 defines value for (2, 1)
  59091. */
  59092. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  59093. /**
  59094. * Fills the matrix from direct values
  59095. * @param m00 defines value for (0, 0)
  59096. * @param m01 defines value for (0, 1)
  59097. * @param m10 defines value for (1, 0)
  59098. * @param m11 defines value for (1, 1)
  59099. * @param m20 defines value for (2, 0)
  59100. * @param m21 defines value for (2, 1)
  59101. * @returns the current modified matrix
  59102. */
  59103. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  59104. /**
  59105. * Gets matrix determinant
  59106. * @returns the determinant
  59107. */
  59108. determinant(): number;
  59109. /**
  59110. * Inverses the matrix and stores it in a target matrix
  59111. * @param result defines the target matrix
  59112. * @returns the current matrix
  59113. */
  59114. invertToRef(result: Matrix2D): Matrix2D;
  59115. /**
  59116. * Multiplies the current matrix with another one
  59117. * @param other defines the second operand
  59118. * @param result defines the target matrix
  59119. * @returns the current matrix
  59120. */
  59121. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  59122. /**
  59123. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  59124. * @param x defines the x coordinate to transform
  59125. * @param y defines the x coordinate to transform
  59126. * @param result defines the target vector2
  59127. * @returns the current matrix
  59128. */
  59129. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  59130. /**
  59131. * Creates an identity matrix
  59132. * @returns a new matrix
  59133. */
  59134. static Identity(): Matrix2D;
  59135. /**
  59136. * Creates a translation matrix and stores it in a target matrix
  59137. * @param x defines the x coordinate of the translation
  59138. * @param y defines the y coordinate of the translation
  59139. * @param result defines the target matrix
  59140. */
  59141. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  59142. /**
  59143. * Creates a scaling matrix and stores it in a target matrix
  59144. * @param x defines the x coordinate of the scaling
  59145. * @param y defines the y coordinate of the scaling
  59146. * @param result defines the target matrix
  59147. */
  59148. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  59149. /**
  59150. * Creates a rotation matrix and stores it in a target matrix
  59151. * @param angle defines the rotation angle
  59152. * @param result defines the target matrix
  59153. */
  59154. static RotationToRef(angle: number, result: Matrix2D): void;
  59155. private static _TempPreTranslationMatrix;
  59156. private static _TempPostTranslationMatrix;
  59157. private static _TempRotationMatrix;
  59158. private static _TempScalingMatrix;
  59159. private static _TempCompose0;
  59160. private static _TempCompose1;
  59161. private static _TempCompose2;
  59162. /**
  59163. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  59164. * @param tx defines the x coordinate of the translation
  59165. * @param ty defines the y coordinate of the translation
  59166. * @param angle defines the rotation angle
  59167. * @param scaleX defines the x coordinate of the scaling
  59168. * @param scaleY defines the y coordinate of the scaling
  59169. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  59170. * @param result defines the target matrix
  59171. */
  59172. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  59173. }
  59174. }
  59175. declare module BABYLON.GUI {
  59176. /**
  59177. * Class used to store 2D control sizes
  59178. */
  59179. export class Measure {
  59180. /** defines left coordinate */
  59181. left: number;
  59182. /** defines top coordinate */
  59183. top: number;
  59184. /** defines width dimension */
  59185. width: number;
  59186. /** defines height dimension */
  59187. height: number;
  59188. /**
  59189. * Creates a new measure
  59190. * @param left defines left coordinate
  59191. * @param top defines top coordinate
  59192. * @param width defines width dimension
  59193. * @param height defines height dimension
  59194. */
  59195. constructor(
  59196. /** defines left coordinate */
  59197. left: number,
  59198. /** defines top coordinate */
  59199. top: number,
  59200. /** defines width dimension */
  59201. width: number,
  59202. /** defines height dimension */
  59203. height: number);
  59204. /**
  59205. * Copy from another measure
  59206. * @param other defines the other measure to copy from
  59207. */
  59208. copyFrom(other: Measure): void;
  59209. /**
  59210. * Copy from a group of 4 floats
  59211. * @param left defines left coordinate
  59212. * @param top defines top coordinate
  59213. * @param width defines width dimension
  59214. * @param height defines height dimension
  59215. */
  59216. copyFromFloats(left: number, top: number, width: number, height: number): void;
  59217. /**
  59218. * Computes the axis aligned bounding box measure for two given measures
  59219. * @param a Input measure
  59220. * @param b Input measure
  59221. * @param result the resulting bounding measure
  59222. */
  59223. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  59224. /**
  59225. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  59226. * @param transform the matrix to transform the measure before computing the AABB
  59227. * @param result the resulting AABB
  59228. */
  59229. transformToRef(transform: Matrix2D, result: Measure): void;
  59230. /**
  59231. * Check equality between this measure and another one
  59232. * @param other defines the other measures
  59233. * @returns true if both measures are equals
  59234. */
  59235. isEqualsTo(other: Measure): boolean;
  59236. /**
  59237. * Creates an empty measure
  59238. * @returns a new measure
  59239. */
  59240. static Empty(): Measure;
  59241. }
  59242. }
  59243. declare module BABYLON.GUI {
  59244. /**
  59245. * Interface used to define a control that can receive focus
  59246. */
  59247. export interface IFocusableControl {
  59248. /**
  59249. * Function called when the control receives the focus
  59250. */
  59251. onFocus(): void;
  59252. /**
  59253. * Function called when the control loses the focus
  59254. */
  59255. onBlur(): void;
  59256. /**
  59257. * Function called to let the control handle keyboard events
  59258. * @param evt defines the current keyboard event
  59259. */
  59260. processKeyboard(evt: KeyboardEvent): void;
  59261. /**
  59262. * Function called to get the list of controls that should not steal the focus from this control
  59263. * @returns an array of controls
  59264. */
  59265. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  59266. }
  59267. /**
  59268. * Class used to create texture to support 2D GUI elements
  59269. * @see http://doc.babylonjs.com/how_to/gui
  59270. */
  59271. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  59272. private _isDirty;
  59273. private _renderObserver;
  59274. private _resizeObserver;
  59275. private _preKeyboardObserver;
  59276. private _pointerMoveObserver;
  59277. private _pointerObserver;
  59278. private _canvasPointerOutObserver;
  59279. private _background;
  59280. /** @hidden */
  59281. _rootContainer: Container;
  59282. /** @hidden */
  59283. _lastPickedControl: Control;
  59284. /** @hidden */
  59285. _lastControlOver: {
  59286. [pointerId: number]: Control;
  59287. };
  59288. /** @hidden */
  59289. _lastControlDown: {
  59290. [pointerId: number]: Control;
  59291. };
  59292. /** @hidden */
  59293. _capturingControl: {
  59294. [pointerId: number]: Control;
  59295. };
  59296. /** @hidden */
  59297. _shouldBlockPointer: boolean;
  59298. /** @hidden */
  59299. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  59300. /** @hidden */
  59301. _linkedControls: Control[];
  59302. private _isFullscreen;
  59303. private _fullscreenViewport;
  59304. private _idealWidth;
  59305. private _idealHeight;
  59306. private _useSmallestIdeal;
  59307. private _renderAtIdealSize;
  59308. private _focusedControl;
  59309. private _blockNextFocusCheck;
  59310. private _renderScale;
  59311. private _rootCanvas;
  59312. private _cursorChanged;
  59313. /**
  59314. * Define type to string to ensure compatibility across browsers
  59315. * Safari doesn't support DataTransfer constructor
  59316. */
  59317. private _clipboardData;
  59318. /**
  59319. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  59320. */
  59321. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  59322. /**
  59323. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  59324. */
  59325. onControlPickedObservable: BABYLON.Observable<Control>;
  59326. /**
  59327. * BABYLON.Observable event triggered before layout is evaluated
  59328. */
  59329. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  59330. /**
  59331. * BABYLON.Observable event triggered after the layout was evaluated
  59332. */
  59333. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  59334. /**
  59335. * BABYLON.Observable event triggered before the texture is rendered
  59336. */
  59337. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  59338. /**
  59339. * BABYLON.Observable event triggered after the texture was rendered
  59340. */
  59341. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  59342. /**
  59343. * Gets or sets a boolean defining if alpha is stored as premultiplied
  59344. */
  59345. premulAlpha: boolean;
  59346. /**
  59347. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  59348. * Useful when you want more antialiasing
  59349. */
  59350. renderScale: number;
  59351. /** Gets or sets the background color */
  59352. background: string;
  59353. /**
  59354. * Gets or sets the ideal width used to design controls.
  59355. * The GUI will then rescale everything accordingly
  59356. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  59357. */
  59358. idealWidth: number;
  59359. /**
  59360. * Gets or sets the ideal height used to design controls.
  59361. * The GUI will then rescale everything accordingly
  59362. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  59363. */
  59364. idealHeight: number;
  59365. /**
  59366. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  59367. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  59368. */
  59369. useSmallestIdeal: boolean;
  59370. /**
  59371. * Gets or sets a boolean indicating if adaptive scaling must be used
  59372. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  59373. */
  59374. renderAtIdealSize: boolean;
  59375. /**
  59376. * Gets the underlying layer used to render the texture when in fullscreen mode
  59377. */
  59378. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  59379. /**
  59380. * Gets the root container control
  59381. */
  59382. readonly rootContainer: Container;
  59383. /**
  59384. * Returns an array containing the root container.
  59385. * This is mostly used to let the Inspector introspects the ADT
  59386. * @returns an array containing the rootContainer
  59387. */
  59388. getChildren(): Array<Container>;
  59389. /**
  59390. * Will return all controls that are inside this texture
  59391. * @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
  59392. * @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
  59393. * @return all child controls
  59394. */
  59395. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  59396. /**
  59397. * Gets or sets the current focused control
  59398. */
  59399. focusedControl: BABYLON.Nullable<IFocusableControl>;
  59400. /**
  59401. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  59402. */
  59403. isForeground: boolean;
  59404. /**
  59405. * Gets or set information about clipboardData
  59406. */
  59407. clipboardData: string;
  59408. /**
  59409. * Creates a new AdvancedDynamicTexture
  59410. * @param name defines the name of the texture
  59411. * @param width defines the width of the texture
  59412. * @param height defines the height of the texture
  59413. * @param scene defines the hosting scene
  59414. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  59415. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  59416. */
  59417. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  59418. /**
  59419. * Get the current class name of the texture useful for serialization or dynamic coding.
  59420. * @returns "AdvancedDynamicTexture"
  59421. */
  59422. getClassName(): string;
  59423. /**
  59424. * Function used to execute a function on all controls
  59425. * @param func defines the function to execute
  59426. * @param container defines the container where controls belong. If null the root container will be used
  59427. */
  59428. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  59429. private _useInvalidateRectOptimization;
  59430. /**
  59431. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  59432. */
  59433. useInvalidateRectOptimization: boolean;
  59434. private _invalidatedRectangle;
  59435. /**
  59436. * Invalidates a rectangle area on the gui texture
  59437. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  59438. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  59439. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  59440. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  59441. */
  59442. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  59443. /**
  59444. * Marks the texture as dirty forcing a complete update
  59445. */
  59446. markAsDirty(): void;
  59447. /**
  59448. * Helper function used to create a new style
  59449. * @returns a new style
  59450. * @see http://doc.babylonjs.com/how_to/gui#styles
  59451. */
  59452. createStyle(): Style;
  59453. /**
  59454. * Adds a new control to the root container
  59455. * @param control defines the control to add
  59456. * @returns the current texture
  59457. */
  59458. addControl(control: Control): AdvancedDynamicTexture;
  59459. /**
  59460. * Removes a control from the root container
  59461. * @param control defines the control to remove
  59462. * @returns the current texture
  59463. */
  59464. removeControl(control: Control): AdvancedDynamicTexture;
  59465. /**
  59466. * Release all resources
  59467. */
  59468. dispose(): void;
  59469. private _onResize;
  59470. /** @hidden */
  59471. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  59472. /**
  59473. * Get screen coordinates for a vector3
  59474. * @param position defines the position to project
  59475. * @param worldMatrix defines the world matrix to use
  59476. * @returns the projected position
  59477. */
  59478. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  59479. private _checkUpdate;
  59480. private _clearMeasure;
  59481. private _render;
  59482. /** @hidden */
  59483. _changeCursor(cursor: string): void;
  59484. /** @hidden */
  59485. _registerLastControlDown(control: Control, pointerId: number): void;
  59486. private _doPicking;
  59487. /** @hidden */
  59488. _cleanControlAfterRemovalFromList(list: {
  59489. [pointerId: number]: Control;
  59490. }, control: Control): void;
  59491. /** @hidden */
  59492. _cleanControlAfterRemoval(control: Control): void;
  59493. /** Attach to all scene events required to support pointer events */
  59494. attach(): void;
  59495. /** @hidden */
  59496. private onClipboardCopy;
  59497. /** @hidden */
  59498. private onClipboardCut;
  59499. /** @hidden */
  59500. private onClipboardPaste;
  59501. /**
  59502. * Register the clipboard Events onto the canvas
  59503. */
  59504. registerClipboardEvents(): void;
  59505. /**
  59506. * Unregister the clipboard Events from the canvas
  59507. */
  59508. unRegisterClipboardEvents(): void;
  59509. /**
  59510. * Connect the texture to a hosting mesh to enable interactions
  59511. * @param mesh defines the mesh to attach to
  59512. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  59513. */
  59514. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  59515. /**
  59516. * Move the focus to a specific control
  59517. * @param control defines the control which will receive the focus
  59518. */
  59519. moveFocusToControl(control: IFocusableControl): void;
  59520. private _manageFocus;
  59521. private _attachToOnPointerOut;
  59522. /**
  59523. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  59524. * @param mesh defines the mesh which will receive the texture
  59525. * @param width defines the texture width (1024 by default)
  59526. * @param height defines the texture height (1024 by default)
  59527. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  59528. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  59529. * @returns a new AdvancedDynamicTexture
  59530. */
  59531. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  59532. /**
  59533. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  59534. * In this mode the texture will rely on a layer for its rendering.
  59535. * This allows it to be treated like any other layer.
  59536. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  59537. * LayerMask is set through advancedTexture.layer.layerMask
  59538. * @param name defines name for the texture
  59539. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  59540. * @param scene defines the hsoting scene
  59541. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  59542. * @returns a new AdvancedDynamicTexture
  59543. */
  59544. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  59545. }
  59546. }
  59547. declare module BABYLON.GUI {
  59548. /**
  59549. * Root class used for all 2D controls
  59550. * @see http://doc.babylonjs.com/how_to/gui#controls
  59551. */
  59552. export class Control {
  59553. /** defines the name of the control */
  59554. name?: string | undefined;
  59555. /**
  59556. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  59557. */
  59558. static AllowAlphaInheritance: boolean;
  59559. private _alpha;
  59560. private _alphaSet;
  59561. private _zIndex;
  59562. /** @hidden */
  59563. _host: AdvancedDynamicTexture;
  59564. /** Gets or sets the control parent */
  59565. parent: BABYLON.Nullable<Container>;
  59566. /** @hidden */
  59567. _currentMeasure: Measure;
  59568. private _fontFamily;
  59569. private _fontStyle;
  59570. private _fontWeight;
  59571. private _fontSize;
  59572. private _font;
  59573. /** @hidden */
  59574. _width: ValueAndUnit;
  59575. /** @hidden */
  59576. _height: ValueAndUnit;
  59577. /** @hidden */
  59578. protected _fontOffset: {
  59579. ascent: number;
  59580. height: number;
  59581. descent: number;
  59582. };
  59583. private _color;
  59584. private _style;
  59585. private _styleObserver;
  59586. /** @hidden */
  59587. protected _horizontalAlignment: number;
  59588. /** @hidden */
  59589. protected _verticalAlignment: number;
  59590. /** @hidden */
  59591. protected _isDirty: boolean;
  59592. /** @hidden */
  59593. protected _wasDirty: boolean;
  59594. /** @hidden */
  59595. _tempParentMeasure: Measure;
  59596. /** @hidden */
  59597. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  59598. /** @hidden */
  59599. protected _cachedParentMeasure: Measure;
  59600. private _paddingLeft;
  59601. private _paddingRight;
  59602. private _paddingTop;
  59603. private _paddingBottom;
  59604. /** @hidden */
  59605. _left: ValueAndUnit;
  59606. /** @hidden */
  59607. _top: ValueAndUnit;
  59608. private _scaleX;
  59609. private _scaleY;
  59610. private _rotation;
  59611. private _transformCenterX;
  59612. private _transformCenterY;
  59613. /** @hidden */
  59614. _transformMatrix: Matrix2D;
  59615. /** @hidden */
  59616. protected _invertTransformMatrix: Matrix2D;
  59617. /** @hidden */
  59618. protected _transformedPosition: BABYLON.Vector2;
  59619. private _isMatrixDirty;
  59620. private _cachedOffsetX;
  59621. private _cachedOffsetY;
  59622. private _isVisible;
  59623. private _isHighlighted;
  59624. /** @hidden */
  59625. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  59626. private _fontSet;
  59627. private _dummyVector2;
  59628. private _downCount;
  59629. private _enterCount;
  59630. private _doNotRender;
  59631. private _downPointerIds;
  59632. protected _isEnabled: boolean;
  59633. protected _disabledColor: string;
  59634. /** @hidden */
  59635. protected _rebuildLayout: boolean;
  59636. /** @hidden */
  59637. _isClipped: boolean;
  59638. /** @hidden */
  59639. _tag: any;
  59640. /**
  59641. * 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
  59642. */
  59643. uniqueId: number;
  59644. /**
  59645. * Gets or sets an object used to store user defined information for the node
  59646. */
  59647. metadata: any;
  59648. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  59649. isHitTestVisible: boolean;
  59650. /** Gets or sets a boolean indicating if the control can block pointer events */
  59651. isPointerBlocker: boolean;
  59652. /** Gets or sets a boolean indicating if the control can be focusable */
  59653. isFocusInvisible: boolean;
  59654. /**
  59655. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  59656. * 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
  59657. */
  59658. clipChildren: boolean;
  59659. /**
  59660. * Gets or sets a boolean indicating that control content must be clipped
  59661. * 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
  59662. */
  59663. clipContent: boolean;
  59664. /**
  59665. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  59666. */
  59667. useBitmapCache: boolean;
  59668. private _cacheData;
  59669. private _shadowOffsetX;
  59670. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  59671. shadowOffsetX: number;
  59672. private _shadowOffsetY;
  59673. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  59674. shadowOffsetY: number;
  59675. private _shadowBlur;
  59676. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  59677. shadowBlur: number;
  59678. private _shadowColor;
  59679. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  59680. shadowColor: string;
  59681. /** Gets or sets the cursor to use when the control is hovered */
  59682. hoverCursor: string;
  59683. /** @hidden */
  59684. protected _linkOffsetX: ValueAndUnit;
  59685. /** @hidden */
  59686. protected _linkOffsetY: ValueAndUnit;
  59687. /** Gets the control type name */
  59688. readonly typeName: string;
  59689. /**
  59690. * Get the current class name of the control.
  59691. * @returns current class name
  59692. */
  59693. getClassName(): string;
  59694. /**
  59695. * An event triggered when the pointer move over the control.
  59696. */
  59697. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  59698. /**
  59699. * An event triggered when the pointer move out of the control.
  59700. */
  59701. onPointerOutObservable: BABYLON.Observable<Control>;
  59702. /**
  59703. * An event triggered when the pointer taps the control
  59704. */
  59705. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  59706. /**
  59707. * An event triggered when pointer up
  59708. */
  59709. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  59710. /**
  59711. * An event triggered when a control is clicked on
  59712. */
  59713. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  59714. /**
  59715. * An event triggered when pointer enters the control
  59716. */
  59717. onPointerEnterObservable: BABYLON.Observable<Control>;
  59718. /**
  59719. * An event triggered when the control is marked as dirty
  59720. */
  59721. onDirtyObservable: BABYLON.Observable<Control>;
  59722. /**
  59723. * An event triggered before drawing the control
  59724. */
  59725. onBeforeDrawObservable: BABYLON.Observable<Control>;
  59726. /**
  59727. * An event triggered after the control was drawn
  59728. */
  59729. onAfterDrawObservable: BABYLON.Observable<Control>;
  59730. /**
  59731. * Get the hosting AdvancedDynamicTexture
  59732. */
  59733. readonly host: AdvancedDynamicTexture;
  59734. /** Gets or set information about font offsets (used to render and align text) */
  59735. fontOffset: {
  59736. ascent: number;
  59737. height: number;
  59738. descent: number;
  59739. };
  59740. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  59741. alpha: number;
  59742. /**
  59743. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  59744. */
  59745. isHighlighted: boolean;
  59746. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  59747. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  59748. */
  59749. scaleX: number;
  59750. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  59751. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  59752. */
  59753. scaleY: number;
  59754. /** Gets or sets the rotation angle (0 by default)
  59755. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  59756. */
  59757. rotation: number;
  59758. /** Gets or sets the transformation center on Y axis (0 by default)
  59759. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  59760. */
  59761. transformCenterY: number;
  59762. /** Gets or sets the transformation center on X axis (0 by default)
  59763. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  59764. */
  59765. transformCenterX: number;
  59766. /**
  59767. * Gets or sets the horizontal alignment
  59768. * @see http://doc.babylonjs.com/how_to/gui#alignments
  59769. */
  59770. horizontalAlignment: number;
  59771. /**
  59772. * Gets or sets the vertical alignment
  59773. * @see http://doc.babylonjs.com/how_to/gui#alignments
  59774. */
  59775. verticalAlignment: number;
  59776. /**
  59777. * Gets or sets control width
  59778. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59779. */
  59780. width: string | number;
  59781. /**
  59782. * Gets or sets the control width in pixel
  59783. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59784. */
  59785. widthInPixels: number;
  59786. /**
  59787. * Gets or sets control height
  59788. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59789. */
  59790. height: string | number;
  59791. /**
  59792. * Gets or sets control height in pixel
  59793. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59794. */
  59795. heightInPixels: number;
  59796. /** Gets or set font family */
  59797. fontFamily: string;
  59798. /** Gets or sets font style */
  59799. fontStyle: string;
  59800. /** Gets or sets font weight */
  59801. fontWeight: string;
  59802. /**
  59803. * Gets or sets style
  59804. * @see http://doc.babylonjs.com/how_to/gui#styles
  59805. */
  59806. style: BABYLON.Nullable<Style>;
  59807. /** @hidden */
  59808. readonly _isFontSizeInPercentage: boolean;
  59809. /** Gets or sets font size in pixels */
  59810. fontSizeInPixels: number;
  59811. /** Gets or sets font size */
  59812. fontSize: string | number;
  59813. /** Gets or sets foreground color */
  59814. color: string;
  59815. /** Gets or sets z index which is used to reorder controls on the z axis */
  59816. zIndex: number;
  59817. /** Gets or sets a boolean indicating if the control can be rendered */
  59818. notRenderable: boolean;
  59819. /** Gets or sets a boolean indicating if the control is visible */
  59820. isVisible: boolean;
  59821. /** Gets a boolean indicating that the control needs to update its rendering */
  59822. readonly isDirty: boolean;
  59823. /**
  59824. * Gets the current linked mesh (or null if none)
  59825. */
  59826. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  59827. /**
  59828. * Gets or sets a value indicating the padding to use on the left of the control
  59829. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59830. */
  59831. paddingLeft: string | number;
  59832. /**
  59833. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  59834. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59835. */
  59836. paddingLeftInPixels: number;
  59837. /**
  59838. * Gets or sets a value indicating the padding to use on the right of the control
  59839. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59840. */
  59841. paddingRight: string | number;
  59842. /**
  59843. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  59844. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59845. */
  59846. paddingRightInPixels: number;
  59847. /**
  59848. * Gets or sets a value indicating the padding to use on the top of the control
  59849. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59850. */
  59851. paddingTop: string | number;
  59852. /**
  59853. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  59854. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59855. */
  59856. paddingTopInPixels: number;
  59857. /**
  59858. * Gets or sets a value indicating the padding to use on the bottom of the control
  59859. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59860. */
  59861. paddingBottom: string | number;
  59862. /**
  59863. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  59864. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59865. */
  59866. paddingBottomInPixels: number;
  59867. /**
  59868. * Gets or sets a value indicating the left coordinate of the control
  59869. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59870. */
  59871. left: string | number;
  59872. /**
  59873. * Gets or sets a value indicating the left coordinate in pixels of the control
  59874. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59875. */
  59876. leftInPixels: number;
  59877. /**
  59878. * Gets or sets a value indicating the top coordinate of the control
  59879. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59880. */
  59881. top: string | number;
  59882. /**
  59883. * Gets or sets a value indicating the top coordinate in pixels of the control
  59884. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  59885. */
  59886. topInPixels: number;
  59887. /**
  59888. * Gets or sets a value indicating the offset on X axis to the linked mesh
  59889. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  59890. */
  59891. linkOffsetX: string | number;
  59892. /**
  59893. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  59894. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  59895. */
  59896. linkOffsetXInPixels: number;
  59897. /**
  59898. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  59899. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  59900. */
  59901. linkOffsetY: string | number;
  59902. /**
  59903. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  59904. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  59905. */
  59906. linkOffsetYInPixels: number;
  59907. /** Gets the center coordinate on X axis */
  59908. readonly centerX: number;
  59909. /** Gets the center coordinate on Y axis */
  59910. readonly centerY: number;
  59911. /** Gets or sets if control is Enabled*/
  59912. isEnabled: boolean;
  59913. /** Gets or sets background color of control if it's disabled*/
  59914. disabledColor: string;
  59915. /**
  59916. * Creates a new control
  59917. * @param name defines the name of the control
  59918. */
  59919. constructor(
  59920. /** defines the name of the control */
  59921. name?: string | undefined);
  59922. /** @hidden */
  59923. protected _getTypeName(): string;
  59924. /**
  59925. * Gets the first ascendant in the hierarchy of the given type
  59926. * @param className defines the required type
  59927. * @returns the ascendant or null if not found
  59928. */
  59929. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  59930. /** @hidden */
  59931. _resetFontCache(): void;
  59932. /**
  59933. * Determines if a container is an ascendant of the current control
  59934. * @param container defines the container to look for
  59935. * @returns true if the container is one of the ascendant of the control
  59936. */
  59937. isAscendant(container: Control): boolean;
  59938. /**
  59939. * Gets coordinates in local control space
  59940. * @param globalCoordinates defines the coordinates to transform
  59941. * @returns the new coordinates in local space
  59942. */
  59943. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  59944. /**
  59945. * Gets coordinates in local control space
  59946. * @param globalCoordinates defines the coordinates to transform
  59947. * @param result defines the target vector2 where to store the result
  59948. * @returns the current control
  59949. */
  59950. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  59951. /**
  59952. * Gets coordinates in parent local control space
  59953. * @param globalCoordinates defines the coordinates to transform
  59954. * @returns the new coordinates in parent local space
  59955. */
  59956. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  59957. /**
  59958. * Move the current control to a vector3 position projected onto the screen.
  59959. * @param position defines the target position
  59960. * @param scene defines the hosting scene
  59961. */
  59962. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  59963. /** @hidden */
  59964. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  59965. /**
  59966. * Will return all controls that have this control as ascendant
  59967. * @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
  59968. * @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
  59969. * @return all child controls
  59970. */
  59971. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  59972. /**
  59973. * Link current control with a target mesh
  59974. * @param mesh defines the mesh to link with
  59975. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  59976. */
  59977. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  59978. /** @hidden */
  59979. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  59980. /** @hidden */
  59981. _offsetLeft(offset: number): void;
  59982. /** @hidden */
  59983. _offsetTop(offset: number): void;
  59984. /** @hidden */
  59985. _markMatrixAsDirty(): void;
  59986. /** @hidden */
  59987. _flagDescendantsAsMatrixDirty(): void;
  59988. /** @hidden */
  59989. _intersectsRect(rect: Measure): boolean;
  59990. /** @hidden */
  59991. protected invalidateRect(): void;
  59992. /** @hidden */
  59993. _markAsDirty(force?: boolean): void;
  59994. /** @hidden */
  59995. _markAllAsDirty(): void;
  59996. /** @hidden */
  59997. _link(host: AdvancedDynamicTexture): void;
  59998. /** @hidden */
  59999. protected _transform(context?: CanvasRenderingContext2D): void;
  60000. /** @hidden */
  60001. _renderHighlight(context: CanvasRenderingContext2D): void;
  60002. /** @hidden */
  60003. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  60004. /** @hidden */
  60005. protected _applyStates(context: CanvasRenderingContext2D): void;
  60006. /** @hidden */
  60007. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  60008. /** @hidden */
  60009. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60010. protected _evaluateClippingState(parentMeasure: Measure): void;
  60011. /** @hidden */
  60012. _measure(): void;
  60013. /** @hidden */
  60014. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60015. /** @hidden */
  60016. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60017. /** @hidden */
  60018. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60019. /** @hidden */
  60020. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  60021. private static _ClipMeasure;
  60022. private _tmpMeasureA;
  60023. private _clip;
  60024. /** @hidden */
  60025. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  60026. /** @hidden */
  60027. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  60028. /**
  60029. * Tests if a given coordinates belong to the current control
  60030. * @param x defines x coordinate to test
  60031. * @param y defines y coordinate to test
  60032. * @returns true if the coordinates are inside the control
  60033. */
  60034. contains(x: number, y: number): boolean;
  60035. /** @hidden */
  60036. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  60037. /** @hidden */
  60038. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  60039. /** @hidden */
  60040. _onPointerEnter(target: Control): boolean;
  60041. /** @hidden */
  60042. _onPointerOut(target: Control, force?: boolean): void;
  60043. /** @hidden */
  60044. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  60045. /** @hidden */
  60046. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  60047. /** @hidden */
  60048. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  60049. /** @hidden */
  60050. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  60051. private _prepareFont;
  60052. /** Releases associated resources */
  60053. dispose(): void;
  60054. private static _HORIZONTAL_ALIGNMENT_LEFT;
  60055. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  60056. private static _HORIZONTAL_ALIGNMENT_CENTER;
  60057. private static _VERTICAL_ALIGNMENT_TOP;
  60058. private static _VERTICAL_ALIGNMENT_BOTTOM;
  60059. private static _VERTICAL_ALIGNMENT_CENTER;
  60060. /** HORIZONTAL_ALIGNMENT_LEFT */
  60061. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  60062. /** HORIZONTAL_ALIGNMENT_RIGHT */
  60063. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  60064. /** HORIZONTAL_ALIGNMENT_CENTER */
  60065. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  60066. /** VERTICAL_ALIGNMENT_TOP */
  60067. static readonly VERTICAL_ALIGNMENT_TOP: number;
  60068. /** VERTICAL_ALIGNMENT_BOTTOM */
  60069. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  60070. /** VERTICAL_ALIGNMENT_CENTER */
  60071. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  60072. private static _FontHeightSizes;
  60073. /** @hidden */
  60074. static _GetFontOffset(font: string): {
  60075. ascent: number;
  60076. height: number;
  60077. descent: number;
  60078. };
  60079. /**
  60080. * Creates a stack panel that can be used to render headers
  60081. * @param control defines the control to associate with the header
  60082. * @param text defines the text of the header
  60083. * @param size defines the size of the header
  60084. * @param options defines options used to configure the header
  60085. * @returns a new StackPanel
  60086. * @ignore
  60087. * @hidden
  60088. */
  60089. static AddHeader: (control: Control, text: string, size: string | number, options: {
  60090. isHorizontal: boolean;
  60091. controlFirst: boolean;
  60092. }) => any;
  60093. /** @hidden */
  60094. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  60095. }
  60096. }
  60097. declare module BABYLON.GUI {
  60098. /**
  60099. * Root class for 2D containers
  60100. * @see http://doc.babylonjs.com/how_to/gui#containers
  60101. */
  60102. export class Container extends Control {
  60103. name?: string | undefined;
  60104. /** @hidden */
  60105. protected _children: Control[];
  60106. /** @hidden */
  60107. protected _measureForChildren: Measure;
  60108. /** @hidden */
  60109. protected _background: string;
  60110. /** @hidden */
  60111. protected _adaptWidthToChildren: boolean;
  60112. /** @hidden */
  60113. protected _adaptHeightToChildren: boolean;
  60114. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  60115. adaptHeightToChildren: boolean;
  60116. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  60117. adaptWidthToChildren: boolean;
  60118. /** Gets or sets background color */
  60119. background: string;
  60120. /** Gets the list of children */
  60121. readonly children: Control[];
  60122. /**
  60123. * Creates a new Container
  60124. * @param name defines the name of the container
  60125. */
  60126. constructor(name?: string | undefined);
  60127. protected _getTypeName(): string;
  60128. _flagDescendantsAsMatrixDirty(): void;
  60129. /**
  60130. * Gets a child using its name
  60131. * @param name defines the child name to look for
  60132. * @returns the child control if found
  60133. */
  60134. getChildByName(name: string): BABYLON.Nullable<Control>;
  60135. /**
  60136. * Gets a child using its type and its name
  60137. * @param name defines the child name to look for
  60138. * @param type defines the child type to look for
  60139. * @returns the child control if found
  60140. */
  60141. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  60142. /**
  60143. * Search for a specific control in children
  60144. * @param control defines the control to look for
  60145. * @returns true if the control is in child list
  60146. */
  60147. containsControl(control: Control): boolean;
  60148. /**
  60149. * Adds a new control to the current container
  60150. * @param control defines the control to add
  60151. * @returns the current container
  60152. */
  60153. addControl(control: BABYLON.Nullable<Control>): Container;
  60154. /**
  60155. * Removes all controls from the current container
  60156. * @returns the current container
  60157. */
  60158. clearControls(): Container;
  60159. /**
  60160. * Removes a control from the current container
  60161. * @param control defines the control to remove
  60162. * @returns the current container
  60163. */
  60164. removeControl(control: Control): Container;
  60165. /** @hidden */
  60166. _reOrderControl(control: Control): void;
  60167. /** @hidden */
  60168. _offsetLeft(offset: number): void;
  60169. /** @hidden */
  60170. _offsetTop(offset: number): void;
  60171. /** @hidden */
  60172. _markAllAsDirty(): void;
  60173. /** @hidden */
  60174. protected _localDraw(context: CanvasRenderingContext2D): void;
  60175. /** @hidden */
  60176. _link(host: AdvancedDynamicTexture): void;
  60177. /** @hidden */
  60178. protected _beforeLayout(): void;
  60179. /** @hidden */
  60180. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60181. /** @hidden */
  60182. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  60183. protected _postMeasure(): void;
  60184. /** @hidden */
  60185. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  60186. /** @hidden */
  60187. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  60188. /** @hidden */
  60189. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  60190. /** @hidden */
  60191. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60192. /** Releases associated resources */
  60193. dispose(): void;
  60194. }
  60195. }
  60196. declare module BABYLON.GUI {
  60197. /** Class used to create rectangle container */
  60198. export class Rectangle extends Container {
  60199. name?: string | undefined;
  60200. private _thickness;
  60201. private _cornerRadius;
  60202. /** Gets or sets border thickness */
  60203. thickness: number;
  60204. /** Gets or sets the corner radius angle */
  60205. cornerRadius: number;
  60206. /**
  60207. * Creates a new Rectangle
  60208. * @param name defines the control name
  60209. */
  60210. constructor(name?: string | undefined);
  60211. protected _getTypeName(): string;
  60212. protected _localDraw(context: CanvasRenderingContext2D): void;
  60213. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60214. private _drawRoundedRect;
  60215. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  60216. }
  60217. }
  60218. declare module BABYLON.GUI {
  60219. /**
  60220. * Enum that determines the text-wrapping mode to use.
  60221. */
  60222. export enum TextWrapping {
  60223. /**
  60224. * Clip the text when it's larger than Control.width; this is the default mode.
  60225. */
  60226. Clip = 0,
  60227. /**
  60228. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  60229. */
  60230. WordWrap = 1,
  60231. /**
  60232. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  60233. */
  60234. Ellipsis = 2
  60235. }
  60236. /**
  60237. * Class used to create text block control
  60238. */
  60239. export class TextBlock extends Control {
  60240. /**
  60241. * Defines the name of the control
  60242. */
  60243. name?: string | undefined;
  60244. private _text;
  60245. private _textWrapping;
  60246. private _textHorizontalAlignment;
  60247. private _textVerticalAlignment;
  60248. private _lines;
  60249. private _resizeToFit;
  60250. private _lineSpacing;
  60251. private _outlineWidth;
  60252. private _outlineColor;
  60253. /**
  60254. * An event triggered after the text is changed
  60255. */
  60256. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  60257. /**
  60258. * An event triggered after the text was broken up into lines
  60259. */
  60260. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  60261. /**
  60262. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  60263. */
  60264. readonly lines: any[];
  60265. /**
  60266. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  60267. */
  60268. /**
  60269. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  60270. */
  60271. resizeToFit: boolean;
  60272. /**
  60273. * Gets or sets a boolean indicating if text must be wrapped
  60274. */
  60275. /**
  60276. * Gets or sets a boolean indicating if text must be wrapped
  60277. */
  60278. textWrapping: TextWrapping | boolean;
  60279. /**
  60280. * Gets or sets text to display
  60281. */
  60282. /**
  60283. * Gets or sets text to display
  60284. */
  60285. text: string;
  60286. /**
  60287. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  60288. */
  60289. /**
  60290. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  60291. */
  60292. textHorizontalAlignment: number;
  60293. /**
  60294. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  60295. */
  60296. /**
  60297. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  60298. */
  60299. textVerticalAlignment: number;
  60300. /**
  60301. * Gets or sets line spacing value
  60302. */
  60303. /**
  60304. * Gets or sets line spacing value
  60305. */
  60306. lineSpacing: string | number;
  60307. /**
  60308. * Gets or sets outlineWidth of the text to display
  60309. */
  60310. /**
  60311. * Gets or sets outlineWidth of the text to display
  60312. */
  60313. outlineWidth: number;
  60314. /**
  60315. * Gets or sets outlineColor of the text to display
  60316. */
  60317. /**
  60318. * Gets or sets outlineColor of the text to display
  60319. */
  60320. outlineColor: string;
  60321. /**
  60322. * Creates a new TextBlock object
  60323. * @param name defines the name of the control
  60324. * @param text defines the text to display (emptry string by default)
  60325. */
  60326. constructor(
  60327. /**
  60328. * Defines the name of the control
  60329. */
  60330. name?: string | undefined, text?: string);
  60331. protected _getTypeName(): string;
  60332. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60333. private _drawText;
  60334. /** @hidden */
  60335. _draw(context: CanvasRenderingContext2D): void;
  60336. protected _applyStates(context: CanvasRenderingContext2D): void;
  60337. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  60338. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  60339. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  60340. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  60341. protected _renderLines(context: CanvasRenderingContext2D): void;
  60342. /**
  60343. * Given a width constraint applied on the text block, find the expected height
  60344. * @returns expected height
  60345. */
  60346. computeExpectedHeight(): number;
  60347. dispose(): void;
  60348. }
  60349. }
  60350. declare module BABYLON.GUI {
  60351. /**
  60352. * Class used to create 2D images
  60353. */
  60354. export class Image extends Control {
  60355. name?: string | undefined;
  60356. private static _WorkingCanvas;
  60357. private _domImage;
  60358. private _imageWidth;
  60359. private _imageHeight;
  60360. private _loaded;
  60361. private _stretch;
  60362. private _source;
  60363. private _autoScale;
  60364. private _sourceLeft;
  60365. private _sourceTop;
  60366. private _sourceWidth;
  60367. private _sourceHeight;
  60368. private _cellWidth;
  60369. private _cellHeight;
  60370. private _cellId;
  60371. private _populateNinePatchSlicesFromImage;
  60372. private _sliceLeft;
  60373. private _sliceRight;
  60374. private _sliceTop;
  60375. private _sliceBottom;
  60376. private _detectPointerOnOpaqueOnly;
  60377. /**
  60378. * BABYLON.Observable notified when the content is loaded
  60379. */
  60380. onImageLoadedObservable: BABYLON.Observable<Image>;
  60381. /**
  60382. * Gets a boolean indicating that the content is loaded
  60383. */
  60384. readonly isLoaded: boolean;
  60385. /**
  60386. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  60387. */
  60388. populateNinePatchSlicesFromImage: boolean;
  60389. /**
  60390. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  60391. * Beware using this as this will comsume more memory as the image has to be stored twice
  60392. */
  60393. detectPointerOnOpaqueOnly: boolean;
  60394. /**
  60395. * Gets or sets the left value for slicing (9-patch)
  60396. */
  60397. sliceLeft: number;
  60398. /**
  60399. * Gets or sets the right value for slicing (9-patch)
  60400. */
  60401. sliceRight: number;
  60402. /**
  60403. * Gets or sets the top value for slicing (9-patch)
  60404. */
  60405. sliceTop: number;
  60406. /**
  60407. * Gets or sets the bottom value for slicing (9-patch)
  60408. */
  60409. sliceBottom: number;
  60410. /**
  60411. * Gets or sets the left coordinate in the source image
  60412. */
  60413. sourceLeft: number;
  60414. /**
  60415. * Gets or sets the top coordinate in the source image
  60416. */
  60417. sourceTop: number;
  60418. /**
  60419. * Gets or sets the width to capture in the source image
  60420. */
  60421. sourceWidth: number;
  60422. /**
  60423. * Gets or sets the height to capture in the source image
  60424. */
  60425. sourceHeight: number;
  60426. /**
  60427. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  60428. * @see http://doc.babylonjs.com/how_to/gui#image
  60429. */
  60430. autoScale: boolean;
  60431. /** Gets or sets the streching mode used by the image */
  60432. stretch: number;
  60433. /**
  60434. * Gets or sets the internal DOM image used to render the control
  60435. */
  60436. domImage: HTMLImageElement;
  60437. private _onImageLoaded;
  60438. private _extractNinePatchSliceDataFromImage;
  60439. /**
  60440. * Gets or sets image source url
  60441. */
  60442. source: BABYLON.Nullable<string>;
  60443. /**
  60444. * Gets or sets the cell width to use when animation sheet is enabled
  60445. * @see http://doc.babylonjs.com/how_to/gui#image
  60446. */
  60447. cellWidth: number;
  60448. /**
  60449. * Gets or sets the cell height to use when animation sheet is enabled
  60450. * @see http://doc.babylonjs.com/how_to/gui#image
  60451. */
  60452. cellHeight: number;
  60453. /**
  60454. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  60455. * @see http://doc.babylonjs.com/how_to/gui#image
  60456. */
  60457. cellId: number;
  60458. /**
  60459. * Creates a new Image
  60460. * @param name defines the control name
  60461. * @param url defines the image url
  60462. */
  60463. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  60464. /**
  60465. * Tests if a given coordinates belong to the current control
  60466. * @param x defines x coordinate to test
  60467. * @param y defines y coordinate to test
  60468. * @returns true if the coordinates are inside the control
  60469. */
  60470. contains(x: number, y: number): boolean;
  60471. protected _getTypeName(): string;
  60472. /** Force the control to synchronize with its content */
  60473. synchronizeSizeWithContent(): void;
  60474. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60475. private _prepareWorkingCanvasForOpaqueDetection;
  60476. private _drawImage;
  60477. _draw(context: CanvasRenderingContext2D): void;
  60478. private _renderCornerPatch;
  60479. private _renderNinePatch;
  60480. dispose(): void;
  60481. /** STRETCH_NONE */
  60482. static readonly STRETCH_NONE: number;
  60483. /** STRETCH_FILL */
  60484. static readonly STRETCH_FILL: number;
  60485. /** STRETCH_UNIFORM */
  60486. static readonly STRETCH_UNIFORM: number;
  60487. /** STRETCH_EXTEND */
  60488. static readonly STRETCH_EXTEND: number;
  60489. /** NINE_PATCH */
  60490. static readonly STRETCH_NINE_PATCH: number;
  60491. }
  60492. }
  60493. declare module BABYLON.GUI {
  60494. /**
  60495. * Class used to create 2D buttons
  60496. */
  60497. export class Button extends Rectangle {
  60498. name?: string | undefined;
  60499. /**
  60500. * Function called to generate a pointer enter animation
  60501. */
  60502. pointerEnterAnimation: () => void;
  60503. /**
  60504. * Function called to generate a pointer out animation
  60505. */
  60506. pointerOutAnimation: () => void;
  60507. /**
  60508. * Function called to generate a pointer down animation
  60509. */
  60510. pointerDownAnimation: () => void;
  60511. /**
  60512. * Function called to generate a pointer up animation
  60513. */
  60514. pointerUpAnimation: () => void;
  60515. private _image;
  60516. /**
  60517. * Returns the image part of the button (if any)
  60518. */
  60519. readonly image: BABYLON.Nullable<Image>;
  60520. private _textBlock;
  60521. /**
  60522. * Returns the image part of the button (if any)
  60523. */
  60524. readonly textBlock: BABYLON.Nullable<TextBlock>;
  60525. /**
  60526. * Creates a new Button
  60527. * @param name defines the name of the button
  60528. */
  60529. constructor(name?: string | undefined);
  60530. protected _getTypeName(): string;
  60531. /** @hidden */
  60532. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  60533. /** @hidden */
  60534. _onPointerEnter(target: Control): boolean;
  60535. /** @hidden */
  60536. _onPointerOut(target: Control, force?: boolean): void;
  60537. /** @hidden */
  60538. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  60539. /** @hidden */
  60540. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  60541. /**
  60542. * Creates a new button made with an image and a text
  60543. * @param name defines the name of the button
  60544. * @param text defines the text of the button
  60545. * @param imageUrl defines the url of the image
  60546. * @returns a new Button
  60547. */
  60548. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  60549. /**
  60550. * Creates a new button made with an image
  60551. * @param name defines the name of the button
  60552. * @param imageUrl defines the url of the image
  60553. * @returns a new Button
  60554. */
  60555. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  60556. /**
  60557. * Creates a new button made with a text
  60558. * @param name defines the name of the button
  60559. * @param text defines the text of the button
  60560. * @returns a new Button
  60561. */
  60562. static CreateSimpleButton(name: string, text: string): Button;
  60563. /**
  60564. * Creates a new button made with an image and a centered text
  60565. * @param name defines the name of the button
  60566. * @param text defines the text of the button
  60567. * @param imageUrl defines the url of the image
  60568. * @returns a new Button
  60569. */
  60570. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  60571. }
  60572. }
  60573. declare module BABYLON.GUI {
  60574. /**
  60575. * Class used to create a 2D stack panel container
  60576. */
  60577. export class StackPanel extends Container {
  60578. name?: string | undefined;
  60579. private _isVertical;
  60580. private _manualWidth;
  60581. private _manualHeight;
  60582. private _doNotTrackManualChanges;
  60583. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  60584. isVertical: boolean;
  60585. /**
  60586. * Gets or sets panel width.
  60587. * This value should not be set when in horizontal mode as it will be computed automatically
  60588. */
  60589. width: string | number;
  60590. /**
  60591. * Gets or sets panel height.
  60592. * This value should not be set when in vertical mode as it will be computed automatically
  60593. */
  60594. height: string | number;
  60595. /**
  60596. * Creates a new StackPanel
  60597. * @param name defines control name
  60598. */
  60599. constructor(name?: string | undefined);
  60600. protected _getTypeName(): string;
  60601. /** @hidden */
  60602. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60603. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60604. protected _postMeasure(): void;
  60605. }
  60606. }
  60607. declare module BABYLON.GUI {
  60608. /**
  60609. * Class used to represent a 2D checkbox
  60610. */
  60611. export class Checkbox extends Control {
  60612. name?: string | undefined;
  60613. private _isChecked;
  60614. private _background;
  60615. private _checkSizeRatio;
  60616. private _thickness;
  60617. /** Gets or sets border thickness */
  60618. thickness: number;
  60619. /**
  60620. * BABYLON.Observable raised when isChecked property changes
  60621. */
  60622. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  60623. /** Gets or sets a value indicating the ratio between overall size and check size */
  60624. checkSizeRatio: number;
  60625. /** Gets or sets background color */
  60626. background: string;
  60627. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  60628. isChecked: boolean;
  60629. /**
  60630. * Creates a new CheckBox
  60631. * @param name defines the control name
  60632. */
  60633. constructor(name?: string | undefined);
  60634. protected _getTypeName(): string;
  60635. /** @hidden */
  60636. _draw(context: CanvasRenderingContext2D): void;
  60637. /** @hidden */
  60638. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  60639. /**
  60640. * Utility function to easily create a checkbox with a header
  60641. * @param title defines the label to use for the header
  60642. * @param onValueChanged defines the callback to call when value changes
  60643. * @returns a StackPanel containing the checkbox and a textBlock
  60644. */
  60645. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  60646. }
  60647. }
  60648. declare module BABYLON.GUI {
  60649. /**
  60650. * Class used to store key control properties
  60651. */
  60652. export class KeyPropertySet {
  60653. /** Width */
  60654. width?: string;
  60655. /** Height */
  60656. height?: string;
  60657. /** Left padding */
  60658. paddingLeft?: string;
  60659. /** Right padding */
  60660. paddingRight?: string;
  60661. /** Top padding */
  60662. paddingTop?: string;
  60663. /** Bottom padding */
  60664. paddingBottom?: string;
  60665. /** Foreground color */
  60666. color?: string;
  60667. /** Background color */
  60668. background?: string;
  60669. }
  60670. /**
  60671. * Class used to create virtual keyboard
  60672. */
  60673. export class VirtualKeyboard extends StackPanel {
  60674. /** BABYLON.Observable raised when a key is pressed */
  60675. onKeyPressObservable: BABYLON.Observable<string>;
  60676. /** Gets or sets default key button width */
  60677. defaultButtonWidth: string;
  60678. /** Gets or sets default key button height */
  60679. defaultButtonHeight: string;
  60680. /** Gets or sets default key button left padding */
  60681. defaultButtonPaddingLeft: string;
  60682. /** Gets or sets default key button right padding */
  60683. defaultButtonPaddingRight: string;
  60684. /** Gets or sets default key button top padding */
  60685. defaultButtonPaddingTop: string;
  60686. /** Gets or sets default key button bottom padding */
  60687. defaultButtonPaddingBottom: string;
  60688. /** Gets or sets default key button foreground color */
  60689. defaultButtonColor: string;
  60690. /** Gets or sets default key button background color */
  60691. defaultButtonBackground: string;
  60692. /** Gets or sets shift button foreground color */
  60693. shiftButtonColor: string;
  60694. /** Gets or sets shift button thickness*/
  60695. selectedShiftThickness: number;
  60696. /** Gets shift key state */
  60697. shiftState: number;
  60698. protected _getTypeName(): string;
  60699. private _createKey;
  60700. /**
  60701. * Adds a new row of keys
  60702. * @param keys defines the list of keys to add
  60703. * @param propertySets defines the associated property sets
  60704. */
  60705. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  60706. /**
  60707. * Set the shift key to a specific state
  60708. * @param shiftState defines the new shift state
  60709. */
  60710. applyShiftState(shiftState: number): void;
  60711. private _currentlyConnectedInputText;
  60712. private _connectedInputTexts;
  60713. private _onKeyPressObserver;
  60714. /** Gets the input text control currently attached to the keyboard */
  60715. readonly connectedInputText: BABYLON.Nullable<InputText>;
  60716. /**
  60717. * Connects the keyboard with an input text control
  60718. *
  60719. * @param input defines the target control
  60720. */
  60721. connect(input: InputText): void;
  60722. /**
  60723. * Disconnects the keyboard from connected InputText controls
  60724. *
  60725. * @param input optionally defines a target control, otherwise all are disconnected
  60726. */
  60727. disconnect(input?: InputText): void;
  60728. private _removeConnectedInputObservables;
  60729. /**
  60730. * Release all resources
  60731. */
  60732. dispose(): void;
  60733. /**
  60734. * Creates a new keyboard using a default layout
  60735. *
  60736. * @param name defines control name
  60737. * @returns a new VirtualKeyboard
  60738. */
  60739. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  60740. }
  60741. }
  60742. declare module BABYLON.GUI {
  60743. /**
  60744. * Class used to create input text control
  60745. */
  60746. export class InputText extends Control implements IFocusableControl {
  60747. name?: string | undefined;
  60748. private _text;
  60749. private _placeholderText;
  60750. private _background;
  60751. private _focusedBackground;
  60752. private _focusedColor;
  60753. private _placeholderColor;
  60754. private _thickness;
  60755. private _margin;
  60756. private _autoStretchWidth;
  60757. private _maxWidth;
  60758. private _isFocused;
  60759. private _blinkTimeout;
  60760. private _blinkIsEven;
  60761. private _cursorOffset;
  60762. private _scrollLeft;
  60763. private _textWidth;
  60764. private _clickedCoordinate;
  60765. private _deadKey;
  60766. private _addKey;
  60767. private _currentKey;
  60768. private _isTextHighlightOn;
  60769. private _textHighlightColor;
  60770. private _highligherOpacity;
  60771. private _highlightedText;
  60772. private _startHighlightIndex;
  60773. private _endHighlightIndex;
  60774. private _cursorIndex;
  60775. private _onFocusSelectAll;
  60776. private _isPointerDown;
  60777. private _onClipboardObserver;
  60778. private _onPointerDblTapObserver;
  60779. /** @hidden */
  60780. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  60781. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  60782. promptMessage: string;
  60783. /** BABYLON.Observable raised when the text changes */
  60784. onTextChangedObservable: BABYLON.Observable<InputText>;
  60785. /** BABYLON.Observable raised just before an entered character is to be added */
  60786. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  60787. /** BABYLON.Observable raised when the control gets the focus */
  60788. onFocusObservable: BABYLON.Observable<InputText>;
  60789. /** BABYLON.Observable raised when the control loses the focus */
  60790. onBlurObservable: BABYLON.Observable<InputText>;
  60791. /**Observable raised when the text is highlighted */
  60792. onTextHighlightObservable: BABYLON.Observable<InputText>;
  60793. /**Observable raised when copy event is triggered */
  60794. onTextCopyObservable: BABYLON.Observable<InputText>;
  60795. /** BABYLON.Observable raised when cut event is triggered */
  60796. onTextCutObservable: BABYLON.Observable<InputText>;
  60797. /** BABYLON.Observable raised when paste event is triggered */
  60798. onTextPasteObservable: BABYLON.Observable<InputText>;
  60799. /** BABYLON.Observable raised when a key event was processed */
  60800. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  60801. /** Gets or sets the maximum width allowed by the control */
  60802. maxWidth: string | number;
  60803. /** Gets the maximum width allowed by the control in pixels */
  60804. readonly maxWidthInPixels: number;
  60805. /** Gets or sets the text highlighter transparency; default: 0.4 */
  60806. highligherOpacity: number;
  60807. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  60808. onFocusSelectAll: boolean;
  60809. /** Gets or sets the text hightlight color */
  60810. textHighlightColor: string;
  60811. /** Gets or sets control margin */
  60812. margin: string;
  60813. /** Gets control margin in pixels */
  60814. readonly marginInPixels: number;
  60815. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  60816. autoStretchWidth: boolean;
  60817. /** Gets or sets border thickness */
  60818. thickness: number;
  60819. /** Gets or sets the background color when focused */
  60820. focusedBackground: string;
  60821. /** Gets or sets the background color when focused */
  60822. focusedColor: string;
  60823. /** Gets or sets the background color */
  60824. background: string;
  60825. /** Gets or sets the placeholder color */
  60826. placeholderColor: string;
  60827. /** Gets or sets the text displayed when the control is empty */
  60828. placeholderText: string;
  60829. /** Gets or sets the dead key flag */
  60830. deadKey: boolean;
  60831. /** Gets or sets the highlight text */
  60832. highlightedText: string;
  60833. /** Gets or sets if the current key should be added */
  60834. addKey: boolean;
  60835. /** Gets or sets the value of the current key being entered */
  60836. currentKey: string;
  60837. /** Gets or sets the text displayed in the control */
  60838. text: string;
  60839. /** Gets or sets control width */
  60840. width: string | number;
  60841. /**
  60842. * Creates a new InputText
  60843. * @param name defines the control name
  60844. * @param text defines the text of the control
  60845. */
  60846. constructor(name?: string | undefined, text?: string);
  60847. /** @hidden */
  60848. onBlur(): void;
  60849. /** @hidden */
  60850. onFocus(): void;
  60851. protected _getTypeName(): string;
  60852. /**
  60853. * Function called to get the list of controls that should not steal the focus from this control
  60854. * @returns an array of controls
  60855. */
  60856. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  60857. /** @hidden */
  60858. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  60859. /** @hidden */
  60860. private _updateValueFromCursorIndex;
  60861. /** @hidden */
  60862. private _processDblClick;
  60863. /** @hidden */
  60864. private _selectAllText;
  60865. /**
  60866. * Handles the keyboard event
  60867. * @param evt Defines the KeyboardEvent
  60868. */
  60869. processKeyboard(evt: KeyboardEvent): void;
  60870. /** @hidden */
  60871. private _onCopyText;
  60872. /** @hidden */
  60873. private _onCutText;
  60874. /** @hidden */
  60875. private _onPasteText;
  60876. _draw(context: CanvasRenderingContext2D): void;
  60877. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  60878. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  60879. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  60880. protected _beforeRenderText(text: string): string;
  60881. dispose(): void;
  60882. }
  60883. }
  60884. declare module BABYLON.GUI {
  60885. /**
  60886. * Class used to create a 2D grid container
  60887. */
  60888. export class Grid extends Container {
  60889. name?: string | undefined;
  60890. private _rowDefinitions;
  60891. private _columnDefinitions;
  60892. private _cells;
  60893. private _childControls;
  60894. /**
  60895. * Gets the number of columns
  60896. */
  60897. readonly columnCount: number;
  60898. /**
  60899. * Gets the number of rows
  60900. */
  60901. readonly rowCount: number;
  60902. /** Gets the list of children */
  60903. readonly children: Control[];
  60904. /** Gets the list of cells (e.g. the containers) */
  60905. readonly cells: {
  60906. [key: string]: Container;
  60907. };
  60908. /**
  60909. * Gets the definition of a specific row
  60910. * @param index defines the index of the row
  60911. * @returns the row definition
  60912. */
  60913. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  60914. /**
  60915. * Gets the definition of a specific column
  60916. * @param index defines the index of the column
  60917. * @returns the column definition
  60918. */
  60919. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  60920. /**
  60921. * Adds a new row to the grid
  60922. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  60923. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  60924. * @returns the current grid
  60925. */
  60926. addRowDefinition(height: number, isPixel?: boolean): Grid;
  60927. /**
  60928. * Adds a new column to the grid
  60929. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  60930. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  60931. * @returns the current grid
  60932. */
  60933. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  60934. /**
  60935. * Update a row definition
  60936. * @param index defines the index of the row to update
  60937. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  60938. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  60939. * @returns the current grid
  60940. */
  60941. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  60942. /**
  60943. * Update a column definition
  60944. * @param index defines the index of the column to update
  60945. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  60946. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  60947. * @returns the current grid
  60948. */
  60949. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  60950. /**
  60951. * Gets the list of children stored in a specific cell
  60952. * @param row defines the row to check
  60953. * @param column defines the column to check
  60954. * @returns the list of controls
  60955. */
  60956. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  60957. /**
  60958. * Gets a string representing the child cell info (row x column)
  60959. * @param child defines the control to get info from
  60960. * @returns a string containing the child cell info (row x column)
  60961. */
  60962. getChildCellInfo(child: Control): string;
  60963. private _removeCell;
  60964. private _offsetCell;
  60965. /**
  60966. * Remove a column definition at specified index
  60967. * @param index defines the index of the column to remove
  60968. * @returns the current grid
  60969. */
  60970. removeColumnDefinition(index: number): Grid;
  60971. /**
  60972. * Remove a row definition at specified index
  60973. * @param index defines the index of the row to remove
  60974. * @returns the current grid
  60975. */
  60976. removeRowDefinition(index: number): Grid;
  60977. /**
  60978. * Adds a new control to the current grid
  60979. * @param control defines the control to add
  60980. * @param row defines the row where to add the control (0 by default)
  60981. * @param column defines the column where to add the control (0 by default)
  60982. * @returns the current grid
  60983. */
  60984. addControl(control: Control, row?: number, column?: number): Grid;
  60985. /**
  60986. * Removes a control from the current container
  60987. * @param control defines the control to remove
  60988. * @returns the current container
  60989. */
  60990. removeControl(control: Control): Container;
  60991. /**
  60992. * Creates a new Grid
  60993. * @param name defines control name
  60994. */
  60995. constructor(name?: string | undefined);
  60996. protected _getTypeName(): string;
  60997. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  60998. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60999. _flagDescendantsAsMatrixDirty(): void;
  61000. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  61001. /** Releases associated resources */
  61002. dispose(): void;
  61003. }
  61004. }
  61005. declare module BABYLON.GUI {
  61006. /** Class used to create color pickers */
  61007. export class ColorPicker extends Control {
  61008. name?: string | undefined;
  61009. private static _Epsilon;
  61010. private _colorWheelCanvas;
  61011. private _value;
  61012. private _tmpColor;
  61013. private _pointerStartedOnSquare;
  61014. private _pointerStartedOnWheel;
  61015. private _squareLeft;
  61016. private _squareTop;
  61017. private _squareSize;
  61018. private _h;
  61019. private _s;
  61020. private _v;
  61021. private _lastPointerDownID;
  61022. /**
  61023. * BABYLON.Observable raised when the value changes
  61024. */
  61025. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  61026. /** Gets or sets the color of the color picker */
  61027. value: BABYLON.Color3;
  61028. /**
  61029. * Gets or sets control width
  61030. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61031. */
  61032. width: string | number;
  61033. /**
  61034. * Gets or sets control height
  61035. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61036. */
  61037. /** Gets or sets control height */
  61038. height: string | number;
  61039. /** Gets or sets control size */
  61040. size: string | number;
  61041. /**
  61042. * Creates a new ColorPicker
  61043. * @param name defines the control name
  61044. */
  61045. constructor(name?: string | undefined);
  61046. protected _getTypeName(): string;
  61047. /** @hidden */
  61048. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61049. private _updateSquareProps;
  61050. private _drawGradientSquare;
  61051. private _drawCircle;
  61052. private _createColorWheelCanvas;
  61053. /** @hidden */
  61054. _draw(context: CanvasRenderingContext2D): void;
  61055. private _pointerIsDown;
  61056. private _updateValueFromPointer;
  61057. private _isPointOnSquare;
  61058. private _isPointOnWheel;
  61059. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  61060. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  61061. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  61062. /**
  61063. * This function expands the color picker by creating a color picker dialog with manual
  61064. * color value input and the ability to save colors into an array to be used later in
  61065. * subsequent launches of the dialogue.
  61066. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  61067. * @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.
  61068. * @returns picked color as a hex string and the saved colors array as hex strings.
  61069. */
  61070. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  61071. pickerWidth?: string;
  61072. pickerHeight?: string;
  61073. headerHeight?: string;
  61074. lastColor?: string;
  61075. swatchLimit?: number;
  61076. numSwatchesPerLine?: number;
  61077. savedColors?: Array<string>;
  61078. }): Promise<{
  61079. savedColors?: string[];
  61080. pickedColor: string;
  61081. }>;
  61082. }
  61083. }
  61084. declare module BABYLON.GUI {
  61085. /** Class used to create 2D ellipse containers */
  61086. export class Ellipse extends Container {
  61087. name?: string | undefined;
  61088. private _thickness;
  61089. /** Gets or sets border thickness */
  61090. thickness: number;
  61091. /**
  61092. * Creates a new Ellipse
  61093. * @param name defines the control name
  61094. */
  61095. constructor(name?: string | undefined);
  61096. protected _getTypeName(): string;
  61097. protected _localDraw(context: CanvasRenderingContext2D): void;
  61098. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61099. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  61100. }
  61101. }
  61102. declare module BABYLON.GUI {
  61103. /**
  61104. * Class used to create a password control
  61105. */
  61106. export class InputPassword extends InputText {
  61107. protected _beforeRenderText(text: string): string;
  61108. }
  61109. }
  61110. declare module BABYLON.GUI {
  61111. /** Class used to render 2D lines */
  61112. export class Line extends Control {
  61113. name?: string | undefined;
  61114. private _lineWidth;
  61115. private _x1;
  61116. private _y1;
  61117. private _x2;
  61118. private _y2;
  61119. private _dash;
  61120. private _connectedControl;
  61121. private _connectedControlDirtyObserver;
  61122. /** Gets or sets the dash pattern */
  61123. dash: Array<number>;
  61124. /** Gets or sets the control connected with the line end */
  61125. connectedControl: Control;
  61126. /** Gets or sets start coordinates on X axis */
  61127. x1: string | number;
  61128. /** Gets or sets start coordinates on Y axis */
  61129. y1: string | number;
  61130. /** Gets or sets end coordinates on X axis */
  61131. x2: string | number;
  61132. /** Gets or sets end coordinates on Y axis */
  61133. y2: string | number;
  61134. /** Gets or sets line width */
  61135. lineWidth: number;
  61136. /** Gets or sets horizontal alignment */
  61137. horizontalAlignment: number;
  61138. /** Gets or sets vertical alignment */
  61139. verticalAlignment: number;
  61140. private readonly _effectiveX2;
  61141. private readonly _effectiveY2;
  61142. /**
  61143. * Creates a new Line
  61144. * @param name defines the control name
  61145. */
  61146. constructor(name?: string | undefined);
  61147. protected _getTypeName(): string;
  61148. _draw(context: CanvasRenderingContext2D): void;
  61149. _measure(): void;
  61150. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61151. /**
  61152. * Move one end of the line given 3D cartesian coordinates.
  61153. * @param position Targeted world position
  61154. * @param scene BABYLON.Scene
  61155. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  61156. */
  61157. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  61158. /**
  61159. * Move one end of the line to a position in screen absolute space.
  61160. * @param projectedPosition Position in screen absolute space (X, Y)
  61161. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  61162. */
  61163. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  61164. }
  61165. }
  61166. declare module BABYLON.GUI {
  61167. /**
  61168. * Class used to store a point for a MultiLine object.
  61169. * The point can be pure 2D coordinates, a mesh or a control
  61170. */
  61171. export class MultiLinePoint {
  61172. private _multiLine;
  61173. private _x;
  61174. private _y;
  61175. private _control;
  61176. private _mesh;
  61177. private _controlObserver;
  61178. private _meshObserver;
  61179. /** @hidden */
  61180. _point: BABYLON.Vector2;
  61181. /**
  61182. * Creates a new MultiLinePoint
  61183. * @param multiLine defines the source MultiLine object
  61184. */
  61185. constructor(multiLine: MultiLine);
  61186. /** Gets or sets x coordinate */
  61187. x: string | number;
  61188. /** Gets or sets y coordinate */
  61189. y: string | number;
  61190. /** Gets or sets the control associated with this point */
  61191. control: BABYLON.Nullable<Control>;
  61192. /** Gets or sets the mesh associated with this point */
  61193. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  61194. /** Resets links */
  61195. resetLinks(): void;
  61196. /**
  61197. * Gets a translation vector
  61198. * @returns the translation vector
  61199. */
  61200. translate(): BABYLON.Vector2;
  61201. private _translatePoint;
  61202. /** Release associated resources */
  61203. dispose(): void;
  61204. }
  61205. }
  61206. declare module BABYLON.GUI {
  61207. /**
  61208. * Class used to create multi line control
  61209. */
  61210. export class MultiLine extends Control {
  61211. name?: string | undefined;
  61212. private _lineWidth;
  61213. private _dash;
  61214. private _points;
  61215. private _minX;
  61216. private _minY;
  61217. private _maxX;
  61218. private _maxY;
  61219. /**
  61220. * Creates a new MultiLine
  61221. * @param name defines the control name
  61222. */
  61223. constructor(name?: string | undefined);
  61224. /** Gets or sets dash pattern */
  61225. dash: Array<number>;
  61226. /**
  61227. * Gets point stored at specified index
  61228. * @param index defines the index to look for
  61229. * @returns the requested point if found
  61230. */
  61231. getAt(index: number): MultiLinePoint;
  61232. /** Function called when a point is updated */
  61233. onPointUpdate: () => void;
  61234. /**
  61235. * Adds new points to the point collection
  61236. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  61237. * @returns the list of created MultiLinePoint
  61238. */
  61239. add(...items: (AbstractMesh | Control | {
  61240. x: string | number;
  61241. y: string | number;
  61242. })[]): MultiLinePoint[];
  61243. /**
  61244. * Adds a new point to the point collection
  61245. * @param item defines the item (mesh, control or 2d coordiantes) to add
  61246. * @returns the created MultiLinePoint
  61247. */
  61248. push(item?: (AbstractMesh | Control | {
  61249. x: string | number;
  61250. y: string | number;
  61251. })): MultiLinePoint;
  61252. /**
  61253. * Remove a specific value or point from the active point collection
  61254. * @param value defines the value or point to remove
  61255. */
  61256. remove(value: number | MultiLinePoint): void;
  61257. /**
  61258. * Resets this object to initial state (no point)
  61259. */
  61260. reset(): void;
  61261. /**
  61262. * Resets all links
  61263. */
  61264. resetLinks(): void;
  61265. /** Gets or sets line width */
  61266. lineWidth: number;
  61267. horizontalAlignment: number;
  61268. verticalAlignment: number;
  61269. protected _getTypeName(): string;
  61270. _draw(context: CanvasRenderingContext2D): void;
  61271. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61272. _measure(): void;
  61273. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61274. dispose(): void;
  61275. }
  61276. }
  61277. declare module BABYLON.GUI {
  61278. /**
  61279. * Class used to create radio button controls
  61280. */
  61281. export class RadioButton extends Control {
  61282. name?: string | undefined;
  61283. private _isChecked;
  61284. private _background;
  61285. private _checkSizeRatio;
  61286. private _thickness;
  61287. /** Gets or sets border thickness */
  61288. thickness: number;
  61289. /** Gets or sets group name */
  61290. group: string;
  61291. /** BABYLON.Observable raised when isChecked is changed */
  61292. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  61293. /** Gets or sets a value indicating the ratio between overall size and check size */
  61294. checkSizeRatio: number;
  61295. /** Gets or sets background color */
  61296. background: string;
  61297. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  61298. isChecked: boolean;
  61299. /**
  61300. * Creates a new RadioButton
  61301. * @param name defines the control name
  61302. */
  61303. constructor(name?: string | undefined);
  61304. protected _getTypeName(): string;
  61305. _draw(context: CanvasRenderingContext2D): void;
  61306. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  61307. /**
  61308. * Utility function to easily create a radio button with a header
  61309. * @param title defines the label to use for the header
  61310. * @param group defines the group to use for the radio button
  61311. * @param isChecked defines the initial state of the radio button
  61312. * @param onValueChanged defines the callback to call when value changes
  61313. * @returns a StackPanel containing the radio button and a textBlock
  61314. */
  61315. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  61316. }
  61317. }
  61318. declare module BABYLON.GUI {
  61319. /**
  61320. * Class used to create slider controls
  61321. */
  61322. export class BaseSlider extends Control {
  61323. name?: string | undefined;
  61324. protected _thumbWidth: ValueAndUnit;
  61325. private _minimum;
  61326. private _maximum;
  61327. private _value;
  61328. private _isVertical;
  61329. protected _barOffset: ValueAndUnit;
  61330. private _isThumbClamped;
  61331. protected _displayThumb: boolean;
  61332. private _step;
  61333. private _lastPointerDownID;
  61334. protected _effectiveBarOffset: number;
  61335. protected _renderLeft: number;
  61336. protected _renderTop: number;
  61337. protected _renderWidth: number;
  61338. protected _renderHeight: number;
  61339. protected _backgroundBoxLength: number;
  61340. protected _backgroundBoxThickness: number;
  61341. protected _effectiveThumbThickness: number;
  61342. /** BABYLON.Observable raised when the sldier value changes */
  61343. onValueChangedObservable: BABYLON.Observable<number>;
  61344. /** Gets or sets a boolean indicating if the thumb must be rendered */
  61345. displayThumb: boolean;
  61346. /** Gets or sets a step to apply to values (0 by default) */
  61347. step: number;
  61348. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  61349. barOffset: string | number;
  61350. /** Gets main bar offset in pixels*/
  61351. readonly barOffsetInPixels: number;
  61352. /** Gets or sets thumb width */
  61353. thumbWidth: string | number;
  61354. /** Gets thumb width in pixels */
  61355. readonly thumbWidthInPixels: number;
  61356. /** Gets or sets minimum value */
  61357. minimum: number;
  61358. /** Gets or sets maximum value */
  61359. maximum: number;
  61360. /** Gets or sets current value */
  61361. value: number;
  61362. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  61363. isVertical: boolean;
  61364. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  61365. isThumbClamped: boolean;
  61366. /**
  61367. * Creates a new BaseSlider
  61368. * @param name defines the control name
  61369. */
  61370. constructor(name?: string | undefined);
  61371. protected _getTypeName(): string;
  61372. protected _getThumbPosition(): number;
  61373. protected _getThumbThickness(type: string): number;
  61374. protected _prepareRenderingData(type: string): void;
  61375. private _pointerIsDown;
  61376. /** @hidden */
  61377. protected _updateValueFromPointer(x: number, y: number): void;
  61378. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  61379. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  61380. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  61381. }
  61382. }
  61383. declare module BABYLON.GUI {
  61384. /**
  61385. * Class used to create slider controls
  61386. */
  61387. export class Slider extends BaseSlider {
  61388. name?: string | undefined;
  61389. private _background;
  61390. private _borderColor;
  61391. private _isThumbCircle;
  61392. protected _displayValueBar: boolean;
  61393. /** Gets or sets a boolean indicating if the value bar must be rendered */
  61394. displayValueBar: boolean;
  61395. /** Gets or sets border color */
  61396. borderColor: string;
  61397. /** Gets or sets background color */
  61398. background: string;
  61399. /** Gets or sets a boolean indicating if the thumb should be round or square */
  61400. isThumbCircle: boolean;
  61401. /**
  61402. * Creates a new Slider
  61403. * @param name defines the control name
  61404. */
  61405. constructor(name?: string | undefined);
  61406. protected _getTypeName(): string;
  61407. _draw(context: CanvasRenderingContext2D): void;
  61408. }
  61409. }
  61410. declare module BABYLON.GUI {
  61411. /** Class used to create a RadioGroup
  61412. * which contains groups of radio buttons
  61413. */
  61414. export class SelectorGroup {
  61415. /** name of SelectorGroup */
  61416. name: string;
  61417. private _groupPanel;
  61418. private _selectors;
  61419. private _groupHeader;
  61420. /**
  61421. * Creates a new SelectorGroup
  61422. * @param name of group, used as a group heading
  61423. */
  61424. constructor(
  61425. /** name of SelectorGroup */
  61426. name: string);
  61427. /** Gets the groupPanel of the SelectorGroup */
  61428. readonly groupPanel: StackPanel;
  61429. /** Gets the selectors array */
  61430. readonly selectors: StackPanel[];
  61431. /** Gets and sets the group header */
  61432. header: string;
  61433. /** @hidden */
  61434. private _addGroupHeader;
  61435. /** @hidden*/
  61436. _getSelector(selectorNb: number): StackPanel | undefined;
  61437. /** Removes the selector at the given position
  61438. * @param selectorNb the position of the selector within the group
  61439. */
  61440. removeSelector(selectorNb: number): void;
  61441. }
  61442. /** Class used to create a CheckboxGroup
  61443. * which contains groups of checkbox buttons
  61444. */
  61445. export class CheckboxGroup extends SelectorGroup {
  61446. /** Adds a checkbox as a control
  61447. * @param text is the label for the selector
  61448. * @param func is the function called when the Selector is checked
  61449. * @param checked is true when Selector is checked
  61450. */
  61451. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  61452. /** @hidden */
  61453. _setSelectorLabel(selectorNb: number, label: string): void;
  61454. /** @hidden */
  61455. _setSelectorLabelColor(selectorNb: number, color: string): void;
  61456. /** @hidden */
  61457. _setSelectorButtonColor(selectorNb: number, color: string): void;
  61458. /** @hidden */
  61459. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  61460. }
  61461. /** Class used to create a RadioGroup
  61462. * which contains groups of radio buttons
  61463. */
  61464. export class RadioGroup extends SelectorGroup {
  61465. private _selectNb;
  61466. /** Adds a radio button as a control
  61467. * @param label is the label for the selector
  61468. * @param func is the function called when the Selector is checked
  61469. * @param checked is true when Selector is checked
  61470. */
  61471. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  61472. /** @hidden */
  61473. _setSelectorLabel(selectorNb: number, label: string): void;
  61474. /** @hidden */
  61475. _setSelectorLabelColor(selectorNb: number, color: string): void;
  61476. /** @hidden */
  61477. _setSelectorButtonColor(selectorNb: number, color: string): void;
  61478. /** @hidden */
  61479. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  61480. }
  61481. /** Class used to create a SliderGroup
  61482. * which contains groups of slider buttons
  61483. */
  61484. export class SliderGroup extends SelectorGroup {
  61485. /**
  61486. * Adds a slider to the SelectorGroup
  61487. * @param label is the label for the SliderBar
  61488. * @param func is the function called when the Slider moves
  61489. * @param unit is a string describing the units used, eg degrees or metres
  61490. * @param min is the minimum value for the Slider
  61491. * @param max is the maximum value for the Slider
  61492. * @param value is the start value for the Slider between min and max
  61493. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  61494. */
  61495. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  61496. /** @hidden */
  61497. _setSelectorLabel(selectorNb: number, label: string): void;
  61498. /** @hidden */
  61499. _setSelectorLabelColor(selectorNb: number, color: string): void;
  61500. /** @hidden */
  61501. _setSelectorButtonColor(selectorNb: number, color: string): void;
  61502. /** @hidden */
  61503. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  61504. }
  61505. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  61506. * @see http://doc.babylonjs.com/how_to/selector
  61507. */
  61508. export class SelectionPanel extends Rectangle {
  61509. /** name of SelectionPanel */
  61510. name: string;
  61511. /** an array of SelectionGroups */
  61512. groups: SelectorGroup[];
  61513. private _panel;
  61514. private _buttonColor;
  61515. private _buttonBackground;
  61516. private _headerColor;
  61517. private _barColor;
  61518. private _barHeight;
  61519. private _spacerHeight;
  61520. private _labelColor;
  61521. private _groups;
  61522. private _bars;
  61523. /**
  61524. * Creates a new SelectionPanel
  61525. * @param name of SelectionPanel
  61526. * @param groups is an array of SelectionGroups
  61527. */
  61528. constructor(
  61529. /** name of SelectionPanel */
  61530. name: string,
  61531. /** an array of SelectionGroups */
  61532. groups?: SelectorGroup[]);
  61533. protected _getTypeName(): string;
  61534. /** Gets or sets the headerColor */
  61535. headerColor: string;
  61536. private _setHeaderColor;
  61537. /** Gets or sets the button color */
  61538. buttonColor: string;
  61539. private _setbuttonColor;
  61540. /** Gets or sets the label color */
  61541. labelColor: string;
  61542. private _setLabelColor;
  61543. /** Gets or sets the button background */
  61544. buttonBackground: string;
  61545. private _setButtonBackground;
  61546. /** Gets or sets the color of separator bar */
  61547. barColor: string;
  61548. private _setBarColor;
  61549. /** Gets or sets the height of separator bar */
  61550. barHeight: string;
  61551. private _setBarHeight;
  61552. /** Gets or sets the height of spacers*/
  61553. spacerHeight: string;
  61554. private _setSpacerHeight;
  61555. /** Adds a bar between groups */
  61556. private _addSpacer;
  61557. /** Add a group to the selection panel
  61558. * @param group is the selector group to add
  61559. */
  61560. addGroup(group: SelectorGroup): void;
  61561. /** Remove the group from the given position
  61562. * @param groupNb is the position of the group in the list
  61563. */
  61564. removeGroup(groupNb: number): void;
  61565. /** Change a group header label
  61566. * @param label is the new group header label
  61567. * @param groupNb is the number of the group to relabel
  61568. * */
  61569. setHeaderName(label: string, groupNb: number): void;
  61570. /** Change selector label to the one given
  61571. * @param label is the new selector label
  61572. * @param groupNb is the number of the groupcontaining the selector
  61573. * @param selectorNb is the number of the selector within a group to relabel
  61574. * */
  61575. relabel(label: string, groupNb: number, selectorNb: number): void;
  61576. /** For a given group position remove the selector at the given position
  61577. * @param groupNb is the number of the group to remove the selector from
  61578. * @param selectorNb is the number of the selector within the group
  61579. */
  61580. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  61581. /** For a given group position of correct type add a checkbox button
  61582. * @param groupNb is the number of the group to remove the selector from
  61583. * @param label is the label for the selector
  61584. * @param func is the function called when the Selector is checked
  61585. * @param checked is true when Selector is checked
  61586. */
  61587. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  61588. /** For a given group position of correct type add a radio button
  61589. * @param groupNb is the number of the group to remove the selector from
  61590. * @param label is the label for the selector
  61591. * @param func is the function called when the Selector is checked
  61592. * @param checked is true when Selector is checked
  61593. */
  61594. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  61595. /**
  61596. * For a given slider group add a slider
  61597. * @param groupNb is the number of the group to add the slider to
  61598. * @param label is the label for the Slider
  61599. * @param func is the function called when the Slider moves
  61600. * @param unit is a string describing the units used, eg degrees or metres
  61601. * @param min is the minimum value for the Slider
  61602. * @param max is the maximum value for the Slider
  61603. * @param value is the start value for the Slider between min and max
  61604. * @param onVal is the function used to format the value displayed, eg radians to degrees
  61605. */
  61606. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  61607. }
  61608. }
  61609. declare module BABYLON.GUI {
  61610. /**
  61611. * Class used to hold a the container for ScrollViewer
  61612. * @hidden
  61613. */
  61614. export class _ScrollViewerWindow extends Container {
  61615. parentClientWidth: number;
  61616. parentClientHeight: number;
  61617. /**
  61618. * Creates a new ScrollViewerWindow
  61619. * @param name of ScrollViewerWindow
  61620. */
  61621. constructor(name?: string);
  61622. protected _getTypeName(): string;
  61623. /** @hidden */
  61624. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61625. protected _postMeasure(): void;
  61626. }
  61627. }
  61628. declare module BABYLON.GUI {
  61629. /**
  61630. * Class used to create slider controls
  61631. */
  61632. export class ScrollBar extends BaseSlider {
  61633. name?: string | undefined;
  61634. private _background;
  61635. private _borderColor;
  61636. private _thumbMeasure;
  61637. /** Gets or sets border color */
  61638. borderColor: string;
  61639. /** Gets or sets background color */
  61640. background: string;
  61641. /**
  61642. * Creates a new Slider
  61643. * @param name defines the control name
  61644. */
  61645. constructor(name?: string | undefined);
  61646. protected _getTypeName(): string;
  61647. protected _getThumbThickness(): number;
  61648. _draw(context: CanvasRenderingContext2D): void;
  61649. private _first;
  61650. private _originX;
  61651. private _originY;
  61652. /** @hidden */
  61653. protected _updateValueFromPointer(x: number, y: number): void;
  61654. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  61655. }
  61656. }
  61657. declare module BABYLON.GUI {
  61658. /**
  61659. * Class used to hold a viewer window and sliders in a grid
  61660. */
  61661. export class ScrollViewer extends Rectangle {
  61662. private _grid;
  61663. private _horizontalBarSpace;
  61664. private _verticalBarSpace;
  61665. private _dragSpace;
  61666. private _horizontalBar;
  61667. private _verticalBar;
  61668. private _barColor;
  61669. private _barBackground;
  61670. private _barSize;
  61671. private _endLeft;
  61672. private _endTop;
  61673. private _window;
  61674. private _pointerIsOver;
  61675. private _wheelPrecision;
  61676. private _onPointerObserver;
  61677. private _clientWidth;
  61678. private _clientHeight;
  61679. /**
  61680. * Gets the horizontal scrollbar
  61681. */
  61682. readonly horizontalBar: ScrollBar;
  61683. /**
  61684. * Gets the vertical scrollbar
  61685. */
  61686. readonly verticalBar: ScrollBar;
  61687. /**
  61688. * Adds a new control to the current container
  61689. * @param control defines the control to add
  61690. * @returns the current container
  61691. */
  61692. addControl(control: BABYLON.Nullable<Control>): Container;
  61693. /**
  61694. * Removes a control from the current container
  61695. * @param control defines the control to remove
  61696. * @returns the current container
  61697. */
  61698. removeControl(control: Control): Container;
  61699. /** Gets the list of children */
  61700. readonly children: Control[];
  61701. _flagDescendantsAsMatrixDirty(): void;
  61702. /**
  61703. * Creates a new ScrollViewer
  61704. * @param name of ScrollViewer
  61705. */
  61706. constructor(name?: string);
  61707. /** Reset the scroll viewer window to initial size */
  61708. resetWindow(): void;
  61709. protected _getTypeName(): string;
  61710. private _buildClientSizes;
  61711. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61712. protected _postMeasure(): void;
  61713. /**
  61714. * Gets or sets the mouse wheel precision
  61715. * from 0 to 1 with a default value of 0.05
  61716. * */
  61717. wheelPrecision: number;
  61718. /** Gets or sets the bar color */
  61719. barColor: string;
  61720. /** Gets or sets the size of the bar */
  61721. barSize: number;
  61722. /** Gets or sets the bar background */
  61723. barBackground: string;
  61724. /** @hidden */
  61725. private _updateScroller;
  61726. _link(host: AdvancedDynamicTexture): void;
  61727. /** @hidden */
  61728. private _attachWheel;
  61729. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  61730. /** Releases associated resources */
  61731. dispose(): void;
  61732. }
  61733. }
  61734. declare module BABYLON.GUI {
  61735. /** Class used to render a grid */
  61736. export class DisplayGrid extends Control {
  61737. name?: string | undefined;
  61738. private _cellWidth;
  61739. private _cellHeight;
  61740. private _minorLineTickness;
  61741. private _minorLineColor;
  61742. private _majorLineTickness;
  61743. private _majorLineColor;
  61744. private _majorLineFrequency;
  61745. private _background;
  61746. private _displayMajorLines;
  61747. private _displayMinorLines;
  61748. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  61749. displayMinorLines: boolean;
  61750. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  61751. displayMajorLines: boolean;
  61752. /** Gets or sets background color (Black by default) */
  61753. background: string;
  61754. /** Gets or sets the width of each cell (20 by default) */
  61755. cellWidth: number;
  61756. /** Gets or sets the height of each cell (20 by default) */
  61757. cellHeight: number;
  61758. /** Gets or sets the tickness of minor lines (1 by default) */
  61759. minorLineTickness: number;
  61760. /** Gets or sets the color of minor lines (DarkGray by default) */
  61761. minorLineColor: string;
  61762. /** Gets or sets the tickness of major lines (2 by default) */
  61763. majorLineTickness: number;
  61764. /** Gets or sets the color of major lines (White by default) */
  61765. majorLineColor: string;
  61766. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  61767. majorLineFrequency: number;
  61768. /**
  61769. * Creates a new GridDisplayRectangle
  61770. * @param name defines the control name
  61771. */
  61772. constructor(name?: string | undefined);
  61773. _draw(context: CanvasRenderingContext2D): void;
  61774. protected _getTypeName(): string;
  61775. }
  61776. }
  61777. declare module BABYLON.GUI {
  61778. /**
  61779. * Class used to create slider controls based on images
  61780. */
  61781. export class ImageBasedSlider extends BaseSlider {
  61782. name?: string | undefined;
  61783. private _backgroundImage;
  61784. private _thumbImage;
  61785. private _valueBarImage;
  61786. private _tempMeasure;
  61787. displayThumb: boolean;
  61788. /**
  61789. * Gets or sets the image used to render the background
  61790. */
  61791. backgroundImage: Image;
  61792. /**
  61793. * Gets or sets the image used to render the value bar
  61794. */
  61795. valueBarImage: Image;
  61796. /**
  61797. * Gets or sets the image used to render the thumb
  61798. */
  61799. thumbImage: Image;
  61800. /**
  61801. * Creates a new ImageBasedSlider
  61802. * @param name defines the control name
  61803. */
  61804. constructor(name?: string | undefined);
  61805. protected _getTypeName(): string;
  61806. _draw(context: CanvasRenderingContext2D): void;
  61807. }
  61808. }
  61809. declare module BABYLON.GUI {
  61810. /**
  61811. * Forcing an export so that this code will execute
  61812. * @hidden
  61813. */
  61814. const name = "Statics";
  61815. }
  61816. declare module BABYLON.GUI {
  61817. /**
  61818. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  61819. */
  61820. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  61821. /**
  61822. * Define the instrumented AdvancedDynamicTexture.
  61823. */
  61824. texture: AdvancedDynamicTexture;
  61825. private _captureRenderTime;
  61826. private _renderTime;
  61827. private _captureLayoutTime;
  61828. private _layoutTime;
  61829. private _onBeginRenderObserver;
  61830. private _onEndRenderObserver;
  61831. private _onBeginLayoutObserver;
  61832. private _onEndLayoutObserver;
  61833. /**
  61834. * Gets the perf counter used to capture render time
  61835. */
  61836. readonly renderTimeCounter: BABYLON.PerfCounter;
  61837. /**
  61838. * Gets the perf counter used to capture layout time
  61839. */
  61840. readonly layoutTimeCounter: BABYLON.PerfCounter;
  61841. /**
  61842. * Enable or disable the render time capture
  61843. */
  61844. captureRenderTime: boolean;
  61845. /**
  61846. * Enable or disable the layout time capture
  61847. */
  61848. captureLayoutTime: boolean;
  61849. /**
  61850. * Instantiates a new advanced dynamic texture instrumentation.
  61851. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  61852. * @param texture Defines the AdvancedDynamicTexture to instrument
  61853. */
  61854. constructor(
  61855. /**
  61856. * Define the instrumented AdvancedDynamicTexture.
  61857. */
  61858. texture: AdvancedDynamicTexture);
  61859. /**
  61860. * Dispose and release associated resources.
  61861. */
  61862. dispose(): void;
  61863. }
  61864. }
  61865. declare module BABYLON.GUI {
  61866. /**
  61867. * Class used to create containers for controls
  61868. */
  61869. export class Container3D extends Control3D {
  61870. private _blockLayout;
  61871. /**
  61872. * Gets the list of child controls
  61873. */
  61874. protected _children: Control3D[];
  61875. /**
  61876. * Gets the list of child controls
  61877. */
  61878. readonly children: Array<Control3D>;
  61879. /**
  61880. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  61881. * This is helpful to optimize layout operation when adding multiple children in a row
  61882. */
  61883. blockLayout: boolean;
  61884. /**
  61885. * Creates a new container
  61886. * @param name defines the container name
  61887. */
  61888. constructor(name?: string);
  61889. /**
  61890. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  61891. * @returns the current container
  61892. */
  61893. updateLayout(): Container3D;
  61894. /**
  61895. * Gets a boolean indicating if the given control is in the children of this control
  61896. * @param control defines the control to check
  61897. * @returns true if the control is in the child list
  61898. */
  61899. containsControl(control: Control3D): boolean;
  61900. /**
  61901. * Adds a control to the children of this control
  61902. * @param control defines the control to add
  61903. * @returns the current container
  61904. */
  61905. addControl(control: Control3D): Container3D;
  61906. /**
  61907. * This function will be called everytime a new control is added
  61908. */
  61909. protected _arrangeChildren(): void;
  61910. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  61911. /**
  61912. * Removes a control from the children of this control
  61913. * @param control defines the control to remove
  61914. * @returns the current container
  61915. */
  61916. removeControl(control: Control3D): Container3D;
  61917. protected _getTypeName(): string;
  61918. /**
  61919. * Releases all associated resources
  61920. */
  61921. dispose(): void;
  61922. /** Control rotation will remain unchanged */
  61923. static readonly UNSET_ORIENTATION: number;
  61924. /** Control will rotate to make it look at sphere central axis */
  61925. static readonly FACEORIGIN_ORIENTATION: number;
  61926. /** Control will rotate to make it look back at sphere central axis */
  61927. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  61928. /** Control will rotate to look at z axis (0, 0, 1) */
  61929. static readonly FACEFORWARD_ORIENTATION: number;
  61930. /** Control will rotate to look at negative z axis (0, 0, -1) */
  61931. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  61932. }
  61933. }
  61934. declare module BABYLON.GUI {
  61935. /**
  61936. * Class used to manage 3D user interface
  61937. * @see http://doc.babylonjs.com/how_to/gui3d
  61938. */
  61939. export class GUI3DManager implements BABYLON.IDisposable {
  61940. private _scene;
  61941. private _sceneDisposeObserver;
  61942. private _utilityLayer;
  61943. private _rootContainer;
  61944. private _pointerObserver;
  61945. private _pointerOutObserver;
  61946. /** @hidden */
  61947. _lastPickedControl: Control3D;
  61948. /** @hidden */
  61949. _lastControlOver: {
  61950. [pointerId: number]: Control3D;
  61951. };
  61952. /** @hidden */
  61953. _lastControlDown: {
  61954. [pointerId: number]: Control3D;
  61955. };
  61956. /**
  61957. * BABYLON.Observable raised when the point picked by the pointer events changed
  61958. */
  61959. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  61960. /** @hidden */
  61961. _sharedMaterials: {
  61962. [key: string]: BABYLON.Material;
  61963. };
  61964. /** Gets the hosting scene */
  61965. readonly scene: BABYLON.Scene;
  61966. /** Gets associated utility layer */
  61967. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  61968. /**
  61969. * Creates a new GUI3DManager
  61970. * @param scene
  61971. */
  61972. constructor(scene?: BABYLON.Scene);
  61973. private _handlePointerOut;
  61974. private _doPicking;
  61975. /**
  61976. * Gets the root container
  61977. */
  61978. readonly rootContainer: Container3D;
  61979. /**
  61980. * Gets a boolean indicating if the given control is in the root child list
  61981. * @param control defines the control to check
  61982. * @returns true if the control is in the root child list
  61983. */
  61984. containsControl(control: Control3D): boolean;
  61985. /**
  61986. * Adds a control to the root child list
  61987. * @param control defines the control to add
  61988. * @returns the current manager
  61989. */
  61990. addControl(control: Control3D): GUI3DManager;
  61991. /**
  61992. * Removes a control from the root child list
  61993. * @param control defines the control to remove
  61994. * @returns the current container
  61995. */
  61996. removeControl(control: Control3D): GUI3DManager;
  61997. /**
  61998. * Releases all associated resources
  61999. */
  62000. dispose(): void;
  62001. }
  62002. }
  62003. declare module BABYLON.GUI {
  62004. /**
  62005. * Class used to transport BABYLON.Vector3 information for pointer events
  62006. */
  62007. export class Vector3WithInfo extends BABYLON.Vector3 {
  62008. /** defines the current mouse button index */
  62009. buttonIndex: number;
  62010. /**
  62011. * Creates a new Vector3WithInfo
  62012. * @param source defines the vector3 data to transport
  62013. * @param buttonIndex defines the current mouse button index
  62014. */
  62015. constructor(source: BABYLON.Vector3,
  62016. /** defines the current mouse button index */
  62017. buttonIndex?: number);
  62018. }
  62019. }
  62020. declare module BABYLON.GUI {
  62021. /**
  62022. * Class used as base class for controls
  62023. */
  62024. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  62025. /** Defines the control name */
  62026. name?: string | undefined;
  62027. /** @hidden */
  62028. _host: GUI3DManager;
  62029. private _node;
  62030. private _downCount;
  62031. private _enterCount;
  62032. private _downPointerIds;
  62033. private _isVisible;
  62034. /** Gets or sets the control position in world space */
  62035. position: BABYLON.Vector3;
  62036. /** Gets or sets the control scaling in world space */
  62037. scaling: BABYLON.Vector3;
  62038. /** Callback used to start pointer enter animation */
  62039. pointerEnterAnimation: () => void;
  62040. /** Callback used to start pointer out animation */
  62041. pointerOutAnimation: () => void;
  62042. /** Callback used to start pointer down animation */
  62043. pointerDownAnimation: () => void;
  62044. /** Callback used to start pointer up animation */
  62045. pointerUpAnimation: () => void;
  62046. /**
  62047. * An event triggered when the pointer move over the control
  62048. */
  62049. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  62050. /**
  62051. * An event triggered when the pointer move out of the control
  62052. */
  62053. onPointerOutObservable: BABYLON.Observable<Control3D>;
  62054. /**
  62055. * An event triggered when the pointer taps the control
  62056. */
  62057. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  62058. /**
  62059. * An event triggered when pointer is up
  62060. */
  62061. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  62062. /**
  62063. * An event triggered when a control is clicked on (with a mouse)
  62064. */
  62065. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  62066. /**
  62067. * An event triggered when pointer enters the control
  62068. */
  62069. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  62070. /**
  62071. * Gets or sets the parent container
  62072. */
  62073. parent: BABYLON.Nullable<Container3D>;
  62074. private _behaviors;
  62075. /**
  62076. * Gets the list of attached behaviors
  62077. * @see http://doc.babylonjs.com/features/behaviour
  62078. */
  62079. readonly behaviors: BABYLON.Behavior<Control3D>[];
  62080. /**
  62081. * Attach a behavior to the control
  62082. * @see http://doc.babylonjs.com/features/behaviour
  62083. * @param behavior defines the behavior to attach
  62084. * @returns the current control
  62085. */
  62086. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  62087. /**
  62088. * Remove an attached behavior
  62089. * @see http://doc.babylonjs.com/features/behaviour
  62090. * @param behavior defines the behavior to attach
  62091. * @returns the current control
  62092. */
  62093. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  62094. /**
  62095. * Gets an attached behavior by name
  62096. * @param name defines the name of the behavior to look for
  62097. * @see http://doc.babylonjs.com/features/behaviour
  62098. * @returns null if behavior was not found else the requested behavior
  62099. */
  62100. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  62101. /** Gets or sets a boolean indicating if the control is visible */
  62102. isVisible: boolean;
  62103. /**
  62104. * Creates a new control
  62105. * @param name defines the control name
  62106. */
  62107. constructor(
  62108. /** Defines the control name */
  62109. name?: string | undefined);
  62110. /**
  62111. * Gets a string representing the class name
  62112. */
  62113. readonly typeName: string;
  62114. /**
  62115. * Get the current class name of the control.
  62116. * @returns current class name
  62117. */
  62118. getClassName(): string;
  62119. protected _getTypeName(): string;
  62120. /**
  62121. * Gets the transform node used by this control
  62122. */
  62123. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  62124. /**
  62125. * Gets the mesh used to render this control
  62126. */
  62127. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  62128. /**
  62129. * Link the control as child of the given node
  62130. * @param node defines the node to link to. Use null to unlink the control
  62131. * @returns the current control
  62132. */
  62133. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  62134. /** @hidden **/
  62135. _prepareNode(scene: BABYLON.Scene): void;
  62136. /**
  62137. * Node creation.
  62138. * Can be overriden by children
  62139. * @param scene defines the scene where the node must be attached
  62140. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  62141. */
  62142. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  62143. /**
  62144. * Affect a material to the given mesh
  62145. * @param mesh defines the mesh which will represent the control
  62146. */
  62147. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  62148. /** @hidden */
  62149. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  62150. /** @hidden */
  62151. _onPointerEnter(target: Control3D): boolean;
  62152. /** @hidden */
  62153. _onPointerOut(target: Control3D): void;
  62154. /** @hidden */
  62155. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  62156. /** @hidden */
  62157. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  62158. /** @hidden */
  62159. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  62160. /** @hidden */
  62161. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  62162. /** @hidden */
  62163. _disposeNode(): void;
  62164. /**
  62165. * Releases all associated resources
  62166. */
  62167. dispose(): void;
  62168. }
  62169. }
  62170. declare module BABYLON.GUI {
  62171. /**
  62172. * Class used as a root to all buttons
  62173. */
  62174. export class AbstractButton3D extends Control3D {
  62175. /**
  62176. * Creates a new button
  62177. * @param name defines the control name
  62178. */
  62179. constructor(name?: string);
  62180. protected _getTypeName(): string;
  62181. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  62182. }
  62183. }
  62184. declare module BABYLON.GUI {
  62185. /**
  62186. * Class used to create a button in 3D
  62187. */
  62188. export class Button3D extends AbstractButton3D {
  62189. /** @hidden */
  62190. protected _currentMaterial: BABYLON.Material;
  62191. private _facadeTexture;
  62192. private _content;
  62193. private _contentResolution;
  62194. private _contentScaleRatio;
  62195. /**
  62196. * Gets or sets the texture resolution used to render content (512 by default)
  62197. */
  62198. contentResolution: BABYLON.int;
  62199. /**
  62200. * Gets or sets the texture scale ratio used to render content (2 by default)
  62201. */
  62202. contentScaleRatio: number;
  62203. protected _disposeFacadeTexture(): void;
  62204. protected _resetContent(): void;
  62205. /**
  62206. * Creates a new button
  62207. * @param name defines the control name
  62208. */
  62209. constructor(name?: string);
  62210. /**
  62211. * Gets or sets the GUI 2D content used to display the button's facade
  62212. */
  62213. content: Control;
  62214. /**
  62215. * Apply the facade texture (created from the content property).
  62216. * This function can be overloaded by child classes
  62217. * @param facadeTexture defines the AdvancedDynamicTexture to use
  62218. */
  62219. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  62220. protected _getTypeName(): string;
  62221. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  62222. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  62223. /**
  62224. * Releases all associated resources
  62225. */
  62226. dispose(): void;
  62227. }
  62228. }
  62229. declare module BABYLON.GUI {
  62230. /**
  62231. * Abstract class used to create a container panel deployed on the surface of a volume
  62232. */
  62233. export abstract class VolumeBasedPanel extends Container3D {
  62234. private _columns;
  62235. private _rows;
  62236. private _rowThenColum;
  62237. private _orientation;
  62238. protected _cellWidth: number;
  62239. protected _cellHeight: number;
  62240. /**
  62241. * Gets or sets the distance between elements
  62242. */
  62243. margin: number;
  62244. /**
  62245. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  62246. * | Value | Type | Description |
  62247. * | ----- | ----------------------------------- | ----------- |
  62248. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  62249. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  62250. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  62251. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  62252. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  62253. */
  62254. orientation: number;
  62255. /**
  62256. * Gets or sets the number of columns requested (10 by default).
  62257. * The panel will automatically compute the number of rows based on number of child controls.
  62258. */
  62259. columns: BABYLON.int;
  62260. /**
  62261. * Gets or sets a the number of rows requested.
  62262. * The panel will automatically compute the number of columns based on number of child controls.
  62263. */
  62264. rows: BABYLON.int;
  62265. /**
  62266. * Creates new VolumeBasedPanel
  62267. */
  62268. constructor();
  62269. protected _arrangeChildren(): void;
  62270. /** Child classes must implement this function to provide correct control positioning */
  62271. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  62272. /** Child classes can implement this function to provide additional processing */
  62273. protected _finalProcessing(): void;
  62274. }
  62275. }
  62276. declare module BABYLON.GUI {
  62277. /**
  62278. * Class used to create a container panel deployed on the surface of a cylinder
  62279. */
  62280. export class CylinderPanel extends VolumeBasedPanel {
  62281. private _radius;
  62282. /**
  62283. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  62284. */
  62285. radius: BABYLON.float;
  62286. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  62287. private _cylindricalMapping;
  62288. }
  62289. }
  62290. declare module BABYLON.GUI {
  62291. /** @hidden */
  62292. export var fluentVertexShader: {
  62293. name: string;
  62294. shader: string;
  62295. };
  62296. }
  62297. declare module BABYLON.GUI {
  62298. /** @hidden */
  62299. export var fluentPixelShader: {
  62300. name: string;
  62301. shader: string;
  62302. };
  62303. }
  62304. declare module BABYLON.GUI {
  62305. /** @hidden */
  62306. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  62307. INNERGLOW: boolean;
  62308. BORDER: boolean;
  62309. HOVERLIGHT: boolean;
  62310. TEXTURE: boolean;
  62311. constructor();
  62312. }
  62313. /**
  62314. * Class used to render controls with fluent desgin
  62315. */
  62316. export class FluentMaterial extends BABYLON.PushMaterial {
  62317. /**
  62318. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  62319. */
  62320. innerGlowColorIntensity: number;
  62321. /**
  62322. * Gets or sets the inner glow color (white by default)
  62323. */
  62324. innerGlowColor: BABYLON.Color3;
  62325. /**
  62326. * Gets or sets alpha value (default is 1.0)
  62327. */
  62328. alpha: number;
  62329. /**
  62330. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  62331. */
  62332. albedoColor: BABYLON.Color3;
  62333. /**
  62334. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  62335. */
  62336. renderBorders: boolean;
  62337. /**
  62338. * Gets or sets border width (default is 0.5)
  62339. */
  62340. borderWidth: number;
  62341. /**
  62342. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  62343. */
  62344. edgeSmoothingValue: number;
  62345. /**
  62346. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  62347. */
  62348. borderMinValue: number;
  62349. /**
  62350. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  62351. */
  62352. renderHoverLight: boolean;
  62353. /**
  62354. * Gets or sets the radius used to render the hover light (default is 1.0)
  62355. */
  62356. hoverRadius: number;
  62357. /**
  62358. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  62359. */
  62360. hoverColor: BABYLON.Color4;
  62361. /**
  62362. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  62363. */
  62364. hoverPosition: BABYLON.Vector3;
  62365. private _albedoTexture;
  62366. /** Gets or sets the texture to use for albedo color */
  62367. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  62368. /**
  62369. * Creates a new Fluent material
  62370. * @param name defines the name of the material
  62371. * @param scene defines the hosting scene
  62372. */
  62373. constructor(name: string, scene: BABYLON.Scene);
  62374. needAlphaBlending(): boolean;
  62375. needAlphaTesting(): boolean;
  62376. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  62377. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  62378. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  62379. getActiveTextures(): BABYLON.BaseTexture[];
  62380. hasTexture(texture: BABYLON.BaseTexture): boolean;
  62381. dispose(forceDisposeEffect?: boolean): void;
  62382. clone(name: string): FluentMaterial;
  62383. serialize(): any;
  62384. getClassName(): string;
  62385. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  62386. }
  62387. }
  62388. declare module BABYLON.GUI {
  62389. /**
  62390. * Class used to create a holographic button in 3D
  62391. */
  62392. export class HolographicButton extends Button3D {
  62393. private _backPlate;
  62394. private _textPlate;
  62395. private _frontPlate;
  62396. private _text;
  62397. private _imageUrl;
  62398. private _shareMaterials;
  62399. private _frontMaterial;
  62400. private _backMaterial;
  62401. private _plateMaterial;
  62402. private _pickedPointObserver;
  62403. private _tooltipFade;
  62404. private _tooltipTextBlock;
  62405. private _tooltipTexture;
  62406. private _tooltipMesh;
  62407. private _tooltipHoverObserver;
  62408. private _tooltipOutObserver;
  62409. private _disposeTooltip;
  62410. /**
  62411. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  62412. */
  62413. tooltipText: BABYLON.Nullable<string>;
  62414. /**
  62415. * Gets or sets text for the button
  62416. */
  62417. text: string;
  62418. /**
  62419. * Gets or sets the image url for the button
  62420. */
  62421. imageUrl: string;
  62422. /**
  62423. * Gets the back material used by this button
  62424. */
  62425. readonly backMaterial: FluentMaterial;
  62426. /**
  62427. * Gets the front material used by this button
  62428. */
  62429. readonly frontMaterial: FluentMaterial;
  62430. /**
  62431. * Gets the plate material used by this button
  62432. */
  62433. readonly plateMaterial: BABYLON.StandardMaterial;
  62434. /**
  62435. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  62436. */
  62437. readonly shareMaterials: boolean;
  62438. /**
  62439. * Creates a new button
  62440. * @param name defines the control name
  62441. */
  62442. constructor(name?: string, shareMaterials?: boolean);
  62443. protected _getTypeName(): string;
  62444. private _rebuildContent;
  62445. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  62446. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  62447. private _createBackMaterial;
  62448. private _createFrontMaterial;
  62449. private _createPlateMaterial;
  62450. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  62451. /**
  62452. * Releases all associated resources
  62453. */
  62454. dispose(): void;
  62455. }
  62456. }
  62457. declare module BABYLON.GUI {
  62458. /**
  62459. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  62460. */
  62461. export class MeshButton3D extends Button3D {
  62462. /** @hidden */
  62463. protected _currentMesh: BABYLON.Mesh;
  62464. /**
  62465. * Creates a new 3D button based on a mesh
  62466. * @param mesh mesh to become a 3D button
  62467. * @param name defines the control name
  62468. */
  62469. constructor(mesh: BABYLON.Mesh, name?: string);
  62470. protected _getTypeName(): string;
  62471. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  62472. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  62473. }
  62474. }
  62475. declare module BABYLON.GUI {
  62476. /**
  62477. * Class used to create a container panel deployed on the surface of a plane
  62478. */
  62479. export class PlanePanel extends VolumeBasedPanel {
  62480. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  62481. }
  62482. }
  62483. declare module BABYLON.GUI {
  62484. /**
  62485. * Class used to create a container panel where items get randomized planar mapping
  62486. */
  62487. export class ScatterPanel extends VolumeBasedPanel {
  62488. private _iteration;
  62489. /**
  62490. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  62491. */
  62492. iteration: BABYLON.float;
  62493. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  62494. private _scatterMapping;
  62495. protected _finalProcessing(): void;
  62496. }
  62497. }
  62498. declare module BABYLON.GUI {
  62499. /**
  62500. * Class used to create a container panel deployed on the surface of a sphere
  62501. */
  62502. export class SpherePanel extends VolumeBasedPanel {
  62503. private _radius;
  62504. /**
  62505. * Gets or sets the radius of the sphere where to project controls (5 by default)
  62506. */
  62507. radius: BABYLON.float;
  62508. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  62509. private _sphericalMapping;
  62510. }
  62511. }
  62512. declare module BABYLON.GUI {
  62513. /**
  62514. * Class used to create a stack panel in 3D on XY plane
  62515. */
  62516. export class StackPanel3D extends Container3D {
  62517. private _isVertical;
  62518. /**
  62519. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  62520. */
  62521. isVertical: boolean;
  62522. /**
  62523. * Gets or sets the distance between elements
  62524. */
  62525. margin: number;
  62526. /**
  62527. * Creates new StackPanel
  62528. * @param isVertical
  62529. */
  62530. constructor(isVertical?: boolean);
  62531. protected _arrangeChildren(): void;
  62532. }
  62533. }
  62534. declare module BABYLON {
  62535. /**
  62536. * Mode that determines the coordinate system to use.
  62537. */
  62538. export enum GLTFLoaderCoordinateSystemMode {
  62539. /**
  62540. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  62541. */
  62542. AUTO = 0,
  62543. /**
  62544. * Sets the useRightHandedSystem flag on the scene.
  62545. */
  62546. FORCE_RIGHT_HANDED = 1
  62547. }
  62548. /**
  62549. * Mode that determines what animations will start.
  62550. */
  62551. export enum GLTFLoaderAnimationStartMode {
  62552. /**
  62553. * No animation will start.
  62554. */
  62555. NONE = 0,
  62556. /**
  62557. * The first animation will start.
  62558. */
  62559. FIRST = 1,
  62560. /**
  62561. * All animations will start.
  62562. */
  62563. ALL = 2
  62564. }
  62565. /**
  62566. * Interface that contains the data for the glTF asset.
  62567. */
  62568. export interface IGLTFLoaderData {
  62569. /**
  62570. * Object that represents the glTF JSON.
  62571. */
  62572. json: Object;
  62573. /**
  62574. * The BIN chunk of a binary glTF.
  62575. */
  62576. bin: Nullable<ArrayBufferView>;
  62577. }
  62578. /**
  62579. * Interface for extending the loader.
  62580. */
  62581. export interface IGLTFLoaderExtension {
  62582. /**
  62583. * The name of this extension.
  62584. */
  62585. readonly name: string;
  62586. /**
  62587. * Defines whether this extension is enabled.
  62588. */
  62589. enabled: boolean;
  62590. }
  62591. /**
  62592. * Loader state.
  62593. */
  62594. export enum GLTFLoaderState {
  62595. /**
  62596. * The asset is loading.
  62597. */
  62598. LOADING = 0,
  62599. /**
  62600. * The asset is ready for rendering.
  62601. */
  62602. READY = 1,
  62603. /**
  62604. * The asset is completely loaded.
  62605. */
  62606. COMPLETE = 2
  62607. }
  62608. /** @hidden */
  62609. export interface IGLTFLoader extends IDisposable {
  62610. readonly state: Nullable<GLTFLoaderState>;
  62611. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  62612. meshes: AbstractMesh[];
  62613. particleSystems: IParticleSystem[];
  62614. skeletons: Skeleton[];
  62615. animationGroups: AnimationGroup[];
  62616. }>;
  62617. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  62618. }
  62619. /**
  62620. * File loader for loading glTF files into a scene.
  62621. */
  62622. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  62623. /** @hidden */
  62624. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  62625. /** @hidden */
  62626. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  62627. /**
  62628. * Raised when the asset has been parsed
  62629. */
  62630. onParsedObservable: Observable<IGLTFLoaderData>;
  62631. private _onParsedObserver;
  62632. /**
  62633. * Raised when the asset has been parsed
  62634. */
  62635. onParsed: (loaderData: IGLTFLoaderData) => void;
  62636. /**
  62637. * 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.
  62638. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  62639. * Defaults to true.
  62640. * @hidden
  62641. */
  62642. static IncrementalLoading: boolean;
  62643. /**
  62644. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  62645. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  62646. * @hidden
  62647. */
  62648. static HomogeneousCoordinates: boolean;
  62649. /**
  62650. * The coordinate system mode. Defaults to AUTO.
  62651. */
  62652. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  62653. /**
  62654. * The animation start mode. Defaults to FIRST.
  62655. */
  62656. animationStartMode: GLTFLoaderAnimationStartMode;
  62657. /**
  62658. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  62659. */
  62660. compileMaterials: boolean;
  62661. /**
  62662. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  62663. */
  62664. useClipPlane: boolean;
  62665. /**
  62666. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  62667. */
  62668. compileShadowGenerators: boolean;
  62669. /**
  62670. * Defines if the Alpha blended materials are only applied as coverage.
  62671. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  62672. * If true, no extra effects are applied to transparent pixels.
  62673. */
  62674. transparencyAsCoverage: boolean;
  62675. /**
  62676. * Function called before loading a url referenced by the asset.
  62677. */
  62678. preprocessUrlAsync: (url: string) => Promise<string>;
  62679. /**
  62680. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  62681. */
  62682. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  62683. private _onMeshLoadedObserver;
  62684. /**
  62685. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  62686. */
  62687. onMeshLoaded: (mesh: AbstractMesh) => void;
  62688. /**
  62689. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  62690. */
  62691. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  62692. private _onTextureLoadedObserver;
  62693. /**
  62694. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  62695. */
  62696. onTextureLoaded: (texture: BaseTexture) => void;
  62697. /**
  62698. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  62699. */
  62700. readonly onMaterialLoadedObservable: Observable<Material>;
  62701. private _onMaterialLoadedObserver;
  62702. /**
  62703. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  62704. */
  62705. onMaterialLoaded: (material: Material) => void;
  62706. /**
  62707. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  62708. */
  62709. readonly onCameraLoadedObservable: Observable<Camera>;
  62710. private _onCameraLoadedObserver;
  62711. /**
  62712. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  62713. */
  62714. onCameraLoaded: (camera: Camera) => void;
  62715. /**
  62716. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  62717. * For assets with LODs, raised when all of the LODs are complete.
  62718. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  62719. */
  62720. readonly onCompleteObservable: Observable<void>;
  62721. private _onCompleteObserver;
  62722. /**
  62723. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  62724. * For assets with LODs, raised when all of the LODs are complete.
  62725. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  62726. */
  62727. onComplete: () => void;
  62728. /**
  62729. * Observable raised when an error occurs.
  62730. */
  62731. readonly onErrorObservable: Observable<any>;
  62732. private _onErrorObserver;
  62733. /**
  62734. * Callback raised when an error occurs.
  62735. */
  62736. onError: (reason: any) => void;
  62737. /**
  62738. * Observable raised after the loader is disposed.
  62739. */
  62740. readonly onDisposeObservable: Observable<void>;
  62741. private _onDisposeObserver;
  62742. /**
  62743. * Callback raised after the loader is disposed.
  62744. */
  62745. onDispose: () => void;
  62746. /**
  62747. * Observable raised after a loader extension is created.
  62748. * Set additional options for a loader extension in this event.
  62749. */
  62750. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  62751. private _onExtensionLoadedObserver;
  62752. /**
  62753. * Callback raised after a loader extension is created.
  62754. */
  62755. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  62756. /**
  62757. * Defines if the loader logging is enabled.
  62758. */
  62759. loggingEnabled: boolean;
  62760. /**
  62761. * Defines if the loader should capture performance counters.
  62762. */
  62763. capturePerformanceCounters: boolean;
  62764. /**
  62765. * Defines if the loader should validate the asset.
  62766. */
  62767. validate: boolean;
  62768. /**
  62769. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  62770. */
  62771. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  62772. private _onValidatedObserver;
  62773. /**
  62774. * Callback raised after a loader extension is created.
  62775. */
  62776. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  62777. private _loader;
  62778. /**
  62779. * Name of the loader ("gltf")
  62780. */
  62781. name: string;
  62782. /**
  62783. * Supported file extensions of the loader (.gltf, .glb)
  62784. */
  62785. extensions: ISceneLoaderPluginExtensions;
  62786. /**
  62787. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  62788. */
  62789. dispose(): void;
  62790. /** @hidden */
  62791. _clear(): void;
  62792. /**
  62793. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  62794. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  62795. * @param scene the scene the meshes should be added to
  62796. * @param data the glTF data to load
  62797. * @param rootUrl root url to load from
  62798. * @param onProgress event that fires when loading progress has occured
  62799. * @param fileName Defines the name of the file to load
  62800. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  62801. */
  62802. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  62803. meshes: AbstractMesh[];
  62804. particleSystems: IParticleSystem[];
  62805. skeletons: Skeleton[];
  62806. animationGroups: AnimationGroup[];
  62807. }>;
  62808. /**
  62809. * Imports all objects from the loaded glTF data and adds them to the scene
  62810. * @param scene the scene the objects should be added to
  62811. * @param data the glTF data to load
  62812. * @param rootUrl root url to load from
  62813. * @param onProgress event that fires when loading progress has occured
  62814. * @param fileName Defines the name of the file to load
  62815. * @returns a promise which completes when objects have been loaded to the scene
  62816. */
  62817. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  62818. /**
  62819. * Load into an asset container.
  62820. * @param scene The scene to load into
  62821. * @param data The data to import
  62822. * @param rootUrl The root url for scene and resources
  62823. * @param onProgress The callback when the load progresses
  62824. * @param fileName Defines the name of the file to load
  62825. * @returns The loaded asset container
  62826. */
  62827. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  62828. /**
  62829. * If the data string can be loaded directly.
  62830. * @param data string contianing the file data
  62831. * @returns if the data can be loaded directly
  62832. */
  62833. canDirectLoad(data: string): boolean;
  62834. /**
  62835. * Rewrites a url by combining a root url and response url.
  62836. */
  62837. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  62838. /**
  62839. * Instantiates a glTF file loader plugin.
  62840. * @returns the created plugin
  62841. */
  62842. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  62843. /**
  62844. * The loader state or null if the loader is not active.
  62845. */
  62846. readonly loaderState: Nullable<GLTFLoaderState>;
  62847. /**
  62848. * Returns a promise that resolves when the asset is completely loaded.
  62849. * @returns a promise that resolves when the asset is completely loaded.
  62850. */
  62851. whenCompleteAsync(): Promise<void>;
  62852. private _parseAsync;
  62853. private _validateAsync;
  62854. private _getLoader;
  62855. private _unpackBinary;
  62856. private _unpackBinaryV1;
  62857. private _unpackBinaryV2;
  62858. private static _parseVersion;
  62859. private static _compareVersion;
  62860. private static _decodeBufferToText;
  62861. private static readonly _logSpaces;
  62862. private _logIndentLevel;
  62863. private _loggingEnabled;
  62864. /** @hidden */
  62865. _log: (message: string) => void;
  62866. /** @hidden */
  62867. _logOpen(message: string): void;
  62868. /** @hidden */
  62869. _logClose(): void;
  62870. private _logEnabled;
  62871. private _logDisabled;
  62872. private _capturePerformanceCounters;
  62873. /** @hidden */
  62874. _startPerformanceCounter: (counterName: string) => void;
  62875. /** @hidden */
  62876. _endPerformanceCounter: (counterName: string) => void;
  62877. private _startPerformanceCounterEnabled;
  62878. private _startPerformanceCounterDisabled;
  62879. private _endPerformanceCounterEnabled;
  62880. private _endPerformanceCounterDisabled;
  62881. }
  62882. }
  62883. declare module BABYLON.GLTF1 {
  62884. /**
  62885. * Enums
  62886. * @hidden
  62887. */
  62888. export enum EComponentType {
  62889. BYTE = 5120,
  62890. UNSIGNED_BYTE = 5121,
  62891. SHORT = 5122,
  62892. UNSIGNED_SHORT = 5123,
  62893. FLOAT = 5126
  62894. }
  62895. /** @hidden */
  62896. export enum EShaderType {
  62897. FRAGMENT = 35632,
  62898. VERTEX = 35633
  62899. }
  62900. /** @hidden */
  62901. export enum EParameterType {
  62902. BYTE = 5120,
  62903. UNSIGNED_BYTE = 5121,
  62904. SHORT = 5122,
  62905. UNSIGNED_SHORT = 5123,
  62906. INT = 5124,
  62907. UNSIGNED_INT = 5125,
  62908. FLOAT = 5126,
  62909. FLOAT_VEC2 = 35664,
  62910. FLOAT_VEC3 = 35665,
  62911. FLOAT_VEC4 = 35666,
  62912. INT_VEC2 = 35667,
  62913. INT_VEC3 = 35668,
  62914. INT_VEC4 = 35669,
  62915. BOOL = 35670,
  62916. BOOL_VEC2 = 35671,
  62917. BOOL_VEC3 = 35672,
  62918. BOOL_VEC4 = 35673,
  62919. FLOAT_MAT2 = 35674,
  62920. FLOAT_MAT3 = 35675,
  62921. FLOAT_MAT4 = 35676,
  62922. SAMPLER_2D = 35678
  62923. }
  62924. /** @hidden */
  62925. export enum ETextureWrapMode {
  62926. CLAMP_TO_EDGE = 33071,
  62927. MIRRORED_REPEAT = 33648,
  62928. REPEAT = 10497
  62929. }
  62930. /** @hidden */
  62931. export enum ETextureFilterType {
  62932. NEAREST = 9728,
  62933. LINEAR = 9728,
  62934. NEAREST_MIPMAP_NEAREST = 9984,
  62935. LINEAR_MIPMAP_NEAREST = 9985,
  62936. NEAREST_MIPMAP_LINEAR = 9986,
  62937. LINEAR_MIPMAP_LINEAR = 9987
  62938. }
  62939. /** @hidden */
  62940. export enum ETextureFormat {
  62941. ALPHA = 6406,
  62942. RGB = 6407,
  62943. RGBA = 6408,
  62944. LUMINANCE = 6409,
  62945. LUMINANCE_ALPHA = 6410
  62946. }
  62947. /** @hidden */
  62948. export enum ECullingType {
  62949. FRONT = 1028,
  62950. BACK = 1029,
  62951. FRONT_AND_BACK = 1032
  62952. }
  62953. /** @hidden */
  62954. export enum EBlendingFunction {
  62955. ZERO = 0,
  62956. ONE = 1,
  62957. SRC_COLOR = 768,
  62958. ONE_MINUS_SRC_COLOR = 769,
  62959. DST_COLOR = 774,
  62960. ONE_MINUS_DST_COLOR = 775,
  62961. SRC_ALPHA = 770,
  62962. ONE_MINUS_SRC_ALPHA = 771,
  62963. DST_ALPHA = 772,
  62964. ONE_MINUS_DST_ALPHA = 773,
  62965. CONSTANT_COLOR = 32769,
  62966. ONE_MINUS_CONSTANT_COLOR = 32770,
  62967. CONSTANT_ALPHA = 32771,
  62968. ONE_MINUS_CONSTANT_ALPHA = 32772,
  62969. SRC_ALPHA_SATURATE = 776
  62970. }
  62971. /** @hidden */
  62972. export interface IGLTFProperty {
  62973. extensions?: {
  62974. [key: string]: any;
  62975. };
  62976. extras?: Object;
  62977. }
  62978. /** @hidden */
  62979. export interface IGLTFChildRootProperty extends IGLTFProperty {
  62980. name?: string;
  62981. }
  62982. /** @hidden */
  62983. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  62984. bufferView: string;
  62985. byteOffset: number;
  62986. byteStride: number;
  62987. count: number;
  62988. type: string;
  62989. componentType: EComponentType;
  62990. max?: number[];
  62991. min?: number[];
  62992. name?: string;
  62993. }
  62994. /** @hidden */
  62995. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  62996. buffer: string;
  62997. byteOffset: number;
  62998. byteLength: number;
  62999. byteStride: number;
  63000. target?: number;
  63001. }
  63002. /** @hidden */
  63003. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  63004. uri: string;
  63005. byteLength?: number;
  63006. type?: string;
  63007. }
  63008. /** @hidden */
  63009. export interface IGLTFShader extends IGLTFChildRootProperty {
  63010. uri: string;
  63011. type: EShaderType;
  63012. }
  63013. /** @hidden */
  63014. export interface IGLTFProgram extends IGLTFChildRootProperty {
  63015. attributes: string[];
  63016. fragmentShader: string;
  63017. vertexShader: string;
  63018. }
  63019. /** @hidden */
  63020. export interface IGLTFTechniqueParameter {
  63021. type: number;
  63022. count?: number;
  63023. semantic?: string;
  63024. node?: string;
  63025. value?: number | boolean | string | Array<any>;
  63026. source?: string;
  63027. babylonValue?: any;
  63028. }
  63029. /** @hidden */
  63030. export interface IGLTFTechniqueCommonProfile {
  63031. lightingModel: string;
  63032. texcoordBindings: Object;
  63033. parameters?: Array<any>;
  63034. }
  63035. /** @hidden */
  63036. export interface IGLTFTechniqueStatesFunctions {
  63037. blendColor?: number[];
  63038. blendEquationSeparate?: number[];
  63039. blendFuncSeparate?: number[];
  63040. colorMask: boolean[];
  63041. cullFace: number[];
  63042. }
  63043. /** @hidden */
  63044. export interface IGLTFTechniqueStates {
  63045. enable: number[];
  63046. functions: IGLTFTechniqueStatesFunctions;
  63047. }
  63048. /** @hidden */
  63049. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  63050. parameters: {
  63051. [key: string]: IGLTFTechniqueParameter;
  63052. };
  63053. program: string;
  63054. attributes: {
  63055. [key: string]: string;
  63056. };
  63057. uniforms: {
  63058. [key: string]: string;
  63059. };
  63060. states: IGLTFTechniqueStates;
  63061. }
  63062. /** @hidden */
  63063. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  63064. technique?: string;
  63065. values: string[];
  63066. }
  63067. /** @hidden */
  63068. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  63069. attributes: {
  63070. [key: string]: string;
  63071. };
  63072. indices: string;
  63073. material: string;
  63074. mode?: number;
  63075. }
  63076. /** @hidden */
  63077. export interface IGLTFMesh extends IGLTFChildRootProperty {
  63078. primitives: IGLTFMeshPrimitive[];
  63079. }
  63080. /** @hidden */
  63081. export interface IGLTFImage extends IGLTFChildRootProperty {
  63082. uri: string;
  63083. }
  63084. /** @hidden */
  63085. export interface IGLTFSampler extends IGLTFChildRootProperty {
  63086. magFilter?: number;
  63087. minFilter?: number;
  63088. wrapS?: number;
  63089. wrapT?: number;
  63090. }
  63091. /** @hidden */
  63092. export interface IGLTFTexture extends IGLTFChildRootProperty {
  63093. sampler: string;
  63094. source: string;
  63095. format?: ETextureFormat;
  63096. internalFormat?: ETextureFormat;
  63097. target?: number;
  63098. type?: number;
  63099. babylonTexture?: Texture;
  63100. }
  63101. /** @hidden */
  63102. export interface IGLTFAmbienLight {
  63103. color?: number[];
  63104. }
  63105. /** @hidden */
  63106. export interface IGLTFDirectionalLight {
  63107. color?: number[];
  63108. }
  63109. /** @hidden */
  63110. export interface IGLTFPointLight {
  63111. color?: number[];
  63112. constantAttenuation?: number;
  63113. linearAttenuation?: number;
  63114. quadraticAttenuation?: number;
  63115. }
  63116. /** @hidden */
  63117. export interface IGLTFSpotLight {
  63118. color?: number[];
  63119. constantAttenuation?: number;
  63120. fallOfAngle?: number;
  63121. fallOffExponent?: number;
  63122. linearAttenuation?: number;
  63123. quadraticAttenuation?: number;
  63124. }
  63125. /** @hidden */
  63126. export interface IGLTFLight extends IGLTFChildRootProperty {
  63127. type: string;
  63128. }
  63129. /** @hidden */
  63130. export interface IGLTFCameraOrthographic {
  63131. xmag: number;
  63132. ymag: number;
  63133. zfar: number;
  63134. znear: number;
  63135. }
  63136. /** @hidden */
  63137. export interface IGLTFCameraPerspective {
  63138. aspectRatio: number;
  63139. yfov: number;
  63140. zfar: number;
  63141. znear: number;
  63142. }
  63143. /** @hidden */
  63144. export interface IGLTFCamera extends IGLTFChildRootProperty {
  63145. type: string;
  63146. }
  63147. /** @hidden */
  63148. export interface IGLTFAnimationChannelTarget {
  63149. id: string;
  63150. path: string;
  63151. }
  63152. /** @hidden */
  63153. export interface IGLTFAnimationChannel {
  63154. sampler: string;
  63155. target: IGLTFAnimationChannelTarget;
  63156. }
  63157. /** @hidden */
  63158. export interface IGLTFAnimationSampler {
  63159. input: string;
  63160. output: string;
  63161. interpolation?: string;
  63162. }
  63163. /** @hidden */
  63164. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  63165. channels?: IGLTFAnimationChannel[];
  63166. parameters?: {
  63167. [key: string]: string;
  63168. };
  63169. samplers?: {
  63170. [key: string]: IGLTFAnimationSampler;
  63171. };
  63172. }
  63173. /** @hidden */
  63174. export interface IGLTFNodeInstanceSkin {
  63175. skeletons: string[];
  63176. skin: string;
  63177. meshes: string[];
  63178. }
  63179. /** @hidden */
  63180. export interface IGLTFSkins extends IGLTFChildRootProperty {
  63181. bindShapeMatrix: number[];
  63182. inverseBindMatrices: string;
  63183. jointNames: string[];
  63184. babylonSkeleton?: Skeleton;
  63185. }
  63186. /** @hidden */
  63187. export interface IGLTFNode extends IGLTFChildRootProperty {
  63188. camera?: string;
  63189. children: string[];
  63190. skin?: string;
  63191. jointName?: string;
  63192. light?: string;
  63193. matrix: number[];
  63194. mesh?: string;
  63195. meshes?: string[];
  63196. rotation?: number[];
  63197. scale?: number[];
  63198. translation?: number[];
  63199. babylonNode?: Node;
  63200. }
  63201. /** @hidden */
  63202. export interface IGLTFScene extends IGLTFChildRootProperty {
  63203. nodes: string[];
  63204. }
  63205. /** @hidden */
  63206. export interface IGLTFRuntime {
  63207. extensions: {
  63208. [key: string]: any;
  63209. };
  63210. accessors: {
  63211. [key: string]: IGLTFAccessor;
  63212. };
  63213. buffers: {
  63214. [key: string]: IGLTFBuffer;
  63215. };
  63216. bufferViews: {
  63217. [key: string]: IGLTFBufferView;
  63218. };
  63219. meshes: {
  63220. [key: string]: IGLTFMesh;
  63221. };
  63222. lights: {
  63223. [key: string]: IGLTFLight;
  63224. };
  63225. cameras: {
  63226. [key: string]: IGLTFCamera;
  63227. };
  63228. nodes: {
  63229. [key: string]: IGLTFNode;
  63230. };
  63231. images: {
  63232. [key: string]: IGLTFImage;
  63233. };
  63234. textures: {
  63235. [key: string]: IGLTFTexture;
  63236. };
  63237. shaders: {
  63238. [key: string]: IGLTFShader;
  63239. };
  63240. programs: {
  63241. [key: string]: IGLTFProgram;
  63242. };
  63243. samplers: {
  63244. [key: string]: IGLTFSampler;
  63245. };
  63246. techniques: {
  63247. [key: string]: IGLTFTechnique;
  63248. };
  63249. materials: {
  63250. [key: string]: IGLTFMaterial;
  63251. };
  63252. animations: {
  63253. [key: string]: IGLTFAnimation;
  63254. };
  63255. skins: {
  63256. [key: string]: IGLTFSkins;
  63257. };
  63258. currentScene?: Object;
  63259. scenes: {
  63260. [key: string]: IGLTFScene;
  63261. };
  63262. extensionsUsed: string[];
  63263. extensionsRequired?: string[];
  63264. buffersCount: number;
  63265. shaderscount: number;
  63266. scene: Scene;
  63267. rootUrl: string;
  63268. loadedBufferCount: number;
  63269. loadedBufferViews: {
  63270. [name: string]: ArrayBufferView;
  63271. };
  63272. loadedShaderCount: number;
  63273. importOnlyMeshes: boolean;
  63274. importMeshesNames?: string[];
  63275. dummyNodes: Node[];
  63276. }
  63277. /** @hidden */
  63278. export interface INodeToRoot {
  63279. bone: Bone;
  63280. node: IGLTFNode;
  63281. id: string;
  63282. }
  63283. /** @hidden */
  63284. export interface IJointNode {
  63285. node: IGLTFNode;
  63286. id: string;
  63287. }
  63288. }
  63289. declare module BABYLON.GLTF1 {
  63290. /**
  63291. * Utils functions for GLTF
  63292. * @hidden
  63293. */
  63294. export class GLTFUtils {
  63295. /**
  63296. * Sets the given "parameter" matrix
  63297. * @param scene: the Scene object
  63298. * @param source: the source node where to pick the matrix
  63299. * @param parameter: the GLTF technique parameter
  63300. * @param uniformName: the name of the shader's uniform
  63301. * @param shaderMaterial: the shader material
  63302. */
  63303. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  63304. /**
  63305. * Sets the given "parameter" matrix
  63306. * @param shaderMaterial: the shader material
  63307. * @param uniform: the name of the shader's uniform
  63308. * @param value: the value of the uniform
  63309. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  63310. */
  63311. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  63312. /**
  63313. * Returns the wrap mode of the texture
  63314. * @param mode: the mode value
  63315. */
  63316. static GetWrapMode(mode: number): number;
  63317. /**
  63318. * Returns the byte stride giving an accessor
  63319. * @param accessor: the GLTF accessor objet
  63320. */
  63321. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  63322. /**
  63323. * Returns the texture filter mode giving a mode value
  63324. * @param mode: the filter mode value
  63325. */
  63326. static GetTextureFilterMode(mode: number): ETextureFilterType;
  63327. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  63328. /**
  63329. * Returns a buffer from its accessor
  63330. * @param gltfRuntime: the GLTF runtime
  63331. * @param accessor: the GLTF accessor
  63332. */
  63333. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  63334. /**
  63335. * Decodes a buffer view into a string
  63336. * @param view: the buffer view
  63337. */
  63338. static DecodeBufferToText(view: ArrayBufferView): string;
  63339. /**
  63340. * Returns the default material of gltf. Related to
  63341. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  63342. * @param scene: the Babylon.js scene
  63343. */
  63344. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  63345. private static _DefaultMaterial;
  63346. }
  63347. }
  63348. declare module BABYLON.GLTF1 {
  63349. /**
  63350. * Implementation of the base glTF spec
  63351. * @hidden
  63352. */
  63353. export class GLTFLoaderBase {
  63354. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  63355. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  63356. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  63357. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  63358. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  63359. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  63360. }
  63361. /**
  63362. * glTF V1 Loader
  63363. * @hidden
  63364. */
  63365. export class GLTFLoader implements IGLTFLoader {
  63366. static Extensions: {
  63367. [name: string]: GLTFLoaderExtension;
  63368. };
  63369. static RegisterExtension(extension: GLTFLoaderExtension): void;
  63370. state: Nullable<GLTFLoaderState>;
  63371. dispose(): void;
  63372. private _importMeshAsync;
  63373. /**
  63374. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  63375. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  63376. * @param scene the scene the meshes should be added to
  63377. * @param data gltf data containing information of the meshes in a loaded file
  63378. * @param rootUrl root url to load from
  63379. * @param onProgress event that fires when loading progress has occured
  63380. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  63381. */
  63382. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  63383. meshes: AbstractMesh[];
  63384. particleSystems: IParticleSystem[];
  63385. skeletons: Skeleton[];
  63386. animationGroups: AnimationGroup[];
  63387. }>;
  63388. private _loadAsync;
  63389. /**
  63390. * Imports all objects from a loaded gltf file and adds them to the scene
  63391. * @param scene the scene the objects should be added to
  63392. * @param data gltf data containing information of the meshes in a loaded file
  63393. * @param rootUrl root url to load from
  63394. * @param onProgress event that fires when loading progress has occured
  63395. * @returns a promise which completes when objects have been loaded to the scene
  63396. */
  63397. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  63398. private _loadShadersAsync;
  63399. private _loadBuffersAsync;
  63400. private _createNodes;
  63401. }
  63402. /** @hidden */
  63403. export abstract class GLTFLoaderExtension {
  63404. private _name;
  63405. constructor(name: string);
  63406. readonly name: string;
  63407. /**
  63408. * Defines an override for loading the runtime
  63409. * Return true to stop further extensions from loading the runtime
  63410. */
  63411. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  63412. /**
  63413. * Defines an onverride for creating gltf runtime
  63414. * Return true to stop further extensions from creating the runtime
  63415. */
  63416. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  63417. /**
  63418. * Defines an override for loading buffers
  63419. * Return true to stop further extensions from loading this buffer
  63420. */
  63421. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  63422. /**
  63423. * Defines an override for loading texture buffers
  63424. * Return true to stop further extensions from loading this texture data
  63425. */
  63426. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  63427. /**
  63428. * Defines an override for creating textures
  63429. * Return true to stop further extensions from loading this texture
  63430. */
  63431. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  63432. /**
  63433. * Defines an override for loading shader strings
  63434. * Return true to stop further extensions from loading this shader data
  63435. */
  63436. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  63437. /**
  63438. * Defines an override for loading materials
  63439. * Return true to stop further extensions from loading this material
  63440. */
  63441. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  63442. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  63443. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  63444. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  63445. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  63446. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  63447. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  63448. private static LoadTextureBufferAsync;
  63449. private static CreateTextureAsync;
  63450. private static ApplyExtensions;
  63451. }
  63452. }
  63453. declare module BABYLON.GLTF1 {
  63454. /** @hidden */
  63455. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  63456. private _bin;
  63457. constructor();
  63458. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  63459. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  63460. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  63461. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  63462. }
  63463. }
  63464. declare module BABYLON.GLTF1 {
  63465. /** @hidden */
  63466. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  63467. constructor();
  63468. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  63469. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  63470. private _loadTexture;
  63471. }
  63472. }
  63473. declare module BABYLON.GLTF2.Loader {
  63474. /**
  63475. * Loader interface with an index field.
  63476. */
  63477. export interface IArrayItem {
  63478. /**
  63479. * The index of this item in the array.
  63480. */
  63481. index: number;
  63482. }
  63483. /**
  63484. * Loader interface with additional members.
  63485. */
  63486. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  63487. /** @hidden */
  63488. _data?: Promise<ArrayBufferView>;
  63489. /** @hidden */
  63490. _babylonVertexBuffer?: Promise<VertexBuffer>;
  63491. }
  63492. /**
  63493. * Loader interface with additional members.
  63494. */
  63495. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  63496. }
  63497. /** @hidden */
  63498. export interface _IAnimationSamplerData {
  63499. input: Float32Array;
  63500. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  63501. output: Float32Array;
  63502. }
  63503. /**
  63504. * Loader interface with additional members.
  63505. */
  63506. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  63507. /** @hidden */
  63508. _data?: Promise<_IAnimationSamplerData>;
  63509. }
  63510. /**
  63511. * Loader interface with additional members.
  63512. */
  63513. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  63514. channels: IAnimationChannel[];
  63515. samplers: IAnimationSampler[];
  63516. /** @hidden */
  63517. _babylonAnimationGroup?: AnimationGroup;
  63518. }
  63519. /**
  63520. * Loader interface with additional members.
  63521. */
  63522. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  63523. /** @hidden */
  63524. _data?: Promise<ArrayBufferView>;
  63525. }
  63526. /**
  63527. * Loader interface with additional members.
  63528. */
  63529. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  63530. /** @hidden */
  63531. _data?: Promise<ArrayBufferView>;
  63532. /** @hidden */
  63533. _babylonBuffer?: Promise<Buffer>;
  63534. }
  63535. /**
  63536. * Loader interface with additional members.
  63537. */
  63538. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  63539. }
  63540. /**
  63541. * Loader interface with additional members.
  63542. */
  63543. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  63544. /** @hidden */
  63545. _data?: Promise<ArrayBufferView>;
  63546. }
  63547. /**
  63548. * Loader interface with additional members.
  63549. */
  63550. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  63551. }
  63552. /**
  63553. * Loader interface with additional members.
  63554. */
  63555. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  63556. }
  63557. /**
  63558. * Loader interface with additional members.
  63559. */
  63560. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  63561. baseColorTexture?: ITextureInfo;
  63562. metallicRoughnessTexture?: ITextureInfo;
  63563. }
  63564. /**
  63565. * Loader interface with additional members.
  63566. */
  63567. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  63568. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  63569. normalTexture?: IMaterialNormalTextureInfo;
  63570. occlusionTexture?: IMaterialOcclusionTextureInfo;
  63571. emissiveTexture?: ITextureInfo;
  63572. /** @hidden */
  63573. _data?: {
  63574. [babylonDrawMode: number]: {
  63575. babylonMaterial: Material;
  63576. babylonMeshes: AbstractMesh[];
  63577. promise: Promise<void>;
  63578. };
  63579. };
  63580. }
  63581. /**
  63582. * Loader interface with additional members.
  63583. */
  63584. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  63585. primitives: IMeshPrimitive[];
  63586. }
  63587. /**
  63588. * Loader interface with additional members.
  63589. */
  63590. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  63591. /** @hidden */
  63592. _instanceData?: {
  63593. babylonSourceMesh: Mesh;
  63594. promise: Promise<any>;
  63595. };
  63596. }
  63597. /**
  63598. * Loader interface with additional members.
  63599. */
  63600. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  63601. /**
  63602. * The parent glTF node.
  63603. */
  63604. parent?: INode;
  63605. /** @hidden */
  63606. _babylonTransformNode?: TransformNode;
  63607. /** @hidden */
  63608. _primitiveBabylonMeshes?: AbstractMesh[];
  63609. /** @hidden */
  63610. _babylonBones?: Bone[];
  63611. /** @hidden */
  63612. _numMorphTargets?: number;
  63613. }
  63614. /** @hidden */
  63615. export interface _ISamplerData {
  63616. noMipMaps: boolean;
  63617. samplingMode: number;
  63618. wrapU: number;
  63619. wrapV: number;
  63620. }
  63621. /**
  63622. * Loader interface with additional members.
  63623. */
  63624. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  63625. /** @hidden */
  63626. _data?: _ISamplerData;
  63627. }
  63628. /**
  63629. * Loader interface with additional members.
  63630. */
  63631. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  63632. }
  63633. /**
  63634. * Loader interface with additional members.
  63635. */
  63636. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  63637. /** @hidden */
  63638. _data?: {
  63639. babylonSkeleton: Skeleton;
  63640. promise: Promise<void>;
  63641. };
  63642. }
  63643. /**
  63644. * Loader interface with additional members.
  63645. */
  63646. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  63647. }
  63648. /**
  63649. * Loader interface with additional members.
  63650. */
  63651. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  63652. }
  63653. /**
  63654. * Loader interface with additional members.
  63655. */
  63656. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  63657. accessors?: IAccessor[];
  63658. animations?: IAnimation[];
  63659. buffers?: IBuffer[];
  63660. bufferViews?: IBufferView[];
  63661. cameras?: ICamera[];
  63662. images?: IImage[];
  63663. materials?: IMaterial[];
  63664. meshes?: IMesh[];
  63665. nodes?: INode[];
  63666. samplers?: ISampler[];
  63667. scenes?: IScene[];
  63668. skins?: ISkin[];
  63669. textures?: ITexture[];
  63670. }
  63671. }
  63672. declare module BABYLON.GLTF2 {
  63673. /**
  63674. * Interface for a glTF loader extension.
  63675. */
  63676. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  63677. /**
  63678. * Called after the loader state changes to LOADING.
  63679. */
  63680. onLoading?(): void;
  63681. /**
  63682. * Called after the loader state changes to READY.
  63683. */
  63684. onReady?(): void;
  63685. /**
  63686. * Define this method to modify the default behavior when loading scenes.
  63687. * @param context The context when loading the asset
  63688. * @param scene The glTF scene property
  63689. * @returns A promise that resolves when the load is complete or null if not handled
  63690. */
  63691. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  63692. /**
  63693. * Define this method to modify the default behavior when loading nodes.
  63694. * @param context The context when loading the asset
  63695. * @param node The glTF node property
  63696. * @param assign A function called synchronously after parsing the glTF properties
  63697. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  63698. */
  63699. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  63700. /**
  63701. * Define this method to modify the default behavior when loading cameras.
  63702. * @param context The context when loading the asset
  63703. * @param camera The glTF camera property
  63704. * @param assign A function called synchronously after parsing the glTF properties
  63705. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  63706. */
  63707. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  63708. /**
  63709. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  63710. * @param context The context when loading the asset
  63711. * @param primitive The glTF mesh primitive property
  63712. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  63713. */
  63714. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  63715. /**
  63716. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  63717. * @param context The context when loading the asset
  63718. * @param name The mesh name when loading the asset
  63719. * @param node The glTF node when loading the asset
  63720. * @param mesh The glTF mesh when loading the asset
  63721. * @param primitive The glTF mesh primitive property
  63722. * @param assign A function called synchronously after parsing the glTF properties
  63723. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  63724. */
  63725. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  63726. /**
  63727. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  63728. * @param context The context when loading the asset
  63729. * @param material The glTF material property
  63730. * @param assign A function called synchronously after parsing the glTF properties
  63731. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  63732. */
  63733. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  63734. /**
  63735. * Define this method to modify the default behavior when creating materials.
  63736. * @param context The context when loading the asset
  63737. * @param material The glTF material property
  63738. * @param babylonDrawMode The draw mode for the Babylon material
  63739. * @returns The Babylon material or null if not handled
  63740. */
  63741. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  63742. /**
  63743. * Define this method to modify the default behavior when loading material properties.
  63744. * @param context The context when loading the asset
  63745. * @param material The glTF material property
  63746. * @param babylonMaterial The Babylon material
  63747. * @returns A promise that resolves when the load is complete or null if not handled
  63748. */
  63749. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  63750. /**
  63751. * Define this method to modify the default behavior when loading texture infos.
  63752. * @param context The context when loading the asset
  63753. * @param textureInfo The glTF texture info property
  63754. * @param assign A function called synchronously after parsing the glTF properties
  63755. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  63756. */
  63757. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  63758. /**
  63759. * Define this method to modify the default behavior when loading animations.
  63760. * @param context The context when loading the asset
  63761. * @param animation The glTF animation property
  63762. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  63763. */
  63764. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  63765. /**
  63766. * @hidden Define this method to modify the default behavior when loading skins.
  63767. * @param context The context when loading the asset
  63768. * @param node The glTF node property
  63769. * @param skin The glTF skin property
  63770. * @returns A promise that resolves when the load is complete or null if not handled
  63771. */
  63772. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  63773. /**
  63774. * @hidden Define this method to modify the default behavior when loading uris.
  63775. * @param context The context when loading the asset
  63776. * @param property The glTF property associated with the uri
  63777. * @param uri The uri to load
  63778. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  63779. */
  63780. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  63781. }
  63782. }
  63783. declare module BABYLON.GLTF2 {
  63784. /**
  63785. * Helper class for working with arrays when loading the glTF asset
  63786. */
  63787. export class ArrayItem {
  63788. /**
  63789. * Gets an item from the given array.
  63790. * @param context The context when loading the asset
  63791. * @param array The array to get the item from
  63792. * @param index The index to the array
  63793. * @returns The array item
  63794. */
  63795. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  63796. /**
  63797. * Assign an `index` field to each item of the given array.
  63798. * @param array The array of items
  63799. */
  63800. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  63801. }
  63802. /**
  63803. * The glTF 2.0 loader
  63804. */
  63805. export class GLTFLoader implements IGLTFLoader {
  63806. /** @hidden */
  63807. _completePromises: Promise<any>[];
  63808. private _disposed;
  63809. private _parent;
  63810. private _state;
  63811. private _extensions;
  63812. private _rootUrl;
  63813. private _fileName;
  63814. private _uniqueRootUrl;
  63815. private _gltf;
  63816. private _babylonScene;
  63817. private _rootBabylonMesh;
  63818. private _defaultBabylonMaterialData;
  63819. private _progressCallback?;
  63820. private _requests;
  63821. private static readonly _DefaultSampler;
  63822. private static _ExtensionNames;
  63823. private static _ExtensionFactories;
  63824. /**
  63825. * Registers a loader extension.
  63826. * @param name The name of the loader extension.
  63827. * @param factory The factory function that creates the loader extension.
  63828. */
  63829. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  63830. /**
  63831. * Unregisters a loader extension.
  63832. * @param name The name of the loader extenion.
  63833. * @returns A boolean indicating whether the extension has been unregistered
  63834. */
  63835. static UnregisterExtension(name: string): boolean;
  63836. /**
  63837. * Gets the loader state.
  63838. */
  63839. readonly state: Nullable<GLTFLoaderState>;
  63840. /**
  63841. * The glTF object parsed from the JSON.
  63842. */
  63843. readonly gltf: IGLTF;
  63844. /**
  63845. * The Babylon scene when loading the asset.
  63846. */
  63847. readonly babylonScene: Scene;
  63848. /**
  63849. * The root Babylon mesh when loading the asset.
  63850. */
  63851. readonly rootBabylonMesh: Mesh;
  63852. /** @hidden */
  63853. constructor(parent: GLTFFileLoader);
  63854. /** @hidden */
  63855. dispose(): void;
  63856. /** @hidden */
  63857. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  63858. meshes: AbstractMesh[];
  63859. particleSystems: IParticleSystem[];
  63860. skeletons: Skeleton[];
  63861. animationGroups: AnimationGroup[];
  63862. }>;
  63863. /** @hidden */
  63864. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  63865. private _loadAsync;
  63866. private _loadData;
  63867. private _setupData;
  63868. private _loadExtensions;
  63869. private _checkExtensions;
  63870. private _setState;
  63871. private _createRootNode;
  63872. /**
  63873. * Loads a glTF scene.
  63874. * @param context The context when loading the asset
  63875. * @param scene The glTF scene property
  63876. * @returns A promise that resolves when the load is complete
  63877. */
  63878. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  63879. private _forEachPrimitive;
  63880. private _getMeshes;
  63881. private _getSkeletons;
  63882. private _getAnimationGroups;
  63883. private _startAnimations;
  63884. /**
  63885. * Loads a glTF node.
  63886. * @param context The context when loading the asset
  63887. * @param node The glTF node property
  63888. * @param assign A function called synchronously after parsing the glTF properties
  63889. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  63890. */
  63891. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  63892. private _loadMeshAsync;
  63893. /**
  63894. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  63895. * @param context The context when loading the asset
  63896. * @param name The mesh name when loading the asset
  63897. * @param node The glTF node when loading the asset
  63898. * @param mesh The glTF mesh when loading the asset
  63899. * @param primitive The glTF mesh primitive property
  63900. * @param assign A function called synchronously after parsing the glTF properties
  63901. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  63902. */
  63903. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  63904. private _loadVertexDataAsync;
  63905. private _createMorphTargets;
  63906. private _loadMorphTargetsAsync;
  63907. private _loadMorphTargetVertexDataAsync;
  63908. private static _LoadTransform;
  63909. private _loadSkinAsync;
  63910. private _loadBones;
  63911. private _loadBone;
  63912. private _loadSkinInverseBindMatricesDataAsync;
  63913. private _updateBoneMatrices;
  63914. private _getNodeMatrix;
  63915. /**
  63916. * Loads a glTF camera.
  63917. * @param context The context when loading the asset
  63918. * @param camera The glTF camera property
  63919. * @param assign A function called synchronously after parsing the glTF properties
  63920. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  63921. */
  63922. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  63923. private _loadAnimationsAsync;
  63924. /**
  63925. * Loads a glTF animation.
  63926. * @param context The context when loading the asset
  63927. * @param animation The glTF animation property
  63928. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  63929. */
  63930. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  63931. /**
  63932. * @hidden Loads a glTF animation channel.
  63933. * @param context The context when loading the asset
  63934. * @param animationContext The context of the animation when loading the asset
  63935. * @param animation The glTF animation property
  63936. * @param channel The glTF animation channel property
  63937. * @param babylonAnimationGroup The babylon animation group property
  63938. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  63939. * @returns A void promise when the channel load is complete
  63940. */
  63941. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  63942. private _loadAnimationSamplerAsync;
  63943. private _loadBufferAsync;
  63944. /**
  63945. * Loads a glTF buffer view.
  63946. * @param context The context when loading the asset
  63947. * @param bufferView The glTF buffer view property
  63948. * @returns A promise that resolves with the loaded data when the load is complete
  63949. */
  63950. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  63951. private _loadIndicesAccessorAsync;
  63952. private _loadFloatAccessorAsync;
  63953. private _loadVertexBufferViewAsync;
  63954. private _loadVertexAccessorAsync;
  63955. private _loadMaterialMetallicRoughnessPropertiesAsync;
  63956. /** @hidden */
  63957. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  63958. private _createDefaultMaterial;
  63959. /**
  63960. * Creates a Babylon material from a glTF material.
  63961. * @param context The context when loading the asset
  63962. * @param material The glTF material property
  63963. * @param babylonDrawMode The draw mode for the Babylon material
  63964. * @returns The Babylon material
  63965. */
  63966. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  63967. /**
  63968. * Loads properties from a glTF material into a Babylon material.
  63969. * @param context The context when loading the asset
  63970. * @param material The glTF material property
  63971. * @param babylonMaterial The Babylon material
  63972. * @returns A promise that resolves when the load is complete
  63973. */
  63974. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  63975. /**
  63976. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  63977. * @param context The context when loading the asset
  63978. * @param material The glTF material property
  63979. * @param babylonMaterial The Babylon material
  63980. * @returns A promise that resolves when the load is complete
  63981. */
  63982. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  63983. /**
  63984. * Loads the alpha properties from a glTF material into a Babylon material.
  63985. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  63986. * @param context The context when loading the asset
  63987. * @param material The glTF material property
  63988. * @param babylonMaterial The Babylon material
  63989. */
  63990. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  63991. /**
  63992. * Loads a glTF texture info.
  63993. * @param context The context when loading the asset
  63994. * @param textureInfo The glTF texture info property
  63995. * @param assign A function called synchronously after parsing the glTF properties
  63996. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  63997. */
  63998. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  63999. private _loadTextureAsync;
  64000. private _loadSampler;
  64001. /**
  64002. * Loads a glTF image.
  64003. * @param context The context when loading the asset
  64004. * @param image The glTF image property
  64005. * @returns A promise that resolves with the loaded data when the load is complete
  64006. */
  64007. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  64008. /**
  64009. * Loads a glTF uri.
  64010. * @param context The context when loading the asset
  64011. * @param property The glTF property associated with the uri
  64012. * @param uri The base64 or relative uri
  64013. * @returns A promise that resolves with the loaded data when the load is complete
  64014. */
  64015. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  64016. private _onProgress;
  64017. /**
  64018. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  64019. * @param babylonObject the Babylon object with metadata
  64020. * @param pointer the JSON pointer
  64021. */
  64022. static AddPointerMetadata(babylonObject: {
  64023. metadata: any;
  64024. }, pointer: string): void;
  64025. private static _GetTextureWrapMode;
  64026. private static _GetTextureSamplingMode;
  64027. private static _GetTypedArray;
  64028. private static _GetNumComponents;
  64029. private static _ValidateUri;
  64030. private static _GetDrawMode;
  64031. private _compileMaterialsAsync;
  64032. private _compileShadowGeneratorsAsync;
  64033. private _forEachExtensions;
  64034. private _applyExtensions;
  64035. private _extensionsOnLoading;
  64036. private _extensionsOnReady;
  64037. private _extensionsLoadSceneAsync;
  64038. private _extensionsLoadNodeAsync;
  64039. private _extensionsLoadCameraAsync;
  64040. private _extensionsLoadVertexDataAsync;
  64041. private _extensionsLoadMeshPrimitiveAsync;
  64042. private _extensionsLoadMaterialAsync;
  64043. private _extensionsCreateMaterial;
  64044. private _extensionsLoadMaterialPropertiesAsync;
  64045. private _extensionsLoadTextureInfoAsync;
  64046. private _extensionsLoadAnimationAsync;
  64047. private _extensionsLoadSkinAsync;
  64048. private _extensionsLoadUriAsync;
  64049. /**
  64050. * Helper method called by a loader extension to load an glTF extension.
  64051. * @param context The context when loading the asset
  64052. * @param property The glTF property to load the extension from
  64053. * @param extensionName The name of the extension to load
  64054. * @param actionAsync The action to run
  64055. * @returns The promise returned by actionAsync or null if the extension does not exist
  64056. */
  64057. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  64058. /**
  64059. * Helper method called by a loader extension to load a glTF extra.
  64060. * @param context The context when loading the asset
  64061. * @param property The glTF property to load the extra from
  64062. * @param extensionName The name of the extension to load
  64063. * @param actionAsync The action to run
  64064. * @returns The promise returned by actionAsync or null if the extra does not exist
  64065. */
  64066. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  64067. /**
  64068. * Increments the indentation level and logs a message.
  64069. * @param message The message to log
  64070. */
  64071. logOpen(message: string): void;
  64072. /**
  64073. * Decrements the indentation level.
  64074. */
  64075. logClose(): void;
  64076. /**
  64077. * Logs a message
  64078. * @param message The message to log
  64079. */
  64080. log(message: string): void;
  64081. /**
  64082. * Starts a performance counter.
  64083. * @param counterName The name of the performance counter
  64084. */
  64085. startPerformanceCounter(counterName: string): void;
  64086. /**
  64087. * Ends a performance counter.
  64088. * @param counterName The name of the performance counter
  64089. */
  64090. endPerformanceCounter(counterName: string): void;
  64091. }
  64092. }
  64093. declare module BABYLON.GLTF2.Loader.Extensions {
  64094. /**
  64095. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  64096. */
  64097. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  64098. /** The name of this extension. */
  64099. readonly name: string;
  64100. /** Defines whether this extension is enabled. */
  64101. enabled: boolean;
  64102. private _loader;
  64103. private _lights?;
  64104. /** @hidden */
  64105. constructor(loader: GLTFLoader);
  64106. /** @hidden */
  64107. dispose(): void;
  64108. /** @hidden */
  64109. onLoading(): void;
  64110. /** @hidden */
  64111. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  64112. private _loadLightAsync;
  64113. }
  64114. }
  64115. declare module BABYLON.GLTF2.Loader.Extensions {
  64116. /**
  64117. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  64118. */
  64119. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  64120. /** The name of this extension. */
  64121. readonly name: string;
  64122. /** The draco compression used to decode vertex data or DracoCompression.Default if not defined */
  64123. dracoCompression?: DracoCompression;
  64124. /** Defines whether this extension is enabled. */
  64125. enabled: boolean;
  64126. private _loader;
  64127. /** @hidden */
  64128. constructor(loader: GLTFLoader);
  64129. /** @hidden */
  64130. dispose(): void;
  64131. /** @hidden */
  64132. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  64133. }
  64134. }
  64135. declare module BABYLON.GLTF2.Loader.Extensions {
  64136. /**
  64137. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  64138. */
  64139. export class KHR_lights implements IGLTFLoaderExtension {
  64140. /** The name of this extension. */
  64141. readonly name: string;
  64142. /** Defines whether this extension is enabled. */
  64143. enabled: boolean;
  64144. private _loader;
  64145. private _lights?;
  64146. /** @hidden */
  64147. constructor(loader: GLTFLoader);
  64148. /** @hidden */
  64149. dispose(): void;
  64150. /** @hidden */
  64151. onLoading(): void;
  64152. /** @hidden */
  64153. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  64154. }
  64155. }
  64156. declare module BABYLON.GLTF2.Loader.Extensions {
  64157. /**
  64158. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  64159. */
  64160. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  64161. /** The name of this extension. */
  64162. readonly name: string;
  64163. /** Defines whether this extension is enabled. */
  64164. enabled: boolean;
  64165. private _loader;
  64166. /** @hidden */
  64167. constructor(loader: GLTFLoader);
  64168. /** @hidden */
  64169. dispose(): void;
  64170. /** @hidden */
  64171. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  64172. private _loadSpecularGlossinessPropertiesAsync;
  64173. }
  64174. }
  64175. declare module BABYLON.GLTF2.Loader.Extensions {
  64176. /**
  64177. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  64178. */
  64179. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  64180. /** The name of this extension. */
  64181. readonly name: string;
  64182. /** Defines whether this extension is enabled. */
  64183. enabled: boolean;
  64184. private _loader;
  64185. /** @hidden */
  64186. constructor(loader: GLTFLoader);
  64187. /** @hidden */
  64188. dispose(): void;
  64189. /** @hidden */
  64190. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  64191. private _loadUnlitPropertiesAsync;
  64192. }
  64193. }
  64194. declare module BABYLON.GLTF2.Loader.Extensions {
  64195. /**
  64196. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  64197. */
  64198. export class KHR_texture_transform implements IGLTFLoaderExtension {
  64199. /** The name of this extension. */
  64200. readonly name: string;
  64201. /** Defines whether this extension is enabled. */
  64202. enabled: boolean;
  64203. private _loader;
  64204. /** @hidden */
  64205. constructor(loader: GLTFLoader);
  64206. /** @hidden */
  64207. dispose(): void;
  64208. /** @hidden */
  64209. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  64210. }
  64211. }
  64212. declare module BABYLON.GLTF2.Loader.Extensions {
  64213. /**
  64214. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  64215. */
  64216. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  64217. /** The name of this extension. */
  64218. readonly name: string;
  64219. /** Defines whether this extension is enabled. */
  64220. enabled: boolean;
  64221. private _loader;
  64222. private _clips;
  64223. private _emitters;
  64224. /** @hidden */
  64225. constructor(loader: GLTFLoader);
  64226. /** @hidden */
  64227. dispose(): void;
  64228. /** @hidden */
  64229. onLoading(): void;
  64230. /** @hidden */
  64231. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  64232. /** @hidden */
  64233. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  64234. /** @hidden */
  64235. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  64236. private _loadClipAsync;
  64237. private _loadEmitterAsync;
  64238. private _getEventAction;
  64239. private _loadAnimationEventAsync;
  64240. }
  64241. }
  64242. declare module BABYLON.GLTF2.Loader.Extensions {
  64243. /**
  64244. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  64245. */
  64246. export class MSFT_lod implements IGLTFLoaderExtension {
  64247. /** The name of this extension. */
  64248. readonly name: string;
  64249. /** Defines whether this extension is enabled. */
  64250. enabled: boolean;
  64251. /**
  64252. * Maximum number of LODs to load, starting from the lowest LOD.
  64253. */
  64254. maxLODsToLoad: number;
  64255. /**
  64256. * Observable raised when all node LODs of one level are loaded.
  64257. * The event data is the index of the loaded LOD starting from zero.
  64258. * Dispose the loader to cancel the loading of the next level of LODs.
  64259. */
  64260. onNodeLODsLoadedObservable: Observable<number>;
  64261. /**
  64262. * Observable raised when all material LODs of one level are loaded.
  64263. * The event data is the index of the loaded LOD starting from zero.
  64264. * Dispose the loader to cancel the loading of the next level of LODs.
  64265. */
  64266. onMaterialLODsLoadedObservable: Observable<number>;
  64267. private _loader;
  64268. private _nodeIndexLOD;
  64269. private _nodeSignalLODs;
  64270. private _nodePromiseLODs;
  64271. private _materialIndexLOD;
  64272. private _materialSignalLODs;
  64273. private _materialPromiseLODs;
  64274. /** @hidden */
  64275. constructor(loader: GLTFLoader);
  64276. /** @hidden */
  64277. dispose(): void;
  64278. /** @hidden */
  64279. onReady(): void;
  64280. /** @hidden */
  64281. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  64282. /** @hidden */
  64283. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  64284. /** @hidden */
  64285. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  64286. /**
  64287. * Gets an array of LOD properties from lowest to highest.
  64288. */
  64289. private _getLODs;
  64290. private _disposeUnusedMaterials;
  64291. }
  64292. }
  64293. declare module BABYLON.GLTF2.Loader.Extensions {
  64294. /** @hidden */
  64295. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  64296. readonly name: string;
  64297. enabled: boolean;
  64298. private _loader;
  64299. constructor(loader: GLTFLoader);
  64300. dispose(): void;
  64301. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  64302. }
  64303. }
  64304. declare module BABYLON.GLTF2.Loader.Extensions {
  64305. /** @hidden */
  64306. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  64307. readonly name: string;
  64308. enabled: boolean;
  64309. private _loader;
  64310. constructor(loader: GLTFLoader);
  64311. dispose(): void;
  64312. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  64313. }
  64314. }
  64315. declare module BABYLON {
  64316. /**
  64317. * Class reading and parsing the MTL file bundled with the obj file.
  64318. */
  64319. export class MTLFileLoader {
  64320. /**
  64321. * All material loaded from the mtl will be set here
  64322. */
  64323. materials: StandardMaterial[];
  64324. /**
  64325. * This function will read the mtl file and create each material described inside
  64326. * This function could be improve by adding :
  64327. * -some component missing (Ni, Tf...)
  64328. * -including the specific options available
  64329. *
  64330. * @param scene defines the scene the material will be created in
  64331. * @param data defines the mtl data to parse
  64332. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  64333. */
  64334. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  64335. /**
  64336. * Gets the texture for the material.
  64337. *
  64338. * If the material is imported from input file,
  64339. * We sanitize the url to ensure it takes the textre from aside the material.
  64340. *
  64341. * @param rootUrl The root url to load from
  64342. * @param value The value stored in the mtl
  64343. * @return The Texture
  64344. */
  64345. private static _getTexture;
  64346. }
  64347. /**
  64348. * Options for loading OBJ/MTL files
  64349. */
  64350. type MeshLoadOptions = {
  64351. /**
  64352. * Defines if UVs are optimized by default during load.
  64353. */
  64354. OptimizeWithUV: boolean;
  64355. /**
  64356. * Defines custom scaling of UV coordinates of loaded meshes.
  64357. */
  64358. UVScaling: Vector2;
  64359. /**
  64360. * Invert model on y-axis (does a model scaling inversion)
  64361. */
  64362. InvertY: boolean;
  64363. /**
  64364. * Invert Y-Axis of referenced textures on load
  64365. */
  64366. InvertTextureY: boolean;
  64367. /**
  64368. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  64369. */
  64370. ImportVertexColors: boolean;
  64371. /**
  64372. * Compute the normals for the model, even if normals are present in the file.
  64373. */
  64374. ComputeNormals: boolean;
  64375. /**
  64376. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  64377. */
  64378. SkipMaterials: boolean;
  64379. /**
  64380. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  64381. */
  64382. MaterialLoadingFailsSilently: boolean;
  64383. };
  64384. /**
  64385. * OBJ file type loader.
  64386. * This is a babylon scene loader plugin.
  64387. */
  64388. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  64389. /**
  64390. * Defines if UVs are optimized by default during load.
  64391. */
  64392. static OPTIMIZE_WITH_UV: boolean;
  64393. /**
  64394. * Invert model on y-axis (does a model scaling inversion)
  64395. */
  64396. static INVERT_Y: boolean;
  64397. /**
  64398. * Invert Y-Axis of referenced textures on load
  64399. */
  64400. static INVERT_TEXTURE_Y: boolean;
  64401. /**
  64402. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  64403. */
  64404. static IMPORT_VERTEX_COLORS: boolean;
  64405. /**
  64406. * Compute the normals for the model, even if normals are present in the file.
  64407. */
  64408. static COMPUTE_NORMALS: boolean;
  64409. /**
  64410. * Defines custom scaling of UV coordinates of loaded meshes.
  64411. */
  64412. static UV_SCALING: Vector2;
  64413. /**
  64414. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  64415. */
  64416. static SKIP_MATERIALS: boolean;
  64417. /**
  64418. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  64419. *
  64420. * Defaults to true for backwards compatibility.
  64421. */
  64422. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  64423. /**
  64424. * Defines the name of the plugin.
  64425. */
  64426. name: string;
  64427. /**
  64428. * Defines the extension the plugin is able to load.
  64429. */
  64430. extensions: string;
  64431. /** @hidden */
  64432. obj: RegExp;
  64433. /** @hidden */
  64434. group: RegExp;
  64435. /** @hidden */
  64436. mtllib: RegExp;
  64437. /** @hidden */
  64438. usemtl: RegExp;
  64439. /** @hidden */
  64440. smooth: RegExp;
  64441. /** @hidden */
  64442. vertexPattern: RegExp;
  64443. /** @hidden */
  64444. normalPattern: RegExp;
  64445. /** @hidden */
  64446. uvPattern: RegExp;
  64447. /** @hidden */
  64448. facePattern1: RegExp;
  64449. /** @hidden */
  64450. facePattern2: RegExp;
  64451. /** @hidden */
  64452. facePattern3: RegExp;
  64453. /** @hidden */
  64454. facePattern4: RegExp;
  64455. /** @hidden */
  64456. facePattern5: RegExp;
  64457. private _meshLoadOptions;
  64458. /**
  64459. * Creates loader for .OBJ files
  64460. *
  64461. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  64462. */
  64463. constructor(meshLoadOptions?: MeshLoadOptions);
  64464. private static readonly currentMeshLoadOptions;
  64465. /**
  64466. * Calls synchronously the MTL file attached to this obj.
  64467. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  64468. * Without this function materials are not displayed in the first frame (but displayed after).
  64469. * In consequence it is impossible to get material information in your HTML file
  64470. *
  64471. * @param url The URL of the MTL file
  64472. * @param rootUrl
  64473. * @param onSuccess Callback function to be called when the MTL file is loaded
  64474. * @private
  64475. */
  64476. private _loadMTL;
  64477. /**
  64478. * Instantiates a OBJ file loader plugin.
  64479. * @returns the created plugin
  64480. */
  64481. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  64482. /**
  64483. * If the data string can be loaded directly.
  64484. *
  64485. * @param data string containing the file data
  64486. * @returns if the data can be loaded directly
  64487. */
  64488. canDirectLoad(data: string): boolean;
  64489. /**
  64490. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  64491. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  64492. * @param scene the scene the meshes should be added to
  64493. * @param data the OBJ data to load
  64494. * @param rootUrl root url to load from
  64495. * @param onProgress event that fires when loading progress has occured
  64496. * @param fileName Defines the name of the file to load
  64497. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  64498. */
  64499. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  64500. meshes: AbstractMesh[];
  64501. particleSystems: IParticleSystem[];
  64502. skeletons: Skeleton[];
  64503. animationGroups: AnimationGroup[];
  64504. }>;
  64505. /**
  64506. * Imports all objects from the loaded OBJ data and adds them to the scene
  64507. * @param scene the scene the objects should be added to
  64508. * @param data the OBJ data to load
  64509. * @param rootUrl root url to load from
  64510. * @param onProgress event that fires when loading progress has occured
  64511. * @param fileName Defines the name of the file to load
  64512. * @returns a promise which completes when objects have been loaded to the scene
  64513. */
  64514. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  64515. /**
  64516. * Load into an asset container.
  64517. * @param scene The scene to load into
  64518. * @param data The data to import
  64519. * @param rootUrl The root url for scene and resources
  64520. * @param onProgress The callback when the load progresses
  64521. * @param fileName Defines the name of the file to load
  64522. * @returns The loaded asset container
  64523. */
  64524. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  64525. /**
  64526. * Read the OBJ file and create an Array of meshes.
  64527. * Each mesh contains all information given by the OBJ and the MTL file.
  64528. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  64529. *
  64530. * @param meshesNames
  64531. * @param scene Scene The scene where are displayed the data
  64532. * @param data String The content of the obj file
  64533. * @param rootUrl String The path to the folder
  64534. * @returns Array<AbstractMesh>
  64535. * @private
  64536. */
  64537. private _parseSolid;
  64538. }
  64539. }
  64540. declare module BABYLON {
  64541. /**
  64542. * STL file type loader.
  64543. * This is a babylon scene loader plugin.
  64544. */
  64545. export class STLFileLoader implements ISceneLoaderPlugin {
  64546. /** @hidden */
  64547. solidPattern: RegExp;
  64548. /** @hidden */
  64549. facetsPattern: RegExp;
  64550. /** @hidden */
  64551. normalPattern: RegExp;
  64552. /** @hidden */
  64553. vertexPattern: RegExp;
  64554. /**
  64555. * Defines the name of the plugin.
  64556. */
  64557. name: string;
  64558. /**
  64559. * Defines the extensions the stl loader is able to load.
  64560. * force data to come in as an ArrayBuffer
  64561. * we'll convert to string if it looks like it's an ASCII .stl
  64562. */
  64563. extensions: ISceneLoaderPluginExtensions;
  64564. /**
  64565. * Import meshes into a scene.
  64566. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  64567. * @param scene The scene to import into
  64568. * @param data The data to import
  64569. * @param rootUrl The root url for scene and resources
  64570. * @param meshes The meshes array to import into
  64571. * @param particleSystems The particle systems array to import into
  64572. * @param skeletons The skeletons array to import into
  64573. * @param onError The callback when import fails
  64574. * @returns True if successful or false otherwise
  64575. */
  64576. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  64577. /**
  64578. * Load into a scene.
  64579. * @param scene The scene to load into
  64580. * @param data The data to import
  64581. * @param rootUrl The root url for scene and resources
  64582. * @param onError The callback when import fails
  64583. * @returns true if successful or false otherwise
  64584. */
  64585. load(scene: Scene, data: any, rootUrl: string): boolean;
  64586. /**
  64587. * Load into an asset container.
  64588. * @param scene The scene to load into
  64589. * @param data The data to import
  64590. * @param rootUrl The root url for scene and resources
  64591. * @param onError The callback when import fails
  64592. * @returns The loaded asset container
  64593. */
  64594. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  64595. private _isBinary;
  64596. private _parseBinary;
  64597. private _parseASCII;
  64598. }
  64599. }
  64600. declare module BABYLON {
  64601. /**
  64602. * Class for generating OBJ data from a Babylon scene.
  64603. */
  64604. export class OBJExport {
  64605. /**
  64606. * Exports the geometry of a Mesh array in .OBJ file format (text)
  64607. * @param mesh defines the list of meshes to serialize
  64608. * @param materials defines if materials should be exported
  64609. * @param matlibname defines the name of the associated mtl file
  64610. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  64611. * @returns the OBJ content
  64612. */
  64613. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  64614. /**
  64615. * Exports the material(s) of a mesh in .MTL file format (text)
  64616. * @param mesh defines the mesh to extract the material from
  64617. * @returns the mtl content
  64618. */
  64619. static MTL(mesh: Mesh): string;
  64620. }
  64621. }
  64622. declare module BABYLON {
  64623. /** @hidden */
  64624. export var __IGLTFExporterExtension: number;
  64625. /**
  64626. * Interface for extending the exporter
  64627. * @hidden
  64628. */
  64629. export interface IGLTFExporterExtension {
  64630. /**
  64631. * The name of this extension
  64632. */
  64633. readonly name: string;
  64634. /**
  64635. * Defines whether this extension is enabled
  64636. */
  64637. enabled: boolean;
  64638. /**
  64639. * Defines whether this extension is required
  64640. */
  64641. required: boolean;
  64642. }
  64643. }
  64644. declare module BABYLON.GLTF2.Exporter {
  64645. /** @hidden */
  64646. export var __IGLTFExporterExtensionV2: number;
  64647. /**
  64648. * Interface for a glTF exporter extension
  64649. * @hidden
  64650. */
  64651. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  64652. /**
  64653. * Define this method to modify the default behavior before exporting a texture
  64654. * @param context The context when loading the asset
  64655. * @param babylonTexture The glTF texture info property
  64656. * @param mimeType The mime-type of the generated image
  64657. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  64658. */
  64659. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  64660. /**
  64661. * Define this method to modify the default behavior when exporting texture info
  64662. * @param context The context when loading the asset
  64663. * @param meshPrimitive glTF mesh primitive
  64664. * @param babylonSubMesh Babylon submesh
  64665. * @param binaryWriter glTF serializer binary writer instance
  64666. * @returns nullable IMeshPrimitive promise
  64667. */
  64668. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  64669. /**
  64670. * Define this method to modify the default behavior when exporting a node
  64671. * @param context The context when exporting the node
  64672. * @param node glTF node
  64673. * @param babylonNode BabylonJS node
  64674. * @returns nullable INode promise
  64675. */
  64676. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  64677. /**
  64678. * Called after the exporter state changes to EXPORTING
  64679. */
  64680. onExporting?(): void;
  64681. }
  64682. }
  64683. declare module BABYLON.GLTF2.Exporter {
  64684. /**
  64685. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  64686. * @hidden
  64687. */
  64688. export class _GLTFMaterialExporter {
  64689. /**
  64690. * Represents the dielectric specular values for R, G and B
  64691. */
  64692. private static readonly _DielectricSpecular;
  64693. /**
  64694. * Allows the maximum specular power to be defined for material calculations
  64695. */
  64696. private static readonly _MaxSpecularPower;
  64697. /**
  64698. * Mapping to store textures
  64699. */
  64700. private _textureMap;
  64701. /**
  64702. * Numeric tolerance value
  64703. */
  64704. private static readonly _Epsilon;
  64705. /**
  64706. * Reference to the glTF Exporter
  64707. */
  64708. private _exporter;
  64709. constructor(exporter: _Exporter);
  64710. /**
  64711. * Specifies if two colors are approximately equal in value
  64712. * @param color1 first color to compare to
  64713. * @param color2 second color to compare to
  64714. * @param epsilon threshold value
  64715. */
  64716. private static FuzzyEquals;
  64717. /**
  64718. * Gets the materials from a Babylon scene and converts them to glTF materials
  64719. * @param scene babylonjs scene
  64720. * @param mimeType texture mime type
  64721. * @param images array of images
  64722. * @param textures array of textures
  64723. * @param materials array of materials
  64724. * @param imageData mapping of texture names to base64 textures
  64725. * @param hasTextureCoords specifies if texture coordinates are present on the material
  64726. */
  64727. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  64728. /**
  64729. * Makes a copy of the glTF material without the texture parameters
  64730. * @param originalMaterial original glTF material
  64731. * @returns glTF material without texture parameters
  64732. */
  64733. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  64734. /**
  64735. * Specifies if the material has any texture parameters present
  64736. * @param material glTF Material
  64737. * @returns boolean specifying if texture parameters are present
  64738. */
  64739. _hasTexturesPresent(material: IMaterial): boolean;
  64740. /**
  64741. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  64742. * @param babylonStandardMaterial
  64743. * @returns glTF Metallic Roughness Material representation
  64744. */
  64745. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  64746. /**
  64747. * Computes the metallic factor
  64748. * @param diffuse diffused value
  64749. * @param specular specular value
  64750. * @param oneMinusSpecularStrength one minus the specular strength
  64751. * @returns metallic value
  64752. */
  64753. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  64754. /**
  64755. * Gets the glTF alpha mode from the Babylon Material
  64756. * @param babylonMaterial Babylon Material
  64757. * @returns The Babylon alpha mode value
  64758. */
  64759. _getAlphaMode(babylonMaterial: Material): MaterialAlphaMode;
  64760. /**
  64761. * Converts a Babylon Standard Material to a glTF Material
  64762. * @param babylonStandardMaterial BJS Standard Material
  64763. * @param mimeType mime type to use for the textures
  64764. * @param images array of glTF image interfaces
  64765. * @param textures array of glTF texture interfaces
  64766. * @param materials array of glTF material interfaces
  64767. * @param imageData map of image file name to data
  64768. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  64769. */
  64770. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  64771. /**
  64772. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  64773. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  64774. * @param mimeType mime type to use for the textures
  64775. * @param images array of glTF image interfaces
  64776. * @param textures array of glTF texture interfaces
  64777. * @param materials array of glTF material interfaces
  64778. * @param imageData map of image file name to data
  64779. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  64780. */
  64781. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  64782. /**
  64783. * Converts an image typed array buffer to a base64 image
  64784. * @param buffer typed array buffer
  64785. * @param width width of the image
  64786. * @param height height of the image
  64787. * @param mimeType mimetype of the image
  64788. * @returns base64 image string
  64789. */
  64790. private _createBase64FromCanvasAsync;
  64791. /**
  64792. * Generates a white texture based on the specified width and height
  64793. * @param width width of the texture in pixels
  64794. * @param height height of the texture in pixels
  64795. * @param scene babylonjs scene
  64796. * @returns white texture
  64797. */
  64798. private _createWhiteTexture;
  64799. /**
  64800. * 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
  64801. * @param texture1 first texture to resize
  64802. * @param texture2 second texture to resize
  64803. * @param scene babylonjs scene
  64804. * @returns resized textures or null
  64805. */
  64806. private _resizeTexturesToSameDimensions;
  64807. /**
  64808. * Converts an array of pixels to a Float32Array
  64809. * Throws an error if the pixel format is not supported
  64810. * @param pixels - array buffer containing pixel values
  64811. * @returns Float32 of pixels
  64812. */
  64813. private _convertPixelArrayToFloat32;
  64814. /**
  64815. * Convert Specular Glossiness Textures to Metallic Roughness
  64816. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  64817. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  64818. * @param diffuseTexture texture used to store diffuse information
  64819. * @param specularGlossinessTexture texture used to store specular and glossiness information
  64820. * @param factors specular glossiness material factors
  64821. * @param mimeType the mime type to use for the texture
  64822. * @returns pbr metallic roughness interface or null
  64823. */
  64824. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  64825. /**
  64826. * Converts specular glossiness material properties to metallic roughness
  64827. * @param specularGlossiness interface with specular glossiness material properties
  64828. * @returns interface with metallic roughness material properties
  64829. */
  64830. private _convertSpecularGlossinessToMetallicRoughness;
  64831. /**
  64832. * Calculates the surface reflectance, independent of lighting conditions
  64833. * @param color Color source to calculate brightness from
  64834. * @returns number representing the perceived brightness, or zero if color is undefined
  64835. */
  64836. private _getPerceivedBrightness;
  64837. /**
  64838. * Returns the maximum color component value
  64839. * @param color
  64840. * @returns maximum color component value, or zero if color is null or undefined
  64841. */
  64842. private _getMaxComponent;
  64843. /**
  64844. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  64845. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  64846. * @param mimeType mime type to use for the textures
  64847. * @param images array of glTF image interfaces
  64848. * @param textures array of glTF texture interfaces
  64849. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  64850. * @param imageData map of image file name to data
  64851. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  64852. * @returns glTF PBR Metallic Roughness factors
  64853. */
  64854. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  64855. private _getGLTFTextureSampler;
  64856. private _getGLTFTextureWrapMode;
  64857. private _getGLTFTextureWrapModesSampler;
  64858. /**
  64859. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  64860. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  64861. * @param mimeType mime type to use for the textures
  64862. * @param images array of glTF image interfaces
  64863. * @param textures array of glTF texture interfaces
  64864. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  64865. * @param imageData map of image file name to data
  64866. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  64867. * @returns glTF PBR Metallic Roughness factors
  64868. */
  64869. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  64870. /**
  64871. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  64872. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  64873. * @param mimeType mime type to use for the textures
  64874. * @param images array of glTF image interfaces
  64875. * @param textures array of glTF texture interfaces
  64876. * @param materials array of glTF material interfaces
  64877. * @param imageData map of image file name to data
  64878. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  64879. */
  64880. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  64881. private setMetallicRoughnessPbrMaterial;
  64882. private getPixelsFromTexture;
  64883. /**
  64884. * Extracts a texture from a Babylon texture into file data and glTF data
  64885. * @param babylonTexture Babylon texture to extract
  64886. * @param mimeType Mime Type of the babylonTexture
  64887. * @return glTF texture info, or null if the texture format is not supported
  64888. */
  64889. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  64890. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  64891. /**
  64892. * Builds a texture from base64 string
  64893. * @param base64Texture base64 texture string
  64894. * @param baseTextureName Name to use for the texture
  64895. * @param mimeType image mime type for the texture
  64896. * @param images array of images
  64897. * @param textures array of textures
  64898. * @param imageData map of image data
  64899. * @returns glTF texture info, or null if the texture format is not supported
  64900. */
  64901. private _getTextureInfoFromBase64;
  64902. }
  64903. }
  64904. declare module BABYLON {
  64905. /**
  64906. * Class for holding and downloading glTF file data
  64907. */
  64908. export class GLTFData {
  64909. /**
  64910. * Object which contains the file name as the key and its data as the value
  64911. */
  64912. glTFFiles: {
  64913. [fileName: string]: string | Blob;
  64914. };
  64915. /**
  64916. * Initializes the glTF file object
  64917. */
  64918. constructor();
  64919. /**
  64920. * Downloads the glTF data as files based on their names and data
  64921. */
  64922. downloadFiles(): void;
  64923. }
  64924. }
  64925. declare module BABYLON {
  64926. /**
  64927. * Holds a collection of exporter options and parameters
  64928. */
  64929. export interface IExportOptions {
  64930. /**
  64931. * Function which indicates whether a babylon node should be exported or not
  64932. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  64933. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  64934. */
  64935. shouldExportNode?(node: Node): boolean;
  64936. /**
  64937. * The sample rate to bake animation curves
  64938. */
  64939. animationSampleRate?: number;
  64940. /**
  64941. * Begin serialization without waiting for the scene to be ready
  64942. */
  64943. exportWithoutWaitingForScene?: boolean;
  64944. }
  64945. /**
  64946. * Class for generating glTF data from a Babylon scene.
  64947. */
  64948. export class GLTF2Export {
  64949. /**
  64950. * Exports the geometry of the scene to .gltf file format asynchronously
  64951. * @param scene Babylon scene with scene hierarchy information
  64952. * @param filePrefix File prefix to use when generating the glTF file
  64953. * @param options Exporter options
  64954. * @returns Returns an object with a .gltf file and associates texture names
  64955. * as keys and their data and paths as values
  64956. */
  64957. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  64958. private static _PreExportAsync;
  64959. private static _PostExportAsync;
  64960. /**
  64961. * Exports the geometry of the scene to .glb file format asychronously
  64962. * @param scene Babylon scene with scene hierarchy information
  64963. * @param filePrefix File prefix to use when generating glb file
  64964. * @param options Exporter options
  64965. * @returns Returns an object with a .glb filename as key and data as value
  64966. */
  64967. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  64968. }
  64969. }
  64970. declare module BABYLON.GLTF2.Exporter {
  64971. /**
  64972. * @hidden
  64973. */
  64974. export class _GLTFUtilities {
  64975. /**
  64976. * Creates a buffer view based on the supplied arguments
  64977. * @param bufferIndex index value of the specified buffer
  64978. * @param byteOffset byte offset value
  64979. * @param byteLength byte length of the bufferView
  64980. * @param byteStride byte distance between conequential elements
  64981. * @param name name of the buffer view
  64982. * @returns bufferView for glTF
  64983. */
  64984. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  64985. /**
  64986. * Creates an accessor based on the supplied arguments
  64987. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  64988. * @param name The name of the accessor
  64989. * @param type The type of the accessor
  64990. * @param componentType The datatype of components in the attribute
  64991. * @param count The number of attributes referenced by this accessor
  64992. * @param byteOffset The offset relative to the start of the bufferView in bytes
  64993. * @param min Minimum value of each component in this attribute
  64994. * @param max Maximum value of each component in this attribute
  64995. * @returns accessor for glTF
  64996. */
  64997. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  64998. /**
  64999. * Calculates the minimum and maximum values of an array of position floats
  65000. * @param positions Positions array of a mesh
  65001. * @param vertexStart Starting vertex offset to calculate min and max values
  65002. * @param vertexCount Number of vertices to check for min and max values
  65003. * @returns min number array and max number array
  65004. */
  65005. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  65006. min: number[];
  65007. max: number[];
  65008. };
  65009. /**
  65010. * Converts a new right-handed Vector3
  65011. * @param vector vector3 array
  65012. * @returns right-handed Vector3
  65013. */
  65014. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  65015. /**
  65016. * Converts a Vector3 to right-handed
  65017. * @param vector Vector3 to convert to right-handed
  65018. */
  65019. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  65020. /**
  65021. * Converts a three element number array to right-handed
  65022. * @param vector number array to convert to right-handed
  65023. */
  65024. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  65025. /**
  65026. * Converts a new right-handed Vector3
  65027. * @param vector vector3 array
  65028. * @returns right-handed Vector3
  65029. */
  65030. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  65031. /**
  65032. * Converts a Vector3 to right-handed
  65033. * @param vector Vector3 to convert to right-handed
  65034. */
  65035. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  65036. /**
  65037. * Converts a three element number array to right-handed
  65038. * @param vector number array to convert to right-handed
  65039. */
  65040. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  65041. /**
  65042. * Converts a Vector4 to right-handed
  65043. * @param vector Vector4 to convert to right-handed
  65044. */
  65045. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  65046. /**
  65047. * Converts a Vector4 to right-handed
  65048. * @param vector Vector4 to convert to right-handed
  65049. */
  65050. static _GetRightHandedArray4FromRef(vector: number[]): void;
  65051. /**
  65052. * Converts a Quaternion to right-handed
  65053. * @param quaternion Source quaternion to convert to right-handed
  65054. */
  65055. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  65056. /**
  65057. * Converts a Quaternion to right-handed
  65058. * @param quaternion Source quaternion to convert to right-handed
  65059. */
  65060. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  65061. static _NormalizeTangentFromRef(tangent: Vector4): void;
  65062. }
  65063. }
  65064. declare module BABYLON.GLTF2.Exporter {
  65065. /**
  65066. * Converts Babylon Scene into glTF 2.0.
  65067. * @hidden
  65068. */
  65069. export class _Exporter {
  65070. /**
  65071. * Stores the glTF to export
  65072. */
  65073. _glTF: IGLTF;
  65074. /**
  65075. * Stores all generated buffer views, which represents views into the main glTF buffer data
  65076. */
  65077. _bufferViews: IBufferView[];
  65078. /**
  65079. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  65080. */
  65081. _accessors: IAccessor[];
  65082. /**
  65083. * Stores all the generated nodes, which contains transform and/or mesh information per node
  65084. */
  65085. private _nodes;
  65086. /**
  65087. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  65088. */
  65089. private _scenes;
  65090. /**
  65091. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  65092. */
  65093. private _meshes;
  65094. /**
  65095. * Stores all the generated material information, which represents the appearance of each primitive
  65096. */
  65097. _materials: IMaterial[];
  65098. _materialMap: {
  65099. [materialID: number]: number;
  65100. };
  65101. /**
  65102. * Stores all the generated texture information, which is referenced by glTF materials
  65103. */
  65104. _textures: ITexture[];
  65105. /**
  65106. * Stores all the generated image information, which is referenced by glTF textures
  65107. */
  65108. _images: IImage[];
  65109. /**
  65110. * Stores all the texture samplers
  65111. */
  65112. _samplers: ISampler[];
  65113. /**
  65114. * Stores all the generated animation samplers, which is referenced by glTF animations
  65115. */
  65116. /**
  65117. * Stores the animations for glTF models
  65118. */
  65119. private _animations;
  65120. /**
  65121. * Stores the total amount of bytes stored in the glTF buffer
  65122. */
  65123. private _totalByteLength;
  65124. /**
  65125. * Stores a reference to the Babylon scene containing the source geometry and material information
  65126. */
  65127. _babylonScene: Scene;
  65128. /**
  65129. * Stores a map of the image data, where the key is the file name and the value
  65130. * is the image data
  65131. */
  65132. _imageData: {
  65133. [fileName: string]: {
  65134. data: Uint8Array;
  65135. mimeType: ImageMimeType;
  65136. };
  65137. };
  65138. /**
  65139. * Stores a map of the unique id of a node to its index in the node array
  65140. */
  65141. private _nodeMap;
  65142. /**
  65143. * Specifies if the Babylon scene should be converted to right-handed on export
  65144. */
  65145. _convertToRightHandedSystem: boolean;
  65146. /**
  65147. * Baked animation sample rate
  65148. */
  65149. private _animationSampleRate;
  65150. /**
  65151. * Callback which specifies if a node should be exported or not
  65152. */
  65153. private _shouldExportNode;
  65154. private _localEngine;
  65155. _glTFMaterialExporter: _GLTFMaterialExporter;
  65156. private _extensions;
  65157. private static _ExtensionNames;
  65158. private static _ExtensionFactories;
  65159. private _applyExtensions;
  65160. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<BaseTexture>>;
  65161. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  65162. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  65163. private _forEachExtensions;
  65164. private _extensionsOnExporting;
  65165. /**
  65166. * Load glTF serializer extensions
  65167. */
  65168. private _loadExtensions;
  65169. /**
  65170. * Creates a glTF Exporter instance, which can accept optional exporter options
  65171. * @param babylonScene Babylon scene object
  65172. * @param options Options to modify the behavior of the exporter
  65173. */
  65174. constructor(babylonScene: Scene, options?: IExportOptions);
  65175. /**
  65176. * Registers a glTF exporter extension
  65177. * @param name Name of the extension to export
  65178. * @param factory The factory function that creates the exporter extension
  65179. */
  65180. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  65181. /**
  65182. * Un-registers an exporter extension
  65183. * @param name The name fo the exporter extension
  65184. * @returns A boolean indicating whether the extension has been un-registered
  65185. */
  65186. static UnregisterExtension(name: string): boolean;
  65187. /**
  65188. * Lazy load a local engine with premultiplied alpha set to false
  65189. */
  65190. _getLocalEngine(): Engine;
  65191. private reorderIndicesBasedOnPrimitiveMode;
  65192. /**
  65193. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  65194. * clock-wise during export to glTF
  65195. * @param submesh BabylonJS submesh
  65196. * @param primitiveMode Primitive mode of the mesh
  65197. * @param sideOrientation the winding order of the submesh
  65198. * @param vertexBufferKind The type of vertex attribute
  65199. * @param meshAttributeArray The vertex attribute data
  65200. * @param byteOffset The offset to the binary data
  65201. * @param binaryWriter The binary data for the glTF file
  65202. */
  65203. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  65204. /**
  65205. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  65206. * clock-wise during export to glTF
  65207. * @param submesh BabylonJS submesh
  65208. * @param primitiveMode Primitive mode of the mesh
  65209. * @param sideOrientation the winding order of the submesh
  65210. * @param vertexBufferKind The type of vertex attribute
  65211. * @param meshAttributeArray The vertex attribute data
  65212. * @param byteOffset The offset to the binary data
  65213. * @param binaryWriter The binary data for the glTF file
  65214. */
  65215. private reorderTriangleFillMode;
  65216. /**
  65217. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  65218. * clock-wise during export to glTF
  65219. * @param submesh BabylonJS submesh
  65220. * @param primitiveMode Primitive mode of the mesh
  65221. * @param sideOrientation the winding order of the submesh
  65222. * @param vertexBufferKind The type of vertex attribute
  65223. * @param meshAttributeArray The vertex attribute data
  65224. * @param byteOffset The offset to the binary data
  65225. * @param binaryWriter The binary data for the glTF file
  65226. */
  65227. private reorderTriangleStripDrawMode;
  65228. /**
  65229. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  65230. * clock-wise during export to glTF
  65231. * @param submesh BabylonJS submesh
  65232. * @param primitiveMode Primitive mode of the mesh
  65233. * @param sideOrientation the winding order of the submesh
  65234. * @param vertexBufferKind The type of vertex attribute
  65235. * @param meshAttributeArray The vertex attribute data
  65236. * @param byteOffset The offset to the binary data
  65237. * @param binaryWriter The binary data for the glTF file
  65238. */
  65239. private reorderTriangleFanMode;
  65240. /**
  65241. * Writes the vertex attribute data to binary
  65242. * @param vertices The vertices to write to the binary writer
  65243. * @param byteOffset The offset into the binary writer to overwrite binary data
  65244. * @param vertexAttributeKind The vertex attribute type
  65245. * @param meshAttributeArray The vertex attribute data
  65246. * @param binaryWriter The writer containing the binary data
  65247. */
  65248. private writeVertexAttributeData;
  65249. /**
  65250. * Writes mesh attribute data to a data buffer
  65251. * Returns the bytelength of the data
  65252. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  65253. * @param meshAttributeArray Array containing the attribute data
  65254. * @param binaryWriter The buffer to write the binary data to
  65255. * @param indices Used to specify the order of the vertex data
  65256. */
  65257. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  65258. /**
  65259. * Generates glTF json data
  65260. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  65261. * @param glTFPrefix Text to use when prefixing a glTF file
  65262. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  65263. * @returns json data as string
  65264. */
  65265. private generateJSON;
  65266. /**
  65267. * Generates data for .gltf and .bin files based on the glTF prefix string
  65268. * @param glTFPrefix Text to use when prefixing a glTF file
  65269. * @returns GLTFData with glTF file data
  65270. */
  65271. _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  65272. /**
  65273. * Creates a binary buffer for glTF
  65274. * @returns array buffer for binary data
  65275. */
  65276. private _generateBinaryAsync;
  65277. /**
  65278. * Pads the number to a multiple of 4
  65279. * @param num number to pad
  65280. * @returns padded number
  65281. */
  65282. private _getPadding;
  65283. /**
  65284. * Generates a glb file from the json and binary data
  65285. * Returns an object with the glb file name as the key and data as the value
  65286. * @param glTFPrefix
  65287. * @returns object with glb filename as key and data as value
  65288. */
  65289. _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  65290. /**
  65291. * Sets the TRS for each node
  65292. * @param node glTF Node for storing the transformation data
  65293. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  65294. */
  65295. private setNodeTransformation;
  65296. private getVertexBufferFromMesh;
  65297. /**
  65298. * Creates a bufferview based on the vertices type for the Babylon mesh
  65299. * @param kind Indicates the type of vertices data
  65300. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  65301. * @param binaryWriter The buffer to write the bufferview data to
  65302. */
  65303. private createBufferViewKind;
  65304. /**
  65305. * The primitive mode of the Babylon mesh
  65306. * @param babylonMesh The BabylonJS mesh
  65307. */
  65308. private getMeshPrimitiveMode;
  65309. /**
  65310. * Sets the primitive mode of the glTF mesh primitive
  65311. * @param meshPrimitive glTF mesh primitive
  65312. * @param primitiveMode The primitive mode
  65313. */
  65314. private setPrimitiveMode;
  65315. /**
  65316. * Sets the vertex attribute accessor based of the glTF mesh primitive
  65317. * @param meshPrimitive glTF mesh primitive
  65318. * @param attributeKind vertex attribute
  65319. * @returns boolean specifying if uv coordinates are present
  65320. */
  65321. private setAttributeKind;
  65322. /**
  65323. * Sets data for the primitive attributes of each submesh
  65324. * @param mesh glTF Mesh object to store the primitive attribute information
  65325. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  65326. * @param binaryWriter Buffer to write the attribute data to
  65327. */
  65328. private setPrimitiveAttributesAsync;
  65329. /**
  65330. * Creates a glTF scene based on the array of meshes
  65331. * Returns the the total byte offset
  65332. * @param babylonScene Babylon scene to get the mesh data from
  65333. * @param binaryWriter Buffer to write binary data to
  65334. */
  65335. private createSceneAsync;
  65336. /**
  65337. * Creates a mapping of Node unique id to node index and handles animations
  65338. * @param babylonScene Babylon Scene
  65339. * @param nodes Babylon transform nodes
  65340. * @param shouldExportNode Callback specifying if a transform node should be exported
  65341. * @param binaryWriter Buffer to write binary data to
  65342. * @returns Node mapping of unique id to index
  65343. */
  65344. private createNodeMapAndAnimationsAsync;
  65345. /**
  65346. * Creates a glTF node from a Babylon mesh
  65347. * @param babylonMesh Source Babylon mesh
  65348. * @param binaryWriter Buffer for storing geometry data
  65349. * @returns glTF node
  65350. */
  65351. private createNodeAsync;
  65352. }
  65353. /**
  65354. * @hidden
  65355. *
  65356. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  65357. */
  65358. export class _BinaryWriter {
  65359. /**
  65360. * Array buffer which stores all binary data
  65361. */
  65362. private _arrayBuffer;
  65363. /**
  65364. * View of the array buffer
  65365. */
  65366. private _dataView;
  65367. /**
  65368. * byte offset of data in array buffer
  65369. */
  65370. private _byteOffset;
  65371. /**
  65372. * Initialize binary writer with an initial byte length
  65373. * @param byteLength Initial byte length of the array buffer
  65374. */
  65375. constructor(byteLength: number);
  65376. /**
  65377. * Resize the array buffer to the specified byte length
  65378. * @param byteLength
  65379. */
  65380. private resizeBuffer;
  65381. /**
  65382. * Get an array buffer with the length of the byte offset
  65383. * @returns ArrayBuffer resized to the byte offset
  65384. */
  65385. getArrayBuffer(): ArrayBuffer;
  65386. /**
  65387. * Get the byte offset of the array buffer
  65388. * @returns byte offset
  65389. */
  65390. getByteOffset(): number;
  65391. /**
  65392. * Stores an UInt8 in the array buffer
  65393. * @param entry
  65394. * @param byteOffset If defined, specifies where to set the value as an offset.
  65395. */
  65396. setUInt8(entry: number, byteOffset?: number): void;
  65397. /**
  65398. * Gets an UInt32 in the array buffer
  65399. * @param entry
  65400. * @param byteOffset If defined, specifies where to set the value as an offset.
  65401. */
  65402. getUInt32(byteOffset: number): number;
  65403. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  65404. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  65405. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  65406. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  65407. /**
  65408. * Stores a Float32 in the array buffer
  65409. * @param entry
  65410. */
  65411. setFloat32(entry: number, byteOffset?: number): void;
  65412. /**
  65413. * Stores an UInt32 in the array buffer
  65414. * @param entry
  65415. * @param byteOffset If defined, specifies where to set the value as an offset.
  65416. */
  65417. setUInt32(entry: number, byteOffset?: number): void;
  65418. }
  65419. }
  65420. declare module BABYLON.GLTF2.Exporter {
  65421. /**
  65422. * @hidden
  65423. * Interface to store animation data.
  65424. */
  65425. export interface _IAnimationData {
  65426. /**
  65427. * Keyframe data.
  65428. */
  65429. inputs: number[];
  65430. /**
  65431. * Value data.
  65432. */
  65433. outputs: number[][];
  65434. /**
  65435. * Animation interpolation data.
  65436. */
  65437. samplerInterpolation: AnimationSamplerInterpolation;
  65438. /**
  65439. * Minimum keyframe value.
  65440. */
  65441. inputsMin: number;
  65442. /**
  65443. * Maximum keyframe value.
  65444. */
  65445. inputsMax: number;
  65446. }
  65447. /**
  65448. * @hidden
  65449. */
  65450. export interface _IAnimationInfo {
  65451. /**
  65452. * The target channel for the animation
  65453. */
  65454. animationChannelTargetPath: AnimationChannelTargetPath;
  65455. /**
  65456. * The glTF accessor type for the data.
  65457. */
  65458. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  65459. /**
  65460. * Specifies if quaternions should be used.
  65461. */
  65462. useQuaternion: boolean;
  65463. }
  65464. /**
  65465. * @hidden
  65466. * Utility class for generating glTF animation data from BabylonJS.
  65467. */
  65468. export class _GLTFAnimation {
  65469. /**
  65470. * @ignore
  65471. *
  65472. * Creates glTF channel animation from BabylonJS animation.
  65473. * @param babylonTransformNode - BabylonJS mesh.
  65474. * @param animation - animation.
  65475. * @param animationChannelTargetPath - The target animation channel.
  65476. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  65477. * @param useQuaternion - Specifies if quaternions are used.
  65478. * @returns nullable IAnimationData
  65479. */
  65480. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  65481. private static _DeduceAnimationInfo;
  65482. /**
  65483. * @ignore
  65484. * Create node animations from the transform node animations
  65485. * @param babylonNode
  65486. * @param runtimeGLTFAnimation
  65487. * @param idleGLTFAnimations
  65488. * @param nodeMap
  65489. * @param nodes
  65490. * @param binaryWriter
  65491. * @param bufferViews
  65492. * @param accessors
  65493. * @param convertToRightHandedSystem
  65494. */
  65495. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  65496. [key: number]: number;
  65497. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  65498. /**
  65499. * @ignore
  65500. * Create node animations from the animation groups
  65501. * @param babylonScene
  65502. * @param glTFAnimations
  65503. * @param nodeMap
  65504. * @param nodes
  65505. * @param binaryWriter
  65506. * @param bufferViews
  65507. * @param accessors
  65508. * @param convertToRightHandedSystem
  65509. */
  65510. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  65511. [key: number]: number;
  65512. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  65513. private static AddAnimation;
  65514. /**
  65515. * Create a baked animation
  65516. * @param babylonTransformNode BabylonJS mesh
  65517. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  65518. * @param animationChannelTargetPath animation target channel
  65519. * @param minFrame minimum animation frame
  65520. * @param maxFrame maximum animation frame
  65521. * @param fps frames per second of the animation
  65522. * @param inputs input key frames of the animation
  65523. * @param outputs output key frame data of the animation
  65524. * @param convertToRightHandedSystem converts the values to right-handed
  65525. * @param useQuaternion specifies if quaternions should be used
  65526. */
  65527. private static _CreateBakedAnimation;
  65528. private static _ConvertFactorToVector3OrQuaternion;
  65529. private static _SetInterpolatedValue;
  65530. /**
  65531. * Creates linear animation from the animation key frames
  65532. * @param babylonTransformNode BabylonJS mesh
  65533. * @param animation BabylonJS animation
  65534. * @param animationChannelTargetPath The target animation channel
  65535. * @param frameDelta The difference between the last and first frame of the animation
  65536. * @param inputs Array to store the key frame times
  65537. * @param outputs Array to store the key frame data
  65538. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  65539. * @param useQuaternion Specifies if quaternions are used in the animation
  65540. */
  65541. private static _CreateLinearOrStepAnimation;
  65542. /**
  65543. * Creates cubic spline animation from the animation key frames
  65544. * @param babylonTransformNode BabylonJS mesh
  65545. * @param animation BabylonJS animation
  65546. * @param animationChannelTargetPath The target animation channel
  65547. * @param frameDelta The difference between the last and first frame of the animation
  65548. * @param inputs Array to store the key frame times
  65549. * @param outputs Array to store the key frame data
  65550. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  65551. * @param useQuaternion Specifies if quaternions are used in the animation
  65552. */
  65553. private static _CreateCubicSplineAnimation;
  65554. private static _GetBasePositionRotationOrScale;
  65555. /**
  65556. * Adds a key frame value
  65557. * @param keyFrame
  65558. * @param animation
  65559. * @param outputs
  65560. * @param animationChannelTargetPath
  65561. * @param basePositionRotationOrScale
  65562. * @param convertToRightHandedSystem
  65563. * @param useQuaternion
  65564. */
  65565. private static _AddKeyframeValue;
  65566. /**
  65567. * Determine the interpolation based on the key frames
  65568. * @param keyFrames
  65569. * @param animationChannelTargetPath
  65570. * @param useQuaternion
  65571. */
  65572. private static _DeduceInterpolation;
  65573. /**
  65574. * Adds an input tangent or output tangent to the output data
  65575. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  65576. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  65577. * @param outputs The animation data by keyframe
  65578. * @param animationChannelTargetPath The target animation channel
  65579. * @param interpolation The interpolation type
  65580. * @param keyFrame The key frame with the animation data
  65581. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  65582. * @param useQuaternion Specifies if quaternions are used
  65583. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  65584. */
  65585. private static AddSplineTangent;
  65586. /**
  65587. * Get the minimum and maximum key frames' frame values
  65588. * @param keyFrames animation key frames
  65589. * @returns the minimum and maximum key frame value
  65590. */
  65591. private static calculateMinMaxKeyFrames;
  65592. }
  65593. }
  65594. declare module BABYLON.GLTF2.Exporter {
  65595. /** @hidden */
  65596. export var textureTransformPixelShader: {
  65597. name: string;
  65598. shader: string;
  65599. };
  65600. }
  65601. declare module BABYLON.GLTF2.Exporter.Extensions {
  65602. /**
  65603. * @hidden
  65604. */
  65605. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  65606. /** Name of this extension */
  65607. readonly name: string;
  65608. /** Defines whether this extension is enabled */
  65609. enabled: boolean;
  65610. /** Defines whether this extension is required */
  65611. required: boolean;
  65612. /** Reference to the glTF exporter */
  65613. private _exporter;
  65614. constructor(exporter: _Exporter);
  65615. dispose(): void;
  65616. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  65617. /**
  65618. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  65619. * @param babylonTexture
  65620. * @param offset
  65621. * @param rotation
  65622. * @param scale
  65623. * @param scene
  65624. */
  65625. private _textureTransformTextureAsync;
  65626. }
  65627. }
  65628. declare module BABYLON.GLTF2.Exporter.Extensions {
  65629. /**
  65630. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  65631. */
  65632. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  65633. /** The name of this extension. */
  65634. readonly name: string;
  65635. /** Defines whether this extension is enabled. */
  65636. enabled: boolean;
  65637. /** Defines whether this extension is required */
  65638. required: boolean;
  65639. /** Reference to the glTF exporter */
  65640. private _exporter;
  65641. private _lights;
  65642. /** @hidden */
  65643. constructor(exporter: _Exporter);
  65644. /** @hidden */
  65645. dispose(): void;
  65646. /** @hidden */
  65647. onExporting(): void;
  65648. /**
  65649. * Define this method to modify the default behavior when exporting a node
  65650. * @param context The context when exporting the node
  65651. * @param node glTF node
  65652. * @param babylonNode BabylonJS node
  65653. * @returns nullable INode promise
  65654. */
  65655. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  65656. }
  65657. }
  65658. declare module BABYLON {
  65659. /**
  65660. * Class for generating STL data from a Babylon scene.
  65661. */
  65662. export class STLExport {
  65663. /**
  65664. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  65665. * @param meshes list defines the mesh to serialize
  65666. * @param download triggers the automatic download of the file.
  65667. * @param fileName changes the downloads fileName.
  65668. * @param binary changes the STL to a binary type.
  65669. * @param isLittleEndian toggle for binary type exporter.
  65670. * @returns the STL as UTF8 string
  65671. */
  65672. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  65673. }
  65674. }
  65675. /**
  65676. * @ignoreChildren
  65677. * @ignore
  65678. */
  65679. declare module "babylonjs-gltf2interface" {
  65680. export = BABYLON.GLTF2;
  65681. }
  65682. /**
  65683. * Module for glTF 2.0 Interface
  65684. * @ignoreChildren
  65685. * @ignore
  65686. */
  65687. declare module BABYLON.GLTF2 {
  65688. /**
  65689. * The datatype of the components in the attribute
  65690. */
  65691. const enum AccessorComponentType {
  65692. /**
  65693. * Byte
  65694. */
  65695. BYTE = 5120,
  65696. /**
  65697. * Unsigned Byte
  65698. */
  65699. UNSIGNED_BYTE = 5121,
  65700. /**
  65701. * Short
  65702. */
  65703. SHORT = 5122,
  65704. /**
  65705. * Unsigned Short
  65706. */
  65707. UNSIGNED_SHORT = 5123,
  65708. /**
  65709. * Unsigned Int
  65710. */
  65711. UNSIGNED_INT = 5125,
  65712. /**
  65713. * Float
  65714. */
  65715. FLOAT = 5126,
  65716. }
  65717. /**
  65718. * Specifies if the attirbute is a scalar, vector, or matrix
  65719. */
  65720. const enum AccessorType {
  65721. /**
  65722. * Scalar
  65723. */
  65724. SCALAR = "SCALAR",
  65725. /**
  65726. * Vector2
  65727. */
  65728. VEC2 = "VEC2",
  65729. /**
  65730. * Vector3
  65731. */
  65732. VEC3 = "VEC3",
  65733. /**
  65734. * Vector4
  65735. */
  65736. VEC4 = "VEC4",
  65737. /**
  65738. * Matrix2x2
  65739. */
  65740. MAT2 = "MAT2",
  65741. /**
  65742. * Matrix3x3
  65743. */
  65744. MAT3 = "MAT3",
  65745. /**
  65746. * Matrix4x4
  65747. */
  65748. MAT4 = "MAT4",
  65749. }
  65750. /**
  65751. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  65752. */
  65753. const enum AnimationChannelTargetPath {
  65754. /**
  65755. * Translation
  65756. */
  65757. TRANSLATION = "translation",
  65758. /**
  65759. * Rotation
  65760. */
  65761. ROTATION = "rotation",
  65762. /**
  65763. * Scale
  65764. */
  65765. SCALE = "scale",
  65766. /**
  65767. * Weights
  65768. */
  65769. WEIGHTS = "weights",
  65770. }
  65771. /**
  65772. * Interpolation algorithm
  65773. */
  65774. const enum AnimationSamplerInterpolation {
  65775. /**
  65776. * The animated values are linearly interpolated between keyframes
  65777. */
  65778. LINEAR = "LINEAR",
  65779. /**
  65780. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  65781. */
  65782. STEP = "STEP",
  65783. /**
  65784. * The animation's interpolation is computed using a cubic spline with specified tangents
  65785. */
  65786. CUBICSPLINE = "CUBICSPLINE",
  65787. }
  65788. /**
  65789. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  65790. */
  65791. const enum CameraType {
  65792. /**
  65793. * A perspective camera containing properties to create a perspective projection matrix
  65794. */
  65795. PERSPECTIVE = "perspective",
  65796. /**
  65797. * An orthographic camera containing properties to create an orthographic projection matrix
  65798. */
  65799. ORTHOGRAPHIC = "orthographic",
  65800. }
  65801. /**
  65802. * The mime-type of the image
  65803. */
  65804. const enum ImageMimeType {
  65805. /**
  65806. * JPEG Mime-type
  65807. */
  65808. JPEG = "image/jpeg",
  65809. /**
  65810. * PNG Mime-type
  65811. */
  65812. PNG = "image/png",
  65813. }
  65814. /**
  65815. * The alpha rendering mode of the material
  65816. */
  65817. const enum MaterialAlphaMode {
  65818. /**
  65819. * The alpha value is ignored and the rendered output is fully opaque
  65820. */
  65821. OPAQUE = "OPAQUE",
  65822. /**
  65823. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  65824. */
  65825. MASK = "MASK",
  65826. /**
  65827. * 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)
  65828. */
  65829. BLEND = "BLEND",
  65830. }
  65831. /**
  65832. * The type of the primitives to render
  65833. */
  65834. const enum MeshPrimitiveMode {
  65835. /**
  65836. * Points
  65837. */
  65838. POINTS = 0,
  65839. /**
  65840. * Lines
  65841. */
  65842. LINES = 1,
  65843. /**
  65844. * Line Loop
  65845. */
  65846. LINE_LOOP = 2,
  65847. /**
  65848. * Line Strip
  65849. */
  65850. LINE_STRIP = 3,
  65851. /**
  65852. * Triangles
  65853. */
  65854. TRIANGLES = 4,
  65855. /**
  65856. * Triangle Strip
  65857. */
  65858. TRIANGLE_STRIP = 5,
  65859. /**
  65860. * Triangle Fan
  65861. */
  65862. TRIANGLE_FAN = 6,
  65863. }
  65864. /**
  65865. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  65866. */
  65867. const enum TextureMagFilter {
  65868. /**
  65869. * Nearest
  65870. */
  65871. NEAREST = 9728,
  65872. /**
  65873. * Linear
  65874. */
  65875. LINEAR = 9729,
  65876. }
  65877. /**
  65878. * Minification filter. All valid values correspond to WebGL enums
  65879. */
  65880. const enum TextureMinFilter {
  65881. /**
  65882. * Nearest
  65883. */
  65884. NEAREST = 9728,
  65885. /**
  65886. * Linear
  65887. */
  65888. LINEAR = 9729,
  65889. /**
  65890. * Nearest Mip-Map Nearest
  65891. */
  65892. NEAREST_MIPMAP_NEAREST = 9984,
  65893. /**
  65894. * Linear Mipmap Nearest
  65895. */
  65896. LINEAR_MIPMAP_NEAREST = 9985,
  65897. /**
  65898. * Nearest Mipmap Linear
  65899. */
  65900. NEAREST_MIPMAP_LINEAR = 9986,
  65901. /**
  65902. * Linear Mipmap Linear
  65903. */
  65904. LINEAR_MIPMAP_LINEAR = 9987,
  65905. }
  65906. /**
  65907. * S (U) wrapping mode. All valid values correspond to WebGL enums
  65908. */
  65909. const enum TextureWrapMode {
  65910. /**
  65911. * Clamp to Edge
  65912. */
  65913. CLAMP_TO_EDGE = 33071,
  65914. /**
  65915. * Mirrored Repeat
  65916. */
  65917. MIRRORED_REPEAT = 33648,
  65918. /**
  65919. * Repeat
  65920. */
  65921. REPEAT = 10497,
  65922. }
  65923. /**
  65924. * glTF Property
  65925. */
  65926. interface IProperty {
  65927. /**
  65928. * Dictionary object with extension-specific objects
  65929. */
  65930. extensions?: {
  65931. [key: string]: any;
  65932. };
  65933. /**
  65934. * Application-Specific data
  65935. */
  65936. extras?: any;
  65937. }
  65938. /**
  65939. * glTF Child of Root Property
  65940. */
  65941. interface IChildRootProperty extends IProperty {
  65942. /**
  65943. * The user-defined name of this object
  65944. */
  65945. name?: string;
  65946. }
  65947. /**
  65948. * Indices of those attributes that deviate from their initialization value
  65949. */
  65950. interface IAccessorSparseIndices extends IProperty {
  65951. /**
  65952. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  65953. */
  65954. bufferView: number;
  65955. /**
  65956. * The offset relative to the start of the bufferView in bytes. Must be aligned
  65957. */
  65958. byteOffset?: number;
  65959. /**
  65960. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  65961. */
  65962. componentType: AccessorComponentType;
  65963. }
  65964. /**
  65965. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  65966. */
  65967. interface IAccessorSparseValues extends IProperty {
  65968. /**
  65969. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  65970. */
  65971. bufferView: number;
  65972. /**
  65973. * The offset relative to the start of the bufferView in bytes. Must be aligned
  65974. */
  65975. byteOffset?: number;
  65976. }
  65977. /**
  65978. * Sparse storage of attributes that deviate from their initialization value
  65979. */
  65980. interface IAccessorSparse extends IProperty {
  65981. /**
  65982. * The number of attributes encoded in this sparse accessor
  65983. */
  65984. count: number;
  65985. /**
  65986. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  65987. */
  65988. indices: IAccessorSparseIndices;
  65989. /**
  65990. * 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
  65991. */
  65992. values: IAccessorSparseValues;
  65993. }
  65994. /**
  65995. * 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
  65996. */
  65997. interface IAccessor extends IChildRootProperty {
  65998. /**
  65999. * The index of the bufferview
  66000. */
  66001. bufferView?: number;
  66002. /**
  66003. * The offset relative to the start of the bufferView in bytes
  66004. */
  66005. byteOffset?: number;
  66006. /**
  66007. * The datatype of components in the attribute
  66008. */
  66009. componentType: AccessorComponentType;
  66010. /**
  66011. * Specifies whether integer data values should be normalized
  66012. */
  66013. normalized?: boolean;
  66014. /**
  66015. * The number of attributes referenced by this accessor
  66016. */
  66017. count: number;
  66018. /**
  66019. * Specifies if the attribute is a scalar, vector, or matrix
  66020. */
  66021. type: AccessorType;
  66022. /**
  66023. * Maximum value of each component in this attribute
  66024. */
  66025. max?: number[];
  66026. /**
  66027. * Minimum value of each component in this attribute
  66028. */
  66029. min?: number[];
  66030. /**
  66031. * Sparse storage of attributes that deviate from their initialization value
  66032. */
  66033. sparse?: IAccessorSparse;
  66034. }
  66035. /**
  66036. * Targets an animation's sampler at a node's property
  66037. */
  66038. interface IAnimationChannel extends IProperty {
  66039. /**
  66040. * The index of a sampler in this animation used to compute the value for the target
  66041. */
  66042. sampler: number;
  66043. /**
  66044. * The index of the node and TRS property to target
  66045. */
  66046. target: IAnimationChannelTarget;
  66047. }
  66048. /**
  66049. * The index of the node and TRS property that an animation channel targets
  66050. */
  66051. interface IAnimationChannelTarget extends IProperty {
  66052. /**
  66053. * The index of the node to target
  66054. */
  66055. node: number;
  66056. /**
  66057. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  66058. */
  66059. path: AnimationChannelTargetPath;
  66060. }
  66061. /**
  66062. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  66063. */
  66064. interface IAnimationSampler extends IProperty {
  66065. /**
  66066. * The index of an accessor containing keyframe input values, e.g., time
  66067. */
  66068. input: number;
  66069. /**
  66070. * Interpolation algorithm
  66071. */
  66072. interpolation?: AnimationSamplerInterpolation;
  66073. /**
  66074. * The index of an accessor, containing keyframe output values
  66075. */
  66076. output: number;
  66077. }
  66078. /**
  66079. * A keyframe animation
  66080. */
  66081. interface IAnimation extends IChildRootProperty {
  66082. /**
  66083. * An array of channels, each of which targets an animation's sampler at a node's property
  66084. */
  66085. channels: IAnimationChannel[];
  66086. /**
  66087. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  66088. */
  66089. samplers: IAnimationSampler[];
  66090. }
  66091. /**
  66092. * Metadata about the glTF asset
  66093. */
  66094. interface IAsset extends IChildRootProperty {
  66095. /**
  66096. * A copyright message suitable for display to credit the content creator
  66097. */
  66098. copyright?: string;
  66099. /**
  66100. * Tool that generated this glTF model. Useful for debugging
  66101. */
  66102. generator?: string;
  66103. /**
  66104. * The glTF version that this asset targets
  66105. */
  66106. version: string;
  66107. /**
  66108. * The minimum glTF version that this asset targets
  66109. */
  66110. minVersion?: string;
  66111. }
  66112. /**
  66113. * A buffer points to binary geometry, animation, or skins
  66114. */
  66115. interface IBuffer extends IChildRootProperty {
  66116. /**
  66117. * 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
  66118. */
  66119. uri?: string;
  66120. /**
  66121. * The length of the buffer in bytes
  66122. */
  66123. byteLength: number;
  66124. }
  66125. /**
  66126. * A view into a buffer generally representing a subset of the buffer
  66127. */
  66128. interface IBufferView extends IChildRootProperty {
  66129. /**
  66130. * The index of the buffer
  66131. */
  66132. buffer: number;
  66133. /**
  66134. * The offset into the buffer in bytes
  66135. */
  66136. byteOffset?: number;
  66137. /**
  66138. * The lenth of the bufferView in bytes
  66139. */
  66140. byteLength: number;
  66141. /**
  66142. * The stride, in bytes
  66143. */
  66144. byteStride?: number;
  66145. }
  66146. /**
  66147. * An orthographic camera containing properties to create an orthographic projection matrix
  66148. */
  66149. interface ICameraOrthographic extends IProperty {
  66150. /**
  66151. * The floating-point horizontal magnification of the view. Must not be zero
  66152. */
  66153. xmag: number;
  66154. /**
  66155. * The floating-point vertical magnification of the view. Must not be zero
  66156. */
  66157. ymag: number;
  66158. /**
  66159. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  66160. */
  66161. zfar: number;
  66162. /**
  66163. * The floating-point distance to the near clipping plane
  66164. */
  66165. znear: number;
  66166. }
  66167. /**
  66168. * A perspective camera containing properties to create a perspective projection matrix
  66169. */
  66170. interface ICameraPerspective extends IProperty {
  66171. /**
  66172. * The floating-point aspect ratio of the field of view
  66173. */
  66174. aspectRatio?: number;
  66175. /**
  66176. * The floating-point vertical field of view in radians
  66177. */
  66178. yfov: number;
  66179. /**
  66180. * The floating-point distance to the far clipping plane
  66181. */
  66182. zfar?: number;
  66183. /**
  66184. * The floating-point distance to the near clipping plane
  66185. */
  66186. znear: number;
  66187. }
  66188. /**
  66189. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  66190. */
  66191. interface ICamera extends IChildRootProperty {
  66192. /**
  66193. * An orthographic camera containing properties to create an orthographic projection matrix
  66194. */
  66195. orthographic?: ICameraOrthographic;
  66196. /**
  66197. * A perspective camera containing properties to create a perspective projection matrix
  66198. */
  66199. perspective?: ICameraPerspective;
  66200. /**
  66201. * Specifies if the camera uses a perspective or orthographic projection
  66202. */
  66203. type: CameraType;
  66204. }
  66205. /**
  66206. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  66207. */
  66208. interface IImage extends IChildRootProperty {
  66209. /**
  66210. * 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
  66211. */
  66212. uri?: string;
  66213. /**
  66214. * The image's MIME type
  66215. */
  66216. mimeType?: ImageMimeType;
  66217. /**
  66218. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  66219. */
  66220. bufferView?: number;
  66221. }
  66222. /**
  66223. * Material Normal Texture Info
  66224. */
  66225. interface IMaterialNormalTextureInfo extends ITextureInfo {
  66226. /**
  66227. * The scalar multiplier applied to each normal vector of the normal texture
  66228. */
  66229. scale?: number;
  66230. }
  66231. /**
  66232. * Material Occlusion Texture Info
  66233. */
  66234. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  66235. /**
  66236. * A scalar multiplier controlling the amount of occlusion applied
  66237. */
  66238. strength?: number;
  66239. }
  66240. /**
  66241. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  66242. */
  66243. interface IMaterialPbrMetallicRoughness {
  66244. /**
  66245. * The material's base color factor
  66246. */
  66247. baseColorFactor?: number[];
  66248. /**
  66249. * The base color texture
  66250. */
  66251. baseColorTexture?: ITextureInfo;
  66252. /**
  66253. * The metalness of the material
  66254. */
  66255. metallicFactor?: number;
  66256. /**
  66257. * The roughness of the material
  66258. */
  66259. roughnessFactor?: number;
  66260. /**
  66261. * The metallic-roughness texture
  66262. */
  66263. metallicRoughnessTexture?: ITextureInfo;
  66264. }
  66265. /**
  66266. * The material appearance of a primitive
  66267. */
  66268. interface IMaterial extends IChildRootProperty {
  66269. /**
  66270. * 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
  66271. */
  66272. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  66273. /**
  66274. * The normal map texture
  66275. */
  66276. normalTexture?: IMaterialNormalTextureInfo;
  66277. /**
  66278. * The occlusion map texture
  66279. */
  66280. occlusionTexture?: IMaterialOcclusionTextureInfo;
  66281. /**
  66282. * The emissive map texture
  66283. */
  66284. emissiveTexture?: ITextureInfo;
  66285. /**
  66286. * 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
  66287. */
  66288. emissiveFactor?: number[];
  66289. /**
  66290. * The alpha rendering mode of the material
  66291. */
  66292. alphaMode?: MaterialAlphaMode;
  66293. /**
  66294. * The alpha cutoff value of the material
  66295. */
  66296. alphaCutoff?: number;
  66297. /**
  66298. * Specifies whether the material is double sided
  66299. */
  66300. doubleSided?: boolean;
  66301. }
  66302. /**
  66303. * Geometry to be rendered with the given material
  66304. */
  66305. interface IMeshPrimitive extends IProperty {
  66306. /**
  66307. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  66308. */
  66309. attributes: {
  66310. [name: string]: number;
  66311. };
  66312. /**
  66313. * The index of the accessor that contains the indices
  66314. */
  66315. indices?: number;
  66316. /**
  66317. * The index of the material to apply to this primitive when rendering
  66318. */
  66319. material?: number;
  66320. /**
  66321. * The type of primitives to render. All valid values correspond to WebGL enums
  66322. */
  66323. mode?: MeshPrimitiveMode;
  66324. /**
  66325. * 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
  66326. */
  66327. targets?: {
  66328. [name: string]: number;
  66329. }[];
  66330. }
  66331. /**
  66332. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  66333. */
  66334. interface IMesh extends IChildRootProperty {
  66335. /**
  66336. * An array of primitives, each defining geometry to be rendered with a material
  66337. */
  66338. primitives: IMeshPrimitive[];
  66339. /**
  66340. * Array of weights to be applied to the Morph Targets
  66341. */
  66342. weights?: number[];
  66343. }
  66344. /**
  66345. * A node in the node hierarchy
  66346. */
  66347. interface INode extends IChildRootProperty {
  66348. /**
  66349. * The index of the camera referenced by this node
  66350. */
  66351. camera?: number;
  66352. /**
  66353. * The indices of this node's children
  66354. */
  66355. children?: number[];
  66356. /**
  66357. * The index of the skin referenced by this node
  66358. */
  66359. skin?: number;
  66360. /**
  66361. * A floating-point 4x4 transformation matrix stored in column-major order
  66362. */
  66363. matrix?: number[];
  66364. /**
  66365. * The index of the mesh in this node
  66366. */
  66367. mesh?: number;
  66368. /**
  66369. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  66370. */
  66371. rotation?: number[];
  66372. /**
  66373. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  66374. */
  66375. scale?: number[];
  66376. /**
  66377. * The node's translation along the x, y, and z axes
  66378. */
  66379. translation?: number[];
  66380. /**
  66381. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  66382. */
  66383. weights?: number[];
  66384. }
  66385. /**
  66386. * Texture sampler properties for filtering and wrapping modes
  66387. */
  66388. interface ISampler extends IChildRootProperty {
  66389. /**
  66390. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  66391. */
  66392. magFilter?: TextureMagFilter;
  66393. /**
  66394. * Minification filter. All valid values correspond to WebGL enums
  66395. */
  66396. minFilter?: TextureMinFilter;
  66397. /**
  66398. * S (U) wrapping mode. All valid values correspond to WebGL enums
  66399. */
  66400. wrapS?: TextureWrapMode;
  66401. /**
  66402. * T (V) wrapping mode. All valid values correspond to WebGL enums
  66403. */
  66404. wrapT?: TextureWrapMode;
  66405. }
  66406. /**
  66407. * The root nodes of a scene
  66408. */
  66409. interface IScene extends IChildRootProperty {
  66410. /**
  66411. * The indices of each root node
  66412. */
  66413. nodes: number[];
  66414. }
  66415. /**
  66416. * Joints and matrices defining a skin
  66417. */
  66418. interface ISkin extends IChildRootProperty {
  66419. /**
  66420. * 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
  66421. */
  66422. inverseBindMatrices?: number;
  66423. /**
  66424. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  66425. */
  66426. skeleton?: number;
  66427. /**
  66428. * 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)
  66429. */
  66430. joints: number[];
  66431. }
  66432. /**
  66433. * A texture and its sampler
  66434. */
  66435. interface ITexture extends IChildRootProperty {
  66436. /**
  66437. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  66438. */
  66439. sampler?: number;
  66440. /**
  66441. * The index of the image used by this texture
  66442. */
  66443. source: number;
  66444. }
  66445. /**
  66446. * Reference to a texture
  66447. */
  66448. interface ITextureInfo extends IProperty {
  66449. /**
  66450. * The index of the texture
  66451. */
  66452. index: number;
  66453. /**
  66454. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  66455. */
  66456. texCoord?: number;
  66457. }
  66458. /**
  66459. * The root object for a glTF asset
  66460. */
  66461. interface IGLTF extends IProperty {
  66462. /**
  66463. * An array of accessors. An accessor is a typed view into a bufferView
  66464. */
  66465. accessors?: IAccessor[];
  66466. /**
  66467. * An array of keyframe animations
  66468. */
  66469. animations?: IAnimation[];
  66470. /**
  66471. * Metadata about the glTF asset
  66472. */
  66473. asset: IAsset;
  66474. /**
  66475. * An array of buffers. A buffer points to binary geometry, animation, or skins
  66476. */
  66477. buffers?: IBuffer[];
  66478. /**
  66479. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  66480. */
  66481. bufferViews?: IBufferView[];
  66482. /**
  66483. * An array of cameras
  66484. */
  66485. cameras?: ICamera[];
  66486. /**
  66487. * Names of glTF extensions used somewhere in this asset
  66488. */
  66489. extensionsUsed?: string[];
  66490. /**
  66491. * Names of glTF extensions required to properly load this asset
  66492. */
  66493. extensionsRequired?: string[];
  66494. /**
  66495. * An array of images. An image defines data used to create a texture
  66496. */
  66497. images?: IImage[];
  66498. /**
  66499. * An array of materials. A material defines the appearance of a primitive
  66500. */
  66501. materials?: IMaterial[];
  66502. /**
  66503. * An array of meshes. A mesh is a set of primitives to be rendered
  66504. */
  66505. meshes?: IMesh[];
  66506. /**
  66507. * An array of nodes
  66508. */
  66509. nodes?: INode[];
  66510. /**
  66511. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  66512. */
  66513. samplers?: ISampler[];
  66514. /**
  66515. * The index of the default scene
  66516. */
  66517. scene?: number;
  66518. /**
  66519. * An array of scenes
  66520. */
  66521. scenes?: IScene[];
  66522. /**
  66523. * An array of skins. A skin is defined by joints and matrices
  66524. */
  66525. skins?: ISkin[];
  66526. /**
  66527. * An array of textures
  66528. */
  66529. textures?: ITexture[];
  66530. }
  66531. /**
  66532. * The glTF validation results
  66533. */
  66534. interface IGLTFValidationResults {
  66535. info: {
  66536. generator: string;
  66537. hasAnimations: boolean;
  66538. hasDefaultScene: boolean;
  66539. hasMaterials: boolean;
  66540. hasMorphTargets: boolean;
  66541. hasSkins: boolean;
  66542. hasTextures: boolean;
  66543. maxAttributesUsed: number;
  66544. primitivesCount: number
  66545. };
  66546. issues: {
  66547. messages: Array<string>;
  66548. numErrors: number;
  66549. numHints: number;
  66550. numInfos: number;
  66551. numWarnings: number;
  66552. truncated: boolean
  66553. };
  66554. mimeType: string;
  66555. uri: string;
  66556. validatedAt: string;
  66557. validatorVersion: string;
  66558. }
  66559. /**
  66560. * The glTF validation options
  66561. */
  66562. interface IGLTFValidationOptions {
  66563. uri?: string;
  66564. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  66565. validateAccessorData?: boolean;
  66566. maxIssues?: number;
  66567. ignoredIssues?: Array<string>;
  66568. severityOverrides?: Object;
  66569. }
  66570. /**
  66571. * The glTF validator object
  66572. */
  66573. interface IGLTFValidator {
  66574. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  66575. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  66576. }
  66577. }
  66578. declare module BABYLON {
  66579. /** @hidden */
  66580. export var cellPixelShader: {
  66581. name: string;
  66582. shader: string;
  66583. };
  66584. }
  66585. declare module BABYLON {
  66586. /** @hidden */
  66587. export var cellVertexShader: {
  66588. name: string;
  66589. shader: string;
  66590. };
  66591. }
  66592. declare module BABYLON {
  66593. export class CellMaterial extends BABYLON.PushMaterial {
  66594. private _diffuseTexture;
  66595. diffuseTexture: BABYLON.BaseTexture;
  66596. diffuseColor: BABYLON.Color3;
  66597. _computeHighLevel: boolean;
  66598. computeHighLevel: boolean;
  66599. private _disableLighting;
  66600. disableLighting: boolean;
  66601. private _maxSimultaneousLights;
  66602. maxSimultaneousLights: number;
  66603. private _renderId;
  66604. constructor(name: string, scene: BABYLON.Scene);
  66605. needAlphaBlending(): boolean;
  66606. needAlphaTesting(): boolean;
  66607. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  66608. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  66609. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  66610. getAnimatables(): BABYLON.IAnimatable[];
  66611. getActiveTextures(): BABYLON.BaseTexture[];
  66612. hasTexture(texture: BABYLON.BaseTexture): boolean;
  66613. dispose(forceDisposeEffect?: boolean): void;
  66614. getClassName(): string;
  66615. clone(name: string): CellMaterial;
  66616. serialize(): any;
  66617. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  66618. }
  66619. }
  66620. declare module BABYLON {
  66621. export class CustomShaderStructure {
  66622. FragmentStore: string;
  66623. VertexStore: string;
  66624. constructor();
  66625. }
  66626. export class ShaderSpecialParts {
  66627. constructor();
  66628. Fragment_Begin: string;
  66629. Fragment_Definitions: string;
  66630. Fragment_MainBegin: string;
  66631. Fragment_Custom_Diffuse: string;
  66632. Fragment_Before_Lights: string;
  66633. Fragment_Before_Fog: string;
  66634. Fragment_Custom_Alpha: string;
  66635. Fragment_Before_FragColor: string;
  66636. Vertex_Begin: string;
  66637. Vertex_Definitions: string;
  66638. Vertex_MainBegin: string;
  66639. Vertex_Before_PositionUpdated: string;
  66640. Vertex_Before_NormalUpdated: string;
  66641. Vertex_MainEnd: string;
  66642. }
  66643. export class CustomMaterial extends BABYLON.StandardMaterial {
  66644. static ShaderIndexer: number;
  66645. CustomParts: ShaderSpecialParts;
  66646. _isCreatedShader: boolean;
  66647. _createdShaderName: string;
  66648. _customUniform: string[];
  66649. _newUniforms: string[];
  66650. _newUniformInstances: any[];
  66651. _newSamplerInstances: BABYLON.Texture[];
  66652. FragmentShader: string;
  66653. VertexShader: string;
  66654. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  66655. ReviewUniform(name: string, arr: string[]): string[];
  66656. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  66657. constructor(name: string, scene: BABYLON.Scene);
  66658. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  66659. Fragment_Begin(shaderPart: string): CustomMaterial;
  66660. Fragment_Definitions(shaderPart: string): CustomMaterial;
  66661. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  66662. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  66663. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  66664. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  66665. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  66666. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  66667. Vertex_Begin(shaderPart: string): CustomMaterial;
  66668. Vertex_Definitions(shaderPart: string): CustomMaterial;
  66669. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  66670. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  66671. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  66672. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  66673. }
  66674. }
  66675. declare module BABYLON {
  66676. export class ShaderAlebdoParts {
  66677. constructor();
  66678. Fragment_Begin: string;
  66679. Fragment_Definitions: string;
  66680. Fragment_MainBegin: string;
  66681. Fragment_Custom_Albedo: string;
  66682. Fragment_Before_Lights: string;
  66683. Fragment_Custom_MetallicRoughness: string;
  66684. Fragment_Custom_MicroSurface: string;
  66685. Fragment_Before_Fog: string;
  66686. Fragment_Custom_Alpha: string;
  66687. Fragment_Before_FragColor: string;
  66688. Vertex_Begin: string;
  66689. Vertex_Definitions: string;
  66690. Vertex_MainBegin: string;
  66691. Vertex_Before_PositionUpdated: string;
  66692. Vertex_Before_NormalUpdated: string;
  66693. Vertex_MainEnd: string;
  66694. }
  66695. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  66696. static ShaderIndexer: number;
  66697. CustomParts: ShaderAlebdoParts;
  66698. _isCreatedShader: boolean;
  66699. _createdShaderName: string;
  66700. _customUniform: string[];
  66701. _newUniforms: string[];
  66702. _newUniformInstances: any[];
  66703. _newSamplerInstances: BABYLON.Texture[];
  66704. FragmentShader: string;
  66705. VertexShader: string;
  66706. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  66707. ReviewUniform(name: string, arr: string[]): string[];
  66708. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  66709. constructor(name: string, scene: BABYLON.Scene);
  66710. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  66711. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  66712. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  66713. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  66714. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  66715. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  66716. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  66717. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  66718. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  66719. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  66720. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  66721. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  66722. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  66723. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  66724. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  66725. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  66726. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  66727. }
  66728. }
  66729. declare module BABYLON {
  66730. /** @hidden */
  66731. export var firePixelShader: {
  66732. name: string;
  66733. shader: string;
  66734. };
  66735. }
  66736. declare module BABYLON {
  66737. /** @hidden */
  66738. export var fireVertexShader: {
  66739. name: string;
  66740. shader: string;
  66741. };
  66742. }
  66743. declare module BABYLON {
  66744. export class FireMaterial extends BABYLON.PushMaterial {
  66745. private _diffuseTexture;
  66746. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  66747. private _distortionTexture;
  66748. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  66749. private _opacityTexture;
  66750. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  66751. diffuseColor: BABYLON.Color3;
  66752. speed: number;
  66753. private _scaledDiffuse;
  66754. private _renderId;
  66755. private _lastTime;
  66756. constructor(name: string, scene: BABYLON.Scene);
  66757. needAlphaBlending(): boolean;
  66758. needAlphaTesting(): boolean;
  66759. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  66760. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  66761. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  66762. getAnimatables(): BABYLON.IAnimatable[];
  66763. getActiveTextures(): BABYLON.BaseTexture[];
  66764. hasTexture(texture: BABYLON.BaseTexture): boolean;
  66765. getClassName(): string;
  66766. dispose(forceDisposeEffect?: boolean): void;
  66767. clone(name: string): FireMaterial;
  66768. serialize(): any;
  66769. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  66770. }
  66771. }
  66772. declare module BABYLON {
  66773. /** @hidden */
  66774. export var furPixelShader: {
  66775. name: string;
  66776. shader: string;
  66777. };
  66778. }
  66779. declare module BABYLON {
  66780. /** @hidden */
  66781. export var furVertexShader: {
  66782. name: string;
  66783. shader: string;
  66784. };
  66785. }
  66786. declare module BABYLON {
  66787. export class FurMaterial extends BABYLON.PushMaterial {
  66788. private _diffuseTexture;
  66789. diffuseTexture: BABYLON.BaseTexture;
  66790. private _heightTexture;
  66791. heightTexture: BABYLON.BaseTexture;
  66792. diffuseColor: BABYLON.Color3;
  66793. furLength: number;
  66794. furAngle: number;
  66795. furColor: BABYLON.Color3;
  66796. furOffset: number;
  66797. furSpacing: number;
  66798. furGravity: BABYLON.Vector3;
  66799. furSpeed: number;
  66800. furDensity: number;
  66801. furOcclusion: number;
  66802. furTexture: BABYLON.DynamicTexture;
  66803. private _disableLighting;
  66804. disableLighting: boolean;
  66805. private _maxSimultaneousLights;
  66806. maxSimultaneousLights: number;
  66807. highLevelFur: boolean;
  66808. _meshes: BABYLON.AbstractMesh[];
  66809. private _renderId;
  66810. private _furTime;
  66811. constructor(name: string, scene: BABYLON.Scene);
  66812. furTime: number;
  66813. needAlphaBlending(): boolean;
  66814. needAlphaTesting(): boolean;
  66815. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  66816. updateFur(): void;
  66817. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  66818. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  66819. getAnimatables(): BABYLON.IAnimatable[];
  66820. getActiveTextures(): BABYLON.BaseTexture[];
  66821. hasTexture(texture: BABYLON.BaseTexture): boolean;
  66822. dispose(forceDisposeEffect?: boolean): void;
  66823. clone(name: string): FurMaterial;
  66824. serialize(): any;
  66825. getClassName(): string;
  66826. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  66827. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  66828. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  66829. }
  66830. }
  66831. declare module BABYLON {
  66832. /** @hidden */
  66833. export var gradientPixelShader: {
  66834. name: string;
  66835. shader: string;
  66836. };
  66837. }
  66838. declare module BABYLON {
  66839. /** @hidden */
  66840. export var gradientVertexShader: {
  66841. name: string;
  66842. shader: string;
  66843. };
  66844. }
  66845. declare module BABYLON {
  66846. export class GradientMaterial extends BABYLON.PushMaterial {
  66847. private _maxSimultaneousLights;
  66848. maxSimultaneousLights: number;
  66849. topColor: BABYLON.Color3;
  66850. topColorAlpha: number;
  66851. bottomColor: BABYLON.Color3;
  66852. bottomColorAlpha: number;
  66853. offset: number;
  66854. scale: number;
  66855. smoothness: number;
  66856. private _disableLighting;
  66857. disableLighting: boolean;
  66858. private _renderId;
  66859. constructor(name: string, scene: BABYLON.Scene);
  66860. needAlphaBlending(): boolean;
  66861. needAlphaTesting(): boolean;
  66862. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  66863. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  66864. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  66865. getAnimatables(): BABYLON.IAnimatable[];
  66866. dispose(forceDisposeEffect?: boolean): void;
  66867. clone(name: string): GradientMaterial;
  66868. serialize(): any;
  66869. getClassName(): string;
  66870. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  66871. }
  66872. }
  66873. declare module BABYLON {
  66874. /** @hidden */
  66875. export var gridPixelShader: {
  66876. name: string;
  66877. shader: string;
  66878. };
  66879. }
  66880. declare module BABYLON {
  66881. /** @hidden */
  66882. export var gridVertexShader: {
  66883. name: string;
  66884. shader: string;
  66885. };
  66886. }
  66887. declare module BABYLON {
  66888. /**
  66889. * The grid materials allows you to wrap any shape with a grid.
  66890. * Colors are customizable.
  66891. */
  66892. export class GridMaterial extends BABYLON.PushMaterial {
  66893. /**
  66894. * Main color of the grid (e.g. between lines)
  66895. */
  66896. mainColor: BABYLON.Color3;
  66897. /**
  66898. * Color of the grid lines.
  66899. */
  66900. lineColor: BABYLON.Color3;
  66901. /**
  66902. * The scale of the grid compared to unit.
  66903. */
  66904. gridRatio: number;
  66905. /**
  66906. * Allows setting an offset for the grid lines.
  66907. */
  66908. gridOffset: BABYLON.Vector3;
  66909. /**
  66910. * The frequency of thicker lines.
  66911. */
  66912. majorUnitFrequency: number;
  66913. /**
  66914. * The visibility of minor units in the grid.
  66915. */
  66916. minorUnitVisibility: number;
  66917. /**
  66918. * The grid opacity outside of the lines.
  66919. */
  66920. opacity: number;
  66921. /**
  66922. * Determine RBG output is premultiplied by alpha value.
  66923. */
  66924. preMultiplyAlpha: boolean;
  66925. private _opacityTexture;
  66926. opacityTexture: BABYLON.BaseTexture;
  66927. private _gridControl;
  66928. private _renderId;
  66929. /**
  66930. * constructor
  66931. * @param name The name given to the material in order to identify it afterwards.
  66932. * @param scene The scene the material is used in.
  66933. */
  66934. constructor(name: string, scene: BABYLON.Scene);
  66935. /**
  66936. * Returns wehter or not the grid requires alpha blending.
  66937. */
  66938. needAlphaBlending(): boolean;
  66939. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  66940. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  66941. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  66942. /**
  66943. * Dispose the material and its associated resources.
  66944. * @param forceDisposeEffect will also dispose the used effect when true
  66945. */
  66946. dispose(forceDisposeEffect?: boolean): void;
  66947. clone(name: string): GridMaterial;
  66948. serialize(): any;
  66949. getClassName(): string;
  66950. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  66951. }
  66952. }
  66953. declare module BABYLON {
  66954. /** @hidden */
  66955. export var lavaPixelShader: {
  66956. name: string;
  66957. shader: string;
  66958. };
  66959. }
  66960. declare module BABYLON {
  66961. /** @hidden */
  66962. export var lavaVertexShader: {
  66963. name: string;
  66964. shader: string;
  66965. };
  66966. }
  66967. declare module BABYLON {
  66968. export class LavaMaterial extends BABYLON.PushMaterial {
  66969. private _diffuseTexture;
  66970. diffuseTexture: BABYLON.BaseTexture;
  66971. noiseTexture: BABYLON.BaseTexture;
  66972. fogColor: BABYLON.Color3;
  66973. speed: number;
  66974. movingSpeed: number;
  66975. lowFrequencySpeed: number;
  66976. fogDensity: number;
  66977. private _lastTime;
  66978. diffuseColor: BABYLON.Color3;
  66979. private _disableLighting;
  66980. disableLighting: boolean;
  66981. private _unlit;
  66982. unlit: boolean;
  66983. private _maxSimultaneousLights;
  66984. maxSimultaneousLights: number;
  66985. private _scaledDiffuse;
  66986. private _renderId;
  66987. constructor(name: string, scene: BABYLON.Scene);
  66988. needAlphaBlending(): boolean;
  66989. needAlphaTesting(): boolean;
  66990. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  66991. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  66992. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  66993. getAnimatables(): BABYLON.IAnimatable[];
  66994. getActiveTextures(): BABYLON.BaseTexture[];
  66995. hasTexture(texture: BABYLON.BaseTexture): boolean;
  66996. dispose(forceDisposeEffect?: boolean): void;
  66997. clone(name: string): LavaMaterial;
  66998. serialize(): any;
  66999. getClassName(): string;
  67000. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  67001. }
  67002. }
  67003. declare module BABYLON {
  67004. /** @hidden */
  67005. export var mixPixelShader: {
  67006. name: string;
  67007. shader: string;
  67008. };
  67009. }
  67010. declare module BABYLON {
  67011. /** @hidden */
  67012. export var mixVertexShader: {
  67013. name: string;
  67014. shader: string;
  67015. };
  67016. }
  67017. declare module BABYLON {
  67018. export class MixMaterial extends BABYLON.PushMaterial {
  67019. /**
  67020. * Mix textures
  67021. */
  67022. private _mixTexture1;
  67023. mixTexture1: BABYLON.BaseTexture;
  67024. private _mixTexture2;
  67025. mixTexture2: BABYLON.BaseTexture;
  67026. /**
  67027. * Diffuse textures
  67028. */
  67029. private _diffuseTexture1;
  67030. diffuseTexture1: BABYLON.Texture;
  67031. private _diffuseTexture2;
  67032. diffuseTexture2: BABYLON.Texture;
  67033. private _diffuseTexture3;
  67034. diffuseTexture3: BABYLON.Texture;
  67035. private _diffuseTexture4;
  67036. diffuseTexture4: BABYLON.Texture;
  67037. private _diffuseTexture5;
  67038. diffuseTexture5: BABYLON.Texture;
  67039. private _diffuseTexture6;
  67040. diffuseTexture6: BABYLON.Texture;
  67041. private _diffuseTexture7;
  67042. diffuseTexture7: BABYLON.Texture;
  67043. private _diffuseTexture8;
  67044. diffuseTexture8: BABYLON.Texture;
  67045. /**
  67046. * Uniforms
  67047. */
  67048. diffuseColor: BABYLON.Color3;
  67049. specularColor: BABYLON.Color3;
  67050. specularPower: number;
  67051. private _disableLighting;
  67052. disableLighting: boolean;
  67053. private _maxSimultaneousLights;
  67054. maxSimultaneousLights: number;
  67055. private _renderId;
  67056. constructor(name: string, scene: BABYLON.Scene);
  67057. needAlphaBlending(): boolean;
  67058. needAlphaTesting(): boolean;
  67059. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67060. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67061. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67062. getAnimatables(): BABYLON.IAnimatable[];
  67063. getActiveTextures(): BABYLON.BaseTexture[];
  67064. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67065. dispose(forceDisposeEffect?: boolean): void;
  67066. clone(name: string): MixMaterial;
  67067. serialize(): any;
  67068. getClassName(): string;
  67069. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  67070. }
  67071. }
  67072. declare module BABYLON {
  67073. /** @hidden */
  67074. export var normalPixelShader: {
  67075. name: string;
  67076. shader: string;
  67077. };
  67078. }
  67079. declare module BABYLON {
  67080. /** @hidden */
  67081. export var normalVertexShader: {
  67082. name: string;
  67083. shader: string;
  67084. };
  67085. }
  67086. declare module BABYLON {
  67087. export class NormalMaterial extends BABYLON.PushMaterial {
  67088. private _diffuseTexture;
  67089. diffuseTexture: BABYLON.BaseTexture;
  67090. diffuseColor: BABYLON.Color3;
  67091. private _disableLighting;
  67092. disableLighting: boolean;
  67093. private _maxSimultaneousLights;
  67094. maxSimultaneousLights: number;
  67095. private _renderId;
  67096. constructor(name: string, scene: BABYLON.Scene);
  67097. needAlphaBlending(): boolean;
  67098. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  67099. needAlphaTesting(): boolean;
  67100. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67101. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67102. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67103. getAnimatables(): BABYLON.IAnimatable[];
  67104. getActiveTextures(): BABYLON.BaseTexture[];
  67105. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67106. dispose(forceDisposeEffect?: boolean): void;
  67107. clone(name: string): NormalMaterial;
  67108. serialize(): any;
  67109. getClassName(): string;
  67110. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  67111. }
  67112. }
  67113. declare module BABYLON {
  67114. /** @hidden */
  67115. export var shadowOnlyPixelShader: {
  67116. name: string;
  67117. shader: string;
  67118. };
  67119. }
  67120. declare module BABYLON {
  67121. /** @hidden */
  67122. export var shadowOnlyVertexShader: {
  67123. name: string;
  67124. shader: string;
  67125. };
  67126. }
  67127. declare module BABYLON {
  67128. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  67129. private _renderId;
  67130. private _activeLight;
  67131. constructor(name: string, scene: BABYLON.Scene);
  67132. shadowColor: BABYLON.Color3;
  67133. needAlphaBlending(): boolean;
  67134. needAlphaTesting(): boolean;
  67135. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67136. activeLight: BABYLON.IShadowLight;
  67137. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67138. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67139. clone(name: string): ShadowOnlyMaterial;
  67140. serialize(): any;
  67141. getClassName(): string;
  67142. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  67143. }
  67144. }
  67145. declare module BABYLON {
  67146. /** @hidden */
  67147. export var simplePixelShader: {
  67148. name: string;
  67149. shader: string;
  67150. };
  67151. }
  67152. declare module BABYLON {
  67153. /** @hidden */
  67154. export var simpleVertexShader: {
  67155. name: string;
  67156. shader: string;
  67157. };
  67158. }
  67159. declare module BABYLON {
  67160. export class SimpleMaterial extends BABYLON.PushMaterial {
  67161. private _diffuseTexture;
  67162. diffuseTexture: BABYLON.BaseTexture;
  67163. diffuseColor: BABYLON.Color3;
  67164. private _disableLighting;
  67165. disableLighting: boolean;
  67166. private _maxSimultaneousLights;
  67167. maxSimultaneousLights: number;
  67168. private _renderId;
  67169. constructor(name: string, scene: BABYLON.Scene);
  67170. needAlphaBlending(): boolean;
  67171. needAlphaTesting(): boolean;
  67172. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67173. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67174. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67175. getAnimatables(): BABYLON.IAnimatable[];
  67176. getActiveTextures(): BABYLON.BaseTexture[];
  67177. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67178. dispose(forceDisposeEffect?: boolean): void;
  67179. clone(name: string): SimpleMaterial;
  67180. serialize(): any;
  67181. getClassName(): string;
  67182. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  67183. }
  67184. }
  67185. declare module BABYLON {
  67186. /** @hidden */
  67187. export var skyPixelShader: {
  67188. name: string;
  67189. shader: string;
  67190. };
  67191. }
  67192. declare module BABYLON {
  67193. /** @hidden */
  67194. export var skyVertexShader: {
  67195. name: string;
  67196. shader: string;
  67197. };
  67198. }
  67199. declare module BABYLON {
  67200. /**
  67201. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  67202. * @see https://doc.babylonjs.com/extensions/sky
  67203. */
  67204. export class SkyMaterial extends BABYLON.PushMaterial {
  67205. /**
  67206. * Defines the overall luminance of sky in interval ]0, 1[.
  67207. */
  67208. luminance: number;
  67209. /**
  67210. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  67211. */
  67212. turbidity: number;
  67213. /**
  67214. * Defines the sky appearance (light intensity).
  67215. */
  67216. rayleigh: number;
  67217. /**
  67218. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  67219. */
  67220. mieCoefficient: number;
  67221. /**
  67222. * Defines the amount of haze particles following the Mie scattering theory.
  67223. */
  67224. mieDirectionalG: number;
  67225. /**
  67226. * Defines the distance of the sun according to the active scene camera.
  67227. */
  67228. distance: number;
  67229. /**
  67230. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  67231. * "inclined".
  67232. */
  67233. inclination: number;
  67234. /**
  67235. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  67236. * an object direction and a reference direction.
  67237. */
  67238. azimuth: number;
  67239. /**
  67240. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  67241. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  67242. */
  67243. sunPosition: BABYLON.Vector3;
  67244. /**
  67245. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  67246. * .sunPosition property.
  67247. */
  67248. useSunPosition: boolean;
  67249. /**
  67250. * Defines an offset vector used to get a horizon offset.
  67251. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  67252. */
  67253. cameraOffset: BABYLON.Vector3;
  67254. private _cameraPosition;
  67255. private _renderId;
  67256. /**
  67257. * Instantiates a new sky material.
  67258. * This material allows to create dynamic and texture free
  67259. * effects for skyboxes by taking care of the atmosphere state.
  67260. * @see https://doc.babylonjs.com/extensions/sky
  67261. * @param name Define the name of the material in the scene
  67262. * @param scene Define the scene the material belong to
  67263. */
  67264. constructor(name: string, scene: BABYLON.Scene);
  67265. /**
  67266. * Specifies if the material will require alpha blending
  67267. * @returns a boolean specifying if alpha blending is needed
  67268. */
  67269. needAlphaBlending(): boolean;
  67270. /**
  67271. * Specifies if this material should be rendered in alpha test mode
  67272. * @returns false as the sky material doesn't need alpha testing.
  67273. */
  67274. needAlphaTesting(): boolean;
  67275. /**
  67276. * Get the texture used for alpha test purpose.
  67277. * @returns null as the sky material has no texture.
  67278. */
  67279. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67280. /**
  67281. * Get if the submesh is ready to be used and all its information available.
  67282. * Child classes can use it to update shaders
  67283. * @param mesh defines the mesh to check
  67284. * @param subMesh defines which submesh to check
  67285. * @param useInstances specifies that instances should be used
  67286. * @returns a boolean indicating that the submesh is ready or not
  67287. */
  67288. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67289. /**
  67290. * Binds the submesh to this material by preparing the effect and shader to draw
  67291. * @param world defines the world transformation matrix
  67292. * @param mesh defines the mesh containing the submesh
  67293. * @param subMesh defines the submesh to bind the material to
  67294. */
  67295. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67296. /**
  67297. * Get the list of animatables in the material.
  67298. * @returns the list of animatables object used in the material
  67299. */
  67300. getAnimatables(): BABYLON.IAnimatable[];
  67301. /**
  67302. * Disposes the material
  67303. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  67304. */
  67305. dispose(forceDisposeEffect?: boolean): void;
  67306. /**
  67307. * Makes a duplicate of the material, and gives it a new name
  67308. * @param name defines the new name for the duplicated material
  67309. * @returns the cloned material
  67310. */
  67311. clone(name: string): SkyMaterial;
  67312. /**
  67313. * Serializes this material in a JSON representation
  67314. * @returns the serialized material object
  67315. */
  67316. serialize(): any;
  67317. /**
  67318. * Gets the current class name of the material e.g. "SkyMaterial"
  67319. * Mainly use in serialization.
  67320. * @returns the class name
  67321. */
  67322. getClassName(): string;
  67323. /**
  67324. * Creates a sky material from parsed material data
  67325. * @param source defines the JSON representation of the material
  67326. * @param scene defines the hosting scene
  67327. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  67328. * @returns a new sky material
  67329. */
  67330. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  67331. }
  67332. }
  67333. declare module BABYLON {
  67334. /** @hidden */
  67335. export var terrainPixelShader: {
  67336. name: string;
  67337. shader: string;
  67338. };
  67339. }
  67340. declare module BABYLON {
  67341. /** @hidden */
  67342. export var terrainVertexShader: {
  67343. name: string;
  67344. shader: string;
  67345. };
  67346. }
  67347. declare module BABYLON {
  67348. export class TerrainMaterial extends BABYLON.PushMaterial {
  67349. private _mixTexture;
  67350. mixTexture: BABYLON.BaseTexture;
  67351. private _diffuseTexture1;
  67352. diffuseTexture1: BABYLON.Texture;
  67353. private _diffuseTexture2;
  67354. diffuseTexture2: BABYLON.Texture;
  67355. private _diffuseTexture3;
  67356. diffuseTexture3: BABYLON.Texture;
  67357. private _bumpTexture1;
  67358. bumpTexture1: BABYLON.Texture;
  67359. private _bumpTexture2;
  67360. bumpTexture2: BABYLON.Texture;
  67361. private _bumpTexture3;
  67362. bumpTexture3: BABYLON.Texture;
  67363. diffuseColor: BABYLON.Color3;
  67364. specularColor: BABYLON.Color3;
  67365. specularPower: number;
  67366. private _disableLighting;
  67367. disableLighting: boolean;
  67368. private _maxSimultaneousLights;
  67369. maxSimultaneousLights: number;
  67370. private _renderId;
  67371. constructor(name: string, scene: BABYLON.Scene);
  67372. needAlphaBlending(): boolean;
  67373. needAlphaTesting(): boolean;
  67374. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67375. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67376. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67377. getAnimatables(): BABYLON.IAnimatable[];
  67378. getActiveTextures(): BABYLON.BaseTexture[];
  67379. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67380. dispose(forceDisposeEffect?: boolean): void;
  67381. clone(name: string): TerrainMaterial;
  67382. serialize(): any;
  67383. getClassName(): string;
  67384. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  67385. }
  67386. }
  67387. declare module BABYLON {
  67388. /** @hidden */
  67389. export var triplanarPixelShader: {
  67390. name: string;
  67391. shader: string;
  67392. };
  67393. }
  67394. declare module BABYLON {
  67395. /** @hidden */
  67396. export var triplanarVertexShader: {
  67397. name: string;
  67398. shader: string;
  67399. };
  67400. }
  67401. declare module BABYLON {
  67402. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  67403. mixTexture: BABYLON.BaseTexture;
  67404. private _diffuseTextureX;
  67405. diffuseTextureX: BABYLON.BaseTexture;
  67406. private _diffuseTextureY;
  67407. diffuseTextureY: BABYLON.BaseTexture;
  67408. private _diffuseTextureZ;
  67409. diffuseTextureZ: BABYLON.BaseTexture;
  67410. private _normalTextureX;
  67411. normalTextureX: BABYLON.BaseTexture;
  67412. private _normalTextureY;
  67413. normalTextureY: BABYLON.BaseTexture;
  67414. private _normalTextureZ;
  67415. normalTextureZ: BABYLON.BaseTexture;
  67416. tileSize: number;
  67417. diffuseColor: BABYLON.Color3;
  67418. specularColor: BABYLON.Color3;
  67419. specularPower: number;
  67420. private _disableLighting;
  67421. disableLighting: boolean;
  67422. private _maxSimultaneousLights;
  67423. maxSimultaneousLights: number;
  67424. private _renderId;
  67425. constructor(name: string, scene: BABYLON.Scene);
  67426. needAlphaBlending(): boolean;
  67427. needAlphaTesting(): boolean;
  67428. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67429. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67430. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67431. getAnimatables(): BABYLON.IAnimatable[];
  67432. getActiveTextures(): BABYLON.BaseTexture[];
  67433. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67434. dispose(forceDisposeEffect?: boolean): void;
  67435. clone(name: string): TriPlanarMaterial;
  67436. serialize(): any;
  67437. getClassName(): string;
  67438. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  67439. }
  67440. }
  67441. declare module BABYLON {
  67442. /** @hidden */
  67443. export var waterPixelShader: {
  67444. name: string;
  67445. shader: string;
  67446. };
  67447. }
  67448. declare module BABYLON {
  67449. /** @hidden */
  67450. export var waterVertexShader: {
  67451. name: string;
  67452. shader: string;
  67453. };
  67454. }
  67455. declare module BABYLON {
  67456. export class WaterMaterial extends BABYLON.PushMaterial {
  67457. renderTargetSize: BABYLON.Vector2;
  67458. private _bumpTexture;
  67459. bumpTexture: BABYLON.BaseTexture;
  67460. diffuseColor: BABYLON.Color3;
  67461. specularColor: BABYLON.Color3;
  67462. specularPower: number;
  67463. private _disableLighting;
  67464. disableLighting: boolean;
  67465. private _maxSimultaneousLights;
  67466. maxSimultaneousLights: number;
  67467. /**
  67468. * @param {number}: Represents the wind force
  67469. */
  67470. windForce: number;
  67471. /**
  67472. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  67473. */
  67474. windDirection: BABYLON.Vector2;
  67475. /**
  67476. * @param {number}: Wave height, represents the height of the waves
  67477. */
  67478. waveHeight: number;
  67479. /**
  67480. * @param {number}: Bump height, represents the bump height related to the bump map
  67481. */
  67482. bumpHeight: number;
  67483. /**
  67484. * @param {boolean}: Add a smaller moving bump to less steady waves.
  67485. */
  67486. private _bumpSuperimpose;
  67487. bumpSuperimpose: boolean;
  67488. /**
  67489. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  67490. */
  67491. private _fresnelSeparate;
  67492. fresnelSeparate: boolean;
  67493. /**
  67494. * @param {boolean}: bump Waves modify the reflection.
  67495. */
  67496. private _bumpAffectsReflection;
  67497. bumpAffectsReflection: boolean;
  67498. /**
  67499. * @param {number}: The water color blended with the refraction (near)
  67500. */
  67501. waterColor: BABYLON.Color3;
  67502. /**
  67503. * @param {number}: The blend factor related to the water color
  67504. */
  67505. colorBlendFactor: number;
  67506. /**
  67507. * @param {number}: The water color blended with the reflection (far)
  67508. */
  67509. waterColor2: BABYLON.Color3;
  67510. /**
  67511. * @param {number}: The blend factor related to the water color (reflection, far)
  67512. */
  67513. colorBlendFactor2: number;
  67514. /**
  67515. * @param {number}: Represents the maximum length of a wave
  67516. */
  67517. waveLength: number;
  67518. /**
  67519. * @param {number}: Defines the waves speed
  67520. */
  67521. waveSpeed: number;
  67522. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  67523. private _mesh;
  67524. private _refractionRTT;
  67525. private _reflectionRTT;
  67526. private _reflectionTransform;
  67527. private _lastTime;
  67528. private _lastDeltaTime;
  67529. private _renderId;
  67530. private _useLogarithmicDepth;
  67531. private _waitingRenderList;
  67532. /**
  67533. * Gets a boolean indicating that current material needs to register RTT
  67534. */
  67535. readonly hasRenderTargetTextures: boolean;
  67536. /**
  67537. * Constructor
  67538. */
  67539. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  67540. useLogarithmicDepth: boolean;
  67541. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  67542. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  67543. addToRenderList(node: any): void;
  67544. enableRenderTargets(enable: boolean): void;
  67545. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  67546. readonly renderTargetsEnabled: boolean;
  67547. needAlphaBlending(): boolean;
  67548. needAlphaTesting(): boolean;
  67549. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67550. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67551. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67552. private _createRenderTargets;
  67553. getAnimatables(): BABYLON.IAnimatable[];
  67554. getActiveTextures(): BABYLON.BaseTexture[];
  67555. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67556. dispose(forceDisposeEffect?: boolean): void;
  67557. clone(name: string): WaterMaterial;
  67558. serialize(): any;
  67559. getClassName(): string;
  67560. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  67561. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  67562. }
  67563. }
  67564. declare module BABYLON {
  67565. /** @hidden */
  67566. export var asciiartPixelShader: {
  67567. name: string;
  67568. shader: string;
  67569. };
  67570. }
  67571. declare module BABYLON {
  67572. /**
  67573. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  67574. *
  67575. * It basically takes care rendering the font front the given font size to a texture.
  67576. * This is used later on in the postprocess.
  67577. */
  67578. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  67579. private _font;
  67580. private _text;
  67581. private _charSize;
  67582. /**
  67583. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  67584. */
  67585. readonly charSize: number;
  67586. /**
  67587. * Create a new instance of the Ascii Art FontTexture class
  67588. * @param name the name of the texture
  67589. * @param font the font to use, use the W3C CSS notation
  67590. * @param text the caracter set to use in the rendering.
  67591. * @param scene the scene that owns the texture
  67592. */
  67593. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  67594. /**
  67595. * Gets the max char width of a font.
  67596. * @param font the font to use, use the W3C CSS notation
  67597. * @return the max char width
  67598. */
  67599. private getFontWidth;
  67600. /**
  67601. * Gets the max char height of a font.
  67602. * @param font the font to use, use the W3C CSS notation
  67603. * @return the max char height
  67604. */
  67605. private getFontHeight;
  67606. /**
  67607. * Clones the current AsciiArtTexture.
  67608. * @return the clone of the texture.
  67609. */
  67610. clone(): AsciiArtFontTexture;
  67611. /**
  67612. * Parses a json object representing the texture and returns an instance of it.
  67613. * @param source the source JSON representation
  67614. * @param scene the scene to create the texture for
  67615. * @return the parsed texture
  67616. */
  67617. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  67618. }
  67619. /**
  67620. * Option available in the Ascii Art Post Process.
  67621. */
  67622. export interface IAsciiArtPostProcessOptions {
  67623. /**
  67624. * The font to use following the w3c font definition.
  67625. */
  67626. font?: string;
  67627. /**
  67628. * The character set to use in the postprocess.
  67629. */
  67630. characterSet?: string;
  67631. /**
  67632. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  67633. * This number is defined between 0 and 1;
  67634. */
  67635. mixToTile?: number;
  67636. /**
  67637. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  67638. * This number is defined between 0 and 1;
  67639. */
  67640. mixToNormal?: number;
  67641. }
  67642. /**
  67643. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  67644. *
  67645. * Simmply add it to your scene and let the nerd that lives in you have fun.
  67646. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  67647. */
  67648. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  67649. /**
  67650. * The font texture used to render the char in the post process.
  67651. */
  67652. private _asciiArtFontTexture;
  67653. /**
  67654. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  67655. * This number is defined between 0 and 1;
  67656. */
  67657. mixToTile: number;
  67658. /**
  67659. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  67660. * This number is defined between 0 and 1;
  67661. */
  67662. mixToNormal: number;
  67663. /**
  67664. * Instantiates a new Ascii Art Post Process.
  67665. * @param name the name to give to the postprocess
  67666. * @camera the camera to apply the post process to.
  67667. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  67668. */
  67669. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  67670. }
  67671. }
  67672. declare module BABYLON {
  67673. /** @hidden */
  67674. export var digitalrainPixelShader: {
  67675. name: string;
  67676. shader: string;
  67677. };
  67678. }
  67679. declare module BABYLON {
  67680. /**
  67681. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  67682. *
  67683. * It basically takes care rendering the font front the given font size to a texture.
  67684. * This is used later on in the postprocess.
  67685. */
  67686. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  67687. private _font;
  67688. private _text;
  67689. private _charSize;
  67690. /**
  67691. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  67692. */
  67693. readonly charSize: number;
  67694. /**
  67695. * Create a new instance of the Digital Rain FontTexture class
  67696. * @param name the name of the texture
  67697. * @param font the font to use, use the W3C CSS notation
  67698. * @param text the caracter set to use in the rendering.
  67699. * @param scene the scene that owns the texture
  67700. */
  67701. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  67702. /**
  67703. * Gets the max char width of a font.
  67704. * @param font the font to use, use the W3C CSS notation
  67705. * @return the max char width
  67706. */
  67707. private getFontWidth;
  67708. /**
  67709. * Gets the max char height of a font.
  67710. * @param font the font to use, use the W3C CSS notation
  67711. * @return the max char height
  67712. */
  67713. private getFontHeight;
  67714. /**
  67715. * Clones the current DigitalRainFontTexture.
  67716. * @return the clone of the texture.
  67717. */
  67718. clone(): DigitalRainFontTexture;
  67719. /**
  67720. * Parses a json object representing the texture and returns an instance of it.
  67721. * @param source the source JSON representation
  67722. * @param scene the scene to create the texture for
  67723. * @return the parsed texture
  67724. */
  67725. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  67726. }
  67727. /**
  67728. * Option available in the Digital Rain Post Process.
  67729. */
  67730. export interface IDigitalRainPostProcessOptions {
  67731. /**
  67732. * The font to use following the w3c font definition.
  67733. */
  67734. font?: string;
  67735. /**
  67736. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  67737. * This number is defined between 0 and 1;
  67738. */
  67739. mixToTile?: number;
  67740. /**
  67741. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  67742. * This number is defined between 0 and 1;
  67743. */
  67744. mixToNormal?: number;
  67745. }
  67746. /**
  67747. * DigitalRainPostProcess helps rendering everithing in digital rain.
  67748. *
  67749. * Simmply add it to your scene and let the nerd that lives in you have fun.
  67750. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  67751. */
  67752. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  67753. /**
  67754. * The font texture used to render the char in the post process.
  67755. */
  67756. private _digitalRainFontTexture;
  67757. /**
  67758. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  67759. * This number is defined between 0 and 1;
  67760. */
  67761. mixToTile: number;
  67762. /**
  67763. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  67764. * This number is defined between 0 and 1;
  67765. */
  67766. mixToNormal: number;
  67767. /**
  67768. * Instantiates a new Digital Rain Post Process.
  67769. * @param name the name to give to the postprocess
  67770. * @camera the camera to apply the post process to.
  67771. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  67772. */
  67773. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  67774. }
  67775. }
  67776. declare module BABYLON {
  67777. /** @hidden */
  67778. export var oceanPostProcessPixelShader: {
  67779. name: string;
  67780. shader: string;
  67781. };
  67782. }
  67783. declare module BABYLON {
  67784. /**
  67785. * Option available in the Ocean Post Process.
  67786. */
  67787. export interface IOceanPostProcessOptions {
  67788. /**
  67789. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  67790. */
  67791. reflectionSize?: number | {
  67792. width: number;
  67793. height: number;
  67794. } | {
  67795. ratio: number;
  67796. };
  67797. /**
  67798. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  67799. */
  67800. refractionSize?: number | {
  67801. width: number;
  67802. height: number;
  67803. } | {
  67804. ratio: number;
  67805. };
  67806. }
  67807. /**
  67808. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  67809. *
  67810. * Simmply add it to your scene and let the nerd that lives in you have fun.
  67811. * Example usage:
  67812. * var pp = new OceanPostProcess("myOcean", camera);
  67813. * pp.reflectionEnabled = true;
  67814. * pp.refractionEnabled = true;
  67815. */
  67816. export class OceanPostProcess extends BABYLON.PostProcess {
  67817. /**
  67818. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  67819. */
  67820. /**
  67821. * Sets weither or not the real-time reflection is enabled on the ocean.
  67822. * Is set to true, the reflection mirror texture will be used as reflection texture.
  67823. */
  67824. reflectionEnabled: boolean;
  67825. /**
  67826. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  67827. */
  67828. /**
  67829. * Sets weither or not the real-time refraction is enabled on the ocean.
  67830. * Is set to true, the refraction render target texture will be used as refraction texture.
  67831. */
  67832. refractionEnabled: boolean;
  67833. /**
  67834. * Gets wether or not the post-processes is supported by the running hardware.
  67835. * This requires draw buffer supports.
  67836. */
  67837. readonly isSupported: boolean;
  67838. /**
  67839. * This is the reflection mirror texture used to display reflections on the ocean.
  67840. * By default, render list is empty.
  67841. */
  67842. reflectionTexture: BABYLON.MirrorTexture;
  67843. /**
  67844. * This is the refraction render target texture used to display refraction on the ocean.
  67845. * By default, render list is empty.
  67846. */
  67847. refractionTexture: BABYLON.RenderTargetTexture;
  67848. private _time;
  67849. private _cameraRotation;
  67850. private _cameraViewMatrix;
  67851. private _reflectionEnabled;
  67852. private _refractionEnabled;
  67853. private _geometryRenderer;
  67854. /**
  67855. * Instantiates a new Ocean Post Process.
  67856. * @param name the name to give to the postprocess.
  67857. * @camera the camera to apply the post process to.
  67858. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  67859. */
  67860. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  67861. /**
  67862. * Returns the appropriate defines according to the current configuration.
  67863. */
  67864. private _getDefines;
  67865. /**
  67866. * Computes the current camera rotation as the shader requires a camera rotation.
  67867. */
  67868. private _computeCameraRotation;
  67869. }
  67870. }
  67871. declare module BABYLON {
  67872. /** @hidden */
  67873. export var brickProceduralTexturePixelShader: {
  67874. name: string;
  67875. shader: string;
  67876. };
  67877. }
  67878. declare module BABYLON {
  67879. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  67880. private _numberOfBricksHeight;
  67881. private _numberOfBricksWidth;
  67882. private _jointColor;
  67883. private _brickColor;
  67884. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  67885. updateShaderUniforms(): void;
  67886. numberOfBricksHeight: number;
  67887. numberOfBricksWidth: number;
  67888. jointColor: BABYLON.Color3;
  67889. brickColor: BABYLON.Color3;
  67890. /**
  67891. * Serializes this brick procedural texture
  67892. * @returns a serialized brick procedural texture object
  67893. */
  67894. serialize(): any;
  67895. /**
  67896. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  67897. * @param parsedTexture defines parsed texture data
  67898. * @param scene defines the current scene
  67899. * @param rootUrl defines the root URL containing brick procedural texture information
  67900. * @returns a parsed Brick Procedural BABYLON.Texture
  67901. */
  67902. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  67903. }
  67904. }
  67905. declare module BABYLON {
  67906. /** @hidden */
  67907. export var cloudProceduralTexturePixelShader: {
  67908. name: string;
  67909. shader: string;
  67910. };
  67911. }
  67912. declare module BABYLON {
  67913. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  67914. private _skyColor;
  67915. private _cloudColor;
  67916. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  67917. updateShaderUniforms(): void;
  67918. skyColor: BABYLON.Color4;
  67919. cloudColor: BABYLON.Color4;
  67920. /**
  67921. * Serializes this cloud procedural texture
  67922. * @returns a serialized cloud procedural texture object
  67923. */
  67924. serialize(): any;
  67925. /**
  67926. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  67927. * @param parsedTexture defines parsed texture data
  67928. * @param scene defines the current scene
  67929. * @param rootUrl defines the root URL containing cloud procedural texture information
  67930. * @returns a parsed Cloud Procedural BABYLON.Texture
  67931. */
  67932. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  67933. }
  67934. }
  67935. declare module BABYLON {
  67936. /** @hidden */
  67937. export var fireProceduralTexturePixelShader: {
  67938. name: string;
  67939. shader: string;
  67940. };
  67941. }
  67942. declare module BABYLON {
  67943. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  67944. private _time;
  67945. private _speed;
  67946. private _autoGenerateTime;
  67947. private _fireColors;
  67948. private _alphaThreshold;
  67949. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  67950. updateShaderUniforms(): void;
  67951. render(useCameraPostProcess?: boolean): void;
  67952. static readonly PurpleFireColors: BABYLON.Color3[];
  67953. static readonly GreenFireColors: BABYLON.Color3[];
  67954. static readonly RedFireColors: BABYLON.Color3[];
  67955. static readonly BlueFireColors: BABYLON.Color3[];
  67956. autoGenerateTime: boolean;
  67957. fireColors: BABYLON.Color3[];
  67958. time: number;
  67959. speed: BABYLON.Vector2;
  67960. alphaThreshold: number;
  67961. /**
  67962. * Serializes this fire procedural texture
  67963. * @returns a serialized fire procedural texture object
  67964. */
  67965. serialize(): any;
  67966. /**
  67967. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  67968. * @param parsedTexture defines parsed texture data
  67969. * @param scene defines the current scene
  67970. * @param rootUrl defines the root URL containing fire procedural texture information
  67971. * @returns a parsed Fire Procedural BABYLON.Texture
  67972. */
  67973. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  67974. }
  67975. }
  67976. declare module BABYLON {
  67977. /** @hidden */
  67978. export var grassProceduralTexturePixelShader: {
  67979. name: string;
  67980. shader: string;
  67981. };
  67982. }
  67983. declare module BABYLON {
  67984. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  67985. private _grassColors;
  67986. private _groundColor;
  67987. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  67988. updateShaderUniforms(): void;
  67989. grassColors: BABYLON.Color3[];
  67990. groundColor: BABYLON.Color3;
  67991. /**
  67992. * Serializes this grass procedural texture
  67993. * @returns a serialized grass procedural texture object
  67994. */
  67995. serialize(): any;
  67996. /**
  67997. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  67998. * @param parsedTexture defines parsed texture data
  67999. * @param scene defines the current scene
  68000. * @param rootUrl defines the root URL containing grass procedural texture information
  68001. * @returns a parsed Grass Procedural BABYLON.Texture
  68002. */
  68003. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  68004. }
  68005. }
  68006. declare module BABYLON {
  68007. /** @hidden */
  68008. export var marbleProceduralTexturePixelShader: {
  68009. name: string;
  68010. shader: string;
  68011. };
  68012. }
  68013. declare module BABYLON {
  68014. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  68015. private _numberOfTilesHeight;
  68016. private _numberOfTilesWidth;
  68017. private _amplitude;
  68018. private _jointColor;
  68019. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68020. updateShaderUniforms(): void;
  68021. numberOfTilesHeight: number;
  68022. amplitude: number;
  68023. numberOfTilesWidth: number;
  68024. jointColor: BABYLON.Color3;
  68025. /**
  68026. * Serializes this marble procedural texture
  68027. * @returns a serialized marble procedural texture object
  68028. */
  68029. serialize(): any;
  68030. /**
  68031. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  68032. * @param parsedTexture defines parsed texture data
  68033. * @param scene defines the current scene
  68034. * @param rootUrl defines the root URL containing marble procedural texture information
  68035. * @returns a parsed Marble Procedural BABYLON.Texture
  68036. */
  68037. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  68038. }
  68039. }
  68040. declare module BABYLON {
  68041. /** @hidden */
  68042. export var normalMapProceduralTexturePixelShader: {
  68043. name: string;
  68044. shader: string;
  68045. };
  68046. }
  68047. declare module BABYLON {
  68048. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  68049. private _baseTexture;
  68050. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68051. updateShaderUniforms(): void;
  68052. render(useCameraPostProcess?: boolean): void;
  68053. resize(size: any, generateMipMaps: any): void;
  68054. baseTexture: BABYLON.Texture;
  68055. /**
  68056. * Serializes this normal map procedural texture
  68057. * @returns a serialized normal map procedural texture object
  68058. */
  68059. serialize(): any;
  68060. /**
  68061. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  68062. * @param parsedTexture defines parsed texture data
  68063. * @param scene defines the current scene
  68064. * @param rootUrl defines the root URL containing normal map procedural texture information
  68065. * @returns a parsed Normal Map Procedural BABYLON.Texture
  68066. */
  68067. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  68068. }
  68069. }
  68070. declare module BABYLON {
  68071. /** @hidden */
  68072. export var perlinNoiseProceduralTexturePixelShader: {
  68073. name: string;
  68074. shader: string;
  68075. };
  68076. }
  68077. declare module BABYLON {
  68078. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  68079. time: number;
  68080. timeScale: number;
  68081. translationSpeed: number;
  68082. private _currentTranslation;
  68083. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68084. updateShaderUniforms(): void;
  68085. render(useCameraPostProcess?: boolean): void;
  68086. resize(size: any, generateMipMaps: any): void;
  68087. /**
  68088. * Serializes this perlin noise procedural texture
  68089. * @returns a serialized perlin noise procedural texture object
  68090. */
  68091. serialize(): any;
  68092. /**
  68093. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  68094. * @param parsedTexture defines parsed texture data
  68095. * @param scene defines the current scene
  68096. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  68097. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  68098. */
  68099. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  68100. }
  68101. }
  68102. declare module BABYLON {
  68103. /** @hidden */
  68104. export var roadProceduralTexturePixelShader: {
  68105. name: string;
  68106. shader: string;
  68107. };
  68108. }
  68109. declare module BABYLON {
  68110. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  68111. private _roadColor;
  68112. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68113. updateShaderUniforms(): void;
  68114. roadColor: BABYLON.Color3;
  68115. /**
  68116. * Serializes this road procedural texture
  68117. * @returns a serialized road procedural texture object
  68118. */
  68119. serialize(): any;
  68120. /**
  68121. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  68122. * @param parsedTexture defines parsed texture data
  68123. * @param scene defines the current scene
  68124. * @param rootUrl defines the root URL containing road procedural texture information
  68125. * @returns a parsed Road Procedural BABYLON.Texture
  68126. */
  68127. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  68128. }
  68129. }
  68130. declare module BABYLON {
  68131. /** @hidden */
  68132. export var starfieldProceduralTexturePixelShader: {
  68133. name: string;
  68134. shader: string;
  68135. };
  68136. }
  68137. declare module BABYLON {
  68138. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  68139. private _time;
  68140. private _alpha;
  68141. private _beta;
  68142. private _zoom;
  68143. private _formuparam;
  68144. private _stepsize;
  68145. private _tile;
  68146. private _brightness;
  68147. private _darkmatter;
  68148. private _distfading;
  68149. private _saturation;
  68150. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68151. updateShaderUniforms(): void;
  68152. time: number;
  68153. alpha: number;
  68154. beta: number;
  68155. formuparam: number;
  68156. stepsize: number;
  68157. zoom: number;
  68158. tile: number;
  68159. brightness: number;
  68160. darkmatter: number;
  68161. distfading: number;
  68162. saturation: number;
  68163. /**
  68164. * Serializes this starfield procedural texture
  68165. * @returns a serialized starfield procedural texture object
  68166. */
  68167. serialize(): any;
  68168. /**
  68169. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  68170. * @param parsedTexture defines parsed texture data
  68171. * @param scene defines the current scene
  68172. * @param rootUrl defines the root URL containing startfield procedural texture information
  68173. * @returns a parsed Starfield Procedural BABYLON.Texture
  68174. */
  68175. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  68176. }
  68177. }
  68178. declare module BABYLON {
  68179. /** @hidden */
  68180. export var woodProceduralTexturePixelShader: {
  68181. name: string;
  68182. shader: string;
  68183. };
  68184. }
  68185. declare module BABYLON {
  68186. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  68187. private _ampScale;
  68188. private _woodColor;
  68189. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  68190. updateShaderUniforms(): void;
  68191. ampScale: number;
  68192. woodColor: BABYLON.Color3;
  68193. /**
  68194. * Serializes this wood procedural texture
  68195. * @returns a serialized wood procedural texture object
  68196. */
  68197. serialize(): any;
  68198. /**
  68199. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  68200. * @param parsedTexture defines parsed texture data
  68201. * @param scene defines the current scene
  68202. * @param rootUrl defines the root URL containing wood procedural texture information
  68203. * @returns a parsed Wood Procedural BABYLON.Texture
  68204. */
  68205. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  68206. }
  68207. }