documentation.d.ts 2.9 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726687276872868729687306873168732687336873468735687366873768738687396874068741687426874368744687456874668747687486874968750687516875268753687546875568756687576875868759687606876168762687636876468765687666876768768687696877068771687726877368774687756877668777687786877968780687816878268783687846878568786687876878868789687906879168792687936879468795687966879768798687996880068801688026880368804688056880668807688086880968810688116881268813688146881568816688176881868819688206882168822688236882468825688266882768828688296883068831688326883368834688356883668837688386883968840688416884268843688446884568846688476884868849688506885168852688536885468855688566885768858688596886068861688626886368864688656886668867688686886968870688716887268873688746887568876688776887868879688806888168882688836888468885688866888768888688896889068891688926889368894688956889668897688986889968900689016890268903689046890568906689076890868909689106891168912689136891468915689166891768918689196892068921689226892368924689256892668927689286892968930689316893268933689346893568936689376893868939689406894168942689436894468945689466894768948689496895068951689526895368954689556895668957689586895968960689616896268963689646896568966689676896868969689706897168972689736897468975689766897768978689796898068981689826898368984689856898668987689886898968990689916899268993689946899568996689976899868999690006900169002690036900469005690066900769008690096901069011690126901369014690156901669017690186901969020690216902269023690246902569026690276902869029690306903169032690336903469035690366903769038690396904069041690426904369044690456904669047690486904969050690516905269053690546905569056690576905869059690606906169062690636906469065690666906769068690696907069071690726907369074690756907669077690786907969080690816908269083690846908569086690876908869089690906909169092690936909469095690966909769098690996910069101691026910369104691056910669107691086910969110691116911269113691146911569116691176911869119691206912169122691236912469125691266912769128691296913069131691326913369134691356913669137691386913969140691416914269143691446914569146691476914869149691506915169152691536915469155691566915769158691596916069161691626916369164691656916669167691686916969170691716917269173691746917569176691776917869179691806918169182691836918469185691866918769188691896919069191691926919369194691956919669197691986919969200692016920269203692046920569206692076920869209692106921169212692136921469215692166921769218692196922069221692226922369224692256922669227692286922969230692316923269233692346923569236692376923869239692406924169242692436924469245692466924769248692496925069251692526925369254692556925669257692586925969260692616926269263692646926569266692676926869269692706927169272692736927469275692766927769278692796928069281692826928369284692856928669287692886928969290692916929269293692946929569296692976929869299693006930169302693036930469305693066930769308693096931069311693126931369314693156931669317693186931969320693216932269323693246932569326693276932869329693306933169332693336933469335693366933769338693396934069341693426934369344693456934669347693486934969350693516935269353693546935569356693576935869359693606936169362693636936469365693666936769368693696937069371693726937369374693756937669377693786937969380693816938269383693846938569386693876938869389693906939169392693936939469395693966939769398693996940069401694026940369404694056940669407694086940969410694116941269413694146941569416694176941869419694206942169422694236942469425694266942769428694296943069431694326943369434694356943669437
  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 Vector3
  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. * Gets the list of observers
  4357. */
  4358. readonly observers: Array<Observer<T>>;
  4359. /**
  4360. * Creates a new observable
  4361. * @param onObserverAdded defines a callback to call when a new observer is added
  4362. */
  4363. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4364. /**
  4365. * Create a new Observer with the specified callback
  4366. * @param callback the callback that will be executed for that Observer
  4367. * @param mask the mask used to filter observers
  4368. * @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.
  4369. * @param scope optional scope for the callback to be called from
  4370. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4371. * @returns the new observer created for the callback
  4372. */
  4373. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4374. /**
  4375. * Create a new Observer with the specified callback and unregisters after the next notification
  4376. * @param callback the callback that will be executed for that Observer
  4377. * @returns the new observer created for the callback
  4378. */
  4379. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4380. /**
  4381. * Remove an Observer from the Observable object
  4382. * @param observer the instance of the Observer to remove
  4383. * @returns false if it doesn't belong to this Observable
  4384. */
  4385. remove(observer: Nullable<Observer<T>>): boolean;
  4386. /**
  4387. * Remove a callback from the Observable object
  4388. * @param callback the callback to remove
  4389. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4390. * @returns false if it doesn't belong to this Observable
  4391. */
  4392. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4393. private _deferUnregister;
  4394. private _remove;
  4395. /**
  4396. * Moves the observable to the top of the observer list making it get called first when notified
  4397. * @param observer the observer to move
  4398. */
  4399. makeObserverTopPriority(observer: Observer<T>): void;
  4400. /**
  4401. * Moves the observable to the bottom of the observer list making it get called last when notified
  4402. * @param observer the observer to move
  4403. */
  4404. makeObserverBottomPriority(observer: Observer<T>): void;
  4405. /**
  4406. * Notify all Observers by calling their respective callback with the given data
  4407. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4408. * @param eventData defines the data to send to all observers
  4409. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4410. * @param target defines the original target of the state
  4411. * @param currentTarget defines the current target of the state
  4412. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4413. */
  4414. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4415. /**
  4416. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4417. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4418. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4419. * and it is crucial that all callbacks will be executed.
  4420. * The order of the callbacks is kept, callbacks are not executed parallel.
  4421. *
  4422. * @param eventData The data to be sent to each callback
  4423. * @param mask is used to filter observers defaults to -1
  4424. * @param target defines the callback target (see EventState)
  4425. * @param currentTarget defines he current object in the bubbling phase
  4426. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4427. */
  4428. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4429. /**
  4430. * Notify a specific observer
  4431. * @param observer defines the observer to notify
  4432. * @param eventData defines the data to be sent to each callback
  4433. * @param mask is used to filter observers defaults to -1
  4434. */
  4435. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4436. /**
  4437. * Gets a boolean indicating if the observable has at least one observer
  4438. * @returns true is the Observable has at least one Observer registered
  4439. */
  4440. hasObservers(): boolean;
  4441. /**
  4442. * Clear the list of observers
  4443. */
  4444. clear(): void;
  4445. /**
  4446. * Clone the current observable
  4447. * @returns a new observable
  4448. */
  4449. clone(): Observable<T>;
  4450. /**
  4451. * Does this observable handles observer registered with a given mask
  4452. * @param mask defines the mask to be tested
  4453. * @return whether or not one observer registered with the given mask is handeled
  4454. **/
  4455. hasSpecificMask(mask?: number): boolean;
  4456. }
  4457. }
  4458. declare module BABYLON {
  4459. /**
  4460. * Class used to help managing file picking and drag'n'drop
  4461. * File Storage
  4462. */
  4463. export class FilesInputStore {
  4464. /**
  4465. * List of files ready to be loaded
  4466. */
  4467. static FilesToLoad: {
  4468. [key: string]: File;
  4469. };
  4470. }
  4471. }
  4472. declare module BABYLON {
  4473. /** Defines the cross module used constants to avoid circular dependncies */
  4474. export class Constants {
  4475. /** Defines that alpha blending is disabled */
  4476. static readonly ALPHA_DISABLE: number;
  4477. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4478. static readonly ALPHA_ADD: number;
  4479. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4480. static readonly ALPHA_COMBINE: number;
  4481. /** Defines that alpha blending to DEST - SRC * DEST */
  4482. static readonly ALPHA_SUBTRACT: number;
  4483. /** Defines that alpha blending to SRC * DEST */
  4484. static readonly ALPHA_MULTIPLY: number;
  4485. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4486. static readonly ALPHA_MAXIMIZED: number;
  4487. /** Defines that alpha blending to SRC + DEST */
  4488. static readonly ALPHA_ONEONE: number;
  4489. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4490. static readonly ALPHA_PREMULTIPLIED: number;
  4491. /**
  4492. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4493. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4494. */
  4495. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4496. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4497. static readonly ALPHA_INTERPOLATE: number;
  4498. /**
  4499. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4500. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4501. */
  4502. static readonly ALPHA_SCREENMODE: number;
  4503. /** Defines that the ressource is not delayed*/
  4504. static readonly DELAYLOADSTATE_NONE: number;
  4505. /** Defines that the ressource was successfully delay loaded */
  4506. static readonly DELAYLOADSTATE_LOADED: number;
  4507. /** Defines that the ressource is currently delay loading */
  4508. static readonly DELAYLOADSTATE_LOADING: number;
  4509. /** Defines that the ressource is delayed and has not started loading */
  4510. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4511. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4512. static readonly NEVER: number;
  4513. /** 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 */
  4514. static readonly ALWAYS: number;
  4515. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4516. static readonly LESS: number;
  4517. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4518. static readonly EQUAL: number;
  4519. /** 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 */
  4520. static readonly LEQUAL: number;
  4521. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4522. static readonly GREATER: number;
  4523. /** 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 */
  4524. static readonly GEQUAL: number;
  4525. /** 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 */
  4526. static readonly NOTEQUAL: number;
  4527. /** Passed to stencilOperation to specify that stencil value must be kept */
  4528. static readonly KEEP: number;
  4529. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4530. static readonly REPLACE: number;
  4531. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4532. static readonly INCR: number;
  4533. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4534. static readonly DECR: number;
  4535. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4536. static readonly INVERT: number;
  4537. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4538. static readonly INCR_WRAP: number;
  4539. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4540. static readonly DECR_WRAP: number;
  4541. /** Texture is not repeating outside of 0..1 UVs */
  4542. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4543. /** Texture is repeating outside of 0..1 UVs */
  4544. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4545. /** Texture is repeating and mirrored */
  4546. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4547. /** ALPHA */
  4548. static readonly TEXTUREFORMAT_ALPHA: number;
  4549. /** LUMINANCE */
  4550. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4551. /** LUMINANCE_ALPHA */
  4552. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4553. /** RGB */
  4554. static readonly TEXTUREFORMAT_RGB: number;
  4555. /** RGBA */
  4556. static readonly TEXTUREFORMAT_RGBA: number;
  4557. /** RED */
  4558. static readonly TEXTUREFORMAT_RED: number;
  4559. /** RED (2nd reference) */
  4560. static readonly TEXTUREFORMAT_R: number;
  4561. /** RG */
  4562. static readonly TEXTUREFORMAT_RG: number;
  4563. /** RED_INTEGER */
  4564. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4565. /** RED_INTEGER (2nd reference) */
  4566. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4567. /** RG_INTEGER */
  4568. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4569. /** RGB_INTEGER */
  4570. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4571. /** RGBA_INTEGER */
  4572. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4573. /** UNSIGNED_BYTE */
  4574. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4575. /** UNSIGNED_BYTE (2nd reference) */
  4576. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4577. /** FLOAT */
  4578. static readonly TEXTURETYPE_FLOAT: number;
  4579. /** HALF_FLOAT */
  4580. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4581. /** BYTE */
  4582. static readonly TEXTURETYPE_BYTE: number;
  4583. /** SHORT */
  4584. static readonly TEXTURETYPE_SHORT: number;
  4585. /** UNSIGNED_SHORT */
  4586. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4587. /** INT */
  4588. static readonly TEXTURETYPE_INT: number;
  4589. /** UNSIGNED_INT */
  4590. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4591. /** UNSIGNED_SHORT_4_4_4_4 */
  4592. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4593. /** UNSIGNED_SHORT_5_5_5_1 */
  4594. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4595. /** UNSIGNED_SHORT_5_6_5 */
  4596. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4597. /** UNSIGNED_INT_2_10_10_10_REV */
  4598. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4599. /** UNSIGNED_INT_24_8 */
  4600. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4601. /** UNSIGNED_INT_10F_11F_11F_REV */
  4602. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4603. /** UNSIGNED_INT_5_9_9_9_REV */
  4604. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4605. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4606. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4607. /** nearest is mag = nearest and min = nearest and mip = linear */
  4608. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4609. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4610. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4611. /** Trilinear is mag = linear and min = linear and mip = linear */
  4612. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4613. /** nearest is mag = nearest and min = nearest and mip = linear */
  4614. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4615. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4616. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4617. /** Trilinear is mag = linear and min = linear and mip = linear */
  4618. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4619. /** mag = nearest and min = nearest and mip = nearest */
  4620. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4621. /** mag = nearest and min = linear and mip = nearest */
  4622. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4623. /** mag = nearest and min = linear and mip = linear */
  4624. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4625. /** mag = nearest and min = linear and mip = none */
  4626. static readonly TEXTURE_NEAREST_LINEAR: number;
  4627. /** mag = nearest and min = nearest and mip = none */
  4628. static readonly TEXTURE_NEAREST_NEAREST: number;
  4629. /** mag = linear and min = nearest and mip = nearest */
  4630. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4631. /** mag = linear and min = nearest and mip = linear */
  4632. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4633. /** mag = linear and min = linear and mip = none */
  4634. static readonly TEXTURE_LINEAR_LINEAR: number;
  4635. /** mag = linear and min = nearest and mip = none */
  4636. static readonly TEXTURE_LINEAR_NEAREST: number;
  4637. /** Explicit coordinates mode */
  4638. static readonly TEXTURE_EXPLICIT_MODE: number;
  4639. /** Spherical coordinates mode */
  4640. static readonly TEXTURE_SPHERICAL_MODE: number;
  4641. /** Planar coordinates mode */
  4642. static readonly TEXTURE_PLANAR_MODE: number;
  4643. /** Cubic coordinates mode */
  4644. static readonly TEXTURE_CUBIC_MODE: number;
  4645. /** Projection coordinates mode */
  4646. static readonly TEXTURE_PROJECTION_MODE: number;
  4647. /** Skybox coordinates mode */
  4648. static readonly TEXTURE_SKYBOX_MODE: number;
  4649. /** Inverse Cubic coordinates mode */
  4650. static readonly TEXTURE_INVCUBIC_MODE: number;
  4651. /** Equirectangular coordinates mode */
  4652. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4653. /** Equirectangular Fixed coordinates mode */
  4654. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4655. /** Equirectangular Fixed Mirrored coordinates mode */
  4656. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4657. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4658. static readonly SCALEMODE_FLOOR: number;
  4659. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4660. static readonly SCALEMODE_NEAREST: number;
  4661. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4662. static readonly SCALEMODE_CEILING: number;
  4663. /**
  4664. * The dirty texture flag value
  4665. */
  4666. static readonly MATERIAL_TextureDirtyFlag: number;
  4667. /**
  4668. * The dirty light flag value
  4669. */
  4670. static readonly MATERIAL_LightDirtyFlag: number;
  4671. /**
  4672. * The dirty fresnel flag value
  4673. */
  4674. static readonly MATERIAL_FresnelDirtyFlag: number;
  4675. /**
  4676. * The dirty attribute flag value
  4677. */
  4678. static readonly MATERIAL_AttributesDirtyFlag: number;
  4679. /**
  4680. * The dirty misc flag value
  4681. */
  4682. static readonly MATERIAL_MiscDirtyFlag: number;
  4683. /**
  4684. * The all dirty flag value
  4685. */
  4686. static readonly MATERIAL_AllDirtyFlag: number;
  4687. /**
  4688. * Returns the triangle fill mode
  4689. */
  4690. static readonly MATERIAL_TriangleFillMode: number;
  4691. /**
  4692. * Returns the wireframe mode
  4693. */
  4694. static readonly MATERIAL_WireFrameFillMode: number;
  4695. /**
  4696. * Returns the point fill mode
  4697. */
  4698. static readonly MATERIAL_PointFillMode: number;
  4699. /**
  4700. * Returns the point list draw mode
  4701. */
  4702. static readonly MATERIAL_PointListDrawMode: number;
  4703. /**
  4704. * Returns the line list draw mode
  4705. */
  4706. static readonly MATERIAL_LineListDrawMode: number;
  4707. /**
  4708. * Returns the line loop draw mode
  4709. */
  4710. static readonly MATERIAL_LineLoopDrawMode: number;
  4711. /**
  4712. * Returns the line strip draw mode
  4713. */
  4714. static readonly MATERIAL_LineStripDrawMode: number;
  4715. /**
  4716. * Returns the triangle strip draw mode
  4717. */
  4718. static readonly MATERIAL_TriangleStripDrawMode: number;
  4719. /**
  4720. * Returns the triangle fan draw mode
  4721. */
  4722. static readonly MATERIAL_TriangleFanDrawMode: number;
  4723. /**
  4724. * Stores the clock-wise side orientation
  4725. */
  4726. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4727. /**
  4728. * Stores the counter clock-wise side orientation
  4729. */
  4730. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4731. /**
  4732. * Nothing
  4733. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4734. */
  4735. static readonly ACTION_NothingTrigger: number;
  4736. /**
  4737. * On pick
  4738. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4739. */
  4740. static readonly ACTION_OnPickTrigger: number;
  4741. /**
  4742. * On left pick
  4743. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4744. */
  4745. static readonly ACTION_OnLeftPickTrigger: number;
  4746. /**
  4747. * On right pick
  4748. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4749. */
  4750. static readonly ACTION_OnRightPickTrigger: number;
  4751. /**
  4752. * On center pick
  4753. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4754. */
  4755. static readonly ACTION_OnCenterPickTrigger: number;
  4756. /**
  4757. * On pick down
  4758. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4759. */
  4760. static readonly ACTION_OnPickDownTrigger: number;
  4761. /**
  4762. * On double pick
  4763. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4764. */
  4765. static readonly ACTION_OnDoublePickTrigger: number;
  4766. /**
  4767. * On pick up
  4768. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4769. */
  4770. static readonly ACTION_OnPickUpTrigger: number;
  4771. /**
  4772. * On pick out.
  4773. * This trigger will only be raised if you also declared a OnPickDown
  4774. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4775. */
  4776. static readonly ACTION_OnPickOutTrigger: number;
  4777. /**
  4778. * On long press
  4779. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4780. */
  4781. static readonly ACTION_OnLongPressTrigger: number;
  4782. /**
  4783. * On pointer over
  4784. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4785. */
  4786. static readonly ACTION_OnPointerOverTrigger: number;
  4787. /**
  4788. * On pointer out
  4789. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4790. */
  4791. static readonly ACTION_OnPointerOutTrigger: number;
  4792. /**
  4793. * On every frame
  4794. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4795. */
  4796. static readonly ACTION_OnEveryFrameTrigger: number;
  4797. /**
  4798. * On intersection enter
  4799. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4800. */
  4801. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4802. /**
  4803. * On intersection exit
  4804. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4805. */
  4806. static readonly ACTION_OnIntersectionExitTrigger: number;
  4807. /**
  4808. * On key down
  4809. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4810. */
  4811. static readonly ACTION_OnKeyDownTrigger: number;
  4812. /**
  4813. * On key up
  4814. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4815. */
  4816. static readonly ACTION_OnKeyUpTrigger: number;
  4817. /**
  4818. * Billboard mode will only apply to Y axis
  4819. */
  4820. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4821. /**
  4822. * Billboard mode will apply to all axes
  4823. */
  4824. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4825. /**
  4826. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4827. */
  4828. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4829. /**
  4830. * Gets or sets base Assets URL
  4831. */
  4832. static PARTICLES_BaseAssetsUrl: string;
  4833. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4834. * Test order :
  4835. * Is the bounding sphere outside the frustum ?
  4836. * If not, are the bounding box vertices outside the frustum ?
  4837. * It not, then the cullable object is in the frustum.
  4838. */
  4839. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4840. /** Culling strategy : Bounding Sphere Only.
  4841. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4842. * It's also less accurate than the standard because some not visible objects can still be selected.
  4843. * Test : is the bounding sphere outside the frustum ?
  4844. * If not, then the cullable object is in the frustum.
  4845. */
  4846. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4847. /** Culling strategy : Optimistic Inclusion.
  4848. * This in an inclusion test first, then the standard exclusion test.
  4849. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4850. * 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.
  4851. * Anyway, it's as accurate as the standard strategy.
  4852. * Test :
  4853. * Is the cullable object bounding sphere center in the frustum ?
  4854. * If not, apply the default culling strategy.
  4855. */
  4856. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4857. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4858. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4859. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4860. * 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.
  4861. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4862. * Test :
  4863. * Is the cullable object bounding sphere center in the frustum ?
  4864. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4865. */
  4866. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4867. /**
  4868. * No logging while loading
  4869. */
  4870. static readonly SCENELOADER_NO_LOGGING: number;
  4871. /**
  4872. * Minimal logging while loading
  4873. */
  4874. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4875. /**
  4876. * Summary logging while loading
  4877. */
  4878. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4879. /**
  4880. * Detailled logging while loading
  4881. */
  4882. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4883. }
  4884. }
  4885. declare module BABYLON {
  4886. /**
  4887. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4888. * Babylon.js
  4889. */
  4890. export class DomManagement {
  4891. /**
  4892. * Checks if the window object exists
  4893. * @returns true if the window object exists
  4894. */
  4895. static IsWindowObjectExist(): boolean;
  4896. /**
  4897. * Extracts text content from a DOM element hierarchy
  4898. * @param element defines the root element
  4899. * @returns a string
  4900. */
  4901. static GetDOMTextContent(element: HTMLElement): string;
  4902. }
  4903. }
  4904. declare module BABYLON {
  4905. /**
  4906. * Logger used througouht the application to allow configuration of
  4907. * the log level required for the messages.
  4908. */
  4909. export class Logger {
  4910. /**
  4911. * No log
  4912. */
  4913. static readonly NoneLogLevel: number;
  4914. /**
  4915. * Only message logs
  4916. */
  4917. static readonly MessageLogLevel: number;
  4918. /**
  4919. * Only warning logs
  4920. */
  4921. static readonly WarningLogLevel: number;
  4922. /**
  4923. * Only error logs
  4924. */
  4925. static readonly ErrorLogLevel: number;
  4926. /**
  4927. * All logs
  4928. */
  4929. static readonly AllLogLevel: number;
  4930. private static _LogCache;
  4931. /**
  4932. * Gets a value indicating the number of loading errors
  4933. * @ignorenaming
  4934. */
  4935. static errorsCount: number;
  4936. /**
  4937. * Callback called when a new log is added
  4938. */
  4939. static OnNewCacheEntry: (entry: string) => void;
  4940. private static _AddLogEntry;
  4941. private static _FormatMessage;
  4942. private static _LogDisabled;
  4943. private static _LogEnabled;
  4944. private static _WarnDisabled;
  4945. private static _WarnEnabled;
  4946. private static _ErrorDisabled;
  4947. private static _ErrorEnabled;
  4948. /**
  4949. * Log a message to the console
  4950. */
  4951. static Log: (message: string) => void;
  4952. /**
  4953. * Write a warning message to the console
  4954. */
  4955. static Warn: (message: string) => void;
  4956. /**
  4957. * Write an error message to the console
  4958. */
  4959. static Error: (message: string) => void;
  4960. /**
  4961. * Gets current log cache (list of logs)
  4962. */
  4963. static readonly LogCache: string;
  4964. /**
  4965. * Clears the log cache
  4966. */
  4967. static ClearLogCache(): void;
  4968. /**
  4969. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4970. */
  4971. static LogLevels: number;
  4972. }
  4973. }
  4974. declare module BABYLON {
  4975. /** @hidden */
  4976. export class _TypeStore {
  4977. /** @hidden */
  4978. static RegisteredTypes: {
  4979. [key: string]: Object;
  4980. };
  4981. /** @hidden */
  4982. static GetClass(fqdn: string): any;
  4983. }
  4984. }
  4985. declare module BABYLON {
  4986. /**
  4987. * Class containing a set of static utilities functions for deep copy.
  4988. */
  4989. export class DeepCopier {
  4990. /**
  4991. * Tries to copy an object by duplicating every property
  4992. * @param source defines the source object
  4993. * @param destination defines the target object
  4994. * @param doNotCopyList defines a list of properties to avoid
  4995. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4996. */
  4997. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4998. }
  4999. }
  5000. declare module BABYLON {
  5001. /**
  5002. * Class containing a set of static utilities functions for precision date
  5003. */
  5004. export class PrecisionDate {
  5005. /**
  5006. * Gets either window.performance.now() if supported or Date.now() else
  5007. */
  5008. static readonly Now: number;
  5009. }
  5010. }
  5011. declare module BABYLON {
  5012. /** @hidden */
  5013. export class _DevTools {
  5014. static WarnImport(name: string): string;
  5015. }
  5016. }
  5017. declare module BABYLON {
  5018. /**
  5019. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  5020. */
  5021. export class WebRequest {
  5022. private _xhr;
  5023. /**
  5024. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  5025. * i.e. when loading files, where the server/service expects an Authorization header
  5026. */
  5027. static CustomRequestHeaders: {
  5028. [key: string]: string;
  5029. };
  5030. /**
  5031. * Add callback functions in this array to update all the requests before they get sent to the network
  5032. */
  5033. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  5034. private _injectCustomRequestHeaders;
  5035. /**
  5036. * Gets or sets a function to be called when loading progress changes
  5037. */
  5038. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  5039. /**
  5040. * Returns client's state
  5041. */
  5042. readonly readyState: number;
  5043. /**
  5044. * Returns client's status
  5045. */
  5046. readonly status: number;
  5047. /**
  5048. * Returns client's status as a text
  5049. */
  5050. readonly statusText: string;
  5051. /**
  5052. * Returns client's response
  5053. */
  5054. readonly response: any;
  5055. /**
  5056. * Returns client's response url
  5057. */
  5058. readonly responseURL: string;
  5059. /**
  5060. * Returns client's response as text
  5061. */
  5062. readonly responseText: string;
  5063. /**
  5064. * Gets or sets the expected response type
  5065. */
  5066. responseType: XMLHttpRequestResponseType;
  5067. /** @hidden */
  5068. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5069. /** @hidden */
  5070. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5071. /**
  5072. * Cancels any network activity
  5073. */
  5074. abort(): void;
  5075. /**
  5076. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5077. * @param body defines an optional request body
  5078. */
  5079. send(body?: Document | BodyInit | null): void;
  5080. /**
  5081. * Sets the request method, request URL
  5082. * @param method defines the method to use (GET, POST, etc..)
  5083. * @param url defines the url to connect with
  5084. */
  5085. open(method: string, url: string): void;
  5086. }
  5087. }
  5088. declare module BABYLON {
  5089. /**
  5090. * Class used to evalaute queries containing `and` and `or` operators
  5091. */
  5092. export class AndOrNotEvaluator {
  5093. /**
  5094. * Evaluate a query
  5095. * @param query defines the query to evaluate
  5096. * @param evaluateCallback defines the callback used to filter result
  5097. * @returns true if the query matches
  5098. */
  5099. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5100. private static _HandleParenthesisContent;
  5101. private static _SimplifyNegation;
  5102. }
  5103. }
  5104. declare module BABYLON {
  5105. /**
  5106. * Class used to store custom tags
  5107. */
  5108. export class Tags {
  5109. /**
  5110. * Adds support for tags on the given object
  5111. * @param obj defines the object to use
  5112. */
  5113. static EnableFor(obj: any): void;
  5114. /**
  5115. * Removes tags support
  5116. * @param obj defines the object to use
  5117. */
  5118. static DisableFor(obj: any): void;
  5119. /**
  5120. * Gets a boolean indicating if the given object has tags
  5121. * @param obj defines the object to use
  5122. * @returns a boolean
  5123. */
  5124. static HasTags(obj: any): boolean;
  5125. /**
  5126. * Gets the tags available on a given object
  5127. * @param obj defines the object to use
  5128. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5129. * @returns the tags
  5130. */
  5131. static GetTags(obj: any, asString?: boolean): any;
  5132. /**
  5133. * Adds tags to an object
  5134. * @param obj defines the object to use
  5135. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5136. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5137. */
  5138. static AddTagsTo(obj: any, tagsString: string): void;
  5139. /**
  5140. * @hidden
  5141. */
  5142. static _AddTagTo(obj: any, tag: string): void;
  5143. /**
  5144. * Removes specific tags from a specific object
  5145. * @param obj defines the object to use
  5146. * @param tagsString defines the tags to remove
  5147. */
  5148. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5149. /**
  5150. * @hidden
  5151. */
  5152. static _RemoveTagFrom(obj: any, tag: string): void;
  5153. /**
  5154. * Defines if tags hosted on an object match a given query
  5155. * @param obj defines the object to use
  5156. * @param tagsQuery defines the tag query
  5157. * @returns a boolean
  5158. */
  5159. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5160. }
  5161. }
  5162. declare module BABYLON {
  5163. /**
  5164. * Manages the defines for the Material
  5165. */
  5166. export class MaterialDefines {
  5167. /** @hidden */
  5168. protected _keys: string[];
  5169. private _isDirty;
  5170. /** @hidden */
  5171. _renderId: number;
  5172. /** @hidden */
  5173. _areLightsDirty: boolean;
  5174. /** @hidden */
  5175. _areAttributesDirty: boolean;
  5176. /** @hidden */
  5177. _areTexturesDirty: boolean;
  5178. /** @hidden */
  5179. _areFresnelDirty: boolean;
  5180. /** @hidden */
  5181. _areMiscDirty: boolean;
  5182. /** @hidden */
  5183. _areImageProcessingDirty: boolean;
  5184. /** @hidden */
  5185. _normals: boolean;
  5186. /** @hidden */
  5187. _uvs: boolean;
  5188. /** @hidden */
  5189. _needNormals: boolean;
  5190. /** @hidden */
  5191. _needUVs: boolean;
  5192. [id: string]: any;
  5193. /**
  5194. * Specifies if the material needs to be re-calculated
  5195. */
  5196. readonly isDirty: boolean;
  5197. /**
  5198. * Marks the material to indicate that it has been re-calculated
  5199. */
  5200. markAsProcessed(): void;
  5201. /**
  5202. * Marks the material to indicate that it needs to be re-calculated
  5203. */
  5204. markAsUnprocessed(): void;
  5205. /**
  5206. * Marks the material to indicate all of its defines need to be re-calculated
  5207. */
  5208. markAllAsDirty(): void;
  5209. /**
  5210. * Marks the material to indicate that image processing needs to be re-calculated
  5211. */
  5212. markAsImageProcessingDirty(): void;
  5213. /**
  5214. * Marks the material to indicate the lights need to be re-calculated
  5215. */
  5216. markAsLightDirty(): void;
  5217. /**
  5218. * Marks the attribute state as changed
  5219. */
  5220. markAsAttributesDirty(): void;
  5221. /**
  5222. * Marks the texture state as changed
  5223. */
  5224. markAsTexturesDirty(): void;
  5225. /**
  5226. * Marks the fresnel state as changed
  5227. */
  5228. markAsFresnelDirty(): void;
  5229. /**
  5230. * Marks the misc state as changed
  5231. */
  5232. markAsMiscDirty(): void;
  5233. /**
  5234. * Rebuilds the material defines
  5235. */
  5236. rebuild(): void;
  5237. /**
  5238. * Specifies if two material defines are equal
  5239. * @param other - A material define instance to compare to
  5240. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5241. */
  5242. isEqual(other: MaterialDefines): boolean;
  5243. /**
  5244. * Clones this instance's defines to another instance
  5245. * @param other - material defines to clone values to
  5246. */
  5247. cloneTo(other: MaterialDefines): void;
  5248. /**
  5249. * Resets the material define values
  5250. */
  5251. reset(): void;
  5252. /**
  5253. * Converts the material define values to a string
  5254. * @returns - String of material define information
  5255. */
  5256. toString(): string;
  5257. }
  5258. }
  5259. declare module BABYLON {
  5260. /**
  5261. * Class used to store and describe the pipeline context associated with an effect
  5262. */
  5263. export interface IPipelineContext {
  5264. /**
  5265. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  5266. */
  5267. isAsync: boolean;
  5268. /**
  5269. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  5270. */
  5271. isReady: boolean;
  5272. /** @hidden */
  5273. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  5274. }
  5275. }
  5276. declare module BABYLON {
  5277. /**
  5278. * Class used to store gfx data (like WebGLBuffer)
  5279. */
  5280. export class DataBuffer {
  5281. /**
  5282. * Gets or sets the number of objects referencing this buffer
  5283. */
  5284. references: number;
  5285. /** Gets or sets the size of the underlying buffer */
  5286. capacity: number;
  5287. /**
  5288. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  5289. */
  5290. is32Bits: boolean;
  5291. /**
  5292. * Gets the underlying buffer
  5293. */
  5294. readonly underlyingResource: any;
  5295. }
  5296. }
  5297. declare module BABYLON {
  5298. /** @hidden */
  5299. export interface IShaderProcessor {
  5300. attributeProcessor?: (attribute: string) => string;
  5301. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  5302. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  5303. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  5304. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  5305. lineProcessor?: (line: string, isFragment: boolean) => string;
  5306. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  5307. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  5308. }
  5309. }
  5310. declare module BABYLON {
  5311. /** @hidden */
  5312. export interface ProcessingOptions {
  5313. defines: string[];
  5314. indexParameters: any;
  5315. isFragment: boolean;
  5316. shouldUseHighPrecisionShader: boolean;
  5317. supportsUniformBuffers: boolean;
  5318. shadersRepository: string;
  5319. includesShadersStore: {
  5320. [key: string]: string;
  5321. };
  5322. processor?: IShaderProcessor;
  5323. version: string;
  5324. platformName: string;
  5325. lookForClosingBracketForUniformBuffer?: boolean;
  5326. }
  5327. }
  5328. declare module BABYLON {
  5329. /** @hidden */
  5330. export class ShaderCodeNode {
  5331. line: string;
  5332. children: ShaderCodeNode[];
  5333. additionalDefineKey?: string;
  5334. additionalDefineValue?: string;
  5335. isValid(preprocessors: {
  5336. [key: string]: string;
  5337. }): boolean;
  5338. process(preprocessors: {
  5339. [key: string]: string;
  5340. }, options: ProcessingOptions): string;
  5341. }
  5342. }
  5343. declare module BABYLON {
  5344. /** @hidden */
  5345. export class ShaderCodeCursor {
  5346. private _lines;
  5347. lineIndex: number;
  5348. readonly currentLine: string;
  5349. readonly canRead: boolean;
  5350. lines: string[];
  5351. }
  5352. }
  5353. declare module BABYLON {
  5354. /** @hidden */
  5355. export class ShaderCodeConditionNode extends ShaderCodeNode {
  5356. process(preprocessors: {
  5357. [key: string]: string;
  5358. }, options: ProcessingOptions): string;
  5359. }
  5360. }
  5361. declare module BABYLON {
  5362. /** @hidden */
  5363. export class ShaderDefineExpression {
  5364. isTrue(preprocessors: {
  5365. [key: string]: string;
  5366. }): boolean;
  5367. }
  5368. }
  5369. declare module BABYLON {
  5370. /** @hidden */
  5371. export class ShaderCodeTestNode extends ShaderCodeNode {
  5372. testExpression: ShaderDefineExpression;
  5373. isValid(preprocessors: {
  5374. [key: string]: string;
  5375. }): boolean;
  5376. }
  5377. }
  5378. declare module BABYLON {
  5379. /** @hidden */
  5380. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  5381. define: string;
  5382. not: boolean;
  5383. constructor(define: string, not?: boolean);
  5384. isTrue(preprocessors: {
  5385. [key: string]: string;
  5386. }): boolean;
  5387. }
  5388. }
  5389. declare module BABYLON {
  5390. /** @hidden */
  5391. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  5392. leftOperand: ShaderDefineExpression;
  5393. rightOperand: ShaderDefineExpression;
  5394. isTrue(preprocessors: {
  5395. [key: string]: string;
  5396. }): boolean;
  5397. }
  5398. }
  5399. declare module BABYLON {
  5400. /** @hidden */
  5401. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  5402. leftOperand: ShaderDefineExpression;
  5403. rightOperand: ShaderDefineExpression;
  5404. isTrue(preprocessors: {
  5405. [key: string]: string;
  5406. }): boolean;
  5407. }
  5408. }
  5409. declare module BABYLON {
  5410. /** @hidden */
  5411. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  5412. define: string;
  5413. operand: string;
  5414. testValue: string;
  5415. constructor(define: string, operand: string, testValue: string);
  5416. isTrue(preprocessors: {
  5417. [key: string]: string;
  5418. }): boolean;
  5419. }
  5420. }
  5421. declare module BABYLON {
  5422. /** @hidden */
  5423. export class ShaderProcessor {
  5424. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  5425. private static _ProcessPrecision;
  5426. private static _ExtractOperation;
  5427. private static _BuildSubExpression;
  5428. private static _BuildExpression;
  5429. private static _MoveCursorWithinIf;
  5430. private static _MoveCursor;
  5431. private static _EvaluatePreProcessors;
  5432. private static _PreparePreProcessors;
  5433. private static _ProcessShaderConversion;
  5434. private static _ProcessIncludes;
  5435. }
  5436. }
  5437. declare module BABYLON {
  5438. /**
  5439. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5440. */
  5441. export class PerformanceMonitor {
  5442. private _enabled;
  5443. private _rollingFrameTime;
  5444. private _lastFrameTimeMs;
  5445. /**
  5446. * constructor
  5447. * @param frameSampleSize The number of samples required to saturate the sliding window
  5448. */
  5449. constructor(frameSampleSize?: number);
  5450. /**
  5451. * Samples current frame
  5452. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5453. */
  5454. sampleFrame(timeMs?: number): void;
  5455. /**
  5456. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5457. */
  5458. readonly averageFrameTime: number;
  5459. /**
  5460. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5461. */
  5462. readonly averageFrameTimeVariance: number;
  5463. /**
  5464. * Returns the frame time of the most recent frame
  5465. */
  5466. readonly instantaneousFrameTime: number;
  5467. /**
  5468. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5469. */
  5470. readonly averageFPS: number;
  5471. /**
  5472. * Returns the average framerate in frames per second using the most recent frame time
  5473. */
  5474. readonly instantaneousFPS: number;
  5475. /**
  5476. * Returns true if enough samples have been taken to completely fill the sliding window
  5477. */
  5478. readonly isSaturated: boolean;
  5479. /**
  5480. * Enables contributions to the sliding window sample set
  5481. */
  5482. enable(): void;
  5483. /**
  5484. * Disables contributions to the sliding window sample set
  5485. * Samples will not be interpolated over the disabled period
  5486. */
  5487. disable(): void;
  5488. /**
  5489. * Returns true if sampling is enabled
  5490. */
  5491. readonly isEnabled: boolean;
  5492. /**
  5493. * Resets performance monitor
  5494. */
  5495. reset(): void;
  5496. }
  5497. /**
  5498. * RollingAverage
  5499. *
  5500. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5501. */
  5502. export class RollingAverage {
  5503. /**
  5504. * Current average
  5505. */
  5506. average: number;
  5507. /**
  5508. * Current variance
  5509. */
  5510. variance: number;
  5511. protected _samples: Array<number>;
  5512. protected _sampleCount: number;
  5513. protected _pos: number;
  5514. protected _m2: number;
  5515. /**
  5516. * constructor
  5517. * @param length The number of samples required to saturate the sliding window
  5518. */
  5519. constructor(length: number);
  5520. /**
  5521. * Adds a sample to the sample set
  5522. * @param v The sample value
  5523. */
  5524. add(v: number): void;
  5525. /**
  5526. * Returns previously added values or null if outside of history or outside the sliding window domain
  5527. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5528. * @return Value previously recorded with add() or null if outside of range
  5529. */
  5530. history(i: number): number;
  5531. /**
  5532. * Returns true if enough samples have been taken to completely fill the sliding window
  5533. * @return true if sample-set saturated
  5534. */
  5535. isSaturated(): boolean;
  5536. /**
  5537. * Resets the rolling average (equivalent to 0 samples taken so far)
  5538. */
  5539. reset(): void;
  5540. /**
  5541. * Wraps a value around the sample range boundaries
  5542. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5543. * @return Wrapped position in sample range
  5544. */
  5545. protected _wrapPosition(i: number): number;
  5546. }
  5547. }
  5548. declare module BABYLON {
  5549. /**
  5550. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5551. * The underlying implementation relies on an associative array to ensure the best performances.
  5552. * The value can be anything including 'null' but except 'undefined'
  5553. */
  5554. export class StringDictionary<T> {
  5555. /**
  5556. * This will clear this dictionary and copy the content from the 'source' one.
  5557. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5558. * @param source the dictionary to take the content from and copy to this dictionary
  5559. */
  5560. copyFrom(source: StringDictionary<T>): void;
  5561. /**
  5562. * Get a value based from its key
  5563. * @param key the given key to get the matching value from
  5564. * @return the value if found, otherwise undefined is returned
  5565. */
  5566. get(key: string): T | undefined;
  5567. /**
  5568. * Get a value from its key or add it if it doesn't exist.
  5569. * This method will ensure you that a given key/data will be present in the dictionary.
  5570. * @param key the given key to get the matching value from
  5571. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5572. * The factory will only be invoked if there's no data for the given key.
  5573. * @return the value corresponding to the key.
  5574. */
  5575. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5576. /**
  5577. * Get a value from its key if present in the dictionary otherwise add it
  5578. * @param key the key to get the value from
  5579. * @param val if there's no such key/value pair in the dictionary add it with this value
  5580. * @return the value corresponding to the key
  5581. */
  5582. getOrAdd(key: string, val: T): T;
  5583. /**
  5584. * Check if there's a given key in the dictionary
  5585. * @param key the key to check for
  5586. * @return true if the key is present, false otherwise
  5587. */
  5588. contains(key: string): boolean;
  5589. /**
  5590. * Add a new key and its corresponding value
  5591. * @param key the key to add
  5592. * @param value the value corresponding to the key
  5593. * @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
  5594. */
  5595. add(key: string, value: T): boolean;
  5596. /**
  5597. * Update a specific value associated to a key
  5598. * @param key defines the key to use
  5599. * @param value defines the value to store
  5600. * @returns true if the value was updated (or false if the key was not found)
  5601. */
  5602. set(key: string, value: T): boolean;
  5603. /**
  5604. * Get the element of the given key and remove it from the dictionary
  5605. * @param key defines the key to search
  5606. * @returns the value associated with the key or null if not found
  5607. */
  5608. getAndRemove(key: string): Nullable<T>;
  5609. /**
  5610. * Remove a key/value from the dictionary.
  5611. * @param key the key to remove
  5612. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5613. */
  5614. remove(key: string): boolean;
  5615. /**
  5616. * Clear the whole content of the dictionary
  5617. */
  5618. clear(): void;
  5619. /**
  5620. * Gets the current count
  5621. */
  5622. readonly count: number;
  5623. /**
  5624. * Execute a callback on each key/val of the dictionary.
  5625. * Note that you can remove any element in this dictionary in the callback implementation
  5626. * @param callback the callback to execute on a given key/value pair
  5627. */
  5628. forEach(callback: (key: string, val: T) => void): void;
  5629. /**
  5630. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5631. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5632. * Note that you can remove any element in this dictionary in the callback implementation
  5633. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5634. * @returns the first item
  5635. */
  5636. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5637. private _count;
  5638. private _data;
  5639. }
  5640. }
  5641. declare module BABYLON {
  5642. /**
  5643. * Helper class that provides a small promise polyfill
  5644. */
  5645. export class PromisePolyfill {
  5646. /**
  5647. * Static function used to check if the polyfill is required
  5648. * If this is the case then the function will inject the polyfill to window.Promise
  5649. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5650. */
  5651. static Apply(force?: boolean): void;
  5652. }
  5653. }
  5654. declare module BABYLON {
  5655. /**
  5656. * Class used to store data that will be store in GPU memory
  5657. */
  5658. export class Buffer {
  5659. private _engine;
  5660. private _buffer;
  5661. /** @hidden */
  5662. _data: Nullable<DataArray>;
  5663. private _updatable;
  5664. private _instanced;
  5665. /**
  5666. * Gets the byte stride.
  5667. */
  5668. readonly byteStride: number;
  5669. /**
  5670. * Constructor
  5671. * @param engine the engine
  5672. * @param data the data to use for this buffer
  5673. * @param updatable whether the data is updatable
  5674. * @param stride the stride (optional)
  5675. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5676. * @param instanced whether the buffer is instanced (optional)
  5677. * @param useBytes set to true if the stride in in bytes (optional)
  5678. */
  5679. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5680. /**
  5681. * Create a new VertexBuffer based on the current buffer
  5682. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5683. * @param offset defines offset in the buffer (0 by default)
  5684. * @param size defines the size in floats of attributes (position is 3 for instance)
  5685. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5686. * @param instanced defines if the vertex buffer contains indexed data
  5687. * @param useBytes defines if the offset and stride are in bytes
  5688. * @returns the new vertex buffer
  5689. */
  5690. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5691. /**
  5692. * Gets a boolean indicating if the Buffer is updatable?
  5693. * @returns true if the buffer is updatable
  5694. */
  5695. isUpdatable(): boolean;
  5696. /**
  5697. * Gets current buffer's data
  5698. * @returns a DataArray or null
  5699. */
  5700. getData(): Nullable<DataArray>;
  5701. /**
  5702. * Gets underlying native buffer
  5703. * @returns underlying native buffer
  5704. */
  5705. getBuffer(): Nullable<DataBuffer>;
  5706. /**
  5707. * Gets the stride in float32 units (i.e. byte stride / 4).
  5708. * May not be an integer if the byte stride is not divisible by 4.
  5709. * DEPRECATED. Use byteStride instead.
  5710. * @returns the stride in float32 units
  5711. */
  5712. getStrideSize(): number;
  5713. /**
  5714. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5715. * @param data defines the data to store
  5716. */
  5717. create(data?: Nullable<DataArray>): void;
  5718. /** @hidden */
  5719. _rebuild(): void;
  5720. /**
  5721. * Update current buffer data
  5722. * @param data defines the data to store
  5723. */
  5724. update(data: DataArray): void;
  5725. /**
  5726. * Updates the data directly.
  5727. * @param data the new data
  5728. * @param offset the new offset
  5729. * @param vertexCount the vertex count (optional)
  5730. * @param useBytes set to true if the offset is in bytes
  5731. */
  5732. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5733. /**
  5734. * Release all resources
  5735. */
  5736. dispose(): void;
  5737. }
  5738. /**
  5739. * Specialized buffer used to store vertex data
  5740. */
  5741. export class VertexBuffer {
  5742. /** @hidden */
  5743. _buffer: Buffer;
  5744. private _kind;
  5745. private _size;
  5746. private _ownsBuffer;
  5747. private _instanced;
  5748. private _instanceDivisor;
  5749. /**
  5750. * The byte type.
  5751. */
  5752. static readonly BYTE: number;
  5753. /**
  5754. * The unsigned byte type.
  5755. */
  5756. static readonly UNSIGNED_BYTE: number;
  5757. /**
  5758. * The short type.
  5759. */
  5760. static readonly SHORT: number;
  5761. /**
  5762. * The unsigned short type.
  5763. */
  5764. static readonly UNSIGNED_SHORT: number;
  5765. /**
  5766. * The integer type.
  5767. */
  5768. static readonly INT: number;
  5769. /**
  5770. * The unsigned integer type.
  5771. */
  5772. static readonly UNSIGNED_INT: number;
  5773. /**
  5774. * The float type.
  5775. */
  5776. static readonly FLOAT: number;
  5777. /**
  5778. * Gets or sets the instance divisor when in instanced mode
  5779. */
  5780. instanceDivisor: number;
  5781. /**
  5782. * Gets the byte stride.
  5783. */
  5784. readonly byteStride: number;
  5785. /**
  5786. * Gets the byte offset.
  5787. */
  5788. readonly byteOffset: number;
  5789. /**
  5790. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5791. */
  5792. readonly normalized: boolean;
  5793. /**
  5794. * Gets the data type of each component in the array.
  5795. */
  5796. readonly type: number;
  5797. /**
  5798. * Constructor
  5799. * @param engine the engine
  5800. * @param data the data to use for this vertex buffer
  5801. * @param kind the vertex buffer kind
  5802. * @param updatable whether the data is updatable
  5803. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5804. * @param stride the stride (optional)
  5805. * @param instanced whether the buffer is instanced (optional)
  5806. * @param offset the offset of the data (optional)
  5807. * @param size the number of components (optional)
  5808. * @param type the type of the component (optional)
  5809. * @param normalized whether the data contains normalized data (optional)
  5810. * @param useBytes set to true if stride and offset are in bytes (optional)
  5811. */
  5812. 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);
  5813. /** @hidden */
  5814. _rebuild(): void;
  5815. /**
  5816. * Returns the kind of the VertexBuffer (string)
  5817. * @returns a string
  5818. */
  5819. getKind(): string;
  5820. /**
  5821. * Gets a boolean indicating if the VertexBuffer is updatable?
  5822. * @returns true if the buffer is updatable
  5823. */
  5824. isUpdatable(): boolean;
  5825. /**
  5826. * Gets current buffer's data
  5827. * @returns a DataArray or null
  5828. */
  5829. getData(): Nullable<DataArray>;
  5830. /**
  5831. * Gets underlying native buffer
  5832. * @returns underlying native buffer
  5833. */
  5834. getBuffer(): Nullable<DataBuffer>;
  5835. /**
  5836. * Gets the stride in float32 units (i.e. byte stride / 4).
  5837. * May not be an integer if the byte stride is not divisible by 4.
  5838. * DEPRECATED. Use byteStride instead.
  5839. * @returns the stride in float32 units
  5840. */
  5841. getStrideSize(): number;
  5842. /**
  5843. * Returns the offset as a multiple of the type byte length.
  5844. * DEPRECATED. Use byteOffset instead.
  5845. * @returns the offset in bytes
  5846. */
  5847. getOffset(): number;
  5848. /**
  5849. * Returns the number of components per vertex attribute (integer)
  5850. * @returns the size in float
  5851. */
  5852. getSize(): number;
  5853. /**
  5854. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5855. * @returns true if this buffer is instanced
  5856. */
  5857. getIsInstanced(): boolean;
  5858. /**
  5859. * Returns the instancing divisor, zero for non-instanced (integer).
  5860. * @returns a number
  5861. */
  5862. getInstanceDivisor(): number;
  5863. /**
  5864. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5865. * @param data defines the data to store
  5866. */
  5867. create(data?: DataArray): void;
  5868. /**
  5869. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5870. * This function will create a new buffer if the current one is not updatable
  5871. * @param data defines the data to store
  5872. */
  5873. update(data: DataArray): void;
  5874. /**
  5875. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5876. * Returns the directly updated WebGLBuffer.
  5877. * @param data the new data
  5878. * @param offset the new offset
  5879. * @param useBytes set to true if the offset is in bytes
  5880. */
  5881. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5882. /**
  5883. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5884. */
  5885. dispose(): void;
  5886. /**
  5887. * Enumerates each value of this vertex buffer as numbers.
  5888. * @param count the number of values to enumerate
  5889. * @param callback the callback function called for each value
  5890. */
  5891. forEach(count: number, callback: (value: number, index: number) => void): void;
  5892. /**
  5893. * Positions
  5894. */
  5895. static readonly PositionKind: string;
  5896. /**
  5897. * Normals
  5898. */
  5899. static readonly NormalKind: string;
  5900. /**
  5901. * Tangents
  5902. */
  5903. static readonly TangentKind: string;
  5904. /**
  5905. * Texture coordinates
  5906. */
  5907. static readonly UVKind: string;
  5908. /**
  5909. * Texture coordinates 2
  5910. */
  5911. static readonly UV2Kind: string;
  5912. /**
  5913. * Texture coordinates 3
  5914. */
  5915. static readonly UV3Kind: string;
  5916. /**
  5917. * Texture coordinates 4
  5918. */
  5919. static readonly UV4Kind: string;
  5920. /**
  5921. * Texture coordinates 5
  5922. */
  5923. static readonly UV5Kind: string;
  5924. /**
  5925. * Texture coordinates 6
  5926. */
  5927. static readonly UV6Kind: string;
  5928. /**
  5929. * Colors
  5930. */
  5931. static readonly ColorKind: string;
  5932. /**
  5933. * Matrix indices (for bones)
  5934. */
  5935. static readonly MatricesIndicesKind: string;
  5936. /**
  5937. * Matrix weights (for bones)
  5938. */
  5939. static readonly MatricesWeightsKind: string;
  5940. /**
  5941. * Additional matrix indices (for bones)
  5942. */
  5943. static readonly MatricesIndicesExtraKind: string;
  5944. /**
  5945. * Additional matrix weights (for bones)
  5946. */
  5947. static readonly MatricesWeightsExtraKind: string;
  5948. /**
  5949. * Deduces the stride given a kind.
  5950. * @param kind The kind string to deduce
  5951. * @returns The deduced stride
  5952. */
  5953. static DeduceStride(kind: string): number;
  5954. /**
  5955. * Gets the byte length of the given type.
  5956. * @param type the type
  5957. * @returns the number of bytes
  5958. */
  5959. static GetTypeByteLength(type: number): number;
  5960. /**
  5961. * Enumerates each value of the given parameters as numbers.
  5962. * @param data the data to enumerate
  5963. * @param byteOffset the byte offset of the data
  5964. * @param byteStride the byte stride of the data
  5965. * @param componentCount the number of components per element
  5966. * @param componentType the type of the component
  5967. * @param count the number of values to enumerate
  5968. * @param normalized whether the data is normalized
  5969. * @param callback the callback function called for each value
  5970. */
  5971. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5972. private static _GetFloatValue;
  5973. }
  5974. }
  5975. declare module BABYLON {
  5976. /**
  5977. * Class representing spherical harmonics coefficients to the 3rd degree
  5978. */
  5979. export class SphericalHarmonics {
  5980. /**
  5981. * Defines whether or not the harmonics have been prescaled for rendering.
  5982. */
  5983. preScaled: boolean;
  5984. /**
  5985. * The l0,0 coefficients of the spherical harmonics
  5986. */
  5987. l00: Vector3;
  5988. /**
  5989. * The l1,-1 coefficients of the spherical harmonics
  5990. */
  5991. l1_1: Vector3;
  5992. /**
  5993. * The l1,0 coefficients of the spherical harmonics
  5994. */
  5995. l10: Vector3;
  5996. /**
  5997. * The l1,1 coefficients of the spherical harmonics
  5998. */
  5999. l11: Vector3;
  6000. /**
  6001. * The l2,-2 coefficients of the spherical harmonics
  6002. */
  6003. l2_2: Vector3;
  6004. /**
  6005. * The l2,-1 coefficients of the spherical harmonics
  6006. */
  6007. l2_1: Vector3;
  6008. /**
  6009. * The l2,0 coefficients of the spherical harmonics
  6010. */
  6011. l20: Vector3;
  6012. /**
  6013. * The l2,1 coefficients of the spherical harmonics
  6014. */
  6015. l21: Vector3;
  6016. /**
  6017. * The l2,2 coefficients of the spherical harmonics
  6018. */
  6019. l22: Vector3;
  6020. /**
  6021. * Adds a light to the spherical harmonics
  6022. * @param direction the direction of the light
  6023. * @param color the color of the light
  6024. * @param deltaSolidAngle the delta solid angle of the light
  6025. */
  6026. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  6027. /**
  6028. * Scales the spherical harmonics by the given amount
  6029. * @param scale the amount to scale
  6030. */
  6031. scaleInPlace(scale: number): void;
  6032. /**
  6033. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  6034. *
  6035. * ```
  6036. * E_lm = A_l * L_lm
  6037. * ```
  6038. *
  6039. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  6040. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  6041. * the scaling factors are given in equation 9.
  6042. */
  6043. convertIncidentRadianceToIrradiance(): void;
  6044. /**
  6045. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  6046. *
  6047. * ```
  6048. * L = (1/pi) * E * rho
  6049. * ```
  6050. *
  6051. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  6052. */
  6053. convertIrradianceToLambertianRadiance(): void;
  6054. /**
  6055. * Integrates the reconstruction coefficients directly in to the SH preventing further
  6056. * required operations at run time.
  6057. *
  6058. * This is simply done by scaling back the SH with Ylm constants parameter.
  6059. * The trigonometric part being applied by the shader at run time.
  6060. */
  6061. preScaleForRendering(): void;
  6062. /**
  6063. * Constructs a spherical harmonics from an array.
  6064. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  6065. * @returns the spherical harmonics
  6066. */
  6067. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  6068. /**
  6069. * Gets the spherical harmonics from polynomial
  6070. * @param polynomial the spherical polynomial
  6071. * @returns the spherical harmonics
  6072. */
  6073. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  6074. }
  6075. /**
  6076. * Class representing spherical polynomial coefficients to the 3rd degree
  6077. */
  6078. export class SphericalPolynomial {
  6079. private _harmonics;
  6080. /**
  6081. * The spherical harmonics used to create the polynomials.
  6082. */
  6083. readonly preScaledHarmonics: SphericalHarmonics;
  6084. /**
  6085. * The x coefficients of the spherical polynomial
  6086. */
  6087. x: Vector3;
  6088. /**
  6089. * The y coefficients of the spherical polynomial
  6090. */
  6091. y: Vector3;
  6092. /**
  6093. * The z coefficients of the spherical polynomial
  6094. */
  6095. z: Vector3;
  6096. /**
  6097. * The xx coefficients of the spherical polynomial
  6098. */
  6099. xx: Vector3;
  6100. /**
  6101. * The yy coefficients of the spherical polynomial
  6102. */
  6103. yy: Vector3;
  6104. /**
  6105. * The zz coefficients of the spherical polynomial
  6106. */
  6107. zz: Vector3;
  6108. /**
  6109. * The xy coefficients of the spherical polynomial
  6110. */
  6111. xy: Vector3;
  6112. /**
  6113. * The yz coefficients of the spherical polynomial
  6114. */
  6115. yz: Vector3;
  6116. /**
  6117. * The zx coefficients of the spherical polynomial
  6118. */
  6119. zx: Vector3;
  6120. /**
  6121. * Adds an ambient color to the spherical polynomial
  6122. * @param color the color to add
  6123. */
  6124. addAmbient(color: Color3): void;
  6125. /**
  6126. * Scales the spherical polynomial by the given amount
  6127. * @param scale the amount to scale
  6128. */
  6129. scaleInPlace(scale: number): void;
  6130. /**
  6131. * Gets the spherical polynomial from harmonics
  6132. * @param harmonics the spherical harmonics
  6133. * @returns the spherical polynomial
  6134. */
  6135. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  6136. /**
  6137. * Constructs a spherical polynomial from an array.
  6138. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  6139. * @returns the spherical polynomial
  6140. */
  6141. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  6142. }
  6143. }
  6144. declare module BABYLON {
  6145. /**
  6146. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  6147. */
  6148. export interface CubeMapInfo {
  6149. /**
  6150. * The pixel array for the front face.
  6151. * This is stored in format, left to right, up to down format.
  6152. */
  6153. front: Nullable<ArrayBufferView>;
  6154. /**
  6155. * The pixel array for the back face.
  6156. * This is stored in format, left to right, up to down format.
  6157. */
  6158. back: Nullable<ArrayBufferView>;
  6159. /**
  6160. * The pixel array for the left face.
  6161. * This is stored in format, left to right, up to down format.
  6162. */
  6163. left: Nullable<ArrayBufferView>;
  6164. /**
  6165. * The pixel array for the right face.
  6166. * This is stored in format, left to right, up to down format.
  6167. */
  6168. right: Nullable<ArrayBufferView>;
  6169. /**
  6170. * The pixel array for the up face.
  6171. * This is stored in format, left to right, up to down format.
  6172. */
  6173. up: Nullable<ArrayBufferView>;
  6174. /**
  6175. * The pixel array for the down face.
  6176. * This is stored in format, left to right, up to down format.
  6177. */
  6178. down: Nullable<ArrayBufferView>;
  6179. /**
  6180. * The size of the cubemap stored.
  6181. *
  6182. * Each faces will be size * size pixels.
  6183. */
  6184. size: number;
  6185. /**
  6186. * The format of the texture.
  6187. *
  6188. * RGBA, RGB.
  6189. */
  6190. format: number;
  6191. /**
  6192. * The type of the texture data.
  6193. *
  6194. * UNSIGNED_INT, FLOAT.
  6195. */
  6196. type: number;
  6197. /**
  6198. * Specifies whether the texture is in gamma space.
  6199. */
  6200. gammaSpace: boolean;
  6201. }
  6202. /**
  6203. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  6204. */
  6205. export class PanoramaToCubeMapTools {
  6206. private static FACE_FRONT;
  6207. private static FACE_BACK;
  6208. private static FACE_RIGHT;
  6209. private static FACE_LEFT;
  6210. private static FACE_DOWN;
  6211. private static FACE_UP;
  6212. /**
  6213. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  6214. *
  6215. * @param float32Array The source data.
  6216. * @param inputWidth The width of the input panorama.
  6217. * @param inputHeight The height of the input panorama.
  6218. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  6219. * @return The cubemap data
  6220. */
  6221. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  6222. private static CreateCubemapTexture;
  6223. private static CalcProjectionSpherical;
  6224. }
  6225. }
  6226. declare module BABYLON {
  6227. /**
  6228. * Helper class dealing with the extraction of spherical polynomial dataArray
  6229. * from a cube map.
  6230. */
  6231. export class CubeMapToSphericalPolynomialTools {
  6232. private static FileFaces;
  6233. /**
  6234. * Converts a texture to the according Spherical Polynomial data.
  6235. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6236. *
  6237. * @param texture The texture to extract the information from.
  6238. * @return The Spherical Polynomial data.
  6239. */
  6240. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6241. /**
  6242. * Converts a cubemap to the according Spherical Polynomial data.
  6243. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6244. *
  6245. * @param cubeInfo The Cube map to extract the information from.
  6246. * @return The Spherical Polynomial data.
  6247. */
  6248. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6249. }
  6250. }
  6251. declare module BABYLON {
  6252. /**
  6253. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6254. * during the life time of the application.
  6255. */
  6256. export class EngineStore {
  6257. /** Gets the list of created engines */
  6258. static Instances: Engine[];
  6259. /** @hidden */
  6260. static _LastCreatedScene: Nullable<Scene>;
  6261. /**
  6262. * Gets the latest created engine
  6263. */
  6264. static readonly LastCreatedEngine: Nullable<Engine>;
  6265. /**
  6266. * Gets the latest created scene
  6267. */
  6268. static readonly LastCreatedScene: Nullable<Scene>;
  6269. }
  6270. }
  6271. declare module BABYLON {
  6272. /**
  6273. * Define options used to create a render target texture
  6274. */
  6275. export class RenderTargetCreationOptions {
  6276. /**
  6277. * Specifies is mipmaps must be generated
  6278. */
  6279. generateMipMaps?: boolean;
  6280. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6281. generateDepthBuffer?: boolean;
  6282. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6283. generateStencilBuffer?: boolean;
  6284. /** Defines texture type (int by default) */
  6285. type?: number;
  6286. /** Defines sampling mode (trilinear by default) */
  6287. samplingMode?: number;
  6288. /** Defines format (RGBA by default) */
  6289. format?: number;
  6290. }
  6291. }
  6292. declare module BABYLON {
  6293. /**
  6294. * @hidden
  6295. **/
  6296. export class _AlphaState {
  6297. private _isAlphaBlendDirty;
  6298. private _isBlendFunctionParametersDirty;
  6299. private _isBlendEquationParametersDirty;
  6300. private _isBlendConstantsDirty;
  6301. private _alphaBlend;
  6302. private _blendFunctionParameters;
  6303. private _blendEquationParameters;
  6304. private _blendConstants;
  6305. /**
  6306. * Initializes the state.
  6307. */
  6308. constructor();
  6309. readonly isDirty: boolean;
  6310. alphaBlend: boolean;
  6311. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6312. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6313. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6314. reset(): void;
  6315. apply(gl: WebGLRenderingContext): void;
  6316. }
  6317. }
  6318. declare module BABYLON {
  6319. /**
  6320. * @hidden
  6321. **/
  6322. export class _DepthCullingState {
  6323. private _isDepthTestDirty;
  6324. private _isDepthMaskDirty;
  6325. private _isDepthFuncDirty;
  6326. private _isCullFaceDirty;
  6327. private _isCullDirty;
  6328. private _isZOffsetDirty;
  6329. private _isFrontFaceDirty;
  6330. private _depthTest;
  6331. private _depthMask;
  6332. private _depthFunc;
  6333. private _cull;
  6334. private _cullFace;
  6335. private _zOffset;
  6336. private _frontFace;
  6337. /**
  6338. * Initializes the state.
  6339. */
  6340. constructor();
  6341. readonly isDirty: boolean;
  6342. zOffset: number;
  6343. cullFace: Nullable<number>;
  6344. cull: Nullable<boolean>;
  6345. depthFunc: Nullable<number>;
  6346. depthMask: boolean;
  6347. depthTest: boolean;
  6348. frontFace: Nullable<number>;
  6349. reset(): void;
  6350. apply(gl: WebGLRenderingContext): void;
  6351. }
  6352. }
  6353. declare module BABYLON {
  6354. /**
  6355. * @hidden
  6356. **/
  6357. export class _StencilState {
  6358. /** 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 */
  6359. static readonly ALWAYS: number;
  6360. /** Passed to stencilOperation to specify that stencil value must be kept */
  6361. static readonly KEEP: number;
  6362. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6363. static readonly REPLACE: number;
  6364. private _isStencilTestDirty;
  6365. private _isStencilMaskDirty;
  6366. private _isStencilFuncDirty;
  6367. private _isStencilOpDirty;
  6368. private _stencilTest;
  6369. private _stencilMask;
  6370. private _stencilFunc;
  6371. private _stencilFuncRef;
  6372. private _stencilFuncMask;
  6373. private _stencilOpStencilFail;
  6374. private _stencilOpDepthFail;
  6375. private _stencilOpStencilDepthPass;
  6376. readonly isDirty: boolean;
  6377. stencilFunc: number;
  6378. stencilFuncRef: number;
  6379. stencilFuncMask: number;
  6380. stencilOpStencilFail: number;
  6381. stencilOpDepthFail: number;
  6382. stencilOpStencilDepthPass: number;
  6383. stencilMask: number;
  6384. stencilTest: boolean;
  6385. constructor();
  6386. reset(): void;
  6387. apply(gl: WebGLRenderingContext): void;
  6388. }
  6389. }
  6390. declare module BABYLON {
  6391. /**
  6392. * @hidden
  6393. **/
  6394. export class _TimeToken {
  6395. _startTimeQuery: Nullable<WebGLQuery>;
  6396. _endTimeQuery: Nullable<WebGLQuery>;
  6397. _timeElapsedQuery: Nullable<WebGLQuery>;
  6398. _timeElapsedQueryEnded: boolean;
  6399. }
  6400. }
  6401. declare module BABYLON {
  6402. /**
  6403. * Class used to store data associated with WebGL texture data for the engine
  6404. * This class should not be used directly
  6405. */
  6406. export class InternalTexture {
  6407. /** @hidden */
  6408. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6409. /**
  6410. * The source of the texture data is unknown
  6411. */
  6412. static DATASOURCE_UNKNOWN: number;
  6413. /**
  6414. * Texture data comes from an URL
  6415. */
  6416. static DATASOURCE_URL: number;
  6417. /**
  6418. * Texture data is only used for temporary storage
  6419. */
  6420. static DATASOURCE_TEMP: number;
  6421. /**
  6422. * Texture data comes from raw data (ArrayBuffer)
  6423. */
  6424. static DATASOURCE_RAW: number;
  6425. /**
  6426. * Texture content is dynamic (video or dynamic texture)
  6427. */
  6428. static DATASOURCE_DYNAMIC: number;
  6429. /**
  6430. * Texture content is generated by rendering to it
  6431. */
  6432. static DATASOURCE_RENDERTARGET: number;
  6433. /**
  6434. * Texture content is part of a multi render target process
  6435. */
  6436. static DATASOURCE_MULTIRENDERTARGET: number;
  6437. /**
  6438. * Texture data comes from a cube data file
  6439. */
  6440. static DATASOURCE_CUBE: number;
  6441. /**
  6442. * Texture data comes from a raw cube data
  6443. */
  6444. static DATASOURCE_CUBERAW: number;
  6445. /**
  6446. * Texture data come from a prefiltered cube data file
  6447. */
  6448. static DATASOURCE_CUBEPREFILTERED: number;
  6449. /**
  6450. * Texture content is raw 3D data
  6451. */
  6452. static DATASOURCE_RAW3D: number;
  6453. /**
  6454. * Texture content is a depth texture
  6455. */
  6456. static DATASOURCE_DEPTHTEXTURE: number;
  6457. /**
  6458. * Texture data comes from a raw cube data encoded with RGBD
  6459. */
  6460. static DATASOURCE_CUBERAW_RGBD: number;
  6461. /**
  6462. * Defines if the texture is ready
  6463. */
  6464. isReady: boolean;
  6465. /**
  6466. * Defines if the texture is a cube texture
  6467. */
  6468. isCube: boolean;
  6469. /**
  6470. * Defines if the texture contains 3D data
  6471. */
  6472. is3D: boolean;
  6473. /**
  6474. * Defines if the texture contains multiview data
  6475. */
  6476. isMultiview: boolean;
  6477. /**
  6478. * Gets the URL used to load this texture
  6479. */
  6480. url: string;
  6481. /**
  6482. * Gets the sampling mode of the texture
  6483. */
  6484. samplingMode: number;
  6485. /**
  6486. * Gets a boolean indicating if the texture needs mipmaps generation
  6487. */
  6488. generateMipMaps: boolean;
  6489. /**
  6490. * Gets the number of samples used by the texture (WebGL2+ only)
  6491. */
  6492. samples: number;
  6493. /**
  6494. * Gets the type of the texture (int, float...)
  6495. */
  6496. type: number;
  6497. /**
  6498. * Gets the format of the texture (RGB, RGBA...)
  6499. */
  6500. format: number;
  6501. /**
  6502. * Observable called when the texture is loaded
  6503. */
  6504. onLoadedObservable: Observable<InternalTexture>;
  6505. /**
  6506. * Gets the width of the texture
  6507. */
  6508. width: number;
  6509. /**
  6510. * Gets the height of the texture
  6511. */
  6512. height: number;
  6513. /**
  6514. * Gets the depth of the texture
  6515. */
  6516. depth: number;
  6517. /**
  6518. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6519. */
  6520. baseWidth: number;
  6521. /**
  6522. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6523. */
  6524. baseHeight: number;
  6525. /**
  6526. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6527. */
  6528. baseDepth: number;
  6529. /**
  6530. * Gets a boolean indicating if the texture is inverted on Y axis
  6531. */
  6532. invertY: boolean;
  6533. /** @hidden */
  6534. _invertVScale: boolean;
  6535. /** @hidden */
  6536. _associatedChannel: number;
  6537. /** @hidden */
  6538. _dataSource: number;
  6539. /** @hidden */
  6540. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6541. /** @hidden */
  6542. _bufferView: Nullable<ArrayBufferView>;
  6543. /** @hidden */
  6544. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6545. /** @hidden */
  6546. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6547. /** @hidden */
  6548. _size: number;
  6549. /** @hidden */
  6550. _extension: string;
  6551. /** @hidden */
  6552. _files: Nullable<string[]>;
  6553. /** @hidden */
  6554. _workingCanvas: Nullable<HTMLCanvasElement>;
  6555. /** @hidden */
  6556. _workingContext: Nullable<CanvasRenderingContext2D>;
  6557. /** @hidden */
  6558. _framebuffer: Nullable<WebGLFramebuffer>;
  6559. /** @hidden */
  6560. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6561. /** @hidden */
  6562. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6563. /** @hidden */
  6564. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6565. /** @hidden */
  6566. _attachments: Nullable<number[]>;
  6567. /** @hidden */
  6568. _cachedCoordinatesMode: Nullable<number>;
  6569. /** @hidden */
  6570. _cachedWrapU: Nullable<number>;
  6571. /** @hidden */
  6572. _cachedWrapV: Nullable<number>;
  6573. /** @hidden */
  6574. _cachedWrapR: Nullable<number>;
  6575. /** @hidden */
  6576. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6577. /** @hidden */
  6578. _isDisabled: boolean;
  6579. /** @hidden */
  6580. _compression: Nullable<string>;
  6581. /** @hidden */
  6582. _generateStencilBuffer: boolean;
  6583. /** @hidden */
  6584. _generateDepthBuffer: boolean;
  6585. /** @hidden */
  6586. _comparisonFunction: number;
  6587. /** @hidden */
  6588. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6589. /** @hidden */
  6590. _lodGenerationScale: number;
  6591. /** @hidden */
  6592. _lodGenerationOffset: number;
  6593. /** @hidden */
  6594. _colorTextureArray: Nullable<WebGLTexture>;
  6595. /** @hidden */
  6596. _depthStencilTextureArray: Nullable<WebGLTexture>;
  6597. /** @hidden */
  6598. _lodTextureHigh: Nullable<BaseTexture>;
  6599. /** @hidden */
  6600. _lodTextureMid: Nullable<BaseTexture>;
  6601. /** @hidden */
  6602. _lodTextureLow: Nullable<BaseTexture>;
  6603. /** @hidden */
  6604. _isRGBD: boolean;
  6605. /** @hidden */
  6606. _linearSpecularLOD: boolean;
  6607. /** @hidden */
  6608. _irradianceTexture: Nullable<BaseTexture>;
  6609. /** @hidden */
  6610. _webGLTexture: Nullable<WebGLTexture>;
  6611. /** @hidden */
  6612. _references: number;
  6613. private _engine;
  6614. /**
  6615. * Gets the Engine the texture belongs to.
  6616. * @returns The babylon engine
  6617. */
  6618. getEngine(): Engine;
  6619. /**
  6620. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6621. */
  6622. readonly dataSource: number;
  6623. /**
  6624. * Creates a new InternalTexture
  6625. * @param engine defines the engine to use
  6626. * @param dataSource defines the type of data that will be used
  6627. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6628. */
  6629. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6630. /**
  6631. * Increments the number of references (ie. the number of Texture that point to it)
  6632. */
  6633. incrementReferences(): void;
  6634. /**
  6635. * Change the size of the texture (not the size of the content)
  6636. * @param width defines the new width
  6637. * @param height defines the new height
  6638. * @param depth defines the new depth (1 by default)
  6639. */
  6640. updateSize(width: int, height: int, depth?: int): void;
  6641. /** @hidden */
  6642. _rebuild(): void;
  6643. /** @hidden */
  6644. _swapAndDie(target: InternalTexture): void;
  6645. /**
  6646. * Dispose the current allocated resources
  6647. */
  6648. dispose(): void;
  6649. }
  6650. }
  6651. declare module BABYLON {
  6652. /**
  6653. * This represents the main contract an easing function should follow.
  6654. * Easing functions are used throughout the animation system.
  6655. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6656. */
  6657. export interface IEasingFunction {
  6658. /**
  6659. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6660. * of the easing function.
  6661. * The link below provides some of the most common examples of easing functions.
  6662. * @see https://easings.net/
  6663. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6664. * @returns the corresponding value on the curve defined by the easing function
  6665. */
  6666. ease(gradient: number): number;
  6667. }
  6668. /**
  6669. * Base class used for every default easing function.
  6670. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6671. */
  6672. export class EasingFunction implements IEasingFunction {
  6673. /**
  6674. * Interpolation follows the mathematical formula associated with the easing function.
  6675. */
  6676. static readonly EASINGMODE_EASEIN: number;
  6677. /**
  6678. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6679. */
  6680. static readonly EASINGMODE_EASEOUT: number;
  6681. /**
  6682. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6683. */
  6684. static readonly EASINGMODE_EASEINOUT: number;
  6685. private _easingMode;
  6686. /**
  6687. * Sets the easing mode of the current function.
  6688. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6689. */
  6690. setEasingMode(easingMode: number): void;
  6691. /**
  6692. * Gets the current easing mode.
  6693. * @returns the easing mode
  6694. */
  6695. getEasingMode(): number;
  6696. /**
  6697. * @hidden
  6698. */
  6699. easeInCore(gradient: number): number;
  6700. /**
  6701. * Given an input gradient between 0 and 1, this returns the corresponding value
  6702. * of the easing function.
  6703. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6704. * @returns the corresponding value on the curve defined by the easing function
  6705. */
  6706. ease(gradient: number): number;
  6707. }
  6708. /**
  6709. * Easing function with a circle shape (see link below).
  6710. * @see https://easings.net/#easeInCirc
  6711. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6712. */
  6713. export class CircleEase extends EasingFunction implements IEasingFunction {
  6714. /** @hidden */
  6715. easeInCore(gradient: number): number;
  6716. }
  6717. /**
  6718. * Easing function with a ease back shape (see link below).
  6719. * @see https://easings.net/#easeInBack
  6720. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6721. */
  6722. export class BackEase extends EasingFunction implements IEasingFunction {
  6723. /** Defines the amplitude of the function */
  6724. amplitude: number;
  6725. /**
  6726. * Instantiates a back ease easing
  6727. * @see https://easings.net/#easeInBack
  6728. * @param amplitude Defines the amplitude of the function
  6729. */
  6730. constructor(
  6731. /** Defines the amplitude of the function */
  6732. amplitude?: number);
  6733. /** @hidden */
  6734. easeInCore(gradient: number): number;
  6735. }
  6736. /**
  6737. * Easing function with a bouncing shape (see link below).
  6738. * @see https://easings.net/#easeInBounce
  6739. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6740. */
  6741. export class BounceEase extends EasingFunction implements IEasingFunction {
  6742. /** Defines the number of bounces */
  6743. bounces: number;
  6744. /** Defines the amplitude of the bounce */
  6745. bounciness: number;
  6746. /**
  6747. * Instantiates a bounce easing
  6748. * @see https://easings.net/#easeInBounce
  6749. * @param bounces Defines the number of bounces
  6750. * @param bounciness Defines the amplitude of the bounce
  6751. */
  6752. constructor(
  6753. /** Defines the number of bounces */
  6754. bounces?: number,
  6755. /** Defines the amplitude of the bounce */
  6756. bounciness?: number);
  6757. /** @hidden */
  6758. easeInCore(gradient: number): number;
  6759. }
  6760. /**
  6761. * Easing function with a power of 3 shape (see link below).
  6762. * @see https://easings.net/#easeInCubic
  6763. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6764. */
  6765. export class CubicEase extends EasingFunction implements IEasingFunction {
  6766. /** @hidden */
  6767. easeInCore(gradient: number): number;
  6768. }
  6769. /**
  6770. * Easing function with an elastic shape (see link below).
  6771. * @see https://easings.net/#easeInElastic
  6772. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6773. */
  6774. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6775. /** Defines the number of oscillations*/
  6776. oscillations: number;
  6777. /** Defines the amplitude of the oscillations*/
  6778. springiness: number;
  6779. /**
  6780. * Instantiates an elastic easing function
  6781. * @see https://easings.net/#easeInElastic
  6782. * @param oscillations Defines the number of oscillations
  6783. * @param springiness Defines the amplitude of the oscillations
  6784. */
  6785. constructor(
  6786. /** Defines the number of oscillations*/
  6787. oscillations?: number,
  6788. /** Defines the amplitude of the oscillations*/
  6789. springiness?: number);
  6790. /** @hidden */
  6791. easeInCore(gradient: number): number;
  6792. }
  6793. /**
  6794. * Easing function with an exponential shape (see link below).
  6795. * @see https://easings.net/#easeInExpo
  6796. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6797. */
  6798. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6799. /** Defines the exponent of the function */
  6800. exponent: number;
  6801. /**
  6802. * Instantiates an exponential easing function
  6803. * @see https://easings.net/#easeInExpo
  6804. * @param exponent Defines the exponent of the function
  6805. */
  6806. constructor(
  6807. /** Defines the exponent of the function */
  6808. exponent?: number);
  6809. /** @hidden */
  6810. easeInCore(gradient: number): number;
  6811. }
  6812. /**
  6813. * Easing function with a power shape (see link below).
  6814. * @see https://easings.net/#easeInQuad
  6815. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6816. */
  6817. export class PowerEase extends EasingFunction implements IEasingFunction {
  6818. /** Defines the power of the function */
  6819. power: number;
  6820. /**
  6821. * Instantiates an power base easing function
  6822. * @see https://easings.net/#easeInQuad
  6823. * @param power Defines the power of the function
  6824. */
  6825. constructor(
  6826. /** Defines the power of the function */
  6827. power?: number);
  6828. /** @hidden */
  6829. easeInCore(gradient: number): number;
  6830. }
  6831. /**
  6832. * Easing function with a power of 2 shape (see link below).
  6833. * @see https://easings.net/#easeInQuad
  6834. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6835. */
  6836. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6837. /** @hidden */
  6838. easeInCore(gradient: number): number;
  6839. }
  6840. /**
  6841. * Easing function with a power of 4 shape (see link below).
  6842. * @see https://easings.net/#easeInQuart
  6843. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6844. */
  6845. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6846. /** @hidden */
  6847. easeInCore(gradient: number): number;
  6848. }
  6849. /**
  6850. * Easing function with a power of 5 shape (see link below).
  6851. * @see https://easings.net/#easeInQuint
  6852. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6853. */
  6854. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6855. /** @hidden */
  6856. easeInCore(gradient: number): number;
  6857. }
  6858. /**
  6859. * Easing function with a sin shape (see link below).
  6860. * @see https://easings.net/#easeInSine
  6861. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6862. */
  6863. export class SineEase extends EasingFunction implements IEasingFunction {
  6864. /** @hidden */
  6865. easeInCore(gradient: number): number;
  6866. }
  6867. /**
  6868. * Easing function with a bezier shape (see link below).
  6869. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6870. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6871. */
  6872. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6873. /** Defines the x component of the start tangent in the bezier curve */
  6874. x1: number;
  6875. /** Defines the y component of the start tangent in the bezier curve */
  6876. y1: number;
  6877. /** Defines the x component of the end tangent in the bezier curve */
  6878. x2: number;
  6879. /** Defines the y component of the end tangent in the bezier curve */
  6880. y2: number;
  6881. /**
  6882. * Instantiates a bezier function
  6883. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6884. * @param x1 Defines the x component of the start tangent in the bezier curve
  6885. * @param y1 Defines the y component of the start tangent in the bezier curve
  6886. * @param x2 Defines the x component of the end tangent in the bezier curve
  6887. * @param y2 Defines the y component of the end tangent in the bezier curve
  6888. */
  6889. constructor(
  6890. /** Defines the x component of the start tangent in the bezier curve */
  6891. x1?: number,
  6892. /** Defines the y component of the start tangent in the bezier curve */
  6893. y1?: number,
  6894. /** Defines the x component of the end tangent in the bezier curve */
  6895. x2?: number,
  6896. /** Defines the y component of the end tangent in the bezier curve */
  6897. y2?: number);
  6898. /** @hidden */
  6899. easeInCore(gradient: number): number;
  6900. }
  6901. }
  6902. declare module BABYLON {
  6903. /**
  6904. * Defines an interface which represents an animation key frame
  6905. */
  6906. export interface IAnimationKey {
  6907. /**
  6908. * Frame of the key frame
  6909. */
  6910. frame: number;
  6911. /**
  6912. * Value at the specifies key frame
  6913. */
  6914. value: any;
  6915. /**
  6916. * The input tangent for the cubic hermite spline
  6917. */
  6918. inTangent?: any;
  6919. /**
  6920. * The output tangent for the cubic hermite spline
  6921. */
  6922. outTangent?: any;
  6923. /**
  6924. * The animation interpolation type
  6925. */
  6926. interpolation?: AnimationKeyInterpolation;
  6927. }
  6928. /**
  6929. * Enum for the animation key frame interpolation type
  6930. */
  6931. export enum AnimationKeyInterpolation {
  6932. /**
  6933. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6934. */
  6935. STEP = 1
  6936. }
  6937. }
  6938. declare module BABYLON {
  6939. /**
  6940. * Represents the range of an animation
  6941. */
  6942. export class AnimationRange {
  6943. /**The name of the animation range**/
  6944. name: string;
  6945. /**The starting frame of the animation */
  6946. from: number;
  6947. /**The ending frame of the animation*/
  6948. to: number;
  6949. /**
  6950. * Initializes the range of an animation
  6951. * @param name The name of the animation range
  6952. * @param from The starting frame of the animation
  6953. * @param to The ending frame of the animation
  6954. */
  6955. constructor(
  6956. /**The name of the animation range**/
  6957. name: string,
  6958. /**The starting frame of the animation */
  6959. from: number,
  6960. /**The ending frame of the animation*/
  6961. to: number);
  6962. /**
  6963. * Makes a copy of the animation range
  6964. * @returns A copy of the animation range
  6965. */
  6966. clone(): AnimationRange;
  6967. }
  6968. }
  6969. declare module BABYLON {
  6970. /**
  6971. * Composed of a frame, and an action function
  6972. */
  6973. export class AnimationEvent {
  6974. /** The frame for which the event is triggered **/
  6975. frame: number;
  6976. /** The event to perform when triggered **/
  6977. action: (currentFrame: number) => void;
  6978. /** Specifies if the event should be triggered only once**/
  6979. onlyOnce?: boolean | undefined;
  6980. /**
  6981. * Specifies if the animation event is done
  6982. */
  6983. isDone: boolean;
  6984. /**
  6985. * Initializes the animation event
  6986. * @param frame The frame for which the event is triggered
  6987. * @param action The event to perform when triggered
  6988. * @param onlyOnce Specifies if the event should be triggered only once
  6989. */
  6990. constructor(
  6991. /** The frame for which the event is triggered **/
  6992. frame: number,
  6993. /** The event to perform when triggered **/
  6994. action: (currentFrame: number) => void,
  6995. /** Specifies if the event should be triggered only once**/
  6996. onlyOnce?: boolean | undefined);
  6997. /** @hidden */
  6998. _clone(): AnimationEvent;
  6999. }
  7000. }
  7001. declare module BABYLON {
  7002. /**
  7003. * Interface used to define a behavior
  7004. */
  7005. export interface Behavior<T> {
  7006. /** gets or sets behavior's name */
  7007. name: string;
  7008. /**
  7009. * Function called when the behavior needs to be initialized (after attaching it to a target)
  7010. */
  7011. init(): void;
  7012. /**
  7013. * Called when the behavior is attached to a target
  7014. * @param target defines the target where the behavior is attached to
  7015. */
  7016. attach(target: T): void;
  7017. /**
  7018. * Called when the behavior is detached from its target
  7019. */
  7020. detach(): void;
  7021. }
  7022. /**
  7023. * Interface implemented by classes supporting behaviors
  7024. */
  7025. export interface IBehaviorAware<T> {
  7026. /**
  7027. * Attach a behavior
  7028. * @param behavior defines the behavior to attach
  7029. * @returns the current host
  7030. */
  7031. addBehavior(behavior: Behavior<T>): T;
  7032. /**
  7033. * Remove a behavior from the current object
  7034. * @param behavior defines the behavior to detach
  7035. * @returns the current host
  7036. */
  7037. removeBehavior(behavior: Behavior<T>): T;
  7038. /**
  7039. * Gets a behavior using its name to search
  7040. * @param name defines the name to search
  7041. * @returns the behavior or null if not found
  7042. */
  7043. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  7044. }
  7045. }
  7046. declare module BABYLON {
  7047. /**
  7048. * @hidden
  7049. */
  7050. export class IntersectionInfo {
  7051. bu: Nullable<number>;
  7052. bv: Nullable<number>;
  7053. distance: number;
  7054. faceId: number;
  7055. subMeshId: number;
  7056. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  7057. }
  7058. }
  7059. declare module BABYLON {
  7060. /**
  7061. * Class used to store bounding sphere information
  7062. */
  7063. export class BoundingSphere {
  7064. /**
  7065. * Gets the center of the bounding sphere in local space
  7066. */
  7067. readonly center: Vector3;
  7068. /**
  7069. * Radius of the bounding sphere in local space
  7070. */
  7071. radius: number;
  7072. /**
  7073. * Gets the center of the bounding sphere in world space
  7074. */
  7075. readonly centerWorld: Vector3;
  7076. /**
  7077. * Radius of the bounding sphere in world space
  7078. */
  7079. radiusWorld: number;
  7080. /**
  7081. * Gets the minimum vector in local space
  7082. */
  7083. readonly minimum: Vector3;
  7084. /**
  7085. * Gets the maximum vector in local space
  7086. */
  7087. readonly maximum: Vector3;
  7088. private _worldMatrix;
  7089. private static readonly TmpVector3;
  7090. /**
  7091. * Creates a new bounding sphere
  7092. * @param min defines the minimum vector (in local space)
  7093. * @param max defines the maximum vector (in local space)
  7094. * @param worldMatrix defines the new world matrix
  7095. */
  7096. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7097. /**
  7098. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7099. * @param min defines the new minimum vector (in local space)
  7100. * @param max defines the new maximum vector (in local space)
  7101. * @param worldMatrix defines the new world matrix
  7102. */
  7103. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7104. /**
  7105. * Scale the current bounding sphere by applying a scale factor
  7106. * @param factor defines the scale factor to apply
  7107. * @returns the current bounding box
  7108. */
  7109. scale(factor: number): BoundingSphere;
  7110. /**
  7111. * Gets the world matrix of the bounding box
  7112. * @returns a matrix
  7113. */
  7114. getWorldMatrix(): DeepImmutable<Matrix>;
  7115. /** @hidden */
  7116. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7117. /**
  7118. * Tests if the bounding sphere is intersecting the frustum planes
  7119. * @param frustumPlanes defines the frustum planes to test
  7120. * @returns true if there is an intersection
  7121. */
  7122. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7123. /**
  7124. * Tests if the bounding sphere center is in between the frustum planes.
  7125. * Used for optimistic fast inclusion.
  7126. * @param frustumPlanes defines the frustum planes to test
  7127. * @returns true if the sphere center is in between the frustum planes
  7128. */
  7129. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7130. /**
  7131. * Tests if a point is inside the bounding sphere
  7132. * @param point defines the point to test
  7133. * @returns true if the point is inside the bounding sphere
  7134. */
  7135. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7136. /**
  7137. * Checks if two sphere intersct
  7138. * @param sphere0 sphere 0
  7139. * @param sphere1 sphere 1
  7140. * @returns true if the speres intersect
  7141. */
  7142. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7143. }
  7144. }
  7145. declare module BABYLON {
  7146. /**
  7147. * Class used to store bounding box information
  7148. */
  7149. export class BoundingBox implements ICullable {
  7150. /**
  7151. * Gets the 8 vectors representing the bounding box in local space
  7152. */
  7153. readonly vectors: Vector3[];
  7154. /**
  7155. * Gets the center of the bounding box in local space
  7156. */
  7157. readonly center: Vector3;
  7158. /**
  7159. * Gets the center of the bounding box in world space
  7160. */
  7161. readonly centerWorld: Vector3;
  7162. /**
  7163. * Gets the extend size in local space
  7164. */
  7165. readonly extendSize: Vector3;
  7166. /**
  7167. * Gets the extend size in world space
  7168. */
  7169. readonly extendSizeWorld: Vector3;
  7170. /**
  7171. * Gets the OBB (object bounding box) directions
  7172. */
  7173. readonly directions: Vector3[];
  7174. /**
  7175. * Gets the 8 vectors representing the bounding box in world space
  7176. */
  7177. readonly vectorsWorld: Vector3[];
  7178. /**
  7179. * Gets the minimum vector in world space
  7180. */
  7181. readonly minimumWorld: Vector3;
  7182. /**
  7183. * Gets the maximum vector in world space
  7184. */
  7185. readonly maximumWorld: Vector3;
  7186. /**
  7187. * Gets the minimum vector in local space
  7188. */
  7189. readonly minimum: Vector3;
  7190. /**
  7191. * Gets the maximum vector in local space
  7192. */
  7193. readonly maximum: Vector3;
  7194. private _worldMatrix;
  7195. private static readonly TmpVector3;
  7196. /**
  7197. * @hidden
  7198. */
  7199. _tag: number;
  7200. /**
  7201. * Creates a new bounding box
  7202. * @param min defines the minimum vector (in local space)
  7203. * @param max defines the maximum vector (in local space)
  7204. * @param worldMatrix defines the new world matrix
  7205. */
  7206. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7207. /**
  7208. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7209. * @param min defines the new minimum vector (in local space)
  7210. * @param max defines the new maximum vector (in local space)
  7211. * @param worldMatrix defines the new world matrix
  7212. */
  7213. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7214. /**
  7215. * Scale the current bounding box by applying a scale factor
  7216. * @param factor defines the scale factor to apply
  7217. * @returns the current bounding box
  7218. */
  7219. scale(factor: number): BoundingBox;
  7220. /**
  7221. * Gets the world matrix of the bounding box
  7222. * @returns a matrix
  7223. */
  7224. getWorldMatrix(): DeepImmutable<Matrix>;
  7225. /** @hidden */
  7226. _update(world: DeepImmutable<Matrix>): void;
  7227. /**
  7228. * Tests if the bounding box is intersecting the frustum planes
  7229. * @param frustumPlanes defines the frustum planes to test
  7230. * @returns true if there is an intersection
  7231. */
  7232. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7233. /**
  7234. * Tests if the bounding box is entirely inside the frustum planes
  7235. * @param frustumPlanes defines the frustum planes to test
  7236. * @returns true if there is an inclusion
  7237. */
  7238. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7239. /**
  7240. * Tests if a point is inside the bounding box
  7241. * @param point defines the point to test
  7242. * @returns true if the point is inside the bounding box
  7243. */
  7244. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7245. /**
  7246. * Tests if the bounding box intersects with a bounding sphere
  7247. * @param sphere defines the sphere to test
  7248. * @returns true if there is an intersection
  7249. */
  7250. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7251. /**
  7252. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7253. * @param min defines the min vector to use
  7254. * @param max defines the max vector to use
  7255. * @returns true if there is an intersection
  7256. */
  7257. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7258. /**
  7259. * Tests if two bounding boxes are intersections
  7260. * @param box0 defines the first box to test
  7261. * @param box1 defines the second box to test
  7262. * @returns true if there is an intersection
  7263. */
  7264. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7265. /**
  7266. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7267. * @param minPoint defines the minimum vector of the bounding box
  7268. * @param maxPoint defines the maximum vector of the bounding box
  7269. * @param sphereCenter defines the sphere center
  7270. * @param sphereRadius defines the sphere radius
  7271. * @returns true if there is an intersection
  7272. */
  7273. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7274. /**
  7275. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7276. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7277. * @param frustumPlanes defines the frustum planes to test
  7278. * @return true if there is an inclusion
  7279. */
  7280. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7281. /**
  7282. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7283. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7284. * @param frustumPlanes defines the frustum planes to test
  7285. * @return true if there is an intersection
  7286. */
  7287. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7288. }
  7289. }
  7290. declare module BABYLON {
  7291. /** @hidden */
  7292. export class Collider {
  7293. /** Define if a collision was found */
  7294. collisionFound: boolean;
  7295. /**
  7296. * Define last intersection point in local space
  7297. */
  7298. intersectionPoint: Vector3;
  7299. /**
  7300. * Define last collided mesh
  7301. */
  7302. collidedMesh: Nullable<AbstractMesh>;
  7303. private _collisionPoint;
  7304. private _planeIntersectionPoint;
  7305. private _tempVector;
  7306. private _tempVector2;
  7307. private _tempVector3;
  7308. private _tempVector4;
  7309. private _edge;
  7310. private _baseToVertex;
  7311. private _destinationPoint;
  7312. private _slidePlaneNormal;
  7313. private _displacementVector;
  7314. /** @hidden */
  7315. _radius: Vector3;
  7316. /** @hidden */
  7317. _retry: number;
  7318. private _velocity;
  7319. private _basePoint;
  7320. private _epsilon;
  7321. /** @hidden */
  7322. _velocityWorldLength: number;
  7323. /** @hidden */
  7324. _basePointWorld: Vector3;
  7325. private _velocityWorld;
  7326. private _normalizedVelocity;
  7327. /** @hidden */
  7328. _initialVelocity: Vector3;
  7329. /** @hidden */
  7330. _initialPosition: Vector3;
  7331. private _nearestDistance;
  7332. private _collisionMask;
  7333. collisionMask: number;
  7334. /**
  7335. * Gets the plane normal used to compute the sliding response (in local space)
  7336. */
  7337. readonly slidePlaneNormal: Vector3;
  7338. /** @hidden */
  7339. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7340. /** @hidden */
  7341. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7342. /** @hidden */
  7343. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7344. /** @hidden */
  7345. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7346. /** @hidden */
  7347. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7348. /** @hidden */
  7349. _getResponse(pos: Vector3, vel: Vector3): void;
  7350. }
  7351. }
  7352. declare module BABYLON {
  7353. /**
  7354. * Interface for cullable objects
  7355. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7356. */
  7357. export interface ICullable {
  7358. /**
  7359. * Checks if the object or part of the object is in the frustum
  7360. * @param frustumPlanes Camera near/planes
  7361. * @returns true if the object is in frustum otherwise false
  7362. */
  7363. isInFrustum(frustumPlanes: Plane[]): boolean;
  7364. /**
  7365. * Checks if a cullable object (mesh...) is in the camera frustum
  7366. * Unlike isInFrustum this cheks the full bounding box
  7367. * @param frustumPlanes Camera near/planes
  7368. * @returns true if the object is in frustum otherwise false
  7369. */
  7370. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7371. }
  7372. /**
  7373. * Info for a bounding data of a mesh
  7374. */
  7375. export class BoundingInfo implements ICullable {
  7376. /**
  7377. * Bounding box for the mesh
  7378. */
  7379. readonly boundingBox: BoundingBox;
  7380. /**
  7381. * Bounding sphere for the mesh
  7382. */
  7383. readonly boundingSphere: BoundingSphere;
  7384. private _isLocked;
  7385. private static readonly TmpVector3;
  7386. /**
  7387. * Constructs bounding info
  7388. * @param minimum min vector of the bounding box/sphere
  7389. * @param maximum max vector of the bounding box/sphere
  7390. * @param worldMatrix defines the new world matrix
  7391. */
  7392. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7393. /**
  7394. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7395. * @param min defines the new minimum vector (in local space)
  7396. * @param max defines the new maximum vector (in local space)
  7397. * @param worldMatrix defines the new world matrix
  7398. */
  7399. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7400. /**
  7401. * min vector of the bounding box/sphere
  7402. */
  7403. readonly minimum: Vector3;
  7404. /**
  7405. * max vector of the bounding box/sphere
  7406. */
  7407. readonly maximum: Vector3;
  7408. /**
  7409. * If the info is locked and won't be updated to avoid perf overhead
  7410. */
  7411. isLocked: boolean;
  7412. /**
  7413. * Updates the bounding sphere and box
  7414. * @param world world matrix to be used to update
  7415. */
  7416. update(world: DeepImmutable<Matrix>): void;
  7417. /**
  7418. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7419. * @param center New center of the bounding info
  7420. * @param extend New extend of the bounding info
  7421. * @returns the current bounding info
  7422. */
  7423. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7424. /**
  7425. * Scale the current bounding info by applying a scale factor
  7426. * @param factor defines the scale factor to apply
  7427. * @returns the current bounding info
  7428. */
  7429. scale(factor: number): BoundingInfo;
  7430. /**
  7431. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7432. * @param frustumPlanes defines the frustum to test
  7433. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7434. * @returns true if the bounding info is in the frustum planes
  7435. */
  7436. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7437. /**
  7438. * Gets the world distance between the min and max points of the bounding box
  7439. */
  7440. readonly diagonalLength: number;
  7441. /**
  7442. * Checks if a cullable object (mesh...) is in the camera frustum
  7443. * Unlike isInFrustum this cheks the full bounding box
  7444. * @param frustumPlanes Camera near/planes
  7445. * @returns true if the object is in frustum otherwise false
  7446. */
  7447. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7448. /** @hidden */
  7449. _checkCollision(collider: Collider): boolean;
  7450. /**
  7451. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7452. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7453. * @param point the point to check intersection with
  7454. * @returns if the point intersects
  7455. */
  7456. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7457. /**
  7458. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7459. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7460. * @param boundingInfo the bounding info to check intersection with
  7461. * @param precise if the intersection should be done using OBB
  7462. * @returns if the bounding info intersects
  7463. */
  7464. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7465. }
  7466. }
  7467. declare module BABYLON {
  7468. /**
  7469. * Defines an array and its length.
  7470. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7471. */
  7472. export interface ISmartArrayLike<T> {
  7473. /**
  7474. * The data of the array.
  7475. */
  7476. data: Array<T>;
  7477. /**
  7478. * The active length of the array.
  7479. */
  7480. length: number;
  7481. }
  7482. /**
  7483. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7484. */
  7485. export class SmartArray<T> implements ISmartArrayLike<T> {
  7486. /**
  7487. * The full set of data from the array.
  7488. */
  7489. data: Array<T>;
  7490. /**
  7491. * The active length of the array.
  7492. */
  7493. length: number;
  7494. protected _id: number;
  7495. /**
  7496. * Instantiates a Smart Array.
  7497. * @param capacity defines the default capacity of the array.
  7498. */
  7499. constructor(capacity: number);
  7500. /**
  7501. * Pushes a value at the end of the active data.
  7502. * @param value defines the object to push in the array.
  7503. */
  7504. push(value: T): void;
  7505. /**
  7506. * Iterates over the active data and apply the lambda to them.
  7507. * @param func defines the action to apply on each value.
  7508. */
  7509. forEach(func: (content: T) => void): void;
  7510. /**
  7511. * Sorts the full sets of data.
  7512. * @param compareFn defines the comparison function to apply.
  7513. */
  7514. sort(compareFn: (a: T, b: T) => number): void;
  7515. /**
  7516. * Resets the active data to an empty array.
  7517. */
  7518. reset(): void;
  7519. /**
  7520. * Releases all the data from the array as well as the array.
  7521. */
  7522. dispose(): void;
  7523. /**
  7524. * Concats the active data with a given array.
  7525. * @param array defines the data to concatenate with.
  7526. */
  7527. concat(array: any): void;
  7528. /**
  7529. * Returns the position of a value in the active data.
  7530. * @param value defines the value to find the index for
  7531. * @returns the index if found in the active data otherwise -1
  7532. */
  7533. indexOf(value: T): number;
  7534. /**
  7535. * Returns whether an element is part of the active data.
  7536. * @param value defines the value to look for
  7537. * @returns true if found in the active data otherwise false
  7538. */
  7539. contains(value: T): boolean;
  7540. private static _GlobalId;
  7541. }
  7542. /**
  7543. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7544. * The data in this array can only be present once
  7545. */
  7546. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7547. private _duplicateId;
  7548. /**
  7549. * Pushes a value at the end of the active data.
  7550. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7551. * @param value defines the object to push in the array.
  7552. */
  7553. push(value: T): void;
  7554. /**
  7555. * Pushes a value at the end of the active data.
  7556. * If the data is already present, it won t be added again
  7557. * @param value defines the object to push in the array.
  7558. * @returns true if added false if it was already present
  7559. */
  7560. pushNoDuplicate(value: T): boolean;
  7561. /**
  7562. * Resets the active data to an empty array.
  7563. */
  7564. reset(): void;
  7565. /**
  7566. * Concats the active data with a given array.
  7567. * This ensures no dupplicate will be present in the result.
  7568. * @param array defines the data to concatenate with.
  7569. */
  7570. concatWithNoDuplicate(array: any): void;
  7571. }
  7572. }
  7573. declare module BABYLON {
  7574. /**
  7575. * Enum that determines the text-wrapping mode to use.
  7576. */
  7577. export enum InspectableType {
  7578. /**
  7579. * Checkbox for booleans
  7580. */
  7581. Checkbox = 0,
  7582. /**
  7583. * Sliders for numbers
  7584. */
  7585. Slider = 1,
  7586. /**
  7587. * Vector3
  7588. */
  7589. Vector3 = 2,
  7590. /**
  7591. * Quaternions
  7592. */
  7593. Quaternion = 3,
  7594. /**
  7595. * Color3
  7596. */
  7597. Color3 = 4
  7598. }
  7599. /**
  7600. * Interface used to define custom inspectable properties.
  7601. * This interface is used by the inspector to display custom property grids
  7602. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7603. */
  7604. export interface IInspectable {
  7605. /**
  7606. * Gets the label to display
  7607. */
  7608. label: string;
  7609. /**
  7610. * Gets the name of the property to edit
  7611. */
  7612. propertyName: string;
  7613. /**
  7614. * Gets the type of the editor to use
  7615. */
  7616. type: InspectableType;
  7617. /**
  7618. * Gets the minimum value of the property when using in "slider" mode
  7619. */
  7620. min?: number;
  7621. /**
  7622. * Gets the maximum value of the property when using in "slider" mode
  7623. */
  7624. max?: number;
  7625. /**
  7626. * Gets the setp to use when using in "slider" mode
  7627. */
  7628. step?: number;
  7629. }
  7630. }
  7631. declare module BABYLON {
  7632. /**
  7633. * This represents the required contract to create a new type of texture loader.
  7634. */
  7635. export interface IInternalTextureLoader {
  7636. /**
  7637. * Defines wether the loader supports cascade loading the different faces.
  7638. */
  7639. supportCascades: boolean;
  7640. /**
  7641. * This returns if the loader support the current file information.
  7642. * @param extension defines the file extension of the file being loaded
  7643. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7644. * @param fallback defines the fallback internal texture if any
  7645. * @param isBase64 defines whether the texture is encoded as a base64
  7646. * @param isBuffer defines whether the texture data are stored as a buffer
  7647. * @returns true if the loader can load the specified file
  7648. */
  7649. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7650. /**
  7651. * Transform the url before loading if required.
  7652. * @param rootUrl the url of the texture
  7653. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7654. * @returns the transformed texture
  7655. */
  7656. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7657. /**
  7658. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7659. * @param rootUrl the url of the texture
  7660. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7661. * @returns the fallback texture
  7662. */
  7663. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7664. /**
  7665. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7666. * @param data contains the texture data
  7667. * @param texture defines the BabylonJS internal texture
  7668. * @param createPolynomials will be true if polynomials have been requested
  7669. * @param onLoad defines the callback to trigger once the texture is ready
  7670. * @param onError defines the callback to trigger in case of error
  7671. */
  7672. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7673. /**
  7674. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7675. * @param data contains the texture data
  7676. * @param texture defines the BabylonJS internal texture
  7677. * @param callback defines the method to call once ready to upload
  7678. */
  7679. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7680. }
  7681. }
  7682. declare module BABYLON {
  7683. interface Engine {
  7684. /**
  7685. * Creates a depth stencil cube texture.
  7686. * This is only available in WebGL 2.
  7687. * @param size The size of face edge in the cube texture.
  7688. * @param options The options defining the cube texture.
  7689. * @returns The cube texture
  7690. */
  7691. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7692. /**
  7693. * Creates a cube texture
  7694. * @param rootUrl defines the url where the files to load is located
  7695. * @param scene defines the current scene
  7696. * @param files defines the list of files to load (1 per face)
  7697. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7698. * @param onLoad defines an optional callback raised when the texture is loaded
  7699. * @param onError defines an optional callback raised if there is an issue to load the texture
  7700. * @param format defines the format of the data
  7701. * @param forcedExtension defines the extension to use to pick the right loader
  7702. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7703. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7704. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7705. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7706. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7707. * @returns the cube texture as an InternalTexture
  7708. */
  7709. 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;
  7710. /**
  7711. * Creates a cube texture
  7712. * @param rootUrl defines the url where the files to load is located
  7713. * @param scene defines the current scene
  7714. * @param files defines the list of files to load (1 per face)
  7715. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7716. * @param onLoad defines an optional callback raised when the texture is loaded
  7717. * @param onError defines an optional callback raised if there is an issue to load the texture
  7718. * @param format defines the format of the data
  7719. * @param forcedExtension defines the extension to use to pick the right loader
  7720. * @returns the cube texture as an InternalTexture
  7721. */
  7722. 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;
  7723. /**
  7724. * Creates a cube texture
  7725. * @param rootUrl defines the url where the files to load is located
  7726. * @param scene defines the current scene
  7727. * @param files defines the list of files to load (1 per face)
  7728. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7729. * @param onLoad defines an optional callback raised when the texture is loaded
  7730. * @param onError defines an optional callback raised if there is an issue to load the texture
  7731. * @param format defines the format of the data
  7732. * @param forcedExtension defines the extension to use to pick the right loader
  7733. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7734. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7735. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7736. * @returns the cube texture as an InternalTexture
  7737. */
  7738. 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;
  7739. /** @hidden */
  7740. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7741. /** @hidden */
  7742. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7743. /** @hidden */
  7744. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7745. /** @hidden */
  7746. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7747. }
  7748. }
  7749. declare module BABYLON {
  7750. /**
  7751. * Class for creating a cube texture
  7752. */
  7753. export class CubeTexture extends BaseTexture {
  7754. private _delayedOnLoad;
  7755. /**
  7756. * The url of the texture
  7757. */
  7758. url: string;
  7759. /**
  7760. * Gets or sets the center of the bounding box associated with the cube texture.
  7761. * It must define where the camera used to render the texture was set
  7762. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7763. */
  7764. boundingBoxPosition: Vector3;
  7765. private _boundingBoxSize;
  7766. /**
  7767. * Gets or sets the size of the bounding box associated with the cube texture
  7768. * When defined, the cubemap will switch to local mode
  7769. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7770. * @example https://www.babylonjs-playground.com/#RNASML
  7771. */
  7772. /**
  7773. * Returns the bounding box size
  7774. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7775. */
  7776. boundingBoxSize: Vector3;
  7777. protected _rotationY: number;
  7778. /**
  7779. * Sets texture matrix rotation angle around Y axis in radians.
  7780. */
  7781. /**
  7782. * Gets texture matrix rotation angle around Y axis radians.
  7783. */
  7784. rotationY: number;
  7785. /**
  7786. * Are mip maps generated for this texture or not.
  7787. */
  7788. readonly noMipmap: boolean;
  7789. private _noMipmap;
  7790. private _files;
  7791. private _extensions;
  7792. private _textureMatrix;
  7793. private _format;
  7794. private _createPolynomials;
  7795. /** @hidden */
  7796. _prefiltered: boolean;
  7797. /**
  7798. * Creates a cube texture from an array of image urls
  7799. * @param files defines an array of image urls
  7800. * @param scene defines the hosting scene
  7801. * @param noMipmap specifies if mip maps are not used
  7802. * @returns a cube texture
  7803. */
  7804. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7805. /**
  7806. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7807. * @param url defines the url of the prefiltered texture
  7808. * @param scene defines the scene the texture is attached to
  7809. * @param forcedExtension defines the extension of the file if different from the url
  7810. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7811. * @return the prefiltered texture
  7812. */
  7813. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7814. /**
  7815. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7816. * as prefiltered data.
  7817. * @param rootUrl defines the url of the texture or the root name of the six images
  7818. * @param scene defines the scene the texture is attached to
  7819. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7820. * @param noMipmap defines if mipmaps should be created or not
  7821. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7822. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7823. * @param onError defines a callback triggered in case of error during load
  7824. * @param format defines the internal format to use for the texture once loaded
  7825. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7826. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7827. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7828. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7829. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7830. * @return the cube texture
  7831. */
  7832. 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);
  7833. /**
  7834. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7835. */
  7836. readonly isPrefiltered: boolean;
  7837. /**
  7838. * Get the current class name of the texture useful for serialization or dynamic coding.
  7839. * @returns "CubeTexture"
  7840. */
  7841. getClassName(): string;
  7842. /**
  7843. * Update the url (and optional buffer) of this texture if url was null during construction.
  7844. * @param url the url of the texture
  7845. * @param forcedExtension defines the extension to use
  7846. * @param onLoad callback called when the texture is loaded (defaults to null)
  7847. */
  7848. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7849. /**
  7850. * Delays loading of the cube texture
  7851. * @param forcedExtension defines the extension to use
  7852. */
  7853. delayLoad(forcedExtension?: string): void;
  7854. /**
  7855. * Returns the reflection texture matrix
  7856. * @returns the reflection texture matrix
  7857. */
  7858. getReflectionTextureMatrix(): Matrix;
  7859. /**
  7860. * Sets the reflection texture matrix
  7861. * @param value Reflection texture matrix
  7862. */
  7863. setReflectionTextureMatrix(value: Matrix): void;
  7864. /**
  7865. * Parses text to create a cube texture
  7866. * @param parsedTexture define the serialized text to read from
  7867. * @param scene defines the hosting scene
  7868. * @param rootUrl defines the root url of the cube texture
  7869. * @returns a cube texture
  7870. */
  7871. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7872. /**
  7873. * Makes a clone, or deep copy, of the cube texture
  7874. * @returns a new cube texture
  7875. */
  7876. clone(): CubeTexture;
  7877. }
  7878. }
  7879. declare module BABYLON {
  7880. /** @hidden */
  7881. export var postprocessVertexShader: {
  7882. name: string;
  7883. shader: string;
  7884. };
  7885. }
  7886. declare module BABYLON {
  7887. /**
  7888. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  7889. * This is the base of the follow, arc rotate cameras and Free camera
  7890. * @see http://doc.babylonjs.com/features/cameras
  7891. */
  7892. export class TargetCamera extends Camera {
  7893. private static _RigCamTransformMatrix;
  7894. private static _TargetTransformMatrix;
  7895. private static _TargetFocalPoint;
  7896. /**
  7897. * Define the current direction the camera is moving to
  7898. */
  7899. cameraDirection: Vector3;
  7900. /**
  7901. * Define the current rotation the camera is rotating to
  7902. */
  7903. cameraRotation: Vector2;
  7904. /**
  7905. * When set, the up vector of the camera will be updated by the rotation of the camera
  7906. */
  7907. updateUpVectorFromRotation: boolean;
  7908. private _tmpQuaternion;
  7909. /**
  7910. * Define the current rotation of the camera
  7911. */
  7912. rotation: Vector3;
  7913. /**
  7914. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  7915. */
  7916. rotationQuaternion: Quaternion;
  7917. /**
  7918. * Define the current speed of the camera
  7919. */
  7920. speed: number;
  7921. /**
  7922. * Add cconstraint to the camera to prevent it to move freely in all directions and
  7923. * around all axis.
  7924. */
  7925. noRotationConstraint: boolean;
  7926. /**
  7927. * Define the current target of the camera as an object or a position.
  7928. */
  7929. lockedTarget: any;
  7930. /** @hidden */
  7931. _currentTarget: Vector3;
  7932. /** @hidden */
  7933. _initialFocalDistance: number;
  7934. /** @hidden */
  7935. _viewMatrix: Matrix;
  7936. /** @hidden */
  7937. _camMatrix: Matrix;
  7938. /** @hidden */
  7939. _cameraTransformMatrix: Matrix;
  7940. /** @hidden */
  7941. _cameraRotationMatrix: Matrix;
  7942. /** @hidden */
  7943. _referencePoint: Vector3;
  7944. /** @hidden */
  7945. _transformedReferencePoint: Vector3;
  7946. protected _globalCurrentTarget: Vector3;
  7947. protected _globalCurrentUpVector: Vector3;
  7948. /** @hidden */
  7949. _reset: () => void;
  7950. private _defaultUp;
  7951. /**
  7952. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  7953. * This is the base of the follow, arc rotate cameras and Free camera
  7954. * @see http://doc.babylonjs.com/features/cameras
  7955. * @param name Defines the name of the camera in the scene
  7956. * @param position Defines the start position of the camera in the scene
  7957. * @param scene Defines the scene the camera belongs to
  7958. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  7959. */
  7960. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7961. /**
  7962. * Gets the position in front of the camera at a given distance.
  7963. * @param distance The distance from the camera we want the position to be
  7964. * @returns the position
  7965. */
  7966. getFrontPosition(distance: number): Vector3;
  7967. /** @hidden */
  7968. _getLockedTargetPosition(): Nullable<Vector3>;
  7969. private _storedPosition;
  7970. private _storedRotation;
  7971. private _storedRotationQuaternion;
  7972. /**
  7973. * Store current camera state of the camera (fov, position, rotation, etc..)
  7974. * @returns the camera
  7975. */
  7976. storeState(): Camera;
  7977. /**
  7978. * Restored camera state. You must call storeState() first
  7979. * @returns whether it was successful or not
  7980. * @hidden
  7981. */
  7982. _restoreStateValues(): boolean;
  7983. /** @hidden */
  7984. _initCache(): void;
  7985. /** @hidden */
  7986. _updateCache(ignoreParentClass?: boolean): void;
  7987. /** @hidden */
  7988. _isSynchronizedViewMatrix(): boolean;
  7989. /** @hidden */
  7990. _computeLocalCameraSpeed(): number;
  7991. /**
  7992. * Defines the target the camera should look at.
  7993. * @param target Defines the new target as a Vector or a mesh
  7994. */
  7995. setTarget(target: Vector3): void;
  7996. /**
  7997. * Return the current target position of the camera. This value is expressed in local space.
  7998. * @returns the target position
  7999. */
  8000. getTarget(): Vector3;
  8001. /** @hidden */
  8002. _decideIfNeedsToMove(): boolean;
  8003. /** @hidden */
  8004. _updatePosition(): void;
  8005. /** @hidden */
  8006. _checkInputs(): void;
  8007. protected _updateCameraRotationMatrix(): void;
  8008. /**
  8009. * 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)
  8010. * @returns the current camera
  8011. */
  8012. private _rotateUpVectorWithCameraRotationMatrix;
  8013. private _cachedRotationZ;
  8014. private _cachedQuaternionRotationZ;
  8015. /** @hidden */
  8016. _getViewMatrix(): Matrix;
  8017. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8018. /**
  8019. * @hidden
  8020. */
  8021. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8022. /**
  8023. * @hidden
  8024. */
  8025. _updateRigCameras(): void;
  8026. private _getRigCamPositionAndTarget;
  8027. /**
  8028. * Gets the current object class name.
  8029. * @return the class name
  8030. */
  8031. getClassName(): string;
  8032. }
  8033. }
  8034. declare module BABYLON {
  8035. /**
  8036. * @ignore
  8037. * This is a list of all the different input types that are available in the application.
  8038. * Fo instance: ArcRotateCameraGamepadInput...
  8039. */
  8040. export var CameraInputTypes: {};
  8041. /**
  8042. * This is the contract to implement in order to create a new input class.
  8043. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8044. */
  8045. export interface ICameraInput<TCamera extends Camera> {
  8046. /**
  8047. * Defines the camera the input is attached to.
  8048. */
  8049. camera: Nullable<TCamera>;
  8050. /**
  8051. * Gets the class name of the current intput.
  8052. * @returns the class name
  8053. */
  8054. getClassName(): string;
  8055. /**
  8056. * Get the friendly name associated with the input class.
  8057. * @returns the input friendly name
  8058. */
  8059. getSimpleName(): string;
  8060. /**
  8061. * Attach the input controls to a specific dom element to get the input from.
  8062. * @param element Defines the element the controls should be listened from
  8063. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8064. */
  8065. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8066. /**
  8067. * Detach the current controls from the specified dom element.
  8068. * @param element Defines the element to stop listening the inputs from
  8069. */
  8070. detachControl(element: Nullable<HTMLElement>): void;
  8071. /**
  8072. * Update the current camera state depending on the inputs that have been used this frame.
  8073. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8074. */
  8075. checkInputs?: () => void;
  8076. }
  8077. /**
  8078. * Represents a map of input types to input instance or input index to input instance.
  8079. */
  8080. export interface CameraInputsMap<TCamera extends Camera> {
  8081. /**
  8082. * Accessor to the input by input type.
  8083. */
  8084. [name: string]: ICameraInput<TCamera>;
  8085. /**
  8086. * Accessor to the input by input index.
  8087. */
  8088. [idx: number]: ICameraInput<TCamera>;
  8089. }
  8090. /**
  8091. * This represents the input manager used within a camera.
  8092. * It helps dealing with all the different kind of input attached to a camera.
  8093. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8094. */
  8095. export class CameraInputsManager<TCamera extends Camera> {
  8096. /**
  8097. * Defines the list of inputs attahed to the camera.
  8098. */
  8099. attached: CameraInputsMap<TCamera>;
  8100. /**
  8101. * Defines the dom element the camera is collecting inputs from.
  8102. * This is null if the controls have not been attached.
  8103. */
  8104. attachedElement: Nullable<HTMLElement>;
  8105. /**
  8106. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8107. */
  8108. noPreventDefault: boolean;
  8109. /**
  8110. * Defined the camera the input manager belongs to.
  8111. */
  8112. camera: TCamera;
  8113. /**
  8114. * Update the current camera state depending on the inputs that have been used this frame.
  8115. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8116. */
  8117. checkInputs: () => void;
  8118. /**
  8119. * Instantiate a new Camera Input Manager.
  8120. * @param camera Defines the camera the input manager blongs to
  8121. */
  8122. constructor(camera: TCamera);
  8123. /**
  8124. * Add an input method to a camera
  8125. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8126. * @param input camera input method
  8127. */
  8128. add(input: ICameraInput<TCamera>): void;
  8129. /**
  8130. * Remove a specific input method from a camera
  8131. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8132. * @param inputToRemove camera input method
  8133. */
  8134. remove(inputToRemove: ICameraInput<TCamera>): void;
  8135. /**
  8136. * Remove a specific input type from a camera
  8137. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8138. * @param inputType the type of the input to remove
  8139. */
  8140. removeByType(inputType: string): void;
  8141. private _addCheckInputs;
  8142. /**
  8143. * Attach the input controls to the currently attached dom element to listen the events from.
  8144. * @param input Defines the input to attach
  8145. */
  8146. attachInput(input: ICameraInput<TCamera>): void;
  8147. /**
  8148. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8149. * @param element Defines the dom element to collect the events from
  8150. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8151. */
  8152. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8153. /**
  8154. * Detach the current manager inputs controls from a specific dom element.
  8155. * @param element Defines the dom element to collect the events from
  8156. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8157. */
  8158. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8159. /**
  8160. * Rebuild the dynamic inputCheck function from the current list of
  8161. * defined inputs in the manager.
  8162. */
  8163. rebuildInputCheck(): void;
  8164. /**
  8165. * Remove all attached input methods from a camera
  8166. */
  8167. clear(): void;
  8168. /**
  8169. * Serialize the current input manager attached to a camera.
  8170. * This ensures than once parsed,
  8171. * the input associated to the camera will be identical to the current ones
  8172. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8173. */
  8174. serialize(serializedCamera: any): void;
  8175. /**
  8176. * Parses an input manager serialized JSON to restore the previous list of inputs
  8177. * and states associated to a camera.
  8178. * @param parsedCamera Defines the JSON to parse
  8179. */
  8180. parse(parsedCamera: any): void;
  8181. }
  8182. }
  8183. declare module BABYLON {
  8184. /**
  8185. * Gather the list of keyboard event types as constants.
  8186. */
  8187. export class KeyboardEventTypes {
  8188. /**
  8189. * The keydown event is fired when a key becomes active (pressed).
  8190. */
  8191. static readonly KEYDOWN: number;
  8192. /**
  8193. * The keyup event is fired when a key has been released.
  8194. */
  8195. static readonly KEYUP: number;
  8196. }
  8197. /**
  8198. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8199. */
  8200. export class KeyboardInfo {
  8201. /**
  8202. * Defines the type of event (KeyboardEventTypes)
  8203. */
  8204. type: number;
  8205. /**
  8206. * Defines the related dom event
  8207. */
  8208. event: KeyboardEvent;
  8209. /**
  8210. * Instantiates a new keyboard info.
  8211. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8212. * @param type Defines the type of event (KeyboardEventTypes)
  8213. * @param event Defines the related dom event
  8214. */
  8215. constructor(
  8216. /**
  8217. * Defines the type of event (KeyboardEventTypes)
  8218. */
  8219. type: number,
  8220. /**
  8221. * Defines the related dom event
  8222. */
  8223. event: KeyboardEvent);
  8224. }
  8225. /**
  8226. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8227. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8228. */
  8229. export class KeyboardInfoPre extends KeyboardInfo {
  8230. /**
  8231. * Defines the type of event (KeyboardEventTypes)
  8232. */
  8233. type: number;
  8234. /**
  8235. * Defines the related dom event
  8236. */
  8237. event: KeyboardEvent;
  8238. /**
  8239. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8240. */
  8241. skipOnPointerObservable: boolean;
  8242. /**
  8243. * Instantiates a new keyboard pre info.
  8244. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8245. * @param type Defines the type of event (KeyboardEventTypes)
  8246. * @param event Defines the related dom event
  8247. */
  8248. constructor(
  8249. /**
  8250. * Defines the type of event (KeyboardEventTypes)
  8251. */
  8252. type: number,
  8253. /**
  8254. * Defines the related dom event
  8255. */
  8256. event: KeyboardEvent);
  8257. }
  8258. }
  8259. declare module BABYLON {
  8260. /**
  8261. * Manage the keyboard inputs to control the movement of a free camera.
  8262. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8263. */
  8264. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8265. /**
  8266. * Defines the camera the input is attached to.
  8267. */
  8268. camera: FreeCamera;
  8269. /**
  8270. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8271. */
  8272. keysUp: number[];
  8273. /**
  8274. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8275. */
  8276. keysDown: number[];
  8277. /**
  8278. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8279. */
  8280. keysLeft: number[];
  8281. /**
  8282. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8283. */
  8284. keysRight: number[];
  8285. private _keys;
  8286. private _onCanvasBlurObserver;
  8287. private _onKeyboardObserver;
  8288. private _engine;
  8289. private _scene;
  8290. /**
  8291. * Attach the input controls to a specific dom element to get the input from.
  8292. * @param element Defines the element the controls should be listened from
  8293. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8294. */
  8295. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8296. /**
  8297. * Detach the current controls from the specified dom element.
  8298. * @param element Defines the element to stop listening the inputs from
  8299. */
  8300. detachControl(element: Nullable<HTMLElement>): void;
  8301. /**
  8302. * Update the current camera state depending on the inputs that have been used this frame.
  8303. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8304. */
  8305. checkInputs(): void;
  8306. /**
  8307. * Gets the class name of the current intput.
  8308. * @returns the class name
  8309. */
  8310. getClassName(): string;
  8311. /** @hidden */
  8312. _onLostFocus(): void;
  8313. /**
  8314. * Get the friendly name associated with the input class.
  8315. * @returns the input friendly name
  8316. */
  8317. getSimpleName(): string;
  8318. }
  8319. }
  8320. declare module BABYLON {
  8321. /**
  8322. * A multi-material is used to apply different materials to different parts of the same object without the need of
  8323. * separate meshes. This can be use to improve performances.
  8324. * @see http://doc.babylonjs.com/how_to/multi_materials
  8325. */
  8326. export class MultiMaterial extends Material {
  8327. private _subMaterials;
  8328. /**
  8329. * Gets or Sets the list of Materials used within the multi material.
  8330. * They need to be ordered according to the submeshes order in the associated mesh
  8331. */
  8332. subMaterials: Nullable<Material>[];
  8333. /**
  8334. * Function used to align with Node.getChildren()
  8335. * @returns the list of Materials used within the multi material
  8336. */
  8337. getChildren(): Nullable<Material>[];
  8338. /**
  8339. * Instantiates a new Multi Material
  8340. * A multi-material is used to apply different materials to different parts of the same object without the need of
  8341. * separate meshes. This can be use to improve performances.
  8342. * @see http://doc.babylonjs.com/how_to/multi_materials
  8343. * @param name Define the name in the scene
  8344. * @param scene Define the scene the material belongs to
  8345. */
  8346. constructor(name: string, scene: Scene);
  8347. private _hookArray;
  8348. /**
  8349. * Get one of the submaterial by its index in the submaterials array
  8350. * @param index The index to look the sub material at
  8351. * @returns The Material if the index has been defined
  8352. */
  8353. getSubMaterial(index: number): Nullable<Material>;
  8354. /**
  8355. * Get the list of active textures for the whole sub materials list.
  8356. * @returns All the textures that will be used during the rendering
  8357. */
  8358. getActiveTextures(): BaseTexture[];
  8359. /**
  8360. * Gets the current class name of the material e.g. "MultiMaterial"
  8361. * Mainly use in serialization.
  8362. * @returns the class name
  8363. */
  8364. getClassName(): string;
  8365. /**
  8366. * Checks if the material is ready to render the requested sub mesh
  8367. * @param mesh Define the mesh the submesh belongs to
  8368. * @param subMesh Define the sub mesh to look readyness for
  8369. * @param useInstances Define whether or not the material is used with instances
  8370. * @returns true if ready, otherwise false
  8371. */
  8372. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  8373. /**
  8374. * Clones the current material and its related sub materials
  8375. * @param name Define the name of the newly cloned material
  8376. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  8377. * @returns the cloned material
  8378. */
  8379. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  8380. /**
  8381. * Serializes the materials into a JSON representation.
  8382. * @returns the JSON representation
  8383. */
  8384. serialize(): any;
  8385. /**
  8386. * Dispose the material and release its associated resources
  8387. * @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)
  8388. * @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)
  8389. * @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)
  8390. */
  8391. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  8392. /**
  8393. * Creates a MultiMaterial from parsed MultiMaterial data.
  8394. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  8395. * @param scene defines the hosting scene
  8396. * @returns a new MultiMaterial
  8397. */
  8398. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  8399. }
  8400. }
  8401. declare module BABYLON {
  8402. /**
  8403. * Class used to represent data loading progression
  8404. */
  8405. export class SceneLoaderFlags {
  8406. private static _ForceFullSceneLoadingForIncremental;
  8407. private static _ShowLoadingScreen;
  8408. private static _CleanBoneMatrixWeights;
  8409. private static _loggingLevel;
  8410. /**
  8411. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  8412. */
  8413. static ForceFullSceneLoadingForIncremental: boolean;
  8414. /**
  8415. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  8416. */
  8417. static ShowLoadingScreen: boolean;
  8418. /**
  8419. * Defines the current logging level (while loading the scene)
  8420. * @ignorenaming
  8421. */
  8422. static loggingLevel: number;
  8423. /**
  8424. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  8425. */
  8426. static CleanBoneMatrixWeights: boolean;
  8427. }
  8428. }
  8429. declare module BABYLON {
  8430. /**
  8431. * 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.
  8432. * @see https://doc.babylonjs.com/how_to/transformnode
  8433. */
  8434. export class TransformNode extends Node {
  8435. /**
  8436. * Object will not rotate to face the camera
  8437. */
  8438. static BILLBOARDMODE_NONE: number;
  8439. /**
  8440. * Object will rotate to face the camera but only on the x axis
  8441. */
  8442. static BILLBOARDMODE_X: number;
  8443. /**
  8444. * Object will rotate to face the camera but only on the y axis
  8445. */
  8446. static BILLBOARDMODE_Y: number;
  8447. /**
  8448. * Object will rotate to face the camera but only on the z axis
  8449. */
  8450. static BILLBOARDMODE_Z: number;
  8451. /**
  8452. * Object will rotate to face the camera
  8453. */
  8454. static BILLBOARDMODE_ALL: number;
  8455. private _forward;
  8456. private _forwardInverted;
  8457. private _up;
  8458. private _right;
  8459. private _rightInverted;
  8460. private _position;
  8461. private _rotation;
  8462. private _rotationQuaternion;
  8463. protected _scaling: Vector3;
  8464. protected _isDirty: boolean;
  8465. private _transformToBoneReferal;
  8466. private _billboardMode;
  8467. /**
  8468. * Gets or sets the billboard mode. Default is 0.
  8469. *
  8470. * | Value | Type | Description |
  8471. * | --- | --- | --- |
  8472. * | 0 | BILLBOARDMODE_NONE | |
  8473. * | 1 | BILLBOARDMODE_X | |
  8474. * | 2 | BILLBOARDMODE_Y | |
  8475. * | 4 | BILLBOARDMODE_Z | |
  8476. * | 7 | BILLBOARDMODE_ALL | |
  8477. *
  8478. */
  8479. billboardMode: number;
  8480. private _preserveParentRotationForBillboard;
  8481. /**
  8482. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  8483. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  8484. */
  8485. preserveParentRotationForBillboard: boolean;
  8486. /**
  8487. * 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
  8488. */
  8489. scalingDeterminant: number;
  8490. private _infiniteDistance;
  8491. /**
  8492. * Gets or sets the distance of the object to max, often used by skybox
  8493. */
  8494. infiniteDistance: boolean;
  8495. /**
  8496. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  8497. * By default the system will update normals to compensate
  8498. */
  8499. ignoreNonUniformScaling: boolean;
  8500. /**
  8501. * 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
  8502. */
  8503. reIntegrateRotationIntoRotationQuaternion: boolean;
  8504. /** @hidden */
  8505. _poseMatrix: Nullable<Matrix>;
  8506. /** @hidden */
  8507. _localMatrix: Matrix;
  8508. private _usePivotMatrix;
  8509. private _absolutePosition;
  8510. private _pivotMatrix;
  8511. private _pivotMatrixInverse;
  8512. protected _postMultiplyPivotMatrix: boolean;
  8513. protected _isWorldMatrixFrozen: boolean;
  8514. /** @hidden */
  8515. _indexInSceneTransformNodesArray: number;
  8516. /**
  8517. * An event triggered after the world matrix is updated
  8518. */
  8519. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  8520. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  8521. /**
  8522. * Gets a string identifying the name of the class
  8523. * @returns "TransformNode" string
  8524. */
  8525. getClassName(): string;
  8526. /**
  8527. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  8528. */
  8529. position: Vector3;
  8530. /**
  8531. * 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)).
  8532. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  8533. */
  8534. rotation: Vector3;
  8535. /**
  8536. * 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)).
  8537. */
  8538. scaling: Vector3;
  8539. /**
  8540. * 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).
  8541. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  8542. */
  8543. rotationQuaternion: Nullable<Quaternion>;
  8544. /**
  8545. * The forward direction of that transform in world space.
  8546. */
  8547. readonly forward: Vector3;
  8548. /**
  8549. * The up direction of that transform in world space.
  8550. */
  8551. readonly up: Vector3;
  8552. /**
  8553. * The right direction of that transform in world space.
  8554. */
  8555. readonly right: Vector3;
  8556. /**
  8557. * Copies the parameter passed Matrix into the mesh Pose matrix.
  8558. * @param matrix the matrix to copy the pose from
  8559. * @returns this TransformNode.
  8560. */
  8561. updatePoseMatrix(matrix: Matrix): TransformNode;
  8562. /**
  8563. * Returns the mesh Pose matrix.
  8564. * @returns the pose matrix
  8565. */
  8566. getPoseMatrix(): Matrix;
  8567. /** @hidden */
  8568. _isSynchronized(): boolean;
  8569. /** @hidden */
  8570. _initCache(): void;
  8571. /**
  8572. * Flag the transform node as dirty (Forcing it to update everything)
  8573. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  8574. * @returns this transform node
  8575. */
  8576. markAsDirty(property: string): TransformNode;
  8577. /**
  8578. * Returns the current mesh absolute position.
  8579. * Returns a Vector3.
  8580. */
  8581. readonly absolutePosition: Vector3;
  8582. /**
  8583. * Sets a new matrix to apply before all other transformation
  8584. * @param matrix defines the transform matrix
  8585. * @returns the current TransformNode
  8586. */
  8587. setPreTransformMatrix(matrix: Matrix): TransformNode;
  8588. /**
  8589. * Sets a new pivot matrix to the current node
  8590. * @param matrix defines the new pivot matrix to use
  8591. * @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
  8592. * @returns the current TransformNode
  8593. */
  8594. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  8595. /**
  8596. * Returns the mesh pivot matrix.
  8597. * Default : Identity.
  8598. * @returns the matrix
  8599. */
  8600. getPivotMatrix(): Matrix;
  8601. /**
  8602. * Prevents the World matrix to be computed any longer.
  8603. * @returns the TransformNode.
  8604. */
  8605. freezeWorldMatrix(): TransformNode;
  8606. /**
  8607. * Allows back the World matrix computation.
  8608. * @returns the TransformNode.
  8609. */
  8610. unfreezeWorldMatrix(): this;
  8611. /**
  8612. * True if the World matrix has been frozen.
  8613. */
  8614. readonly isWorldMatrixFrozen: boolean;
  8615. /**
  8616. * Retuns the mesh absolute position in the World.
  8617. * @returns a Vector3.
  8618. */
  8619. getAbsolutePosition(): Vector3;
  8620. /**
  8621. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  8622. * @param absolutePosition the absolute position to set
  8623. * @returns the TransformNode.
  8624. */
  8625. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  8626. /**
  8627. * Sets the mesh position in its local space.
  8628. * @param vector3 the position to set in localspace
  8629. * @returns the TransformNode.
  8630. */
  8631. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  8632. /**
  8633. * Returns the mesh position in the local space from the current World matrix values.
  8634. * @returns a new Vector3.
  8635. */
  8636. getPositionExpressedInLocalSpace(): Vector3;
  8637. /**
  8638. * Translates the mesh along the passed Vector3 in its local space.
  8639. * @param vector3 the distance to translate in localspace
  8640. * @returns the TransformNode.
  8641. */
  8642. locallyTranslate(vector3: Vector3): TransformNode;
  8643. private static _lookAtVectorCache;
  8644. /**
  8645. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  8646. * @param targetPoint the position (must be in same space as current mesh) to look at
  8647. * @param yawCor optional yaw (y-axis) correction in radians
  8648. * @param pitchCor optional pitch (x-axis) correction in radians
  8649. * @param rollCor optional roll (z-axis) correction in radians
  8650. * @param space the choosen space of the target
  8651. * @returns the TransformNode.
  8652. */
  8653. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  8654. /**
  8655. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  8656. * This Vector3 is expressed in the World space.
  8657. * @param localAxis axis to rotate
  8658. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  8659. */
  8660. getDirection(localAxis: Vector3): Vector3;
  8661. /**
  8662. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  8663. * localAxis is expressed in the mesh local space.
  8664. * result is computed in the Wordl space from the mesh World matrix.
  8665. * @param localAxis axis to rotate
  8666. * @param result the resulting transformnode
  8667. * @returns this TransformNode.
  8668. */
  8669. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  8670. /**
  8671. * Sets this transform node rotation to the given local axis.
  8672. * @param localAxis the axis in local space
  8673. * @param yawCor optional yaw (y-axis) correction in radians
  8674. * @param pitchCor optional pitch (x-axis) correction in radians
  8675. * @param rollCor optional roll (z-axis) correction in radians
  8676. * @returns this TransformNode
  8677. */
  8678. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  8679. /**
  8680. * Sets a new pivot point to the current node
  8681. * @param point defines the new pivot point to use
  8682. * @param space defines if the point is in world or local space (local by default)
  8683. * @returns the current TransformNode
  8684. */
  8685. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  8686. /**
  8687. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  8688. * @returns the pivot point
  8689. */
  8690. getPivotPoint(): Vector3;
  8691. /**
  8692. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  8693. * @param result the vector3 to store the result
  8694. * @returns this TransformNode.
  8695. */
  8696. getPivotPointToRef(result: Vector3): TransformNode;
  8697. /**
  8698. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  8699. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  8700. */
  8701. getAbsolutePivotPoint(): Vector3;
  8702. /**
  8703. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  8704. * @param result vector3 to store the result
  8705. * @returns this TransformNode.
  8706. */
  8707. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  8708. /**
  8709. * Defines the passed node as the parent of the current node.
  8710. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  8711. * @see https://doc.babylonjs.com/how_to/parenting
  8712. * @param node the node ot set as the parent
  8713. * @returns this TransformNode.
  8714. */
  8715. setParent(node: Nullable<Node>): TransformNode;
  8716. private _nonUniformScaling;
  8717. /**
  8718. * True if the scaling property of this object is non uniform eg. (1,2,1)
  8719. */
  8720. readonly nonUniformScaling: boolean;
  8721. /** @hidden */
  8722. _updateNonUniformScalingState(value: boolean): boolean;
  8723. /**
  8724. * Attach the current TransformNode to another TransformNode associated with a bone
  8725. * @param bone Bone affecting the TransformNode
  8726. * @param affectedTransformNode TransformNode associated with the bone
  8727. * @returns this object
  8728. */
  8729. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  8730. /**
  8731. * Detach the transform node if its associated with a bone
  8732. * @returns this object
  8733. */
  8734. detachFromBone(): TransformNode;
  8735. private static _rotationAxisCache;
  8736. /**
  8737. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  8738. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  8739. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  8740. * The passed axis is also normalized.
  8741. * @param axis the axis to rotate around
  8742. * @param amount the amount to rotate in radians
  8743. * @param space Space to rotate in (Default: local)
  8744. * @returns the TransformNode.
  8745. */
  8746. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  8747. /**
  8748. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  8749. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  8750. * The passed axis is also normalized. .
  8751. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  8752. * @param point the point to rotate around
  8753. * @param axis the axis to rotate around
  8754. * @param amount the amount to rotate in radians
  8755. * @returns the TransformNode
  8756. */
  8757. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  8758. /**
  8759. * Translates the mesh along the axis vector for the passed distance in the given space.
  8760. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  8761. * @param axis the axis to translate in
  8762. * @param distance the distance to translate
  8763. * @param space Space to rotate in (Default: local)
  8764. * @returns the TransformNode.
  8765. */
  8766. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  8767. /**
  8768. * Adds a rotation step to the mesh current rotation.
  8769. * x, y, z are Euler angles expressed in radians.
  8770. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  8771. * This means this rotation is made in the mesh local space only.
  8772. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  8773. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  8774. * ```javascript
  8775. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  8776. * ```
  8777. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  8778. * 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.
  8779. * @param x Rotation to add
  8780. * @param y Rotation to add
  8781. * @param z Rotation to add
  8782. * @returns the TransformNode.
  8783. */
  8784. addRotation(x: number, y: number, z: number): TransformNode;
  8785. /**
  8786. * @hidden
  8787. */
  8788. protected _getEffectiveParent(): Nullable<Node>;
  8789. /**
  8790. * Computes the world matrix of the node
  8791. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8792. * @returns the world matrix
  8793. */
  8794. computeWorldMatrix(force?: boolean): Matrix;
  8795. protected _afterComputeWorldMatrix(): void;
  8796. /**
  8797. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  8798. * @param func callback function to add
  8799. *
  8800. * @returns the TransformNode.
  8801. */
  8802. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  8803. /**
  8804. * Removes a registered callback function.
  8805. * @param func callback function to remove
  8806. * @returns the TransformNode.
  8807. */
  8808. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  8809. /**
  8810. * Gets the position of the current mesh in camera space
  8811. * @param camera defines the camera to use
  8812. * @returns a position
  8813. */
  8814. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  8815. /**
  8816. * Returns the distance from the mesh to the active camera
  8817. * @param camera defines the camera to use
  8818. * @returns the distance
  8819. */
  8820. getDistanceToCamera(camera?: Nullable<Camera>): number;
  8821. /**
  8822. * Clone the current transform node
  8823. * @param name Name of the new clone
  8824. * @param newParent New parent for the clone
  8825. * @param doNotCloneChildren Do not clone children hierarchy
  8826. * @returns the new transform node
  8827. */
  8828. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  8829. /**
  8830. * Serializes the objects information.
  8831. * @param currentSerializationObject defines the object to serialize in
  8832. * @returns the serialized object
  8833. */
  8834. serialize(currentSerializationObject?: any): any;
  8835. /**
  8836. * Returns a new TransformNode object parsed from the source provided.
  8837. * @param parsedTransformNode is the source.
  8838. * @param scene the scne the object belongs to
  8839. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  8840. * @returns a new TransformNode object parsed from the source provided.
  8841. */
  8842. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  8843. /**
  8844. * Get all child-transformNodes of this node
  8845. * @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
  8846. * @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
  8847. * @returns an array of TransformNode
  8848. */
  8849. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  8850. /**
  8851. * Releases resources associated with this transform node.
  8852. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  8853. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  8854. */
  8855. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  8856. /**
  8857. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  8858. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  8859. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  8860. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  8861. * @returns the current mesh
  8862. */
  8863. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  8864. }
  8865. }
  8866. declare module BABYLON {
  8867. /**
  8868. * Class used to override all child animations of a given target
  8869. */
  8870. export class AnimationPropertiesOverride {
  8871. /**
  8872. * Gets or sets a value indicating if animation blending must be used
  8873. */
  8874. enableBlending: boolean;
  8875. /**
  8876. * Gets or sets the blending speed to use when enableBlending is true
  8877. */
  8878. blendingSpeed: number;
  8879. /**
  8880. * Gets or sets the default loop mode to use
  8881. */
  8882. loopMode: number;
  8883. }
  8884. }
  8885. declare module BABYLON {
  8886. /**
  8887. * Class used to store bone information
  8888. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  8889. */
  8890. export class Bone extends Node {
  8891. /**
  8892. * defines the bone name
  8893. */
  8894. name: string;
  8895. private static _tmpVecs;
  8896. private static _tmpQuat;
  8897. private static _tmpMats;
  8898. /**
  8899. * Gets the list of child bones
  8900. */
  8901. children: Bone[];
  8902. /** Gets the animations associated with this bone */
  8903. animations: Animation[];
  8904. /**
  8905. * Gets or sets bone length
  8906. */
  8907. length: number;
  8908. /**
  8909. * @hidden Internal only
  8910. * Set this value to map this bone to a different index in the transform matrices
  8911. * Set this value to -1 to exclude the bone from the transform matrices
  8912. */
  8913. _index: Nullable<number>;
  8914. private _skeleton;
  8915. private _localMatrix;
  8916. private _restPose;
  8917. private _baseMatrix;
  8918. private _absoluteTransform;
  8919. private _invertedAbsoluteTransform;
  8920. private _parent;
  8921. private _scalingDeterminant;
  8922. private _worldTransform;
  8923. private _localScaling;
  8924. private _localRotation;
  8925. private _localPosition;
  8926. private _needToDecompose;
  8927. private _needToCompose;
  8928. /** @hidden */
  8929. _linkedTransformNode: Nullable<TransformNode>;
  8930. /** @hidden */
  8931. _waitingTransformNodeId: Nullable<string>;
  8932. /** @hidden */
  8933. /** @hidden */
  8934. _matrix: Matrix;
  8935. /**
  8936. * Create a new bone
  8937. * @param name defines the bone name
  8938. * @param skeleton defines the parent skeleton
  8939. * @param parentBone defines the parent (can be null if the bone is the root)
  8940. * @param localMatrix defines the local matrix
  8941. * @param restPose defines the rest pose matrix
  8942. * @param baseMatrix defines the base matrix
  8943. * @param index defines index of the bone in the hiearchy
  8944. */
  8945. constructor(
  8946. /**
  8947. * defines the bone name
  8948. */
  8949. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  8950. /**
  8951. * Gets the current object class name.
  8952. * @return the class name
  8953. */
  8954. getClassName(): string;
  8955. /**
  8956. * Gets the parent skeleton
  8957. * @returns a skeleton
  8958. */
  8959. getSkeleton(): Skeleton;
  8960. /**
  8961. * Gets parent bone
  8962. * @returns a bone or null if the bone is the root of the bone hierarchy
  8963. */
  8964. getParent(): Nullable<Bone>;
  8965. /**
  8966. * Returns an array containing the root bones
  8967. * @returns an array containing the root bones
  8968. */
  8969. getChildren(): Array<Bone>;
  8970. /**
  8971. * Sets the parent bone
  8972. * @param parent defines the parent (can be null if the bone is the root)
  8973. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8974. */
  8975. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  8976. /**
  8977. * Gets the local matrix
  8978. * @returns a matrix
  8979. */
  8980. getLocalMatrix(): Matrix;
  8981. /**
  8982. * Gets the base matrix (initial matrix which remains unchanged)
  8983. * @returns a matrix
  8984. */
  8985. getBaseMatrix(): Matrix;
  8986. /**
  8987. * Gets the rest pose matrix
  8988. * @returns a matrix
  8989. */
  8990. getRestPose(): Matrix;
  8991. /**
  8992. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  8993. */
  8994. getWorldMatrix(): Matrix;
  8995. /**
  8996. * Sets the local matrix to rest pose matrix
  8997. */
  8998. returnToRest(): void;
  8999. /**
  9000. * Gets the inverse of the absolute transform matrix.
  9001. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  9002. * @returns a matrix
  9003. */
  9004. getInvertedAbsoluteTransform(): Matrix;
  9005. /**
  9006. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  9007. * @returns a matrix
  9008. */
  9009. getAbsoluteTransform(): Matrix;
  9010. /**
  9011. * Links with the given transform node.
  9012. * The local matrix of this bone is copied from the transform node every frame.
  9013. * @param transformNode defines the transform node to link to
  9014. */
  9015. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  9016. /** Gets or sets current position (in local space) */
  9017. position: Vector3;
  9018. /** Gets or sets current rotation (in local space) */
  9019. rotation: Vector3;
  9020. /** Gets or sets current rotation quaternion (in local space) */
  9021. rotationQuaternion: Quaternion;
  9022. /** Gets or sets current scaling (in local space) */
  9023. scaling: Vector3;
  9024. /**
  9025. * Gets the animation properties override
  9026. */
  9027. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  9028. private _decompose;
  9029. private _compose;
  9030. /**
  9031. * Update the base and local matrices
  9032. * @param matrix defines the new base or local matrix
  9033. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9034. * @param updateLocalMatrix defines if the local matrix should be updated
  9035. */
  9036. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  9037. /** @hidden */
  9038. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  9039. /**
  9040. * Flag the bone as dirty (Forcing it to update everything)
  9041. */
  9042. markAsDirty(): void;
  9043. /** @hidden */
  9044. _markAsDirtyAndCompose(): void;
  9045. private _markAsDirtyAndDecompose;
  9046. /**
  9047. * Translate the bone in local or world space
  9048. * @param vec The amount to translate the bone
  9049. * @param space The space that the translation is in
  9050. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9051. */
  9052. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9053. /**
  9054. * Set the postion of the bone in local or world space
  9055. * @param position The position to set the bone
  9056. * @param space The space that the position is in
  9057. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9058. */
  9059. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9060. /**
  9061. * Set the absolute position of the bone (world space)
  9062. * @param position The position to set the bone
  9063. * @param mesh The mesh that this bone is attached to
  9064. */
  9065. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  9066. /**
  9067. * Scale the bone on the x, y and z axes (in local space)
  9068. * @param x The amount to scale the bone on the x axis
  9069. * @param y The amount to scale the bone on the y axis
  9070. * @param z The amount to scale the bone on the z axis
  9071. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  9072. */
  9073. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  9074. /**
  9075. * Set the bone scaling in local space
  9076. * @param scale defines the scaling vector
  9077. */
  9078. setScale(scale: Vector3): void;
  9079. /**
  9080. * Gets the current scaling in local space
  9081. * @returns the current scaling vector
  9082. */
  9083. getScale(): Vector3;
  9084. /**
  9085. * Gets the current scaling in local space and stores it in a target vector
  9086. * @param result defines the target vector
  9087. */
  9088. getScaleToRef(result: Vector3): void;
  9089. /**
  9090. * Set the yaw, pitch, and roll of the bone in local or world space
  9091. * @param yaw The rotation of the bone on the y axis
  9092. * @param pitch The rotation of the bone on the x axis
  9093. * @param roll The rotation of the bone on the z axis
  9094. * @param space The space that the axes of rotation are in
  9095. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9096. */
  9097. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  9098. /**
  9099. * Add a rotation to the bone on an axis in local or world space
  9100. * @param axis The axis to rotate the bone on
  9101. * @param amount The amount to rotate the bone
  9102. * @param space The space that the axis is in
  9103. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9104. */
  9105. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  9106. /**
  9107. * Set the rotation of the bone to a particular axis angle in local or world space
  9108. * @param axis The axis to rotate the bone on
  9109. * @param angle The angle that the bone should be rotated to
  9110. * @param space The space that the axis is in
  9111. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9112. */
  9113. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  9114. /**
  9115. * Set the euler rotation of the bone in local of world space
  9116. * @param rotation The euler rotation that the bone should be set to
  9117. * @param space The space that the rotation is in
  9118. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9119. */
  9120. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9121. /**
  9122. * Set the quaternion rotation of the bone in local of world space
  9123. * @param quat The quaternion rotation that the bone should be set to
  9124. * @param space The space that the rotation is in
  9125. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9126. */
  9127. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  9128. /**
  9129. * Set the rotation matrix of the bone in local of world space
  9130. * @param rotMat The rotation matrix that the bone should be set to
  9131. * @param space The space that the rotation is in
  9132. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9133. */
  9134. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  9135. private _rotateWithMatrix;
  9136. private _getNegativeRotationToRef;
  9137. /**
  9138. * Get the position of the bone in local or world space
  9139. * @param space The space that the returned position is in
  9140. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9141. * @returns The position of the bone
  9142. */
  9143. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  9144. /**
  9145. * Copy the position of the bone to a vector3 in local or world space
  9146. * @param space The space that the returned position is in
  9147. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9148. * @param result The vector3 to copy the position to
  9149. */
  9150. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  9151. /**
  9152. * Get the absolute position of the bone (world space)
  9153. * @param mesh The mesh that this bone is attached to
  9154. * @returns The absolute position of the bone
  9155. */
  9156. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  9157. /**
  9158. * Copy the absolute position of the bone (world space) to the result param
  9159. * @param mesh The mesh that this bone is attached to
  9160. * @param result The vector3 to copy the absolute position to
  9161. */
  9162. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  9163. /**
  9164. * Compute the absolute transforms of this bone and its children
  9165. */
  9166. computeAbsoluteTransforms(): void;
  9167. /**
  9168. * Get the world direction from an axis that is in the local space of the bone
  9169. * @param localAxis The local direction that is used to compute the world direction
  9170. * @param mesh The mesh that this bone is attached to
  9171. * @returns The world direction
  9172. */
  9173. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9174. /**
  9175. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  9176. * @param localAxis The local direction that is used to compute the world direction
  9177. * @param mesh The mesh that this bone is attached to
  9178. * @param result The vector3 that the world direction will be copied to
  9179. */
  9180. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9181. /**
  9182. * Get the euler rotation of the bone in local or world space
  9183. * @param space The space that the rotation should be in
  9184. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9185. * @returns The euler rotation
  9186. */
  9187. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  9188. /**
  9189. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  9190. * @param space The space that the rotation should be in
  9191. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9192. * @param result The vector3 that the rotation should be copied to
  9193. */
  9194. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9195. /**
  9196. * Get the quaternion rotation of the bone in either local or world space
  9197. * @param space The space that the rotation should be in
  9198. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9199. * @returns The quaternion rotation
  9200. */
  9201. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  9202. /**
  9203. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  9204. * @param space The space that the rotation should be in
  9205. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9206. * @param result The quaternion that the rotation should be copied to
  9207. */
  9208. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  9209. /**
  9210. * Get the rotation matrix of the bone in local or world space
  9211. * @param space The space that the rotation should be in
  9212. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9213. * @returns The rotation matrix
  9214. */
  9215. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  9216. /**
  9217. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  9218. * @param space The space that the rotation should be in
  9219. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9220. * @param result The quaternion that the rotation should be copied to
  9221. */
  9222. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  9223. /**
  9224. * Get the world position of a point that is in the local space of the bone
  9225. * @param position The local position
  9226. * @param mesh The mesh that this bone is attached to
  9227. * @returns The world position
  9228. */
  9229. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9230. /**
  9231. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  9232. * @param position The local position
  9233. * @param mesh The mesh that this bone is attached to
  9234. * @param result The vector3 that the world position should be copied to
  9235. */
  9236. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9237. /**
  9238. * Get the local position of a point that is in world space
  9239. * @param position The world position
  9240. * @param mesh The mesh that this bone is attached to
  9241. * @returns The local position
  9242. */
  9243. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9244. /**
  9245. * Get the local position of a point that is in world space and copy it to the result param
  9246. * @param position The world position
  9247. * @param mesh The mesh that this bone is attached to
  9248. * @param result The vector3 that the local position should be copied to
  9249. */
  9250. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9251. }
  9252. }
  9253. declare module BABYLON {
  9254. interface Engine {
  9255. /**
  9256. * Creates a raw texture
  9257. * @param data defines the data to store in the texture
  9258. * @param width defines the width of the texture
  9259. * @param height defines the height of the texture
  9260. * @param format defines the format of the data
  9261. * @param generateMipMaps defines if the engine should generate the mip levels
  9262. * @param invertY defines if data must be stored with Y axis inverted
  9263. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  9264. * @param compression defines the compression used (null by default)
  9265. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9266. * @returns the raw texture inside an InternalTexture
  9267. */
  9268. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  9269. /**
  9270. * Update a raw texture
  9271. * @param texture defines the texture to update
  9272. * @param data defines the data to store in the texture
  9273. * @param format defines the format of the data
  9274. * @param invertY defines if data must be stored with Y axis inverted
  9275. */
  9276. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  9277. /**
  9278. * Update a raw texture
  9279. * @param texture defines the texture to update
  9280. * @param data defines the data to store in the texture
  9281. * @param format defines the format of the data
  9282. * @param invertY defines if data must be stored with Y axis inverted
  9283. * @param compression defines the compression used (null by default)
  9284. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9285. */
  9286. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  9287. /**
  9288. * Creates a new raw cube texture
  9289. * @param data defines the array of data to use to create each face
  9290. * @param size defines the size of the textures
  9291. * @param format defines the format of the data
  9292. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9293. * @param generateMipMaps defines if the engine should generate the mip levels
  9294. * @param invertY defines if data must be stored with Y axis inverted
  9295. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9296. * @param compression defines the compression used (null by default)
  9297. * @returns the cube texture as an InternalTexture
  9298. */
  9299. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  9300. /**
  9301. * Update a raw cube texture
  9302. * @param texture defines the texture to udpdate
  9303. * @param data defines the data to store
  9304. * @param format defines the data format
  9305. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9306. * @param invertY defines if data must be stored with Y axis inverted
  9307. */
  9308. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  9309. /**
  9310. * Update a raw cube texture
  9311. * @param texture defines the texture to udpdate
  9312. * @param data defines the data to store
  9313. * @param format defines the data format
  9314. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9315. * @param invertY defines if data must be stored with Y axis inverted
  9316. * @param compression defines the compression used (null by default)
  9317. */
  9318. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  9319. /**
  9320. * Update a raw cube texture
  9321. * @param texture defines the texture to udpdate
  9322. * @param data defines the data to store
  9323. * @param format defines the data format
  9324. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9325. * @param invertY defines if data must be stored with Y axis inverted
  9326. * @param compression defines the compression used (null by default)
  9327. * @param level defines which level of the texture to update
  9328. */
  9329. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  9330. /**
  9331. * Creates a new raw cube texture from a specified url
  9332. * @param url defines the url where the data is located
  9333. * @param scene defines the current scene
  9334. * @param size defines the size of the textures
  9335. * @param format defines the format of the data
  9336. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9337. * @param noMipmap defines if the engine should avoid generating the mip levels
  9338. * @param callback defines a callback used to extract texture data from loaded data
  9339. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  9340. * @param onLoad defines a callback called when texture is loaded
  9341. * @param onError defines a callback called if there is an error
  9342. * @returns the cube texture as an InternalTexture
  9343. */
  9344. 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;
  9345. /**
  9346. * Creates a new raw cube texture from a specified url
  9347. * @param url defines the url where the data is located
  9348. * @param scene defines the current scene
  9349. * @param size defines the size of the textures
  9350. * @param format defines the format of the data
  9351. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9352. * @param noMipmap defines if the engine should avoid generating the mip levels
  9353. * @param callback defines a callback used to extract texture data from loaded data
  9354. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  9355. * @param onLoad defines a callback called when texture is loaded
  9356. * @param onError defines a callback called if there is an error
  9357. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9358. * @param invertY defines if data must be stored with Y axis inverted
  9359. * @returns the cube texture as an InternalTexture
  9360. */
  9361. 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;
  9362. /**
  9363. * Creates a new raw 3D texture
  9364. * @param data defines the data used to create the texture
  9365. * @param width defines the width of the texture
  9366. * @param height defines the height of the texture
  9367. * @param depth defines the depth of the texture
  9368. * @param format defines the format of the texture
  9369. * @param generateMipMaps defines if the engine must generate mip levels
  9370. * @param invertY defines if data must be stored with Y axis inverted
  9371. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9372. * @param compression defines the compressed used (can be null)
  9373. * @param textureType defines the compressed used (can be null)
  9374. * @returns a new raw 3D texture (stored in an InternalTexture)
  9375. */
  9376. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  9377. /**
  9378. * Update a raw 3D texture
  9379. * @param texture defines the texture to update
  9380. * @param data defines the data to store
  9381. * @param format defines the data format
  9382. * @param invertY defines if data must be stored with Y axis inverted
  9383. */
  9384. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  9385. /**
  9386. * Update a raw 3D texture
  9387. * @param texture defines the texture to update
  9388. * @param data defines the data to store
  9389. * @param format defines the data format
  9390. * @param invertY defines if data must be stored with Y axis inverted
  9391. * @param compression defines the used compression (can be null)
  9392. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  9393. */
  9394. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  9395. }
  9396. }
  9397. declare module BABYLON {
  9398. /**
  9399. * Raw texture can help creating a texture directly from an array of data.
  9400. * This can be super useful if you either get the data from an uncompressed source or
  9401. * if you wish to create your texture pixel by pixel.
  9402. */
  9403. export class RawTexture extends Texture {
  9404. /**
  9405. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9406. */
  9407. format: number;
  9408. private _engine;
  9409. /**
  9410. * Instantiates a new RawTexture.
  9411. * Raw texture can help creating a texture directly from an array of data.
  9412. * This can be super useful if you either get the data from an uncompressed source or
  9413. * if you wish to create your texture pixel by pixel.
  9414. * @param data define the array of data to use to create the texture
  9415. * @param width define the width of the texture
  9416. * @param height define the height of the texture
  9417. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9418. * @param scene define the scene the texture belongs to
  9419. * @param generateMipMaps define whether mip maps should be generated or not
  9420. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9421. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9422. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9423. */
  9424. constructor(data: ArrayBufferView, width: number, height: number,
  9425. /**
  9426. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9427. */
  9428. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  9429. /**
  9430. * Updates the texture underlying data.
  9431. * @param data Define the new data of the texture
  9432. */
  9433. update(data: ArrayBufferView): void;
  9434. /**
  9435. * Creates a luminance texture from some data.
  9436. * @param data Define the texture data
  9437. * @param width Define the width of the texture
  9438. * @param height Define the height of the texture
  9439. * @param scene Define the scene the texture belongs to
  9440. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9441. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9442. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9443. * @returns the luminance texture
  9444. */
  9445. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9446. /**
  9447. * Creates a luminance alpha texture from some data.
  9448. * @param data Define the texture data
  9449. * @param width Define the width of the texture
  9450. * @param height Define the height of the texture
  9451. * @param scene Define the scene the texture belongs to
  9452. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9453. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9454. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9455. * @returns the luminance alpha texture
  9456. */
  9457. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9458. /**
  9459. * Creates an alpha texture from some data.
  9460. * @param data Define the texture data
  9461. * @param width Define the width of the texture
  9462. * @param height Define the height of the texture
  9463. * @param scene Define the scene the texture belongs to
  9464. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9465. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9466. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9467. * @returns the alpha texture
  9468. */
  9469. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9470. /**
  9471. * Creates a RGB texture from some data.
  9472. * @param data Define the texture data
  9473. * @param width Define the width of the texture
  9474. * @param height Define the height of the texture
  9475. * @param scene Define the scene the texture belongs to
  9476. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9477. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9478. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9479. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9480. * @returns the RGB alpha texture
  9481. */
  9482. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9483. /**
  9484. * Creates a RGBA texture from some data.
  9485. * @param data Define the texture data
  9486. * @param width Define the width of the texture
  9487. * @param height Define the height of the texture
  9488. * @param scene Define the scene the texture belongs to
  9489. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9490. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9491. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9492. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9493. * @returns the RGBA texture
  9494. */
  9495. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9496. /**
  9497. * Creates a R texture from some data.
  9498. * @param data Define the texture data
  9499. * @param width Define the width of the texture
  9500. * @param height Define the height of the texture
  9501. * @param scene Define the scene the texture belongs to
  9502. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9503. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9504. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9505. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9506. * @returns the R texture
  9507. */
  9508. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9509. }
  9510. }
  9511. declare module BABYLON {
  9512. /**
  9513. * Defines a runtime animation
  9514. */
  9515. export class RuntimeAnimation {
  9516. private _events;
  9517. /**
  9518. * The current frame of the runtime animation
  9519. */
  9520. private _currentFrame;
  9521. /**
  9522. * The animation used by the runtime animation
  9523. */
  9524. private _animation;
  9525. /**
  9526. * The target of the runtime animation
  9527. */
  9528. private _target;
  9529. /**
  9530. * The initiating animatable
  9531. */
  9532. private _host;
  9533. /**
  9534. * The original value of the runtime animation
  9535. */
  9536. private _originalValue;
  9537. /**
  9538. * The original blend value of the runtime animation
  9539. */
  9540. private _originalBlendValue;
  9541. /**
  9542. * The offsets cache of the runtime animation
  9543. */
  9544. private _offsetsCache;
  9545. /**
  9546. * The high limits cache of the runtime animation
  9547. */
  9548. private _highLimitsCache;
  9549. /**
  9550. * Specifies if the runtime animation has been stopped
  9551. */
  9552. private _stopped;
  9553. /**
  9554. * The blending factor of the runtime animation
  9555. */
  9556. private _blendingFactor;
  9557. /**
  9558. * The BabylonJS scene
  9559. */
  9560. private _scene;
  9561. /**
  9562. * The current value of the runtime animation
  9563. */
  9564. private _currentValue;
  9565. /** @hidden */
  9566. _animationState: _IAnimationState;
  9567. /**
  9568. * The active target of the runtime animation
  9569. */
  9570. private _activeTargets;
  9571. private _currentActiveTarget;
  9572. private _directTarget;
  9573. /**
  9574. * The target path of the runtime animation
  9575. */
  9576. private _targetPath;
  9577. /**
  9578. * The weight of the runtime animation
  9579. */
  9580. private _weight;
  9581. /**
  9582. * The ratio offset of the runtime animation
  9583. */
  9584. private _ratioOffset;
  9585. /**
  9586. * The previous delay of the runtime animation
  9587. */
  9588. private _previousDelay;
  9589. /**
  9590. * The previous ratio of the runtime animation
  9591. */
  9592. private _previousRatio;
  9593. private _enableBlending;
  9594. private _keys;
  9595. private _minFrame;
  9596. private _maxFrame;
  9597. private _minValue;
  9598. private _maxValue;
  9599. private _targetIsArray;
  9600. /**
  9601. * Gets the current frame of the runtime animation
  9602. */
  9603. readonly currentFrame: number;
  9604. /**
  9605. * Gets the weight of the runtime animation
  9606. */
  9607. readonly weight: number;
  9608. /**
  9609. * Gets the current value of the runtime animation
  9610. */
  9611. readonly currentValue: any;
  9612. /**
  9613. * Gets the target path of the runtime animation
  9614. */
  9615. readonly targetPath: string;
  9616. /**
  9617. * Gets the actual target of the runtime animation
  9618. */
  9619. readonly target: any;
  9620. /** @hidden */
  9621. _onLoop: () => void;
  9622. /**
  9623. * Create a new RuntimeAnimation object
  9624. * @param target defines the target of the animation
  9625. * @param animation defines the source animation object
  9626. * @param scene defines the hosting scene
  9627. * @param host defines the initiating Animatable
  9628. */
  9629. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  9630. private _preparePath;
  9631. /**
  9632. * Gets the animation from the runtime animation
  9633. */
  9634. readonly animation: Animation;
  9635. /**
  9636. * Resets the runtime animation to the beginning
  9637. * @param restoreOriginal defines whether to restore the target property to the original value
  9638. */
  9639. reset(restoreOriginal?: boolean): void;
  9640. /**
  9641. * Specifies if the runtime animation is stopped
  9642. * @returns Boolean specifying if the runtime animation is stopped
  9643. */
  9644. isStopped(): boolean;
  9645. /**
  9646. * Disposes of the runtime animation
  9647. */
  9648. dispose(): void;
  9649. /**
  9650. * Apply the interpolated value to the target
  9651. * @param currentValue defines the value computed by the animation
  9652. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  9653. */
  9654. setValue(currentValue: any, weight: number): void;
  9655. private _getOriginalValues;
  9656. private _setValue;
  9657. /**
  9658. * Gets the loop pmode of the runtime animation
  9659. * @returns Loop Mode
  9660. */
  9661. private _getCorrectLoopMode;
  9662. /**
  9663. * Move the current animation to a given frame
  9664. * @param frame defines the frame to move to
  9665. */
  9666. goToFrame(frame: number): void;
  9667. /**
  9668. * @hidden Internal use only
  9669. */
  9670. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  9671. /**
  9672. * Execute the current animation
  9673. * @param delay defines the delay to add to the current frame
  9674. * @param from defines the lower bound of the animation range
  9675. * @param to defines the upper bound of the animation range
  9676. * @param loop defines if the current animation must loop
  9677. * @param speedRatio defines the current speed ratio
  9678. * @param weight defines the weight of the animation (default is -1 so no weight)
  9679. * @param onLoop optional callback called when animation loops
  9680. * @returns a boolean indicating if the animation is running
  9681. */
  9682. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  9683. }
  9684. }
  9685. declare module BABYLON {
  9686. /**
  9687. * Class used to store an actual running animation
  9688. */
  9689. export class Animatable {
  9690. /** defines the target object */
  9691. target: any;
  9692. /** defines the starting frame number (default is 0) */
  9693. fromFrame: number;
  9694. /** defines the ending frame number (default is 100) */
  9695. toFrame: number;
  9696. /** defines if the animation must loop (default is false) */
  9697. loopAnimation: boolean;
  9698. /** defines a callback to call when animation ends if it is not looping */
  9699. onAnimationEnd?: (() => void) | null | undefined;
  9700. /** defines a callback to call when animation loops */
  9701. onAnimationLoop?: (() => void) | null | undefined;
  9702. private _localDelayOffset;
  9703. private _pausedDelay;
  9704. private _runtimeAnimations;
  9705. private _paused;
  9706. private _scene;
  9707. private _speedRatio;
  9708. private _weight;
  9709. private _syncRoot;
  9710. /**
  9711. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  9712. * This will only apply for non looping animation (default is true)
  9713. */
  9714. disposeOnEnd: boolean;
  9715. /**
  9716. * Gets a boolean indicating if the animation has started
  9717. */
  9718. animationStarted: boolean;
  9719. /**
  9720. * Observer raised when the animation ends
  9721. */
  9722. onAnimationEndObservable: Observable<Animatable>;
  9723. /**
  9724. * Observer raised when the animation loops
  9725. */
  9726. onAnimationLoopObservable: Observable<Animatable>;
  9727. /**
  9728. * Gets the root Animatable used to synchronize and normalize animations
  9729. */
  9730. readonly syncRoot: Nullable<Animatable>;
  9731. /**
  9732. * Gets the current frame of the first RuntimeAnimation
  9733. * Used to synchronize Animatables
  9734. */
  9735. readonly masterFrame: number;
  9736. /**
  9737. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  9738. */
  9739. weight: number;
  9740. /**
  9741. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  9742. */
  9743. speedRatio: number;
  9744. /**
  9745. * Creates a new Animatable
  9746. * @param scene defines the hosting scene
  9747. * @param target defines the target object
  9748. * @param fromFrame defines the starting frame number (default is 0)
  9749. * @param toFrame defines the ending frame number (default is 100)
  9750. * @param loopAnimation defines if the animation must loop (default is false)
  9751. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  9752. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  9753. * @param animations defines a group of animation to add to the new Animatable
  9754. * @param onAnimationLoop defines a callback to call when animation loops
  9755. */
  9756. constructor(scene: Scene,
  9757. /** defines the target object */
  9758. target: any,
  9759. /** defines the starting frame number (default is 0) */
  9760. fromFrame?: number,
  9761. /** defines the ending frame number (default is 100) */
  9762. toFrame?: number,
  9763. /** defines if the animation must loop (default is false) */
  9764. loopAnimation?: boolean, speedRatio?: number,
  9765. /** defines a callback to call when animation ends if it is not looping */
  9766. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  9767. /** defines a callback to call when animation loops */
  9768. onAnimationLoop?: (() => void) | null | undefined);
  9769. /**
  9770. * Synchronize and normalize current Animatable with a source Animatable
  9771. * This is useful when using animation weights and when animations are not of the same length
  9772. * @param root defines the root Animatable to synchronize with
  9773. * @returns the current Animatable
  9774. */
  9775. syncWith(root: Animatable): Animatable;
  9776. /**
  9777. * Gets the list of runtime animations
  9778. * @returns an array of RuntimeAnimation
  9779. */
  9780. getAnimations(): RuntimeAnimation[];
  9781. /**
  9782. * Adds more animations to the current animatable
  9783. * @param target defines the target of the animations
  9784. * @param animations defines the new animations to add
  9785. */
  9786. appendAnimations(target: any, animations: Animation[]): void;
  9787. /**
  9788. * Gets the source animation for a specific property
  9789. * @param property defines the propertyu to look for
  9790. * @returns null or the source animation for the given property
  9791. */
  9792. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  9793. /**
  9794. * Gets the runtime animation for a specific property
  9795. * @param property defines the propertyu to look for
  9796. * @returns null or the runtime animation for the given property
  9797. */
  9798. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  9799. /**
  9800. * Resets the animatable to its original state
  9801. */
  9802. reset(): void;
  9803. /**
  9804. * Allows the animatable to blend with current running animations
  9805. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  9806. * @param blendingSpeed defines the blending speed to use
  9807. */
  9808. enableBlending(blendingSpeed: number): void;
  9809. /**
  9810. * Disable animation blending
  9811. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  9812. */
  9813. disableBlending(): void;
  9814. /**
  9815. * Jump directly to a given frame
  9816. * @param frame defines the frame to jump to
  9817. */
  9818. goToFrame(frame: number): void;
  9819. /**
  9820. * Pause the animation
  9821. */
  9822. pause(): void;
  9823. /**
  9824. * Restart the animation
  9825. */
  9826. restart(): void;
  9827. private _raiseOnAnimationEnd;
  9828. /**
  9829. * Stop and delete the current animation
  9830. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  9831. * @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)
  9832. */
  9833. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  9834. /**
  9835. * Wait asynchronously for the animation to end
  9836. * @returns a promise which will be fullfilled when the animation ends
  9837. */
  9838. waitAsync(): Promise<Animatable>;
  9839. /** @hidden */
  9840. _animate(delay: number): boolean;
  9841. }
  9842. interface Scene {
  9843. /** @hidden */
  9844. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  9845. /** @hidden */
  9846. _processLateAnimationBindingsForMatrices(holder: {
  9847. totalWeight: number;
  9848. animations: RuntimeAnimation[];
  9849. originalValue: Matrix;
  9850. }): any;
  9851. /** @hidden */
  9852. _processLateAnimationBindingsForQuaternions(holder: {
  9853. totalWeight: number;
  9854. animations: RuntimeAnimation[];
  9855. originalValue: Quaternion;
  9856. }, refQuaternion: Quaternion): Quaternion;
  9857. /** @hidden */
  9858. _processLateAnimationBindings(): void;
  9859. /**
  9860. * Will start the animation sequence of a given target
  9861. * @param target defines the target
  9862. * @param from defines from which frame should animation start
  9863. * @param to defines until which frame should animation run.
  9864. * @param weight defines the weight to apply to the animation (1.0 by default)
  9865. * @param loop defines if the animation loops
  9866. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  9867. * @param onAnimationEnd defines the function to be executed when the animation ends
  9868. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  9869. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  9870. * @param onAnimationLoop defines the callback to call when an animation loops
  9871. * @returns the animatable object created for this animation
  9872. */
  9873. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  9874. /**
  9875. * Will start the animation sequence of a given target
  9876. * @param target defines the target
  9877. * @param from defines from which frame should animation start
  9878. * @param to defines until which frame should animation run.
  9879. * @param loop defines if the animation loops
  9880. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  9881. * @param onAnimationEnd defines the function to be executed when the animation ends
  9882. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  9883. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  9884. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  9885. * @param onAnimationLoop defines the callback to call when an animation loops
  9886. * @returns the animatable object created for this animation
  9887. */
  9888. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  9889. /**
  9890. * Will start the animation sequence of a given target and its hierarchy
  9891. * @param target defines the target
  9892. * @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.
  9893. * @param from defines from which frame should animation start
  9894. * @param to defines until which frame should animation run.
  9895. * @param loop defines if the animation loops
  9896. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  9897. * @param onAnimationEnd defines the function to be executed when the animation ends
  9898. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  9899. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  9900. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  9901. * @param onAnimationLoop defines the callback to call when an animation loops
  9902. * @returns the list of created animatables
  9903. */
  9904. 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[];
  9905. /**
  9906. * Begin a new animation on a given node
  9907. * @param target defines the target where the animation will take place
  9908. * @param animations defines the list of animations to start
  9909. * @param from defines the initial value
  9910. * @param to defines the final value
  9911. * @param loop defines if you want animation to loop (off by default)
  9912. * @param speedRatio defines the speed ratio to apply to all animations
  9913. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  9914. * @param onAnimationLoop defines the callback to call when an animation loops
  9915. * @returns the list of created animatables
  9916. */
  9917. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  9918. /**
  9919. * Begin a new animation on a given node and its hierarchy
  9920. * @param target defines the root node where the animation will take place
  9921. * @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.
  9922. * @param animations defines the list of animations to start
  9923. * @param from defines the initial value
  9924. * @param to defines the final value
  9925. * @param loop defines if you want animation to loop (off by default)
  9926. * @param speedRatio defines the speed ratio to apply to all animations
  9927. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  9928. * @param onAnimationLoop defines the callback to call when an animation loops
  9929. * @returns the list of animatables created for all nodes
  9930. */
  9931. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  9932. /**
  9933. * Gets the animatable associated with a specific target
  9934. * @param target defines the target of the animatable
  9935. * @returns the required animatable if found
  9936. */
  9937. getAnimatableByTarget(target: any): Nullable<Animatable>;
  9938. /**
  9939. * Gets all animatables associated with a given target
  9940. * @param target defines the target to look animatables for
  9941. * @returns an array of Animatables
  9942. */
  9943. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  9944. /**
  9945. * Stops and removes all animations that have been applied to the scene
  9946. */
  9947. stopAllAnimations(): void;
  9948. }
  9949. interface Bone {
  9950. /**
  9951. * Copy an animation range from another bone
  9952. * @param source defines the source bone
  9953. * @param rangeName defines the range name to copy
  9954. * @param frameOffset defines the frame offset
  9955. * @param rescaleAsRequired defines if rescaling must be applied if required
  9956. * @param skelDimensionsRatio defines the scaling ratio
  9957. * @returns true if operation was successful
  9958. */
  9959. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  9960. }
  9961. }
  9962. declare module BABYLON {
  9963. /**
  9964. * Class used to handle skinning animations
  9965. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  9966. */
  9967. export class Skeleton implements IAnimatable {
  9968. /** defines the skeleton name */
  9969. name: string;
  9970. /** defines the skeleton Id */
  9971. id: string;
  9972. /**
  9973. * Defines the list of child bones
  9974. */
  9975. bones: Bone[];
  9976. /**
  9977. * Defines an estimate of the dimension of the skeleton at rest
  9978. */
  9979. dimensionsAtRest: Vector3;
  9980. /**
  9981. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  9982. */
  9983. needInitialSkinMatrix: boolean;
  9984. /**
  9985. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  9986. */
  9987. overrideMesh: Nullable<AbstractMesh>;
  9988. /**
  9989. * Gets the list of animations attached to this skeleton
  9990. */
  9991. animations: Array<Animation>;
  9992. private _scene;
  9993. private _isDirty;
  9994. private _transformMatrices;
  9995. private _transformMatrixTexture;
  9996. private _meshesWithPoseMatrix;
  9997. private _animatables;
  9998. private _identity;
  9999. private _synchronizedWithMesh;
  10000. private _ranges;
  10001. private _lastAbsoluteTransformsUpdateId;
  10002. private _canUseTextureForBones;
  10003. private _uniqueId;
  10004. /** @hidden */
  10005. _numBonesWithLinkedTransformNode: number;
  10006. /** @hidden */
  10007. _hasWaitingData: Nullable<boolean>;
  10008. /**
  10009. * Specifies if the skeleton should be serialized
  10010. */
  10011. doNotSerialize: boolean;
  10012. private _useTextureToStoreBoneMatrices;
  10013. /**
  10014. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  10015. * Please note that this option is not available if the hardware does not support it
  10016. */
  10017. useTextureToStoreBoneMatrices: boolean;
  10018. private _animationPropertiesOverride;
  10019. /**
  10020. * Gets or sets the animation properties override
  10021. */
  10022. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  10023. /**
  10024. * List of inspectable custom properties (used by the Inspector)
  10025. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  10026. */
  10027. inspectableCustomProperties: IInspectable[];
  10028. /**
  10029. * An observable triggered before computing the skeleton's matrices
  10030. */
  10031. onBeforeComputeObservable: Observable<Skeleton>;
  10032. /**
  10033. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  10034. */
  10035. readonly isUsingTextureForMatrices: boolean;
  10036. /**
  10037. * Gets the unique ID of this skeleton
  10038. */
  10039. readonly uniqueId: number;
  10040. /**
  10041. * Creates a new skeleton
  10042. * @param name defines the skeleton name
  10043. * @param id defines the skeleton Id
  10044. * @param scene defines the hosting scene
  10045. */
  10046. constructor(
  10047. /** defines the skeleton name */
  10048. name: string,
  10049. /** defines the skeleton Id */
  10050. id: string, scene: Scene);
  10051. /**
  10052. * Gets the current object class name.
  10053. * @return the class name
  10054. */
  10055. getClassName(): string;
  10056. /**
  10057. * Returns an array containing the root bones
  10058. * @returns an array containing the root bones
  10059. */
  10060. getChildren(): Array<Bone>;
  10061. /**
  10062. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  10063. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  10064. * @returns a Float32Array containing matrices data
  10065. */
  10066. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  10067. /**
  10068. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  10069. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  10070. * @returns a raw texture containing the data
  10071. */
  10072. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  10073. /**
  10074. * Gets the current hosting scene
  10075. * @returns a scene object
  10076. */
  10077. getScene(): Scene;
  10078. /**
  10079. * Gets a string representing the current skeleton data
  10080. * @param fullDetails defines a boolean indicating if we want a verbose version
  10081. * @returns a string representing the current skeleton data
  10082. */
  10083. toString(fullDetails?: boolean): string;
  10084. /**
  10085. * Get bone's index searching by name
  10086. * @param name defines bone's name to search for
  10087. * @return the indice of the bone. Returns -1 if not found
  10088. */
  10089. getBoneIndexByName(name: string): number;
  10090. /**
  10091. * Creater a new animation range
  10092. * @param name defines the name of the range
  10093. * @param from defines the start key
  10094. * @param to defines the end key
  10095. */
  10096. createAnimationRange(name: string, from: number, to: number): void;
  10097. /**
  10098. * Delete a specific animation range
  10099. * @param name defines the name of the range
  10100. * @param deleteFrames defines if frames must be removed as well
  10101. */
  10102. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  10103. /**
  10104. * Gets a specific animation range
  10105. * @param name defines the name of the range to look for
  10106. * @returns the requested animation range or null if not found
  10107. */
  10108. getAnimationRange(name: string): Nullable<AnimationRange>;
  10109. /**
  10110. * Gets the list of all animation ranges defined on this skeleton
  10111. * @returns an array
  10112. */
  10113. getAnimationRanges(): Nullable<AnimationRange>[];
  10114. /**
  10115. * Copy animation range from a source skeleton.
  10116. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  10117. * @param source defines the source skeleton
  10118. * @param name defines the name of the range to copy
  10119. * @param rescaleAsRequired defines if rescaling must be applied if required
  10120. * @returns true if operation was successful
  10121. */
  10122. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  10123. /**
  10124. * Forces the skeleton to go to rest pose
  10125. */
  10126. returnToRest(): void;
  10127. private _getHighestAnimationFrame;
  10128. /**
  10129. * Begin a specific animation range
  10130. * @param name defines the name of the range to start
  10131. * @param loop defines if looping must be turned on (false by default)
  10132. * @param speedRatio defines the speed ratio to apply (1 by default)
  10133. * @param onAnimationEnd defines a callback which will be called when animation will end
  10134. * @returns a new animatable
  10135. */
  10136. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  10137. /** @hidden */
  10138. _markAsDirty(): void;
  10139. /** @hidden */
  10140. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  10141. /** @hidden */
  10142. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  10143. private _computeTransformMatrices;
  10144. /**
  10145. * Build all resources required to render a skeleton
  10146. */
  10147. prepare(): void;
  10148. /**
  10149. * Gets the list of animatables currently running for this skeleton
  10150. * @returns an array of animatables
  10151. */
  10152. getAnimatables(): IAnimatable[];
  10153. /**
  10154. * Clone the current skeleton
  10155. * @param name defines the name of the new skeleton
  10156. * @param id defines the id of the new skeleton
  10157. * @returns the new skeleton
  10158. */
  10159. clone(name: string, id: string): Skeleton;
  10160. /**
  10161. * Enable animation blending for this skeleton
  10162. * @param blendingSpeed defines the blending speed to apply
  10163. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  10164. */
  10165. enableBlending(blendingSpeed?: number): void;
  10166. /**
  10167. * Releases all resources associated with the current skeleton
  10168. */
  10169. dispose(): void;
  10170. /**
  10171. * Serialize the skeleton in a JSON object
  10172. * @returns a JSON object
  10173. */
  10174. serialize(): any;
  10175. /**
  10176. * Creates a new skeleton from serialized data
  10177. * @param parsedSkeleton defines the serialized data
  10178. * @param scene defines the hosting scene
  10179. * @returns a new skeleton
  10180. */
  10181. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  10182. /**
  10183. * Compute all node absolute transforms
  10184. * @param forceUpdate defines if computation must be done even if cache is up to date
  10185. */
  10186. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  10187. /**
  10188. * Gets the root pose matrix
  10189. * @returns a matrix
  10190. */
  10191. getPoseMatrix(): Nullable<Matrix>;
  10192. /**
  10193. * Sorts bones per internal index
  10194. */
  10195. sortBones(): void;
  10196. private _sortBones;
  10197. }
  10198. }
  10199. declare module BABYLON {
  10200. /**
  10201. * Defines a target to use with MorphTargetManager
  10202. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  10203. */
  10204. export class MorphTarget implements IAnimatable {
  10205. /** defines the name of the target */
  10206. name: string;
  10207. /**
  10208. * Gets or sets the list of animations
  10209. */
  10210. animations: Animation[];
  10211. private _scene;
  10212. private _positions;
  10213. private _normals;
  10214. private _tangents;
  10215. private _uvs;
  10216. private _influence;
  10217. /**
  10218. * Observable raised when the influence changes
  10219. */
  10220. onInfluenceChanged: Observable<boolean>;
  10221. /** @hidden */
  10222. _onDataLayoutChanged: Observable<void>;
  10223. /**
  10224. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  10225. */
  10226. influence: number;
  10227. /**
  10228. * Gets or sets the id of the morph Target
  10229. */
  10230. id: string;
  10231. private _animationPropertiesOverride;
  10232. /**
  10233. * Gets or sets the animation properties override
  10234. */
  10235. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  10236. /**
  10237. * Creates a new MorphTarget
  10238. * @param name defines the name of the target
  10239. * @param influence defines the influence to use
  10240. * @param scene defines the scene the morphtarget belongs to
  10241. */
  10242. constructor(
  10243. /** defines the name of the target */
  10244. name: string, influence?: number, scene?: Nullable<Scene>);
  10245. /**
  10246. * Gets a boolean defining if the target contains position data
  10247. */
  10248. readonly hasPositions: boolean;
  10249. /**
  10250. * Gets a boolean defining if the target contains normal data
  10251. */
  10252. readonly hasNormals: boolean;
  10253. /**
  10254. * Gets a boolean defining if the target contains tangent data
  10255. */
  10256. readonly hasTangents: boolean;
  10257. /**
  10258. * Gets a boolean defining if the target contains texture coordinates data
  10259. */
  10260. readonly hasUVs: boolean;
  10261. /**
  10262. * Affects position data to this target
  10263. * @param data defines the position data to use
  10264. */
  10265. setPositions(data: Nullable<FloatArray>): void;
  10266. /**
  10267. * Gets the position data stored in this target
  10268. * @returns a FloatArray containing the position data (or null if not present)
  10269. */
  10270. getPositions(): Nullable<FloatArray>;
  10271. /**
  10272. * Affects normal data to this target
  10273. * @param data defines the normal data to use
  10274. */
  10275. setNormals(data: Nullable<FloatArray>): void;
  10276. /**
  10277. * Gets the normal data stored in this target
  10278. * @returns a FloatArray containing the normal data (or null if not present)
  10279. */
  10280. getNormals(): Nullable<FloatArray>;
  10281. /**
  10282. * Affects tangent data to this target
  10283. * @param data defines the tangent data to use
  10284. */
  10285. setTangents(data: Nullable<FloatArray>): void;
  10286. /**
  10287. * Gets the tangent data stored in this target
  10288. * @returns a FloatArray containing the tangent data (or null if not present)
  10289. */
  10290. getTangents(): Nullable<FloatArray>;
  10291. /**
  10292. * Affects texture coordinates data to this target
  10293. * @param data defines the texture coordinates data to use
  10294. */
  10295. setUVs(data: Nullable<FloatArray>): void;
  10296. /**
  10297. * Gets the texture coordinates data stored in this target
  10298. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  10299. */
  10300. getUVs(): Nullable<FloatArray>;
  10301. /**
  10302. * Serializes the current target into a Serialization object
  10303. * @returns the serialized object
  10304. */
  10305. serialize(): any;
  10306. /**
  10307. * Returns the string "MorphTarget"
  10308. * @returns "MorphTarget"
  10309. */
  10310. getClassName(): string;
  10311. /**
  10312. * Creates a new target from serialized data
  10313. * @param serializationObject defines the serialized data to use
  10314. * @returns a new MorphTarget
  10315. */
  10316. static Parse(serializationObject: any): MorphTarget;
  10317. /**
  10318. * Creates a MorphTarget from mesh data
  10319. * @param mesh defines the source mesh
  10320. * @param name defines the name to use for the new target
  10321. * @param influence defines the influence to attach to the target
  10322. * @returns a new MorphTarget
  10323. */
  10324. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  10325. }
  10326. }
  10327. declare module BABYLON {
  10328. /**
  10329. * This class is used to deform meshes using morphing between different targets
  10330. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  10331. */
  10332. export class MorphTargetManager {
  10333. private _targets;
  10334. private _targetInfluenceChangedObservers;
  10335. private _targetDataLayoutChangedObservers;
  10336. private _activeTargets;
  10337. private _scene;
  10338. private _influences;
  10339. private _supportsNormals;
  10340. private _supportsTangents;
  10341. private _supportsUVs;
  10342. private _vertexCount;
  10343. private _uniqueId;
  10344. private _tempInfluences;
  10345. /**
  10346. * Gets or sets a boolean indicating if normals must be morphed
  10347. */
  10348. enableNormalMorphing: boolean;
  10349. /**
  10350. * Gets or sets a boolean indicating if tangents must be morphed
  10351. */
  10352. enableTangentMorphing: boolean;
  10353. /**
  10354. * Gets or sets a boolean indicating if UV must be morphed
  10355. */
  10356. enableUVMorphing: boolean;
  10357. /**
  10358. * Creates a new MorphTargetManager
  10359. * @param scene defines the current scene
  10360. */
  10361. constructor(scene?: Nullable<Scene>);
  10362. /**
  10363. * Gets the unique ID of this manager
  10364. */
  10365. readonly uniqueId: number;
  10366. /**
  10367. * Gets the number of vertices handled by this manager
  10368. */
  10369. readonly vertexCount: number;
  10370. /**
  10371. * Gets a boolean indicating if this manager supports morphing of normals
  10372. */
  10373. readonly supportsNormals: boolean;
  10374. /**
  10375. * Gets a boolean indicating if this manager supports morphing of tangents
  10376. */
  10377. readonly supportsTangents: boolean;
  10378. /**
  10379. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  10380. */
  10381. readonly supportsUVs: boolean;
  10382. /**
  10383. * Gets the number of targets stored in this manager
  10384. */
  10385. readonly numTargets: number;
  10386. /**
  10387. * Gets the number of influencers (ie. the number of targets with influences > 0)
  10388. */
  10389. readonly numInfluencers: number;
  10390. /**
  10391. * Gets the list of influences (one per target)
  10392. */
  10393. readonly influences: Float32Array;
  10394. /**
  10395. * Gets the active target at specified index. An active target is a target with an influence > 0
  10396. * @param index defines the index to check
  10397. * @returns the requested target
  10398. */
  10399. getActiveTarget(index: number): MorphTarget;
  10400. /**
  10401. * Gets the target at specified index
  10402. * @param index defines the index to check
  10403. * @returns the requested target
  10404. */
  10405. getTarget(index: number): MorphTarget;
  10406. /**
  10407. * Add a new target to this manager
  10408. * @param target defines the target to add
  10409. */
  10410. addTarget(target: MorphTarget): void;
  10411. /**
  10412. * Removes a target from the manager
  10413. * @param target defines the target to remove
  10414. */
  10415. removeTarget(target: MorphTarget): void;
  10416. /**
  10417. * Serializes the current manager into a Serialization object
  10418. * @returns the serialized object
  10419. */
  10420. serialize(): any;
  10421. private _syncActiveTargets;
  10422. /**
  10423. * Syncrhonize the targets with all the meshes using this morph target manager
  10424. */
  10425. synchronize(): void;
  10426. /**
  10427. * Creates a new MorphTargetManager from serialized data
  10428. * @param serializationObject defines the serialized data
  10429. * @param scene defines the hosting scene
  10430. * @returns the new MorphTargetManager
  10431. */
  10432. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  10433. }
  10434. }
  10435. declare module BABYLON {
  10436. /**
  10437. * Groups all the scene component constants in one place to ease maintenance.
  10438. * @hidden
  10439. */
  10440. export class SceneComponentConstants {
  10441. static readonly NAME_EFFECTLAYER: string;
  10442. static readonly NAME_LAYER: string;
  10443. static readonly NAME_LENSFLARESYSTEM: string;
  10444. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10445. static readonly NAME_PARTICLESYSTEM: string;
  10446. static readonly NAME_GAMEPAD: string;
  10447. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10448. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10449. static readonly NAME_DEPTHRENDERER: string;
  10450. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10451. static readonly NAME_SPRITE: string;
  10452. static readonly NAME_OUTLINERENDERER: string;
  10453. static readonly NAME_PROCEDURALTEXTURE: string;
  10454. static readonly NAME_SHADOWGENERATOR: string;
  10455. static readonly NAME_OCTREE: string;
  10456. static readonly NAME_PHYSICSENGINE: string;
  10457. static readonly NAME_AUDIO: string;
  10458. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10459. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10460. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10461. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10462. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10463. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10464. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10465. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10466. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10467. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10468. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10469. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10470. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10471. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10472. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10473. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10474. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10475. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10476. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10477. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10478. static readonly STEP_AFTERRENDER_AUDIO: number;
  10479. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10480. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10481. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10482. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10483. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10484. static readonly STEP_POINTERMOVE_SPRITE: number;
  10485. static readonly STEP_POINTERDOWN_SPRITE: number;
  10486. static readonly STEP_POINTERUP_SPRITE: number;
  10487. }
  10488. /**
  10489. * This represents a scene component.
  10490. *
  10491. * This is used to decouple the dependency the scene is having on the different workloads like
  10492. * layers, post processes...
  10493. */
  10494. export interface ISceneComponent {
  10495. /**
  10496. * The name of the component. Each component must have a unique name.
  10497. */
  10498. name: string;
  10499. /**
  10500. * The scene the component belongs to.
  10501. */
  10502. scene: Scene;
  10503. /**
  10504. * Register the component to one instance of a scene.
  10505. */
  10506. register(): void;
  10507. /**
  10508. * Rebuilds the elements related to this component in case of
  10509. * context lost for instance.
  10510. */
  10511. rebuild(): void;
  10512. /**
  10513. * Disposes the component and the associated ressources.
  10514. */
  10515. dispose(): void;
  10516. }
  10517. /**
  10518. * This represents a SERIALIZABLE scene component.
  10519. *
  10520. * This extends Scene Component to add Serialization methods on top.
  10521. */
  10522. export interface ISceneSerializableComponent extends ISceneComponent {
  10523. /**
  10524. * Adds all the elements from the container to the scene
  10525. * @param container the container holding the elements
  10526. */
  10527. addFromContainer(container: AbstractScene): void;
  10528. /**
  10529. * Removes all the elements in the container from the scene
  10530. * @param container contains the elements to remove
  10531. * @param dispose if the removed element should be disposed (default: false)
  10532. */
  10533. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10534. /**
  10535. * Serializes the component data to the specified json object
  10536. * @param serializationObject The object to serialize to
  10537. */
  10538. serialize(serializationObject: any): void;
  10539. }
  10540. /**
  10541. * Strong typing of a Mesh related stage step action
  10542. */
  10543. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10544. /**
  10545. * Strong typing of a Evaluate Sub Mesh related stage step action
  10546. */
  10547. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10548. /**
  10549. * Strong typing of a Active Mesh related stage step action
  10550. */
  10551. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10552. /**
  10553. * Strong typing of a Camera related stage step action
  10554. */
  10555. export type CameraStageAction = (camera: Camera) => void;
  10556. /**
  10557. * Strong typing of a Camera Frame buffer related stage step action
  10558. */
  10559. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10560. /**
  10561. * Strong typing of a Render Target related stage step action
  10562. */
  10563. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10564. /**
  10565. * Strong typing of a RenderingGroup related stage step action
  10566. */
  10567. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10568. /**
  10569. * Strong typing of a Mesh Render related stage step action
  10570. */
  10571. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10572. /**
  10573. * Strong typing of a simple stage step action
  10574. */
  10575. export type SimpleStageAction = () => void;
  10576. /**
  10577. * Strong typing of a render target action.
  10578. */
  10579. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10580. /**
  10581. * Strong typing of a pointer move action.
  10582. */
  10583. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  10584. /**
  10585. * Strong typing of a pointer up/down action.
  10586. */
  10587. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10588. /**
  10589. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  10590. * @hidden
  10591. */
  10592. export class Stage<T extends Function> extends Array<{
  10593. index: number;
  10594. component: ISceneComponent;
  10595. action: T;
  10596. }> {
  10597. /**
  10598. * Hide ctor from the rest of the world.
  10599. * @param items The items to add.
  10600. */
  10601. private constructor();
  10602. /**
  10603. * Creates a new Stage.
  10604. * @returns A new instance of a Stage
  10605. */
  10606. static Create<T extends Function>(): Stage<T>;
  10607. /**
  10608. * Registers a step in an ordered way in the targeted stage.
  10609. * @param index Defines the position to register the step in
  10610. * @param component Defines the component attached to the step
  10611. * @param action Defines the action to launch during the step
  10612. */
  10613. registerStep(index: number, component: ISceneComponent, action: T): void;
  10614. /**
  10615. * Clears all the steps from the stage.
  10616. */
  10617. clear(): void;
  10618. }
  10619. }
  10620. declare module BABYLON {
  10621. /**
  10622. * Class used to represent a specific level of detail of a mesh
  10623. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  10624. */
  10625. export class MeshLODLevel {
  10626. /** Defines the distance where this level should star being displayed */
  10627. distance: number;
  10628. /** Defines the mesh to use to render this level */
  10629. mesh: Nullable<Mesh>;
  10630. /**
  10631. * Creates a new LOD level
  10632. * @param distance defines the distance where this level should star being displayed
  10633. * @param mesh defines the mesh to use to render this level
  10634. */
  10635. constructor(
  10636. /** Defines the distance where this level should star being displayed */
  10637. distance: number,
  10638. /** Defines the mesh to use to render this level */
  10639. mesh: Nullable<Mesh>);
  10640. }
  10641. }
  10642. declare module BABYLON {
  10643. /**
  10644. * Interface describing all the common properties and methods a shadow light needs to implement.
  10645. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  10646. * as well as binding the different shadow properties to the effects.
  10647. */
  10648. export interface IShadowLight extends Light {
  10649. /**
  10650. * The light id in the scene (used in scene.findLighById for instance)
  10651. */
  10652. id: string;
  10653. /**
  10654. * The position the shdow will be casted from.
  10655. */
  10656. position: Vector3;
  10657. /**
  10658. * In 2d mode (needCube being false), the direction used to cast the shadow.
  10659. */
  10660. direction: Vector3;
  10661. /**
  10662. * The transformed position. Position of the light in world space taking parenting in account.
  10663. */
  10664. transformedPosition: Vector3;
  10665. /**
  10666. * The transformed direction. Direction of the light in world space taking parenting in account.
  10667. */
  10668. transformedDirection: Vector3;
  10669. /**
  10670. * The friendly name of the light in the scene.
  10671. */
  10672. name: string;
  10673. /**
  10674. * Defines the shadow projection clipping minimum z value.
  10675. */
  10676. shadowMinZ: number;
  10677. /**
  10678. * Defines the shadow projection clipping maximum z value.
  10679. */
  10680. shadowMaxZ: number;
  10681. /**
  10682. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  10683. * @returns true if the information has been computed, false if it does not need to (no parenting)
  10684. */
  10685. computeTransformedInformation(): boolean;
  10686. /**
  10687. * Gets the scene the light belongs to.
  10688. * @returns The scene
  10689. */
  10690. getScene(): Scene;
  10691. /**
  10692. * Callback defining a custom Projection Matrix Builder.
  10693. * This can be used to override the default projection matrix computation.
  10694. */
  10695. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  10696. /**
  10697. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  10698. * @param matrix The materix to updated with the projection information
  10699. * @param viewMatrix The transform matrix of the light
  10700. * @param renderList The list of mesh to render in the map
  10701. * @returns The current light
  10702. */
  10703. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  10704. /**
  10705. * Gets the current depth scale used in ESM.
  10706. * @returns The scale
  10707. */
  10708. getDepthScale(): number;
  10709. /**
  10710. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  10711. * @returns true if a cube texture needs to be use
  10712. */
  10713. needCube(): boolean;
  10714. /**
  10715. * Detects if the projection matrix requires to be recomputed this frame.
  10716. * @returns true if it requires to be recomputed otherwise, false.
  10717. */
  10718. needProjectionMatrixCompute(): boolean;
  10719. /**
  10720. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  10721. */
  10722. forceProjectionMatrixCompute(): void;
  10723. /**
  10724. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  10725. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10726. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10727. */
  10728. getShadowDirection(faceIndex?: number): Vector3;
  10729. /**
  10730. * Gets the minZ used for shadow according to both the scene and the light.
  10731. * @param activeCamera The camera we are returning the min for
  10732. * @returns the depth min z
  10733. */
  10734. getDepthMinZ(activeCamera: Camera): number;
  10735. /**
  10736. * Gets the maxZ used for shadow according to both the scene and the light.
  10737. * @param activeCamera The camera we are returning the max for
  10738. * @returns the depth max z
  10739. */
  10740. getDepthMaxZ(activeCamera: Camera): number;
  10741. }
  10742. /**
  10743. * Base implementation IShadowLight
  10744. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  10745. */
  10746. export abstract class ShadowLight extends Light implements IShadowLight {
  10747. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  10748. protected _position: Vector3;
  10749. protected _setPosition(value: Vector3): void;
  10750. /**
  10751. * Sets the position the shadow will be casted from. Also use as the light position for both
  10752. * point and spot lights.
  10753. */
  10754. /**
  10755. * Sets the position the shadow will be casted from. Also use as the light position for both
  10756. * point and spot lights.
  10757. */
  10758. position: Vector3;
  10759. protected _direction: Vector3;
  10760. protected _setDirection(value: Vector3): void;
  10761. /**
  10762. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  10763. * Also use as the light direction on spot and directional lights.
  10764. */
  10765. /**
  10766. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  10767. * Also use as the light direction on spot and directional lights.
  10768. */
  10769. direction: Vector3;
  10770. private _shadowMinZ;
  10771. /**
  10772. * Gets the shadow projection clipping minimum z value.
  10773. */
  10774. /**
  10775. * Sets the shadow projection clipping minimum z value.
  10776. */
  10777. shadowMinZ: number;
  10778. private _shadowMaxZ;
  10779. /**
  10780. * Sets the shadow projection clipping maximum z value.
  10781. */
  10782. /**
  10783. * Gets the shadow projection clipping maximum z value.
  10784. */
  10785. shadowMaxZ: number;
  10786. /**
  10787. * Callback defining a custom Projection Matrix Builder.
  10788. * This can be used to override the default projection matrix computation.
  10789. */
  10790. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  10791. /**
  10792. * The transformed position. Position of the light in world space taking parenting in account.
  10793. */
  10794. transformedPosition: Vector3;
  10795. /**
  10796. * The transformed direction. Direction of the light in world space taking parenting in account.
  10797. */
  10798. transformedDirection: Vector3;
  10799. private _needProjectionMatrixCompute;
  10800. /**
  10801. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  10802. * @returns true if the information has been computed, false if it does not need to (no parenting)
  10803. */
  10804. computeTransformedInformation(): boolean;
  10805. /**
  10806. * Return the depth scale used for the shadow map.
  10807. * @returns the depth scale.
  10808. */
  10809. getDepthScale(): number;
  10810. /**
  10811. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  10812. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10813. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10814. */
  10815. getShadowDirection(faceIndex?: number): Vector3;
  10816. /**
  10817. * Returns the ShadowLight absolute position in the World.
  10818. * @returns the position vector in world space
  10819. */
  10820. getAbsolutePosition(): Vector3;
  10821. /**
  10822. * Sets the ShadowLight direction toward the passed target.
  10823. * @param target The point to target in local space
  10824. * @returns the updated ShadowLight direction
  10825. */
  10826. setDirectionToTarget(target: Vector3): Vector3;
  10827. /**
  10828. * Returns the light rotation in euler definition.
  10829. * @returns the x y z rotation in local space.
  10830. */
  10831. getRotation(): Vector3;
  10832. /**
  10833. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  10834. * @returns true if a cube texture needs to be use
  10835. */
  10836. needCube(): boolean;
  10837. /**
  10838. * Detects if the projection matrix requires to be recomputed this frame.
  10839. * @returns true if it requires to be recomputed otherwise, false.
  10840. */
  10841. needProjectionMatrixCompute(): boolean;
  10842. /**
  10843. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  10844. */
  10845. forceProjectionMatrixCompute(): void;
  10846. /** @hidden */
  10847. _initCache(): void;
  10848. /** @hidden */
  10849. _isSynchronized(): boolean;
  10850. /**
  10851. * Computes the world matrix of the node
  10852. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  10853. * @returns the world matrix
  10854. */
  10855. computeWorldMatrix(force?: boolean): Matrix;
  10856. /**
  10857. * Gets the minZ used for shadow according to both the scene and the light.
  10858. * @param activeCamera The camera we are returning the min for
  10859. * @returns the depth min z
  10860. */
  10861. getDepthMinZ(activeCamera: Camera): number;
  10862. /**
  10863. * Gets the maxZ used for shadow according to both the scene and the light.
  10864. * @param activeCamera The camera we are returning the max for
  10865. * @returns the depth max z
  10866. */
  10867. getDepthMaxZ(activeCamera: Camera): number;
  10868. /**
  10869. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  10870. * @param matrix The materix to updated with the projection information
  10871. * @param viewMatrix The transform matrix of the light
  10872. * @param renderList The list of mesh to render in the map
  10873. * @returns The current light
  10874. */
  10875. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  10876. }
  10877. }
  10878. declare module BABYLON {
  10879. /**
  10880. * "Static Class" containing the most commonly used helper while dealing with material for
  10881. * rendering purpose.
  10882. *
  10883. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  10884. *
  10885. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  10886. */
  10887. export class MaterialHelper {
  10888. /**
  10889. * Bind the current view position to an effect.
  10890. * @param effect The effect to be bound
  10891. * @param scene The scene the eyes position is used from
  10892. */
  10893. static BindEyePosition(effect: Effect, scene: Scene): void;
  10894. /**
  10895. * Helps preparing the defines values about the UVs in used in the effect.
  10896. * UVs are shared as much as we can accross channels in the shaders.
  10897. * @param texture The texture we are preparing the UVs for
  10898. * @param defines The defines to update
  10899. * @param key The channel key "diffuse", "specular"... used in the shader
  10900. */
  10901. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  10902. /**
  10903. * Binds a texture matrix value to its corrsponding uniform
  10904. * @param texture The texture to bind the matrix for
  10905. * @param uniformBuffer The uniform buffer receivin the data
  10906. * @param key The channel key "diffuse", "specular"... used in the shader
  10907. */
  10908. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  10909. /**
  10910. * Gets the current status of the fog (should it be enabled?)
  10911. * @param mesh defines the mesh to evaluate for fog support
  10912. * @param scene defines the hosting scene
  10913. * @returns true if fog must be enabled
  10914. */
  10915. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  10916. /**
  10917. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  10918. * @param mesh defines the current mesh
  10919. * @param scene defines the current scene
  10920. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  10921. * @param pointsCloud defines if point cloud rendering has to be turned on
  10922. * @param fogEnabled defines if fog has to be turned on
  10923. * @param alphaTest defines if alpha testing has to be turned on
  10924. * @param defines defines the current list of defines
  10925. */
  10926. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  10927. /**
  10928. * Helper used to prepare the list of defines associated with frame values for shader compilation
  10929. * @param scene defines the current scene
  10930. * @param engine defines the current engine
  10931. * @param defines specifies the list of active defines
  10932. * @param useInstances defines if instances have to be turned on
  10933. * @param useClipPlane defines if clip plane have to be turned on
  10934. */
  10935. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  10936. /**
  10937. * Prepares the defines for bones
  10938. * @param mesh The mesh containing the geometry data we will draw
  10939. * @param defines The defines to update
  10940. */
  10941. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  10942. /**
  10943. * Prepares the defines for morph targets
  10944. * @param mesh The mesh containing the geometry data we will draw
  10945. * @param defines The defines to update
  10946. */
  10947. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  10948. /**
  10949. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  10950. * @param mesh The mesh containing the geometry data we will draw
  10951. * @param defines The defines to update
  10952. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  10953. * @param useBones Precise whether bones should be used or not (override mesh info)
  10954. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  10955. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  10956. * @returns false if defines are considered not dirty and have not been checked
  10957. */
  10958. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  10959. /**
  10960. * Prepares the defines related to multiview
  10961. * @param scene The scene we are intending to draw
  10962. * @param defines The defines to update
  10963. */
  10964. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  10965. /**
  10966. * Prepares the defines related to the light information passed in parameter
  10967. * @param scene The scene we are intending to draw
  10968. * @param mesh The mesh the effect is compiling for
  10969. * @param light The light the effect is compiling for
  10970. * @param lightIndex The index of the light
  10971. * @param defines The defines to update
  10972. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  10973. * @param state Defines the current state regarding what is needed (normals, etc...)
  10974. */
  10975. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  10976. needNormals: boolean;
  10977. needRebuild: boolean;
  10978. shadowEnabled: boolean;
  10979. specularEnabled: boolean;
  10980. lightmapMode: boolean;
  10981. }): void;
  10982. /**
  10983. * Prepares the defines related to the light information passed in parameter
  10984. * @param scene The scene we are intending to draw
  10985. * @param mesh The mesh the effect is compiling for
  10986. * @param defines The defines to update
  10987. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  10988. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  10989. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  10990. * @returns true if normals will be required for the rest of the effect
  10991. */
  10992. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  10993. /**
  10994. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  10995. * @param lightIndex defines the light index
  10996. * @param uniformsList The uniform list
  10997. * @param samplersList The sampler list
  10998. * @param projectedLightTexture defines if projected texture must be used
  10999. * @param uniformBuffersList defines an optional list of uniform buffers
  11000. */
  11001. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  11002. /**
  11003. * Prepares the uniforms and samplers list to be used in the effect
  11004. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  11005. * @param samplersList The sampler list
  11006. * @param defines The defines helping in the list generation
  11007. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  11008. */
  11009. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  11010. /**
  11011. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  11012. * @param defines The defines to update while falling back
  11013. * @param fallbacks The authorized effect fallbacks
  11014. * @param maxSimultaneousLights The maximum number of lights allowed
  11015. * @param rank the current rank of the Effect
  11016. * @returns The newly affected rank
  11017. */
  11018. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  11019. private static _TmpMorphInfluencers;
  11020. /**
  11021. * Prepares the list of attributes required for morph targets according to the effect defines.
  11022. * @param attribs The current list of supported attribs
  11023. * @param mesh The mesh to prepare the morph targets attributes for
  11024. * @param influencers The number of influencers
  11025. */
  11026. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  11027. /**
  11028. * Prepares the list of attributes required for morph targets according to the effect defines.
  11029. * @param attribs The current list of supported attribs
  11030. * @param mesh The mesh to prepare the morph targets attributes for
  11031. * @param defines The current Defines of the effect
  11032. */
  11033. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  11034. /**
  11035. * Prepares the list of attributes required for bones according to the effect defines.
  11036. * @param attribs The current list of supported attribs
  11037. * @param mesh The mesh to prepare the bones attributes for
  11038. * @param defines The current Defines of the effect
  11039. * @param fallbacks The current efffect fallback strategy
  11040. */
  11041. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  11042. /**
  11043. * Check and prepare the list of attributes required for instances according to the effect defines.
  11044. * @param attribs The current list of supported attribs
  11045. * @param defines The current MaterialDefines of the effect
  11046. */
  11047. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  11048. /**
  11049. * Add the list of attributes required for instances to the attribs array.
  11050. * @param attribs The current list of supported attribs
  11051. */
  11052. static PushAttributesForInstances(attribs: string[]): void;
  11053. /**
  11054. * Binds the light shadow information to the effect for the given mesh.
  11055. * @param light The light containing the generator
  11056. * @param scene The scene the lights belongs to
  11057. * @param mesh The mesh we are binding the information to render
  11058. * @param lightIndex The light index in the effect used to render the mesh
  11059. * @param effect The effect we are binding the data to
  11060. */
  11061. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  11062. /**
  11063. * Binds the light information to the effect.
  11064. * @param light The light containing the generator
  11065. * @param effect The effect we are binding the data to
  11066. * @param lightIndex The light index in the effect used to render
  11067. */
  11068. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  11069. /**
  11070. * Binds the lights information from the scene to the effect for the given mesh.
  11071. * @param light Light to bind
  11072. * @param lightIndex Light index
  11073. * @param scene The scene where the light belongs to
  11074. * @param mesh The mesh we are binding the information to render
  11075. * @param effect The effect we are binding the data to
  11076. * @param useSpecular Defines if specular is supported
  11077. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  11078. */
  11079. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean): void;
  11080. /**
  11081. * Binds the lights information from the scene to the effect for the given mesh.
  11082. * @param scene The scene the lights belongs to
  11083. * @param mesh The mesh we are binding the information to render
  11084. * @param effect The effect we are binding the data to
  11085. * @param defines The generated defines for the effect
  11086. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  11087. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  11088. */
  11089. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  11090. private static _tempFogColor;
  11091. /**
  11092. * Binds the fog information from the scene to the effect for the given mesh.
  11093. * @param scene The scene the lights belongs to
  11094. * @param mesh The mesh we are binding the information to render
  11095. * @param effect The effect we are binding the data to
  11096. * @param linearSpace Defines if the fog effect is applied in linear space
  11097. */
  11098. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  11099. /**
  11100. * Binds the bones information from the mesh to the effect.
  11101. * @param mesh The mesh we are binding the information to render
  11102. * @param effect The effect we are binding the data to
  11103. */
  11104. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  11105. /**
  11106. * Binds the morph targets information from the mesh to the effect.
  11107. * @param abstractMesh The mesh we are binding the information to render
  11108. * @param effect The effect we are binding the data to
  11109. */
  11110. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  11111. /**
  11112. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  11113. * @param defines The generated defines used in the effect
  11114. * @param effect The effect we are binding the data to
  11115. * @param scene The scene we are willing to render with logarithmic scale for
  11116. */
  11117. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  11118. /**
  11119. * Binds the clip plane information from the scene to the effect.
  11120. * @param scene The scene the clip plane information are extracted from
  11121. * @param effect The effect we are binding the data to
  11122. */
  11123. static BindClipPlane(effect: Effect, scene: Scene): void;
  11124. }
  11125. }
  11126. declare module BABYLON {
  11127. /** @hidden */
  11128. export var packingFunctions: {
  11129. name: string;
  11130. shader: string;
  11131. };
  11132. }
  11133. declare module BABYLON {
  11134. /** @hidden */
  11135. export var shadowMapPixelShader: {
  11136. name: string;
  11137. shader: string;
  11138. };
  11139. }
  11140. declare module BABYLON {
  11141. /** @hidden */
  11142. export var bonesDeclaration: {
  11143. name: string;
  11144. shader: string;
  11145. };
  11146. }
  11147. declare module BABYLON {
  11148. /** @hidden */
  11149. export var morphTargetsVertexGlobalDeclaration: {
  11150. name: string;
  11151. shader: string;
  11152. };
  11153. }
  11154. declare module BABYLON {
  11155. /** @hidden */
  11156. export var morphTargetsVertexDeclaration: {
  11157. name: string;
  11158. shader: string;
  11159. };
  11160. }
  11161. declare module BABYLON {
  11162. /** @hidden */
  11163. export var instancesDeclaration: {
  11164. name: string;
  11165. shader: string;
  11166. };
  11167. }
  11168. declare module BABYLON {
  11169. /** @hidden */
  11170. export var helperFunctions: {
  11171. name: string;
  11172. shader: string;
  11173. };
  11174. }
  11175. declare module BABYLON {
  11176. /** @hidden */
  11177. export var morphTargetsVertex: {
  11178. name: string;
  11179. shader: string;
  11180. };
  11181. }
  11182. declare module BABYLON {
  11183. /** @hidden */
  11184. export var instancesVertex: {
  11185. name: string;
  11186. shader: string;
  11187. };
  11188. }
  11189. declare module BABYLON {
  11190. /** @hidden */
  11191. export var bonesVertex: {
  11192. name: string;
  11193. shader: string;
  11194. };
  11195. }
  11196. declare module BABYLON {
  11197. /** @hidden */
  11198. export var shadowMapVertexShader: {
  11199. name: string;
  11200. shader: string;
  11201. };
  11202. }
  11203. declare module BABYLON {
  11204. /** @hidden */
  11205. export var depthBoxBlurPixelShader: {
  11206. name: string;
  11207. shader: string;
  11208. };
  11209. }
  11210. declare module BABYLON {
  11211. /**
  11212. * Defines the options associated with the creation of a custom shader for a shadow generator.
  11213. */
  11214. export interface ICustomShaderOptions {
  11215. /**
  11216. * Gets or sets the custom shader name to use
  11217. */
  11218. shaderName: string;
  11219. /**
  11220. * The list of attribute names used in the shader
  11221. */
  11222. attributes?: string[];
  11223. /**
  11224. * The list of unifrom names used in the shader
  11225. */
  11226. uniforms?: string[];
  11227. /**
  11228. * The list of sampler names used in the shader
  11229. */
  11230. samplers?: string[];
  11231. /**
  11232. * The list of defines used in the shader
  11233. */
  11234. defines?: string[];
  11235. }
  11236. /**
  11237. * Interface to implement to create a shadow generator compatible with BJS.
  11238. */
  11239. export interface IShadowGenerator {
  11240. /**
  11241. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  11242. * @returns The render target texture if present otherwise, null
  11243. */
  11244. getShadowMap(): Nullable<RenderTargetTexture>;
  11245. /**
  11246. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  11247. * @returns The render target texture if the shadow map is present otherwise, null
  11248. */
  11249. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  11250. /**
  11251. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  11252. * @param subMesh The submesh we want to render in the shadow map
  11253. * @param useInstances Defines wether will draw in the map using instances
  11254. * @returns true if ready otherwise, false
  11255. */
  11256. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11257. /**
  11258. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  11259. * @param defines Defines of the material we want to update
  11260. * @param lightIndex Index of the light in the enabled light list of the material
  11261. */
  11262. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  11263. /**
  11264. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  11265. * defined in the generator but impacting the effect).
  11266. * It implies the unifroms available on the materials are the standard BJS ones.
  11267. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  11268. * @param effect The effect we are binfing the information for
  11269. */
  11270. bindShadowLight(lightIndex: string, effect: Effect): void;
  11271. /**
  11272. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  11273. * (eq to shadow prjection matrix * light transform matrix)
  11274. * @returns The transform matrix used to create the shadow map
  11275. */
  11276. getTransformMatrix(): Matrix;
  11277. /**
  11278. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  11279. * Cube and 2D textures for instance.
  11280. */
  11281. recreateShadowMap(): void;
  11282. /**
  11283. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11284. * @param onCompiled Callback triggered at the and of the effects compilation
  11285. * @param options Sets of optional options forcing the compilation with different modes
  11286. */
  11287. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  11288. useInstances: boolean;
  11289. }>): void;
  11290. /**
  11291. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11292. * @param options Sets of optional options forcing the compilation with different modes
  11293. * @returns A promise that resolves when the compilation completes
  11294. */
  11295. forceCompilationAsync(options?: Partial<{
  11296. useInstances: boolean;
  11297. }>): Promise<void>;
  11298. /**
  11299. * Serializes the shadow generator setup to a json object.
  11300. * @returns The serialized JSON object
  11301. */
  11302. serialize(): any;
  11303. /**
  11304. * Disposes the Shadow map and related Textures and effects.
  11305. */
  11306. dispose(): void;
  11307. }
  11308. /**
  11309. * Default implementation IShadowGenerator.
  11310. * This is the main object responsible of generating shadows in the framework.
  11311. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  11312. */
  11313. export class ShadowGenerator implements IShadowGenerator {
  11314. /**
  11315. * Shadow generator mode None: no filtering applied.
  11316. */
  11317. static readonly FILTER_NONE: number;
  11318. /**
  11319. * Shadow generator mode ESM: Exponential Shadow Mapping.
  11320. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11321. */
  11322. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  11323. /**
  11324. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  11325. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  11326. */
  11327. static readonly FILTER_POISSONSAMPLING: number;
  11328. /**
  11329. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  11330. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11331. */
  11332. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  11333. /**
  11334. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  11335. * edge artifacts on steep falloff.
  11336. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11337. */
  11338. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  11339. /**
  11340. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  11341. * edge artifacts on steep falloff.
  11342. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11343. */
  11344. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  11345. /**
  11346. * Shadow generator mode PCF: Percentage Closer Filtering
  11347. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  11348. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  11349. */
  11350. static readonly FILTER_PCF: number;
  11351. /**
  11352. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  11353. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  11354. * Contact Hardening
  11355. */
  11356. static readonly FILTER_PCSS: number;
  11357. /**
  11358. * Reserved for PCF and PCSS
  11359. * Highest Quality.
  11360. *
  11361. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  11362. *
  11363. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  11364. */
  11365. static readonly QUALITY_HIGH: number;
  11366. /**
  11367. * Reserved for PCF and PCSS
  11368. * Good tradeoff for quality/perf cross devices
  11369. *
  11370. * Execute PCF on a 3*3 kernel.
  11371. *
  11372. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  11373. */
  11374. static readonly QUALITY_MEDIUM: number;
  11375. /**
  11376. * Reserved for PCF and PCSS
  11377. * The lowest quality but the fastest.
  11378. *
  11379. * Execute PCF on a 1*1 kernel.
  11380. *
  11381. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  11382. */
  11383. static readonly QUALITY_LOW: number;
  11384. /** Gets or sets the custom shader name to use */
  11385. customShaderOptions: ICustomShaderOptions;
  11386. /**
  11387. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  11388. */
  11389. onBeforeShadowMapRenderObservable: Observable<Effect>;
  11390. /**
  11391. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  11392. */
  11393. onAfterShadowMapRenderObservable: Observable<Effect>;
  11394. /**
  11395. * Observable triggered before a mesh is rendered in the shadow map.
  11396. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  11397. */
  11398. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  11399. /**
  11400. * Observable triggered after a mesh is rendered in the shadow map.
  11401. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  11402. */
  11403. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  11404. private _bias;
  11405. /**
  11406. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  11407. */
  11408. /**
  11409. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  11410. */
  11411. bias: number;
  11412. private _normalBias;
  11413. /**
  11414. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  11415. */
  11416. /**
  11417. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  11418. */
  11419. normalBias: number;
  11420. private _blurBoxOffset;
  11421. /**
  11422. * Gets the blur box offset: offset applied during the blur pass.
  11423. * Only useful if useKernelBlur = false
  11424. */
  11425. /**
  11426. * Sets the blur box offset: offset applied during the blur pass.
  11427. * Only useful if useKernelBlur = false
  11428. */
  11429. blurBoxOffset: number;
  11430. private _blurScale;
  11431. /**
  11432. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  11433. * 2 means half of the size.
  11434. */
  11435. /**
  11436. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  11437. * 2 means half of the size.
  11438. */
  11439. blurScale: number;
  11440. private _blurKernel;
  11441. /**
  11442. * Gets the blur kernel: kernel size of the blur pass.
  11443. * Only useful if useKernelBlur = true
  11444. */
  11445. /**
  11446. * Sets the blur kernel: kernel size of the blur pass.
  11447. * Only useful if useKernelBlur = true
  11448. */
  11449. blurKernel: number;
  11450. private _useKernelBlur;
  11451. /**
  11452. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  11453. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  11454. */
  11455. /**
  11456. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  11457. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  11458. */
  11459. useKernelBlur: boolean;
  11460. private _depthScale;
  11461. /**
  11462. * Gets the depth scale used in ESM mode.
  11463. */
  11464. /**
  11465. * Sets the depth scale used in ESM mode.
  11466. * This can override the scale stored on the light.
  11467. */
  11468. depthScale: number;
  11469. private _filter;
  11470. /**
  11471. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  11472. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  11473. */
  11474. /**
  11475. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  11476. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  11477. */
  11478. filter: number;
  11479. /**
  11480. * Gets if the current filter is set to Poisson Sampling.
  11481. */
  11482. /**
  11483. * Sets the current filter to Poisson Sampling.
  11484. */
  11485. usePoissonSampling: boolean;
  11486. /**
  11487. * Gets if the current filter is set to ESM.
  11488. */
  11489. /**
  11490. * Sets the current filter is to ESM.
  11491. */
  11492. useExponentialShadowMap: boolean;
  11493. /**
  11494. * Gets if the current filter is set to filtered ESM.
  11495. */
  11496. /**
  11497. * Gets if the current filter is set to filtered ESM.
  11498. */
  11499. useBlurExponentialShadowMap: boolean;
  11500. /**
  11501. * Gets if the current filter is set to "close ESM" (using the inverse of the
  11502. * exponential to prevent steep falloff artifacts).
  11503. */
  11504. /**
  11505. * Sets the current filter to "close ESM" (using the inverse of the
  11506. * exponential to prevent steep falloff artifacts).
  11507. */
  11508. useCloseExponentialShadowMap: boolean;
  11509. /**
  11510. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  11511. * exponential to prevent steep falloff artifacts).
  11512. */
  11513. /**
  11514. * Sets the current filter to filtered "close ESM" (using the inverse of the
  11515. * exponential to prevent steep falloff artifacts).
  11516. */
  11517. useBlurCloseExponentialShadowMap: boolean;
  11518. /**
  11519. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  11520. */
  11521. /**
  11522. * Sets the current filter to "PCF" (percentage closer filtering).
  11523. */
  11524. usePercentageCloserFiltering: boolean;
  11525. private _filteringQuality;
  11526. /**
  11527. * Gets the PCF or PCSS Quality.
  11528. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  11529. */
  11530. /**
  11531. * Sets the PCF or PCSS Quality.
  11532. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  11533. */
  11534. filteringQuality: number;
  11535. /**
  11536. * Gets if the current filter is set to "PCSS" (contact hardening).
  11537. */
  11538. /**
  11539. * Sets the current filter to "PCSS" (contact hardening).
  11540. */
  11541. useContactHardeningShadow: boolean;
  11542. private _contactHardeningLightSizeUVRatio;
  11543. /**
  11544. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  11545. * Using a ratio helps keeping shape stability independently of the map size.
  11546. *
  11547. * It does not account for the light projection as it was having too much
  11548. * instability during the light setup or during light position changes.
  11549. *
  11550. * Only valid if useContactHardeningShadow is true.
  11551. */
  11552. /**
  11553. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  11554. * Using a ratio helps keeping shape stability independently of the map size.
  11555. *
  11556. * It does not account for the light projection as it was having too much
  11557. * instability during the light setup or during light position changes.
  11558. *
  11559. * Only valid if useContactHardeningShadow is true.
  11560. */
  11561. contactHardeningLightSizeUVRatio: number;
  11562. private _darkness;
  11563. /** Gets or sets the actual darkness of a shadow */
  11564. darkness: number;
  11565. /**
  11566. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  11567. * 0 means strongest and 1 would means no shadow.
  11568. * @returns the darkness.
  11569. */
  11570. getDarkness(): number;
  11571. /**
  11572. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  11573. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  11574. * @returns the shadow generator allowing fluent coding.
  11575. */
  11576. setDarkness(darkness: number): ShadowGenerator;
  11577. private _transparencyShadow;
  11578. /** Gets or sets the ability to have transparent shadow */
  11579. transparencyShadow: boolean;
  11580. /**
  11581. * Sets the ability to have transparent shadow (boolean).
  11582. * @param transparent True if transparent else False
  11583. * @returns the shadow generator allowing fluent coding
  11584. */
  11585. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  11586. private _shadowMap;
  11587. private _shadowMap2;
  11588. /**
  11589. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  11590. * @returns The render target texture if present otherwise, null
  11591. */
  11592. getShadowMap(): Nullable<RenderTargetTexture>;
  11593. /**
  11594. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  11595. * @returns The render target texture if the shadow map is present otherwise, null
  11596. */
  11597. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  11598. /**
  11599. * Gets the class name of that object
  11600. * @returns "ShadowGenerator"
  11601. */
  11602. getClassName(): string;
  11603. /**
  11604. * Helper function to add a mesh and its descendants to the list of shadow casters.
  11605. * @param mesh Mesh to add
  11606. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  11607. * @returns the Shadow Generator itself
  11608. */
  11609. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  11610. /**
  11611. * Helper function to remove a mesh and its descendants from the list of shadow casters
  11612. * @param mesh Mesh to remove
  11613. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  11614. * @returns the Shadow Generator itself
  11615. */
  11616. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  11617. /**
  11618. * Controls the extent to which the shadows fade out at the edge of the frustum
  11619. * Used only by directionals and spots
  11620. */
  11621. frustumEdgeFalloff: number;
  11622. private _light;
  11623. /**
  11624. * Returns the associated light object.
  11625. * @returns the light generating the shadow
  11626. */
  11627. getLight(): IShadowLight;
  11628. /**
  11629. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  11630. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  11631. * It might on the other hand introduce peter panning.
  11632. */
  11633. forceBackFacesOnly: boolean;
  11634. private _scene;
  11635. private _lightDirection;
  11636. private _effect;
  11637. private _viewMatrix;
  11638. private _projectionMatrix;
  11639. private _transformMatrix;
  11640. private _cachedPosition;
  11641. private _cachedDirection;
  11642. private _cachedDefines;
  11643. private _currentRenderID;
  11644. private _boxBlurPostprocess;
  11645. private _kernelBlurXPostprocess;
  11646. private _kernelBlurYPostprocess;
  11647. private _blurPostProcesses;
  11648. private _mapSize;
  11649. private _currentFaceIndex;
  11650. private _currentFaceIndexCache;
  11651. private _textureType;
  11652. private _defaultTextureMatrix;
  11653. /** @hidden */
  11654. static _SceneComponentInitialization: (scene: Scene) => void;
  11655. /**
  11656. * Creates a ShadowGenerator object.
  11657. * A ShadowGenerator is the required tool to use the shadows.
  11658. * Each light casting shadows needs to use its own ShadowGenerator.
  11659. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  11660. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  11661. * @param light The light object generating the shadows.
  11662. * @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.
  11663. */
  11664. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  11665. private _initializeGenerator;
  11666. private _initializeShadowMap;
  11667. private _initializeBlurRTTAndPostProcesses;
  11668. private _renderForShadowMap;
  11669. private _renderSubMeshForShadowMap;
  11670. private _applyFilterValues;
  11671. /**
  11672. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11673. * @param onCompiled Callback triggered at the and of the effects compilation
  11674. * @param options Sets of optional options forcing the compilation with different modes
  11675. */
  11676. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  11677. useInstances: boolean;
  11678. }>): void;
  11679. /**
  11680. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11681. * @param options Sets of optional options forcing the compilation with different modes
  11682. * @returns A promise that resolves when the compilation completes
  11683. */
  11684. forceCompilationAsync(options?: Partial<{
  11685. useInstances: boolean;
  11686. }>): Promise<void>;
  11687. /**
  11688. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  11689. * @param subMesh The submesh we want to render in the shadow map
  11690. * @param useInstances Defines wether will draw in the map using instances
  11691. * @returns true if ready otherwise, false
  11692. */
  11693. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11694. /**
  11695. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  11696. * @param defines Defines of the material we want to update
  11697. * @param lightIndex Index of the light in the enabled light list of the material
  11698. */
  11699. prepareDefines(defines: any, lightIndex: number): void;
  11700. /**
  11701. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  11702. * defined in the generator but impacting the effect).
  11703. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  11704. * @param effect The effect we are binfing the information for
  11705. */
  11706. bindShadowLight(lightIndex: string, effect: Effect): void;
  11707. /**
  11708. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  11709. * (eq to shadow prjection matrix * light transform matrix)
  11710. * @returns The transform matrix used to create the shadow map
  11711. */
  11712. getTransformMatrix(): Matrix;
  11713. /**
  11714. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  11715. * Cube and 2D textures for instance.
  11716. */
  11717. recreateShadowMap(): void;
  11718. private _disposeBlurPostProcesses;
  11719. private _disposeRTTandPostProcesses;
  11720. /**
  11721. * Disposes the ShadowGenerator.
  11722. * Returns nothing.
  11723. */
  11724. dispose(): void;
  11725. /**
  11726. * Serializes the shadow generator setup to a json object.
  11727. * @returns The serialized JSON object
  11728. */
  11729. serialize(): any;
  11730. /**
  11731. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  11732. * @param parsedShadowGenerator The JSON object to parse
  11733. * @param scene The scene to create the shadow map for
  11734. * @returns The parsed shadow generator
  11735. */
  11736. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  11737. }
  11738. }
  11739. declare module BABYLON {
  11740. /**
  11741. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  11742. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  11743. * 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.
  11744. */
  11745. export abstract class Light extends Node {
  11746. /**
  11747. * Falloff Default: light is falling off following the material specification:
  11748. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  11749. */
  11750. static readonly FALLOFF_DEFAULT: number;
  11751. /**
  11752. * Falloff Physical: light is falling off following the inverse squared distance law.
  11753. */
  11754. static readonly FALLOFF_PHYSICAL: number;
  11755. /**
  11756. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  11757. * to enhance interoperability with other engines.
  11758. */
  11759. static readonly FALLOFF_GLTF: number;
  11760. /**
  11761. * Falloff Standard: light is falling off like in the standard material
  11762. * to enhance interoperability with other materials.
  11763. */
  11764. static readonly FALLOFF_STANDARD: number;
  11765. /**
  11766. * If every light affecting the material is in this lightmapMode,
  11767. * material.lightmapTexture adds or multiplies
  11768. * (depends on material.useLightmapAsShadowmap)
  11769. * after every other light calculations.
  11770. */
  11771. static readonly LIGHTMAP_DEFAULT: number;
  11772. /**
  11773. * material.lightmapTexture as only diffuse lighting from this light
  11774. * adds only specular lighting from this light
  11775. * adds dynamic shadows
  11776. */
  11777. static readonly LIGHTMAP_SPECULAR: number;
  11778. /**
  11779. * material.lightmapTexture as only lighting
  11780. * no light calculation from this light
  11781. * only adds dynamic shadows from this light
  11782. */
  11783. static readonly LIGHTMAP_SHADOWSONLY: number;
  11784. /**
  11785. * Each light type uses the default quantity according to its type:
  11786. * point/spot lights use luminous intensity
  11787. * directional lights use illuminance
  11788. */
  11789. static readonly INTENSITYMODE_AUTOMATIC: number;
  11790. /**
  11791. * lumen (lm)
  11792. */
  11793. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  11794. /**
  11795. * candela (lm/sr)
  11796. */
  11797. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  11798. /**
  11799. * lux (lm/m^2)
  11800. */
  11801. static readonly INTENSITYMODE_ILLUMINANCE: number;
  11802. /**
  11803. * nit (cd/m^2)
  11804. */
  11805. static readonly INTENSITYMODE_LUMINANCE: number;
  11806. /**
  11807. * Light type const id of the point light.
  11808. */
  11809. static readonly LIGHTTYPEID_POINTLIGHT: number;
  11810. /**
  11811. * Light type const id of the directional light.
  11812. */
  11813. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  11814. /**
  11815. * Light type const id of the spot light.
  11816. */
  11817. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  11818. /**
  11819. * Light type const id of the hemispheric light.
  11820. */
  11821. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  11822. /**
  11823. * Diffuse gives the basic color to an object.
  11824. */
  11825. diffuse: Color3;
  11826. /**
  11827. * Specular produces a highlight color on an object.
  11828. * Note: This is note affecting PBR materials.
  11829. */
  11830. specular: Color3;
  11831. /**
  11832. * Defines the falloff type for this light. This lets overrriding how punctual light are
  11833. * falling off base on range or angle.
  11834. * This can be set to any values in Light.FALLOFF_x.
  11835. *
  11836. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  11837. * other types of materials.
  11838. */
  11839. falloffType: number;
  11840. /**
  11841. * Strength of the light.
  11842. * Note: By default it is define in the framework own unit.
  11843. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  11844. */
  11845. intensity: number;
  11846. private _range;
  11847. protected _inverseSquaredRange: number;
  11848. /**
  11849. * Defines how far from the source the light is impacting in scene units.
  11850. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  11851. */
  11852. /**
  11853. * Defines how far from the source the light is impacting in scene units.
  11854. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  11855. */
  11856. range: number;
  11857. /**
  11858. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  11859. * of light.
  11860. */
  11861. private _photometricScale;
  11862. private _intensityMode;
  11863. /**
  11864. * Gets the photometric scale used to interpret the intensity.
  11865. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  11866. */
  11867. /**
  11868. * Sets the photometric scale used to interpret the intensity.
  11869. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  11870. */
  11871. intensityMode: number;
  11872. private _radius;
  11873. /**
  11874. * Gets the light radius used by PBR Materials to simulate soft area lights.
  11875. */
  11876. /**
  11877. * sets the light radius used by PBR Materials to simulate soft area lights.
  11878. */
  11879. radius: number;
  11880. private _renderPriority;
  11881. /**
  11882. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  11883. * exceeding the number allowed of the materials.
  11884. */
  11885. renderPriority: number;
  11886. private _shadowEnabled;
  11887. /**
  11888. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  11889. * the current shadow generator.
  11890. */
  11891. /**
  11892. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  11893. * the current shadow generator.
  11894. */
  11895. shadowEnabled: boolean;
  11896. private _includedOnlyMeshes;
  11897. /**
  11898. * Gets the only meshes impacted by this light.
  11899. */
  11900. /**
  11901. * Sets the only meshes impacted by this light.
  11902. */
  11903. includedOnlyMeshes: AbstractMesh[];
  11904. private _excludedMeshes;
  11905. /**
  11906. * Gets the meshes not impacted by this light.
  11907. */
  11908. /**
  11909. * Sets the meshes not impacted by this light.
  11910. */
  11911. excludedMeshes: AbstractMesh[];
  11912. private _excludeWithLayerMask;
  11913. /**
  11914. * Gets the layer id use to find what meshes are not impacted by the light.
  11915. * Inactive if 0
  11916. */
  11917. /**
  11918. * Sets the layer id use to find what meshes are not impacted by the light.
  11919. * Inactive if 0
  11920. */
  11921. excludeWithLayerMask: number;
  11922. private _includeOnlyWithLayerMask;
  11923. /**
  11924. * Gets the layer id use to find what meshes are impacted by the light.
  11925. * Inactive if 0
  11926. */
  11927. /**
  11928. * Sets the layer id use to find what meshes are impacted by the light.
  11929. * Inactive if 0
  11930. */
  11931. includeOnlyWithLayerMask: number;
  11932. private _lightmapMode;
  11933. /**
  11934. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  11935. */
  11936. /**
  11937. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  11938. */
  11939. lightmapMode: number;
  11940. /**
  11941. * Shadow generator associted to the light.
  11942. * @hidden Internal use only.
  11943. */
  11944. _shadowGenerator: Nullable<IShadowGenerator>;
  11945. /**
  11946. * @hidden Internal use only.
  11947. */
  11948. _excludedMeshesIds: string[];
  11949. /**
  11950. * @hidden Internal use only.
  11951. */
  11952. _includedOnlyMeshesIds: string[];
  11953. /**
  11954. * The current light unifom buffer.
  11955. * @hidden Internal use only.
  11956. */
  11957. _uniformBuffer: UniformBuffer;
  11958. /**
  11959. * Creates a Light object in the scene.
  11960. * Documentation : https://doc.babylonjs.com/babylon101/lights
  11961. * @param name The firendly name of the light
  11962. * @param scene The scene the light belongs too
  11963. */
  11964. constructor(name: string, scene: Scene);
  11965. protected abstract _buildUniformLayout(): void;
  11966. /**
  11967. * Sets the passed Effect "effect" with the Light information.
  11968. * @param effect The effect to update
  11969. * @param lightIndex The index of the light in the effect to update
  11970. * @returns The light
  11971. */
  11972. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  11973. /**
  11974. * Returns the string "Light".
  11975. * @returns the class name
  11976. */
  11977. getClassName(): string;
  11978. /** @hidden */
  11979. readonly _isLight: boolean;
  11980. /**
  11981. * Converts the light information to a readable string for debug purpose.
  11982. * @param fullDetails Supports for multiple levels of logging within scene loading
  11983. * @returns the human readable light info
  11984. */
  11985. toString(fullDetails?: boolean): string;
  11986. /** @hidden */
  11987. protected _syncParentEnabledState(): void;
  11988. /**
  11989. * Set the enabled state of this node.
  11990. * @param value - the new enabled state
  11991. */
  11992. setEnabled(value: boolean): void;
  11993. /**
  11994. * Returns the Light associated shadow generator if any.
  11995. * @return the associated shadow generator.
  11996. */
  11997. getShadowGenerator(): Nullable<IShadowGenerator>;
  11998. /**
  11999. * Returns a Vector3, the absolute light position in the World.
  12000. * @returns the world space position of the light
  12001. */
  12002. getAbsolutePosition(): Vector3;
  12003. /**
  12004. * Specifies if the light will affect the passed mesh.
  12005. * @param mesh The mesh to test against the light
  12006. * @return true the mesh is affected otherwise, false.
  12007. */
  12008. canAffectMesh(mesh: AbstractMesh): boolean;
  12009. /**
  12010. * Sort function to order lights for rendering.
  12011. * @param a First Light object to compare to second.
  12012. * @param b Second Light object to compare first.
  12013. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  12014. */
  12015. static CompareLightsPriority(a: Light, b: Light): number;
  12016. /**
  12017. * Releases resources associated with this node.
  12018. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  12019. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  12020. */
  12021. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  12022. /**
  12023. * Returns the light type ID (integer).
  12024. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12025. */
  12026. getTypeID(): number;
  12027. /**
  12028. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  12029. * @returns the scaled intensity in intensity mode unit
  12030. */
  12031. getScaledIntensity(): number;
  12032. /**
  12033. * Returns a new Light object, named "name", from the current one.
  12034. * @param name The name of the cloned light
  12035. * @returns the new created light
  12036. */
  12037. clone(name: string): Nullable<Light>;
  12038. /**
  12039. * Serializes the current light into a Serialization object.
  12040. * @returns the serialized object.
  12041. */
  12042. serialize(): any;
  12043. /**
  12044. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  12045. * This new light is named "name" and added to the passed scene.
  12046. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  12047. * @param name The friendly name of the light
  12048. * @param scene The scene the new light will belong to
  12049. * @returns the constructor function
  12050. */
  12051. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  12052. /**
  12053. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  12054. * @param parsedLight The JSON representation of the light
  12055. * @param scene The scene to create the parsed light in
  12056. * @returns the created light after parsing
  12057. */
  12058. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  12059. private _hookArrayForExcluded;
  12060. private _hookArrayForIncludedOnly;
  12061. private _resyncMeshes;
  12062. /**
  12063. * Forces the meshes to update their light related information in their rendering used effects
  12064. * @hidden Internal Use Only
  12065. */
  12066. _markMeshesAsLightDirty(): void;
  12067. /**
  12068. * Recomputes the cached photometric scale if needed.
  12069. */
  12070. private _computePhotometricScale;
  12071. /**
  12072. * Returns the Photometric Scale according to the light type and intensity mode.
  12073. */
  12074. private _getPhotometricScale;
  12075. /**
  12076. * Reorder the light in the scene according to their defined priority.
  12077. * @hidden Internal Use Only
  12078. */
  12079. _reorderLightsInScene(): void;
  12080. /**
  12081. * Prepares the list of defines specific to the light type.
  12082. * @param defines the list of defines
  12083. * @param lightIndex defines the index of the light for the effect
  12084. */
  12085. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12086. }
  12087. }
  12088. declare module BABYLON {
  12089. /**
  12090. * Creates an instance based on a source mesh.
  12091. */
  12092. export class InstancedMesh extends AbstractMesh {
  12093. private _sourceMesh;
  12094. private _currentLOD;
  12095. /** @hidden */
  12096. _indexInSourceMeshInstanceArray: number;
  12097. constructor(name: string, source: Mesh);
  12098. /**
  12099. * Returns the string "InstancedMesh".
  12100. */
  12101. getClassName(): string;
  12102. /** Gets the list of lights affecting that mesh */
  12103. readonly lightSources: Light[];
  12104. _resyncLightSources(): void;
  12105. _resyncLighSource(light: Light): void;
  12106. _removeLightSource(light: Light): void;
  12107. /**
  12108. * If the source mesh receives shadows
  12109. */
  12110. readonly receiveShadows: boolean;
  12111. /**
  12112. * The material of the source mesh
  12113. */
  12114. readonly material: Nullable<Material>;
  12115. /**
  12116. * Visibility of the source mesh
  12117. */
  12118. readonly visibility: number;
  12119. /**
  12120. * Skeleton of the source mesh
  12121. */
  12122. readonly skeleton: Nullable<Skeleton>;
  12123. /**
  12124. * Rendering ground id of the source mesh
  12125. */
  12126. renderingGroupId: number;
  12127. /**
  12128. * Returns the total number of vertices (integer).
  12129. */
  12130. getTotalVertices(): number;
  12131. /**
  12132. * Returns a positive integer : the total number of indices in this mesh geometry.
  12133. * @returns the numner of indices or zero if the mesh has no geometry.
  12134. */
  12135. getTotalIndices(): number;
  12136. /**
  12137. * The source mesh of the instance
  12138. */
  12139. readonly sourceMesh: Mesh;
  12140. /**
  12141. * Is this node ready to be used/rendered
  12142. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  12143. * @return {boolean} is it ready
  12144. */
  12145. isReady(completeCheck?: boolean): boolean;
  12146. /**
  12147. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  12148. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  12149. * @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.
  12150. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  12151. */
  12152. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  12153. /**
  12154. * Sets the vertex data of the mesh geometry for the requested `kind`.
  12155. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  12156. * The `data` are either a numeric array either a Float32Array.
  12157. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  12158. * 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).
  12159. * Note that a new underlying VertexBuffer object is created each call.
  12160. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  12161. *
  12162. * Possible `kind` values :
  12163. * - VertexBuffer.PositionKind
  12164. * - VertexBuffer.UVKind
  12165. * - VertexBuffer.UV2Kind
  12166. * - VertexBuffer.UV3Kind
  12167. * - VertexBuffer.UV4Kind
  12168. * - VertexBuffer.UV5Kind
  12169. * - VertexBuffer.UV6Kind
  12170. * - VertexBuffer.ColorKind
  12171. * - VertexBuffer.MatricesIndicesKind
  12172. * - VertexBuffer.MatricesIndicesExtraKind
  12173. * - VertexBuffer.MatricesWeightsKind
  12174. * - VertexBuffer.MatricesWeightsExtraKind
  12175. *
  12176. * Returns the Mesh.
  12177. */
  12178. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  12179. /**
  12180. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  12181. * If the mesh has no geometry, it is simply returned as it is.
  12182. * The `data` are either a numeric array either a Float32Array.
  12183. * No new underlying VertexBuffer object is created.
  12184. * 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.
  12185. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  12186. *
  12187. * Possible `kind` values :
  12188. * - VertexBuffer.PositionKind
  12189. * - VertexBuffer.UVKind
  12190. * - VertexBuffer.UV2Kind
  12191. * - VertexBuffer.UV3Kind
  12192. * - VertexBuffer.UV4Kind
  12193. * - VertexBuffer.UV5Kind
  12194. * - VertexBuffer.UV6Kind
  12195. * - VertexBuffer.ColorKind
  12196. * - VertexBuffer.MatricesIndicesKind
  12197. * - VertexBuffer.MatricesIndicesExtraKind
  12198. * - VertexBuffer.MatricesWeightsKind
  12199. * - VertexBuffer.MatricesWeightsExtraKind
  12200. *
  12201. * Returns the Mesh.
  12202. */
  12203. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  12204. /**
  12205. * Sets the mesh indices.
  12206. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  12207. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  12208. * This method creates a new index buffer each call.
  12209. * Returns the Mesh.
  12210. */
  12211. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  12212. /**
  12213. * Boolean : True if the mesh owns the requested kind of data.
  12214. */
  12215. isVerticesDataPresent(kind: string): boolean;
  12216. /**
  12217. * Returns an array of indices (IndicesArray).
  12218. */
  12219. getIndices(): Nullable<IndicesArray>;
  12220. readonly _positions: Nullable<Vector3[]>;
  12221. /**
  12222. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  12223. * This means the mesh underlying bounding box and sphere are recomputed.
  12224. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  12225. * @returns the current mesh
  12226. */
  12227. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  12228. /** @hidden */
  12229. _preActivate(): InstancedMesh;
  12230. /** @hidden */
  12231. _activate(renderId: number, intermediateRendering: boolean): boolean;
  12232. /** @hidden */
  12233. _postActivate(): void;
  12234. getWorldMatrix(): Matrix;
  12235. readonly isAnInstance: boolean;
  12236. /**
  12237. * Returns the current associated LOD AbstractMesh.
  12238. */
  12239. getLOD(camera: Camera): AbstractMesh;
  12240. /** @hidden */
  12241. _syncSubMeshes(): InstancedMesh;
  12242. /** @hidden */
  12243. _generatePointsArray(): boolean;
  12244. /**
  12245. * Creates a new InstancedMesh from the current mesh.
  12246. * - name (string) : the cloned mesh name
  12247. * - newParent (optional Node) : the optional Node to parent the clone to.
  12248. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  12249. *
  12250. * Returns the clone.
  12251. */
  12252. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  12253. /**
  12254. * Disposes the InstancedMesh.
  12255. * Returns nothing.
  12256. */
  12257. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  12258. }
  12259. }
  12260. declare module BABYLON {
  12261. /**
  12262. * Defines the options associated with the creation of a shader material.
  12263. */
  12264. export interface IShaderMaterialOptions {
  12265. /**
  12266. * Does the material work in alpha blend mode
  12267. */
  12268. needAlphaBlending: boolean;
  12269. /**
  12270. * Does the material work in alpha test mode
  12271. */
  12272. needAlphaTesting: boolean;
  12273. /**
  12274. * The list of attribute names used in the shader
  12275. */
  12276. attributes: string[];
  12277. /**
  12278. * The list of unifrom names used in the shader
  12279. */
  12280. uniforms: string[];
  12281. /**
  12282. * The list of UBO names used in the shader
  12283. */
  12284. uniformBuffers: string[];
  12285. /**
  12286. * The list of sampler names used in the shader
  12287. */
  12288. samplers: string[];
  12289. /**
  12290. * The list of defines used in the shader
  12291. */
  12292. defines: string[];
  12293. }
  12294. /**
  12295. * 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.
  12296. *
  12297. * This returned material effects how the mesh will look based on the code in the shaders.
  12298. *
  12299. * @see http://doc.babylonjs.com/how_to/shader_material
  12300. */
  12301. export class ShaderMaterial extends Material {
  12302. private _shaderPath;
  12303. private _options;
  12304. private _textures;
  12305. private _textureArrays;
  12306. private _floats;
  12307. private _ints;
  12308. private _floatsArrays;
  12309. private _colors3;
  12310. private _colors3Arrays;
  12311. private _colors4;
  12312. private _colors4Arrays;
  12313. private _vectors2;
  12314. private _vectors3;
  12315. private _vectors4;
  12316. private _matrices;
  12317. private _matrices3x3;
  12318. private _matrices2x2;
  12319. private _vectors2Arrays;
  12320. private _vectors3Arrays;
  12321. private _vectors4Arrays;
  12322. private _cachedWorldViewMatrix;
  12323. private _cachedWorldViewProjectionMatrix;
  12324. private _renderId;
  12325. /**
  12326. * Instantiate a new shader material.
  12327. * 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.
  12328. * This returned material effects how the mesh will look based on the code in the shaders.
  12329. * @see http://doc.babylonjs.com/how_to/shader_material
  12330. * @param name Define the name of the material in the scene
  12331. * @param scene Define the scene the material belongs to
  12332. * @param shaderPath Defines the route to the shader code in one of three ways:
  12333. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  12334. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  12335. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  12336. * @param options Define the options used to create the shader
  12337. */
  12338. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  12339. /**
  12340. * Gets the options used to compile the shader.
  12341. * They can be modified to trigger a new compilation
  12342. */
  12343. readonly options: IShaderMaterialOptions;
  12344. /**
  12345. * Gets the current class name of the material e.g. "ShaderMaterial"
  12346. * Mainly use in serialization.
  12347. * @returns the class name
  12348. */
  12349. getClassName(): string;
  12350. /**
  12351. * Specifies if the material will require alpha blending
  12352. * @returns a boolean specifying if alpha blending is needed
  12353. */
  12354. needAlphaBlending(): boolean;
  12355. /**
  12356. * Specifies if this material should be rendered in alpha test mode
  12357. * @returns a boolean specifying if an alpha test is needed.
  12358. */
  12359. needAlphaTesting(): boolean;
  12360. private _checkUniform;
  12361. /**
  12362. * Set a texture in the shader.
  12363. * @param name Define the name of the uniform samplers as defined in the shader
  12364. * @param texture Define the texture to bind to this sampler
  12365. * @return the material itself allowing "fluent" like uniform updates
  12366. */
  12367. setTexture(name: string, texture: Texture): ShaderMaterial;
  12368. /**
  12369. * Set a texture array in the shader.
  12370. * @param name Define the name of the uniform sampler array as defined in the shader
  12371. * @param textures Define the list of textures to bind to this sampler
  12372. * @return the material itself allowing "fluent" like uniform updates
  12373. */
  12374. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  12375. /**
  12376. * Set a float in the shader.
  12377. * @param name Define the name of the uniform as defined in the shader
  12378. * @param value Define the value to give to the uniform
  12379. * @return the material itself allowing "fluent" like uniform updates
  12380. */
  12381. setFloat(name: string, value: number): ShaderMaterial;
  12382. /**
  12383. * Set a int in the shader.
  12384. * @param name Define the name of the uniform as defined in the shader
  12385. * @param value Define the value to give to the uniform
  12386. * @return the material itself allowing "fluent" like uniform updates
  12387. */
  12388. setInt(name: string, value: number): ShaderMaterial;
  12389. /**
  12390. * Set an array of floats in the shader.
  12391. * @param name Define the name of the uniform as defined in the shader
  12392. * @param value Define the value to give to the uniform
  12393. * @return the material itself allowing "fluent" like uniform updates
  12394. */
  12395. setFloats(name: string, value: number[]): ShaderMaterial;
  12396. /**
  12397. * Set a vec3 in the shader from a Color3.
  12398. * @param name Define the name of the uniform as defined in the shader
  12399. * @param value Define the value to give to the uniform
  12400. * @return the material itself allowing "fluent" like uniform updates
  12401. */
  12402. setColor3(name: string, value: Color3): ShaderMaterial;
  12403. /**
  12404. * Set a vec3 array in the shader from a Color3 array.
  12405. * @param name Define the name of the uniform as defined in the shader
  12406. * @param value Define the value to give to the uniform
  12407. * @return the material itself allowing "fluent" like uniform updates
  12408. */
  12409. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  12410. /**
  12411. * Set a vec4 in the shader from a Color4.
  12412. * @param name Define the name of the uniform as defined in the shader
  12413. * @param value Define the value to give to the uniform
  12414. * @return the material itself allowing "fluent" like uniform updates
  12415. */
  12416. setColor4(name: string, value: Color4): ShaderMaterial;
  12417. /**
  12418. * Set a vec4 array in the shader from a Color4 array.
  12419. * @param name Define the name of the uniform as defined in the shader
  12420. * @param value Define the value to give to the uniform
  12421. * @return the material itself allowing "fluent" like uniform updates
  12422. */
  12423. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  12424. /**
  12425. * Set a vec2 in the shader from a Vector2.
  12426. * @param name Define the name of the uniform as defined in the shader
  12427. * @param value Define the value to give to the uniform
  12428. * @return the material itself allowing "fluent" like uniform updates
  12429. */
  12430. setVector2(name: string, value: Vector2): ShaderMaterial;
  12431. /**
  12432. * Set a vec3 in the shader from a Vector3.
  12433. * @param name Define the name of the uniform as defined in the shader
  12434. * @param value Define the value to give to the uniform
  12435. * @return the material itself allowing "fluent" like uniform updates
  12436. */
  12437. setVector3(name: string, value: Vector3): ShaderMaterial;
  12438. /**
  12439. * Set a vec4 in the shader from a Vector4.
  12440. * @param name Define the name of the uniform as defined in the shader
  12441. * @param value Define the value to give to the uniform
  12442. * @return the material itself allowing "fluent" like uniform updates
  12443. */
  12444. setVector4(name: string, value: Vector4): ShaderMaterial;
  12445. /**
  12446. * Set a mat4 in the shader from a Matrix.
  12447. * @param name Define the name of the uniform as defined in the shader
  12448. * @param value Define the value to give to the uniform
  12449. * @return the material itself allowing "fluent" like uniform updates
  12450. */
  12451. setMatrix(name: string, value: Matrix): ShaderMaterial;
  12452. /**
  12453. * Set a mat3 in the shader from a Float32Array.
  12454. * @param name Define the name of the uniform as defined in the shader
  12455. * @param value Define the value to give to the uniform
  12456. * @return the material itself allowing "fluent" like uniform updates
  12457. */
  12458. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  12459. /**
  12460. * Set a mat2 in the shader from a Float32Array.
  12461. * @param name Define the name of the uniform as defined in the shader
  12462. * @param value Define the value to give to the uniform
  12463. * @return the material itself allowing "fluent" like uniform updates
  12464. */
  12465. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  12466. /**
  12467. * Set a vec2 array in the shader from a number array.
  12468. * @param name Define the name of the uniform as defined in the shader
  12469. * @param value Define the value to give to the uniform
  12470. * @return the material itself allowing "fluent" like uniform updates
  12471. */
  12472. setArray2(name: string, value: number[]): ShaderMaterial;
  12473. /**
  12474. * Set a vec3 array in the shader from a number array.
  12475. * @param name Define the name of the uniform as defined in the shader
  12476. * @param value Define the value to give to the uniform
  12477. * @return the material itself allowing "fluent" like uniform updates
  12478. */
  12479. setArray3(name: string, value: number[]): ShaderMaterial;
  12480. /**
  12481. * Set a vec4 array in the shader from a number array.
  12482. * @param name Define the name of the uniform as defined in the shader
  12483. * @param value Define the value to give to the uniform
  12484. * @return the material itself allowing "fluent" like uniform updates
  12485. */
  12486. setArray4(name: string, value: number[]): ShaderMaterial;
  12487. private _checkCache;
  12488. /**
  12489. * Specifies that the submesh is ready to be used
  12490. * @param mesh defines the mesh to check
  12491. * @param subMesh defines which submesh to check
  12492. * @param useInstances specifies that instances should be used
  12493. * @returns a boolean indicating that the submesh is ready or not
  12494. */
  12495. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  12496. /**
  12497. * Checks if the material is ready to render the requested mesh
  12498. * @param mesh Define the mesh to render
  12499. * @param useInstances Define whether or not the material is used with instances
  12500. * @returns true if ready, otherwise false
  12501. */
  12502. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  12503. /**
  12504. * Binds the world matrix to the material
  12505. * @param world defines the world transformation matrix
  12506. */
  12507. bindOnlyWorldMatrix(world: Matrix): void;
  12508. /**
  12509. * Binds the material to the mesh
  12510. * @param world defines the world transformation matrix
  12511. * @param mesh defines the mesh to bind the material to
  12512. */
  12513. bind(world: Matrix, mesh?: Mesh): void;
  12514. /**
  12515. * Gets the active textures from the material
  12516. * @returns an array of textures
  12517. */
  12518. getActiveTextures(): BaseTexture[];
  12519. /**
  12520. * Specifies if the material uses a texture
  12521. * @param texture defines the texture to check against the material
  12522. * @returns a boolean specifying if the material uses the texture
  12523. */
  12524. hasTexture(texture: BaseTexture): boolean;
  12525. /**
  12526. * Makes a duplicate of the material, and gives it a new name
  12527. * @param name defines the new name for the duplicated material
  12528. * @returns the cloned material
  12529. */
  12530. clone(name: string): ShaderMaterial;
  12531. /**
  12532. * Disposes the material
  12533. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  12534. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  12535. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  12536. */
  12537. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  12538. /**
  12539. * Serializes this material in a JSON representation
  12540. * @returns the serialized material object
  12541. */
  12542. serialize(): any;
  12543. /**
  12544. * Creates a shader material from parsed shader material data
  12545. * @param source defines the JSON represnetation of the material
  12546. * @param scene defines the hosting scene
  12547. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  12548. * @returns a new material
  12549. */
  12550. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  12551. }
  12552. }
  12553. declare module BABYLON {
  12554. /** @hidden */
  12555. export var clipPlaneFragmentDeclaration: {
  12556. name: string;
  12557. shader: string;
  12558. };
  12559. }
  12560. declare module BABYLON {
  12561. /** @hidden */
  12562. export var clipPlaneFragment: {
  12563. name: string;
  12564. shader: string;
  12565. };
  12566. }
  12567. declare module BABYLON {
  12568. /** @hidden */
  12569. export var colorPixelShader: {
  12570. name: string;
  12571. shader: string;
  12572. };
  12573. }
  12574. declare module BABYLON {
  12575. /** @hidden */
  12576. export var clipPlaneVertexDeclaration: {
  12577. name: string;
  12578. shader: string;
  12579. };
  12580. }
  12581. declare module BABYLON {
  12582. /** @hidden */
  12583. export var clipPlaneVertex: {
  12584. name: string;
  12585. shader: string;
  12586. };
  12587. }
  12588. declare module BABYLON {
  12589. /** @hidden */
  12590. export var colorVertexShader: {
  12591. name: string;
  12592. shader: string;
  12593. };
  12594. }
  12595. declare module BABYLON {
  12596. /**
  12597. * Line mesh
  12598. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  12599. */
  12600. export class LinesMesh extends Mesh {
  12601. /**
  12602. * If vertex color should be applied to the mesh
  12603. */
  12604. readonly useVertexColor?: boolean | undefined;
  12605. /**
  12606. * If vertex alpha should be applied to the mesh
  12607. */
  12608. readonly useVertexAlpha?: boolean | undefined;
  12609. /**
  12610. * Color of the line (Default: White)
  12611. */
  12612. color: Color3;
  12613. /**
  12614. * Alpha of the line (Default: 1)
  12615. */
  12616. alpha: number;
  12617. /**
  12618. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  12619. * This margin is expressed in world space coordinates, so its value may vary.
  12620. * Default value is 0.1
  12621. */
  12622. intersectionThreshold: number;
  12623. private _colorShader;
  12624. private color4;
  12625. /**
  12626. * Creates a new LinesMesh
  12627. * @param name defines the name
  12628. * @param scene defines the hosting scene
  12629. * @param parent defines the parent mesh if any
  12630. * @param source defines the optional source LinesMesh used to clone data from
  12631. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  12632. * When false, achieved by calling a clone(), also passing False.
  12633. * This will make creation of children, recursive.
  12634. * @param useVertexColor defines if this LinesMesh supports vertex color
  12635. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  12636. */
  12637. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  12638. /**
  12639. * If vertex color should be applied to the mesh
  12640. */
  12641. useVertexColor?: boolean | undefined,
  12642. /**
  12643. * If vertex alpha should be applied to the mesh
  12644. */
  12645. useVertexAlpha?: boolean | undefined);
  12646. private _addClipPlaneDefine;
  12647. private _removeClipPlaneDefine;
  12648. isReady(): boolean;
  12649. /**
  12650. * Returns the string "LineMesh"
  12651. */
  12652. getClassName(): string;
  12653. /**
  12654. * @hidden
  12655. */
  12656. /**
  12657. * @hidden
  12658. */
  12659. material: Material;
  12660. /**
  12661. * @hidden
  12662. */
  12663. readonly checkCollisions: boolean;
  12664. /** @hidden */
  12665. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  12666. /** @hidden */
  12667. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  12668. /**
  12669. * Disposes of the line mesh
  12670. * @param doNotRecurse If children should be disposed
  12671. */
  12672. dispose(doNotRecurse?: boolean): void;
  12673. /**
  12674. * Returns a new LineMesh object cloned from the current one.
  12675. */
  12676. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  12677. /**
  12678. * Creates a new InstancedLinesMesh object from the mesh model.
  12679. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  12680. * @param name defines the name of the new instance
  12681. * @returns a new InstancedLinesMesh
  12682. */
  12683. createInstance(name: string): InstancedLinesMesh;
  12684. }
  12685. /**
  12686. * Creates an instance based on a source LinesMesh
  12687. */
  12688. export class InstancedLinesMesh extends InstancedMesh {
  12689. /**
  12690. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  12691. * This margin is expressed in world space coordinates, so its value may vary.
  12692. * Initilized with the intersectionThreshold value of the source LinesMesh
  12693. */
  12694. intersectionThreshold: number;
  12695. constructor(name: string, source: LinesMesh);
  12696. /**
  12697. * Returns the string "InstancedLinesMesh".
  12698. */
  12699. getClassName(): string;
  12700. }
  12701. }
  12702. declare module BABYLON {
  12703. /**
  12704. * Mesh representing the gorund
  12705. */
  12706. export class GroundMesh extends Mesh {
  12707. /** If octree should be generated */
  12708. generateOctree: boolean;
  12709. private _heightQuads;
  12710. /** @hidden */
  12711. _subdivisionsX: number;
  12712. /** @hidden */
  12713. _subdivisionsY: number;
  12714. /** @hidden */
  12715. _width: number;
  12716. /** @hidden */
  12717. _height: number;
  12718. /** @hidden */
  12719. _minX: number;
  12720. /** @hidden */
  12721. _maxX: number;
  12722. /** @hidden */
  12723. _minZ: number;
  12724. /** @hidden */
  12725. _maxZ: number;
  12726. constructor(name: string, scene: Scene);
  12727. /**
  12728. * "GroundMesh"
  12729. * @returns "GroundMesh"
  12730. */
  12731. getClassName(): string;
  12732. /**
  12733. * The minimum of x and y subdivisions
  12734. */
  12735. readonly subdivisions: number;
  12736. /**
  12737. * X subdivisions
  12738. */
  12739. readonly subdivisionsX: number;
  12740. /**
  12741. * Y subdivisions
  12742. */
  12743. readonly subdivisionsY: number;
  12744. /**
  12745. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  12746. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  12747. * @param chunksCount the number of subdivisions for x and y
  12748. * @param octreeBlocksSize (Default: 32)
  12749. */
  12750. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  12751. /**
  12752. * Returns a height (y) value in the Worl system :
  12753. * the ground altitude at the coordinates (x, z) expressed in the World system.
  12754. * @param x x coordinate
  12755. * @param z z coordinate
  12756. * @returns the ground y position if (x, z) are outside the ground surface.
  12757. */
  12758. getHeightAtCoordinates(x: number, z: number): number;
  12759. /**
  12760. * Returns a normalized vector (Vector3) orthogonal to the ground
  12761. * at the ground coordinates (x, z) expressed in the World system.
  12762. * @param x x coordinate
  12763. * @param z z coordinate
  12764. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  12765. */
  12766. getNormalAtCoordinates(x: number, z: number): Vector3;
  12767. /**
  12768. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  12769. * at the ground coordinates (x, z) expressed in the World system.
  12770. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  12771. * @param x x coordinate
  12772. * @param z z coordinate
  12773. * @param ref vector to store the result
  12774. * @returns the GroundMesh.
  12775. */
  12776. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  12777. /**
  12778. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  12779. * if the ground has been updated.
  12780. * This can be used in the render loop.
  12781. * @returns the GroundMesh.
  12782. */
  12783. updateCoordinateHeights(): GroundMesh;
  12784. private _getFacetAt;
  12785. private _initHeightQuads;
  12786. private _computeHeightQuads;
  12787. /**
  12788. * Serializes this ground mesh
  12789. * @param serializationObject object to write serialization to
  12790. */
  12791. serialize(serializationObject: any): void;
  12792. /**
  12793. * Parses a serialized ground mesh
  12794. * @param parsedMesh the serialized mesh
  12795. * @param scene the scene to create the ground mesh in
  12796. * @returns the created ground mesh
  12797. */
  12798. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  12799. }
  12800. }
  12801. declare module BABYLON {
  12802. /**
  12803. * Interface for Physics-Joint data
  12804. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12805. */
  12806. export interface PhysicsJointData {
  12807. /**
  12808. * The main pivot of the joint
  12809. */
  12810. mainPivot?: Vector3;
  12811. /**
  12812. * The connected pivot of the joint
  12813. */
  12814. connectedPivot?: Vector3;
  12815. /**
  12816. * The main axis of the joint
  12817. */
  12818. mainAxis?: Vector3;
  12819. /**
  12820. * The connected axis of the joint
  12821. */
  12822. connectedAxis?: Vector3;
  12823. /**
  12824. * The collision of the joint
  12825. */
  12826. collision?: boolean;
  12827. /**
  12828. * Native Oimo/Cannon/Energy data
  12829. */
  12830. nativeParams?: any;
  12831. }
  12832. /**
  12833. * This is a holder class for the physics joint created by the physics plugin
  12834. * It holds a set of functions to control the underlying joint
  12835. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12836. */
  12837. export class PhysicsJoint {
  12838. /**
  12839. * The type of the physics joint
  12840. */
  12841. type: number;
  12842. /**
  12843. * The data for the physics joint
  12844. */
  12845. jointData: PhysicsJointData;
  12846. private _physicsJoint;
  12847. protected _physicsPlugin: IPhysicsEnginePlugin;
  12848. /**
  12849. * Initializes the physics joint
  12850. * @param type The type of the physics joint
  12851. * @param jointData The data for the physics joint
  12852. */
  12853. constructor(
  12854. /**
  12855. * The type of the physics joint
  12856. */
  12857. type: number,
  12858. /**
  12859. * The data for the physics joint
  12860. */
  12861. jointData: PhysicsJointData);
  12862. /**
  12863. * Gets the physics joint
  12864. */
  12865. /**
  12866. * Sets the physics joint
  12867. */
  12868. physicsJoint: any;
  12869. /**
  12870. * Sets the physics plugin
  12871. */
  12872. physicsPlugin: IPhysicsEnginePlugin;
  12873. /**
  12874. * Execute a function that is physics-plugin specific.
  12875. * @param {Function} func the function that will be executed.
  12876. * It accepts two parameters: the physics world and the physics joint
  12877. */
  12878. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  12879. /**
  12880. * Distance-Joint type
  12881. */
  12882. static DistanceJoint: number;
  12883. /**
  12884. * Hinge-Joint type
  12885. */
  12886. static HingeJoint: number;
  12887. /**
  12888. * Ball-and-Socket joint type
  12889. */
  12890. static BallAndSocketJoint: number;
  12891. /**
  12892. * Wheel-Joint type
  12893. */
  12894. static WheelJoint: number;
  12895. /**
  12896. * Slider-Joint type
  12897. */
  12898. static SliderJoint: number;
  12899. /**
  12900. * Prismatic-Joint type
  12901. */
  12902. static PrismaticJoint: number;
  12903. /**
  12904. * Universal-Joint type
  12905. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  12906. */
  12907. static UniversalJoint: number;
  12908. /**
  12909. * Hinge-Joint 2 type
  12910. */
  12911. static Hinge2Joint: number;
  12912. /**
  12913. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  12914. */
  12915. static PointToPointJoint: number;
  12916. /**
  12917. * Spring-Joint type
  12918. */
  12919. static SpringJoint: number;
  12920. /**
  12921. * Lock-Joint type
  12922. */
  12923. static LockJoint: number;
  12924. }
  12925. /**
  12926. * A class representing a physics distance joint
  12927. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12928. */
  12929. export class DistanceJoint extends PhysicsJoint {
  12930. /**
  12931. *
  12932. * @param jointData The data for the Distance-Joint
  12933. */
  12934. constructor(jointData: DistanceJointData);
  12935. /**
  12936. * Update the predefined distance.
  12937. * @param maxDistance The maximum preferred distance
  12938. * @param minDistance The minimum preferred distance
  12939. */
  12940. updateDistance(maxDistance: number, minDistance?: number): void;
  12941. }
  12942. /**
  12943. * Represents a Motor-Enabled Joint
  12944. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12945. */
  12946. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  12947. /**
  12948. * Initializes the Motor-Enabled Joint
  12949. * @param type The type of the joint
  12950. * @param jointData The physica joint data for the joint
  12951. */
  12952. constructor(type: number, jointData: PhysicsJointData);
  12953. /**
  12954. * Set the motor values.
  12955. * Attention, this function is plugin specific. Engines won't react 100% the same.
  12956. * @param force the force to apply
  12957. * @param maxForce max force for this motor.
  12958. */
  12959. setMotor(force?: number, maxForce?: number): void;
  12960. /**
  12961. * Set the motor's limits.
  12962. * Attention, this function is plugin specific. Engines won't react 100% the same.
  12963. * @param upperLimit The upper limit of the motor
  12964. * @param lowerLimit The lower limit of the motor
  12965. */
  12966. setLimit(upperLimit: number, lowerLimit?: number): void;
  12967. }
  12968. /**
  12969. * This class represents a single physics Hinge-Joint
  12970. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12971. */
  12972. export class HingeJoint extends MotorEnabledJoint {
  12973. /**
  12974. * Initializes the Hinge-Joint
  12975. * @param jointData The joint data for the Hinge-Joint
  12976. */
  12977. constructor(jointData: PhysicsJointData);
  12978. /**
  12979. * Set the motor values.
  12980. * Attention, this function is plugin specific. Engines won't react 100% the same.
  12981. * @param {number} force the force to apply
  12982. * @param {number} maxForce max force for this motor.
  12983. */
  12984. setMotor(force?: number, maxForce?: number): void;
  12985. /**
  12986. * Set the motor's limits.
  12987. * Attention, this function is plugin specific. Engines won't react 100% the same.
  12988. * @param upperLimit The upper limit of the motor
  12989. * @param lowerLimit The lower limit of the motor
  12990. */
  12991. setLimit(upperLimit: number, lowerLimit?: number): void;
  12992. }
  12993. /**
  12994. * This class represents a dual hinge physics joint (same as wheel joint)
  12995. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  12996. */
  12997. export class Hinge2Joint extends MotorEnabledJoint {
  12998. /**
  12999. * Initializes the Hinge2-Joint
  13000. * @param jointData The joint data for the Hinge2-Joint
  13001. */
  13002. constructor(jointData: PhysicsJointData);
  13003. /**
  13004. * Set the motor values.
  13005. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13006. * @param {number} targetSpeed the speed the motor is to reach
  13007. * @param {number} maxForce max force for this motor.
  13008. * @param {motorIndex} the motor's index, 0 or 1.
  13009. */
  13010. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  13011. /**
  13012. * Set the motor limits.
  13013. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13014. * @param {number} upperLimit the upper limit
  13015. * @param {number} lowerLimit lower limit
  13016. * @param {motorIndex} the motor's index, 0 or 1.
  13017. */
  13018. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  13019. }
  13020. /**
  13021. * Interface for a motor enabled joint
  13022. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13023. */
  13024. export interface IMotorEnabledJoint {
  13025. /**
  13026. * Physics joint
  13027. */
  13028. physicsJoint: any;
  13029. /**
  13030. * Sets the motor of the motor-enabled joint
  13031. * @param force The force of the motor
  13032. * @param maxForce The maximum force of the motor
  13033. * @param motorIndex The index of the motor
  13034. */
  13035. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  13036. /**
  13037. * Sets the limit of the motor
  13038. * @param upperLimit The upper limit of the motor
  13039. * @param lowerLimit The lower limit of the motor
  13040. * @param motorIndex The index of the motor
  13041. */
  13042. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  13043. }
  13044. /**
  13045. * Joint data for a Distance-Joint
  13046. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13047. */
  13048. export interface DistanceJointData extends PhysicsJointData {
  13049. /**
  13050. * Max distance the 2 joint objects can be apart
  13051. */
  13052. maxDistance: number;
  13053. }
  13054. /**
  13055. * Joint data from a spring joint
  13056. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13057. */
  13058. export interface SpringJointData extends PhysicsJointData {
  13059. /**
  13060. * Length of the spring
  13061. */
  13062. length: number;
  13063. /**
  13064. * Stiffness of the spring
  13065. */
  13066. stiffness: number;
  13067. /**
  13068. * Damping of the spring
  13069. */
  13070. damping: number;
  13071. /** this callback will be called when applying the force to the impostors. */
  13072. forceApplicationCallback: () => void;
  13073. }
  13074. }
  13075. declare module BABYLON {
  13076. /**
  13077. * Holds the data for the raycast result
  13078. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13079. */
  13080. export class PhysicsRaycastResult {
  13081. private _hasHit;
  13082. private _hitDistance;
  13083. private _hitNormalWorld;
  13084. private _hitPointWorld;
  13085. private _rayFromWorld;
  13086. private _rayToWorld;
  13087. /**
  13088. * Gets if there was a hit
  13089. */
  13090. readonly hasHit: boolean;
  13091. /**
  13092. * Gets the distance from the hit
  13093. */
  13094. readonly hitDistance: number;
  13095. /**
  13096. * Gets the hit normal/direction in the world
  13097. */
  13098. readonly hitNormalWorld: Vector3;
  13099. /**
  13100. * Gets the hit point in the world
  13101. */
  13102. readonly hitPointWorld: Vector3;
  13103. /**
  13104. * Gets the ray "start point" of the ray in the world
  13105. */
  13106. readonly rayFromWorld: Vector3;
  13107. /**
  13108. * Gets the ray "end point" of the ray in the world
  13109. */
  13110. readonly rayToWorld: Vector3;
  13111. /**
  13112. * Sets the hit data (normal & point in world space)
  13113. * @param hitNormalWorld defines the normal in world space
  13114. * @param hitPointWorld defines the point in world space
  13115. */
  13116. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  13117. /**
  13118. * Sets the distance from the start point to the hit point
  13119. * @param distance
  13120. */
  13121. setHitDistance(distance: number): void;
  13122. /**
  13123. * Calculates the distance manually
  13124. */
  13125. calculateHitDistance(): void;
  13126. /**
  13127. * Resets all the values to default
  13128. * @param from The from point on world space
  13129. * @param to The to point on world space
  13130. */
  13131. reset(from?: Vector3, to?: Vector3): void;
  13132. }
  13133. /**
  13134. * Interface for the size containing width and height
  13135. */
  13136. interface IXYZ {
  13137. /**
  13138. * X
  13139. */
  13140. x: number;
  13141. /**
  13142. * Y
  13143. */
  13144. y: number;
  13145. /**
  13146. * Z
  13147. */
  13148. z: number;
  13149. }
  13150. }
  13151. declare module BABYLON {
  13152. /**
  13153. * Interface used to describe a physics joint
  13154. */
  13155. export interface PhysicsImpostorJoint {
  13156. /** Defines the main impostor to which the joint is linked */
  13157. mainImpostor: PhysicsImpostor;
  13158. /** Defines the impostor that is connected to the main impostor using this joint */
  13159. connectedImpostor: PhysicsImpostor;
  13160. /** Defines the joint itself */
  13161. joint: PhysicsJoint;
  13162. }
  13163. /** @hidden */
  13164. export interface IPhysicsEnginePlugin {
  13165. world: any;
  13166. name: string;
  13167. setGravity(gravity: Vector3): void;
  13168. setTimeStep(timeStep: number): void;
  13169. getTimeStep(): number;
  13170. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  13171. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  13172. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  13173. generatePhysicsBody(impostor: PhysicsImpostor): void;
  13174. removePhysicsBody(impostor: PhysicsImpostor): void;
  13175. generateJoint(joint: PhysicsImpostorJoint): void;
  13176. removeJoint(joint: PhysicsImpostorJoint): void;
  13177. isSupported(): boolean;
  13178. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  13179. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  13180. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  13181. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  13182. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  13183. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  13184. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  13185. getBodyMass(impostor: PhysicsImpostor): number;
  13186. getBodyFriction(impostor: PhysicsImpostor): number;
  13187. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  13188. getBodyRestitution(impostor: PhysicsImpostor): number;
  13189. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  13190. getBodyPressure?(impostor: PhysicsImpostor): number;
  13191. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  13192. getBodyStiffness?(impostor: PhysicsImpostor): number;
  13193. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  13194. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  13195. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  13196. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  13197. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  13198. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  13199. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  13200. sleepBody(impostor: PhysicsImpostor): void;
  13201. wakeUpBody(impostor: PhysicsImpostor): void;
  13202. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  13203. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  13204. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  13205. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  13206. getRadius(impostor: PhysicsImpostor): number;
  13207. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  13208. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  13209. dispose(): void;
  13210. }
  13211. /**
  13212. * Interface used to define a physics engine
  13213. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  13214. */
  13215. export interface IPhysicsEngine {
  13216. /**
  13217. * Gets the gravity vector used by the simulation
  13218. */
  13219. gravity: Vector3;
  13220. /**
  13221. * Sets the gravity vector used by the simulation
  13222. * @param gravity defines the gravity vector to use
  13223. */
  13224. setGravity(gravity: Vector3): void;
  13225. /**
  13226. * Set the time step of the physics engine.
  13227. * Default is 1/60.
  13228. * To slow it down, enter 1/600 for example.
  13229. * To speed it up, 1/30
  13230. * @param newTimeStep the new timestep to apply to this world.
  13231. */
  13232. setTimeStep(newTimeStep: number): void;
  13233. /**
  13234. * Get the time step of the physics engine.
  13235. * @returns the current time step
  13236. */
  13237. getTimeStep(): number;
  13238. /**
  13239. * Release all resources
  13240. */
  13241. dispose(): void;
  13242. /**
  13243. * Gets the name of the current physics plugin
  13244. * @returns the name of the plugin
  13245. */
  13246. getPhysicsPluginName(): string;
  13247. /**
  13248. * Adding a new impostor for the impostor tracking.
  13249. * This will be done by the impostor itself.
  13250. * @param impostor the impostor to add
  13251. */
  13252. addImpostor(impostor: PhysicsImpostor): void;
  13253. /**
  13254. * Remove an impostor from the engine.
  13255. * This impostor and its mesh will not longer be updated by the physics engine.
  13256. * @param impostor the impostor to remove
  13257. */
  13258. removeImpostor(impostor: PhysicsImpostor): void;
  13259. /**
  13260. * Add a joint to the physics engine
  13261. * @param mainImpostor defines the main impostor to which the joint is added.
  13262. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  13263. * @param joint defines the joint that will connect both impostors.
  13264. */
  13265. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  13266. /**
  13267. * Removes a joint from the simulation
  13268. * @param mainImpostor defines the impostor used with the joint
  13269. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  13270. * @param joint defines the joint to remove
  13271. */
  13272. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  13273. /**
  13274. * Gets the current plugin used to run the simulation
  13275. * @returns current plugin
  13276. */
  13277. getPhysicsPlugin(): IPhysicsEnginePlugin;
  13278. /**
  13279. * Gets the list of physic impostors
  13280. * @returns an array of PhysicsImpostor
  13281. */
  13282. getImpostors(): Array<PhysicsImpostor>;
  13283. /**
  13284. * Gets the impostor for a physics enabled object
  13285. * @param object defines the object impersonated by the impostor
  13286. * @returns the PhysicsImpostor or null if not found
  13287. */
  13288. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  13289. /**
  13290. * Gets the impostor for a physics body object
  13291. * @param body defines physics body used by the impostor
  13292. * @returns the PhysicsImpostor or null if not found
  13293. */
  13294. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  13295. /**
  13296. * Does a raycast in the physics world
  13297. * @param from when should the ray start?
  13298. * @param to when should the ray end?
  13299. * @returns PhysicsRaycastResult
  13300. */
  13301. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  13302. /**
  13303. * Called by the scene. No need to call it.
  13304. * @param delta defines the timespam between frames
  13305. */
  13306. _step(delta: number): void;
  13307. }
  13308. }
  13309. declare module BABYLON {
  13310. /**
  13311. * The interface for the physics imposter parameters
  13312. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13313. */
  13314. export interface PhysicsImpostorParameters {
  13315. /**
  13316. * The mass of the physics imposter
  13317. */
  13318. mass: number;
  13319. /**
  13320. * The friction of the physics imposter
  13321. */
  13322. friction?: number;
  13323. /**
  13324. * The coefficient of restitution of the physics imposter
  13325. */
  13326. restitution?: number;
  13327. /**
  13328. * The native options of the physics imposter
  13329. */
  13330. nativeOptions?: any;
  13331. /**
  13332. * Specifies if the parent should be ignored
  13333. */
  13334. ignoreParent?: boolean;
  13335. /**
  13336. * Specifies if bi-directional transformations should be disabled
  13337. */
  13338. disableBidirectionalTransformation?: boolean;
  13339. /**
  13340. * The pressure inside the physics imposter, soft object only
  13341. */
  13342. pressure?: number;
  13343. /**
  13344. * The stiffness the physics imposter, soft object only
  13345. */
  13346. stiffness?: number;
  13347. /**
  13348. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  13349. */
  13350. velocityIterations?: number;
  13351. /**
  13352. * The number of iterations used in maintaining consistent vertex positions, soft object only
  13353. */
  13354. positionIterations?: number;
  13355. /**
  13356. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  13357. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  13358. * Add to fix multiple points
  13359. */
  13360. fixedPoints?: number;
  13361. /**
  13362. * The collision margin around a soft object
  13363. */
  13364. margin?: number;
  13365. /**
  13366. * The collision margin around a soft object
  13367. */
  13368. damping?: number;
  13369. /**
  13370. * The path for a rope based on an extrusion
  13371. */
  13372. path?: any;
  13373. /**
  13374. * The shape of an extrusion used for a rope based on an extrusion
  13375. */
  13376. shape?: any;
  13377. }
  13378. /**
  13379. * Interface for a physics-enabled object
  13380. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13381. */
  13382. export interface IPhysicsEnabledObject {
  13383. /**
  13384. * The position of the physics-enabled object
  13385. */
  13386. position: Vector3;
  13387. /**
  13388. * The rotation of the physics-enabled object
  13389. */
  13390. rotationQuaternion: Nullable<Quaternion>;
  13391. /**
  13392. * The scale of the physics-enabled object
  13393. */
  13394. scaling: Vector3;
  13395. /**
  13396. * The rotation of the physics-enabled object
  13397. */
  13398. rotation?: Vector3;
  13399. /**
  13400. * The parent of the physics-enabled object
  13401. */
  13402. parent?: any;
  13403. /**
  13404. * The bounding info of the physics-enabled object
  13405. * @returns The bounding info of the physics-enabled object
  13406. */
  13407. getBoundingInfo(): BoundingInfo;
  13408. /**
  13409. * Computes the world matrix
  13410. * @param force Specifies if the world matrix should be computed by force
  13411. * @returns A world matrix
  13412. */
  13413. computeWorldMatrix(force: boolean): Matrix;
  13414. /**
  13415. * Gets the world matrix
  13416. * @returns A world matrix
  13417. */
  13418. getWorldMatrix?(): Matrix;
  13419. /**
  13420. * Gets the child meshes
  13421. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  13422. * @returns An array of abstract meshes
  13423. */
  13424. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  13425. /**
  13426. * Gets the vertex data
  13427. * @param kind The type of vertex data
  13428. * @returns A nullable array of numbers, or a float32 array
  13429. */
  13430. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  13431. /**
  13432. * Gets the indices from the mesh
  13433. * @returns A nullable array of index arrays
  13434. */
  13435. getIndices?(): Nullable<IndicesArray>;
  13436. /**
  13437. * Gets the scene from the mesh
  13438. * @returns the indices array or null
  13439. */
  13440. getScene?(): Scene;
  13441. /**
  13442. * Gets the absolute position from the mesh
  13443. * @returns the absolute position
  13444. */
  13445. getAbsolutePosition(): Vector3;
  13446. /**
  13447. * Gets the absolute pivot point from the mesh
  13448. * @returns the absolute pivot point
  13449. */
  13450. getAbsolutePivotPoint(): Vector3;
  13451. /**
  13452. * Rotates the mesh
  13453. * @param axis The axis of rotation
  13454. * @param amount The amount of rotation
  13455. * @param space The space of the rotation
  13456. * @returns The rotation transform node
  13457. */
  13458. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13459. /**
  13460. * Translates the mesh
  13461. * @param axis The axis of translation
  13462. * @param distance The distance of translation
  13463. * @param space The space of the translation
  13464. * @returns The transform node
  13465. */
  13466. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  13467. /**
  13468. * Sets the absolute position of the mesh
  13469. * @param absolutePosition The absolute position of the mesh
  13470. * @returns The transform node
  13471. */
  13472. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13473. /**
  13474. * Gets the class name of the mesh
  13475. * @returns The class name
  13476. */
  13477. getClassName(): string;
  13478. }
  13479. /**
  13480. * Represents a physics imposter
  13481. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13482. */
  13483. export class PhysicsImpostor {
  13484. /**
  13485. * The physics-enabled object used as the physics imposter
  13486. */
  13487. object: IPhysicsEnabledObject;
  13488. /**
  13489. * The type of the physics imposter
  13490. */
  13491. type: number;
  13492. private _options;
  13493. private _scene?;
  13494. /**
  13495. * The default object size of the imposter
  13496. */
  13497. static DEFAULT_OBJECT_SIZE: Vector3;
  13498. /**
  13499. * The identity quaternion of the imposter
  13500. */
  13501. static IDENTITY_QUATERNION: Quaternion;
  13502. /** @hidden */
  13503. _pluginData: any;
  13504. private _physicsEngine;
  13505. private _physicsBody;
  13506. private _bodyUpdateRequired;
  13507. private _onBeforePhysicsStepCallbacks;
  13508. private _onAfterPhysicsStepCallbacks;
  13509. /** @hidden */
  13510. _onPhysicsCollideCallbacks: Array<{
  13511. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  13512. otherImpostors: Array<PhysicsImpostor>;
  13513. }>;
  13514. private _deltaPosition;
  13515. private _deltaRotation;
  13516. private _deltaRotationConjugated;
  13517. /** @hidden */
  13518. _isFromLine: boolean;
  13519. private _parent;
  13520. private _isDisposed;
  13521. private static _tmpVecs;
  13522. private static _tmpQuat;
  13523. /**
  13524. * Specifies if the physics imposter is disposed
  13525. */
  13526. readonly isDisposed: boolean;
  13527. /**
  13528. * Gets the mass of the physics imposter
  13529. */
  13530. mass: number;
  13531. /**
  13532. * Gets the coefficient of friction
  13533. */
  13534. /**
  13535. * Sets the coefficient of friction
  13536. */
  13537. friction: number;
  13538. /**
  13539. * Gets the coefficient of restitution
  13540. */
  13541. /**
  13542. * Sets the coefficient of restitution
  13543. */
  13544. restitution: number;
  13545. /**
  13546. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  13547. */
  13548. /**
  13549. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  13550. */
  13551. pressure: number;
  13552. /**
  13553. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  13554. */
  13555. /**
  13556. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  13557. */
  13558. stiffness: number;
  13559. /**
  13560. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  13561. */
  13562. /**
  13563. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  13564. */
  13565. velocityIterations: number;
  13566. /**
  13567. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  13568. */
  13569. /**
  13570. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  13571. */
  13572. positionIterations: number;
  13573. /**
  13574. * The unique id of the physics imposter
  13575. * set by the physics engine when adding this impostor to the array
  13576. */
  13577. uniqueId: number;
  13578. /**
  13579. * @hidden
  13580. */
  13581. soft: boolean;
  13582. /**
  13583. * @hidden
  13584. */
  13585. segments: number;
  13586. private _joints;
  13587. /**
  13588. * Initializes the physics imposter
  13589. * @param object The physics-enabled object used as the physics imposter
  13590. * @param type The type of the physics imposter
  13591. * @param _options The options for the physics imposter
  13592. * @param _scene The Babylon scene
  13593. */
  13594. constructor(
  13595. /**
  13596. * The physics-enabled object used as the physics imposter
  13597. */
  13598. object: IPhysicsEnabledObject,
  13599. /**
  13600. * The type of the physics imposter
  13601. */
  13602. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  13603. /**
  13604. * This function will completly initialize this impostor.
  13605. * It will create a new body - but only if this mesh has no parent.
  13606. * If it has, this impostor will not be used other than to define the impostor
  13607. * of the child mesh.
  13608. * @hidden
  13609. */
  13610. _init(): void;
  13611. private _getPhysicsParent;
  13612. /**
  13613. * Should a new body be generated.
  13614. * @returns boolean specifying if body initialization is required
  13615. */
  13616. isBodyInitRequired(): boolean;
  13617. /**
  13618. * Sets the updated scaling
  13619. * @param updated Specifies if the scaling is updated
  13620. */
  13621. setScalingUpdated(): void;
  13622. /**
  13623. * Force a regeneration of this or the parent's impostor's body.
  13624. * Use under cautious - This will remove all joints already implemented.
  13625. */
  13626. forceUpdate(): void;
  13627. /**
  13628. * Gets the body that holds this impostor. Either its own, or its parent.
  13629. */
  13630. /**
  13631. * Set the physics body. Used mainly by the physics engine/plugin
  13632. */
  13633. physicsBody: any;
  13634. /**
  13635. * Get the parent of the physics imposter
  13636. * @returns Physics imposter or null
  13637. */
  13638. /**
  13639. * Sets the parent of the physics imposter
  13640. */
  13641. parent: Nullable<PhysicsImpostor>;
  13642. /**
  13643. * Resets the update flags
  13644. */
  13645. resetUpdateFlags(): void;
  13646. /**
  13647. * Gets the object extend size
  13648. * @returns the object extend size
  13649. */
  13650. getObjectExtendSize(): Vector3;
  13651. /**
  13652. * Gets the object center
  13653. * @returns The object center
  13654. */
  13655. getObjectCenter(): Vector3;
  13656. /**
  13657. * Get a specific parametes from the options parameter
  13658. * @param paramName The object parameter name
  13659. * @returns The object parameter
  13660. */
  13661. getParam(paramName: string): any;
  13662. /**
  13663. * Sets a specific parameter in the options given to the physics plugin
  13664. * @param paramName The parameter name
  13665. * @param value The value of the parameter
  13666. */
  13667. setParam(paramName: string, value: number): void;
  13668. /**
  13669. * Specifically change the body's mass option. Won't recreate the physics body object
  13670. * @param mass The mass of the physics imposter
  13671. */
  13672. setMass(mass: number): void;
  13673. /**
  13674. * Gets the linear velocity
  13675. * @returns linear velocity or null
  13676. */
  13677. getLinearVelocity(): Nullable<Vector3>;
  13678. /**
  13679. * Sets the linear velocity
  13680. * @param velocity linear velocity or null
  13681. */
  13682. setLinearVelocity(velocity: Nullable<Vector3>): void;
  13683. /**
  13684. * Gets the angular velocity
  13685. * @returns angular velocity or null
  13686. */
  13687. getAngularVelocity(): Nullable<Vector3>;
  13688. /**
  13689. * Sets the angular velocity
  13690. * @param velocity The velocity or null
  13691. */
  13692. setAngularVelocity(velocity: Nullable<Vector3>): void;
  13693. /**
  13694. * Execute a function with the physics plugin native code
  13695. * Provide a function the will have two variables - the world object and the physics body object
  13696. * @param func The function to execute with the physics plugin native code
  13697. */
  13698. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  13699. /**
  13700. * Register a function that will be executed before the physics world is stepping forward
  13701. * @param func The function to execute before the physics world is stepped forward
  13702. */
  13703. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13704. /**
  13705. * Unregister a function that will be executed before the physics world is stepping forward
  13706. * @param func The function to execute before the physics world is stepped forward
  13707. */
  13708. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13709. /**
  13710. * Register a function that will be executed after the physics step
  13711. * @param func The function to execute after physics step
  13712. */
  13713. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13714. /**
  13715. * Unregisters a function that will be executed after the physics step
  13716. * @param func The function to execute after physics step
  13717. */
  13718. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13719. /**
  13720. * register a function that will be executed when this impostor collides against a different body
  13721. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  13722. * @param func Callback that is executed on collision
  13723. */
  13724. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  13725. /**
  13726. * Unregisters the physics imposter on contact
  13727. * @param collideAgainst The physics object to collide against
  13728. * @param func Callback to execute on collision
  13729. */
  13730. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  13731. private _tmpQuat;
  13732. private _tmpQuat2;
  13733. /**
  13734. * Get the parent rotation
  13735. * @returns The parent rotation
  13736. */
  13737. getParentsRotation(): Quaternion;
  13738. /**
  13739. * this function is executed by the physics engine.
  13740. */
  13741. beforeStep: () => void;
  13742. /**
  13743. * this function is executed by the physics engine
  13744. */
  13745. afterStep: () => void;
  13746. /**
  13747. * Legacy collision detection event support
  13748. */
  13749. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  13750. /**
  13751. * event and body object due to cannon's event-based architecture.
  13752. */
  13753. onCollide: (e: {
  13754. body: any;
  13755. }) => void;
  13756. /**
  13757. * Apply a force
  13758. * @param force The force to apply
  13759. * @param contactPoint The contact point for the force
  13760. * @returns The physics imposter
  13761. */
  13762. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  13763. /**
  13764. * Apply an impulse
  13765. * @param force The impulse force
  13766. * @param contactPoint The contact point for the impulse force
  13767. * @returns The physics imposter
  13768. */
  13769. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  13770. /**
  13771. * A help function to create a joint
  13772. * @param otherImpostor A physics imposter used to create a joint
  13773. * @param jointType The type of joint
  13774. * @param jointData The data for the joint
  13775. * @returns The physics imposter
  13776. */
  13777. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  13778. /**
  13779. * Add a joint to this impostor with a different impostor
  13780. * @param otherImpostor A physics imposter used to add a joint
  13781. * @param joint The joint to add
  13782. * @returns The physics imposter
  13783. */
  13784. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  13785. /**
  13786. * Add an anchor to a cloth impostor
  13787. * @param otherImpostor rigid impostor to anchor to
  13788. * @param width ratio across width from 0 to 1
  13789. * @param height ratio up height from 0 to 1
  13790. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  13791. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  13792. * @returns impostor the soft imposter
  13793. */
  13794. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  13795. /**
  13796. * Add a hook to a rope impostor
  13797. * @param otherImpostor rigid impostor to anchor to
  13798. * @param length ratio across rope from 0 to 1
  13799. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  13800. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  13801. * @returns impostor the rope imposter
  13802. */
  13803. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  13804. /**
  13805. * Will keep this body still, in a sleep mode.
  13806. * @returns the physics imposter
  13807. */
  13808. sleep(): PhysicsImpostor;
  13809. /**
  13810. * Wake the body up.
  13811. * @returns The physics imposter
  13812. */
  13813. wakeUp(): PhysicsImpostor;
  13814. /**
  13815. * Clones the physics imposter
  13816. * @param newObject The physics imposter clones to this physics-enabled object
  13817. * @returns A nullable physics imposter
  13818. */
  13819. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  13820. /**
  13821. * Disposes the physics imposter
  13822. */
  13823. dispose(): void;
  13824. /**
  13825. * Sets the delta position
  13826. * @param position The delta position amount
  13827. */
  13828. setDeltaPosition(position: Vector3): void;
  13829. /**
  13830. * Sets the delta rotation
  13831. * @param rotation The delta rotation amount
  13832. */
  13833. setDeltaRotation(rotation: Quaternion): void;
  13834. /**
  13835. * Gets the box size of the physics imposter and stores the result in the input parameter
  13836. * @param result Stores the box size
  13837. * @returns The physics imposter
  13838. */
  13839. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  13840. /**
  13841. * Gets the radius of the physics imposter
  13842. * @returns Radius of the physics imposter
  13843. */
  13844. getRadius(): number;
  13845. /**
  13846. * Sync a bone with this impostor
  13847. * @param bone The bone to sync to the impostor.
  13848. * @param boneMesh The mesh that the bone is influencing.
  13849. * @param jointPivot The pivot of the joint / bone in local space.
  13850. * @param distToJoint Optional distance from the impostor to the joint.
  13851. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  13852. */
  13853. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  13854. /**
  13855. * Sync impostor to a bone
  13856. * @param bone The bone that the impostor will be synced to.
  13857. * @param boneMesh The mesh that the bone is influencing.
  13858. * @param jointPivot The pivot of the joint / bone in local space.
  13859. * @param distToJoint Optional distance from the impostor to the joint.
  13860. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  13861. * @param boneAxis Optional vector3 axis the bone is aligned with
  13862. */
  13863. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  13864. /**
  13865. * No-Imposter type
  13866. */
  13867. static NoImpostor: number;
  13868. /**
  13869. * Sphere-Imposter type
  13870. */
  13871. static SphereImpostor: number;
  13872. /**
  13873. * Box-Imposter type
  13874. */
  13875. static BoxImpostor: number;
  13876. /**
  13877. * Plane-Imposter type
  13878. */
  13879. static PlaneImpostor: number;
  13880. /**
  13881. * Mesh-imposter type
  13882. */
  13883. static MeshImpostor: number;
  13884. /**
  13885. * Capsule-Impostor type (Ammo.js plugin only)
  13886. */
  13887. static CapsuleImpostor: number;
  13888. /**
  13889. * Cylinder-Imposter type
  13890. */
  13891. static CylinderImpostor: number;
  13892. /**
  13893. * Particle-Imposter type
  13894. */
  13895. static ParticleImpostor: number;
  13896. /**
  13897. * Heightmap-Imposter type
  13898. */
  13899. static HeightmapImpostor: number;
  13900. /**
  13901. * ConvexHull-Impostor type (Ammo.js plugin only)
  13902. */
  13903. static ConvexHullImpostor: number;
  13904. /**
  13905. * Rope-Imposter type
  13906. */
  13907. static RopeImpostor: number;
  13908. /**
  13909. * Cloth-Imposter type
  13910. */
  13911. static ClothImpostor: number;
  13912. /**
  13913. * Softbody-Imposter type
  13914. */
  13915. static SoftbodyImpostor: number;
  13916. }
  13917. }
  13918. declare module BABYLON {
  13919. /**
  13920. * @hidden
  13921. **/
  13922. export class _CreationDataStorage {
  13923. closePath?: boolean;
  13924. closeArray?: boolean;
  13925. idx: number[];
  13926. dashSize: number;
  13927. gapSize: number;
  13928. path3D: Path3D;
  13929. pathArray: Vector3[][];
  13930. arc: number;
  13931. radius: number;
  13932. cap: number;
  13933. tessellation: number;
  13934. }
  13935. /**
  13936. * @hidden
  13937. **/
  13938. class _InstanceDataStorage {
  13939. visibleInstances: any;
  13940. batchCache: _InstancesBatch;
  13941. instancesBufferSize: number;
  13942. instancesBuffer: Nullable<Buffer>;
  13943. instancesData: Float32Array;
  13944. overridenInstanceCount: number;
  13945. isFrozen: boolean;
  13946. previousBatch: Nullable<_InstancesBatch>;
  13947. hardwareInstancedRendering: boolean;
  13948. sideOrientation: number;
  13949. }
  13950. /**
  13951. * @hidden
  13952. **/
  13953. export class _InstancesBatch {
  13954. mustReturn: boolean;
  13955. visibleInstances: Nullable<InstancedMesh[]>[];
  13956. renderSelf: boolean[];
  13957. hardwareInstancedRendering: boolean[];
  13958. }
  13959. /**
  13960. * Class used to represent renderable models
  13961. */
  13962. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  13963. /**
  13964. * Mesh side orientation : usually the external or front surface
  13965. */
  13966. static readonly FRONTSIDE: number;
  13967. /**
  13968. * Mesh side orientation : usually the internal or back surface
  13969. */
  13970. static readonly BACKSIDE: number;
  13971. /**
  13972. * Mesh side orientation : both internal and external or front and back surfaces
  13973. */
  13974. static readonly DOUBLESIDE: number;
  13975. /**
  13976. * Mesh side orientation : by default, `FRONTSIDE`
  13977. */
  13978. static readonly DEFAULTSIDE: number;
  13979. /**
  13980. * Mesh cap setting : no cap
  13981. */
  13982. static readonly NO_CAP: number;
  13983. /**
  13984. * Mesh cap setting : one cap at the beginning of the mesh
  13985. */
  13986. static readonly CAP_START: number;
  13987. /**
  13988. * Mesh cap setting : one cap at the end of the mesh
  13989. */
  13990. static readonly CAP_END: number;
  13991. /**
  13992. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  13993. */
  13994. static readonly CAP_ALL: number;
  13995. /**
  13996. * Mesh pattern setting : no flip or rotate
  13997. */
  13998. static readonly NO_FLIP: number;
  13999. /**
  14000. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  14001. */
  14002. static readonly FLIP_TILE: number;
  14003. /**
  14004. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  14005. */
  14006. static readonly ROTATE_TILE: number;
  14007. /**
  14008. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  14009. */
  14010. static readonly FLIP_ROW: number;
  14011. /**
  14012. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  14013. */
  14014. static readonly ROTATE_ROW: number;
  14015. /**
  14016. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  14017. */
  14018. static readonly FLIP_N_ROTATE_TILE: number;
  14019. /**
  14020. * Mesh pattern setting : rotate pattern and rotate
  14021. */
  14022. static readonly FLIP_N_ROTATE_ROW: number;
  14023. /**
  14024. * Mesh tile positioning : part tiles same on left/right or top/bottom
  14025. */
  14026. static readonly CENTER: number;
  14027. /**
  14028. * Mesh tile positioning : part tiles on left
  14029. */
  14030. static readonly LEFT: number;
  14031. /**
  14032. * Mesh tile positioning : part tiles on right
  14033. */
  14034. static readonly RIGHT: number;
  14035. /**
  14036. * Mesh tile positioning : part tiles on top
  14037. */
  14038. static readonly TOP: number;
  14039. /**
  14040. * Mesh tile positioning : part tiles on bottom
  14041. */
  14042. static readonly BOTTOM: number;
  14043. /**
  14044. * Gets the default side orientation.
  14045. * @param orientation the orientation to value to attempt to get
  14046. * @returns the default orientation
  14047. * @hidden
  14048. */
  14049. static _GetDefaultSideOrientation(orientation?: number): number;
  14050. private _internalMeshDataInfo;
  14051. /**
  14052. * An event triggered before rendering the mesh
  14053. */
  14054. readonly onBeforeRenderObservable: Observable<Mesh>;
  14055. /**
  14056. * An event triggered before binding the mesh
  14057. */
  14058. readonly onBeforeBindObservable: Observable<Mesh>;
  14059. /**
  14060. * An event triggered after rendering the mesh
  14061. */
  14062. readonly onAfterRenderObservable: Observable<Mesh>;
  14063. /**
  14064. * An event triggered before drawing the mesh
  14065. */
  14066. readonly onBeforeDrawObservable: Observable<Mesh>;
  14067. private _onBeforeDrawObserver;
  14068. /**
  14069. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  14070. */
  14071. onBeforeDraw: () => void;
  14072. /**
  14073. * Gets the delay loading state of the mesh (when delay loading is turned on)
  14074. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  14075. */
  14076. delayLoadState: number;
  14077. /**
  14078. * Gets the list of instances created from this mesh
  14079. * it is not supposed to be modified manually.
  14080. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  14081. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  14082. */
  14083. instances: InstancedMesh[];
  14084. /**
  14085. * Gets the file containing delay loading data for this mesh
  14086. */
  14087. delayLoadingFile: string;
  14088. /** @hidden */
  14089. _binaryInfo: any;
  14090. /**
  14091. * User defined function used to change how LOD level selection is done
  14092. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  14093. */
  14094. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  14095. /**
  14096. * Gets or sets the morph target manager
  14097. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  14098. */
  14099. morphTargetManager: Nullable<MorphTargetManager>;
  14100. /** @hidden */
  14101. _creationDataStorage: Nullable<_CreationDataStorage>;
  14102. /** @hidden */
  14103. _geometry: Nullable<Geometry>;
  14104. /** @hidden */
  14105. _delayInfo: Array<string>;
  14106. /** @hidden */
  14107. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  14108. /** @hidden */
  14109. _instanceDataStorage: _InstanceDataStorage;
  14110. private _effectiveMaterial;
  14111. /** @hidden */
  14112. _shouldGenerateFlatShading: boolean;
  14113. /** @hidden */
  14114. _originalBuilderSideOrientation: number;
  14115. /**
  14116. * Use this property to change the original side orientation defined at construction time
  14117. */
  14118. overrideMaterialSideOrientation: Nullable<number>;
  14119. /**
  14120. * Gets the source mesh (the one used to clone this one from)
  14121. */
  14122. readonly source: Nullable<Mesh>;
  14123. /**
  14124. * Gets or sets a boolean indicating that this mesh does not use index buffer
  14125. */
  14126. isUnIndexed: boolean;
  14127. /**
  14128. * @constructor
  14129. * @param name The value used by scene.getMeshByName() to do a lookup.
  14130. * @param scene The scene to add this mesh to.
  14131. * @param parent The parent of this mesh, if it has one
  14132. * @param source An optional Mesh from which geometry is shared, cloned.
  14133. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  14134. * When false, achieved by calling a clone(), also passing False.
  14135. * This will make creation of children, recursive.
  14136. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  14137. */
  14138. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  14139. /**
  14140. * Gets the class name
  14141. * @returns the string "Mesh".
  14142. */
  14143. getClassName(): string;
  14144. /** @hidden */
  14145. readonly _isMesh: boolean;
  14146. /**
  14147. * Returns a description of this mesh
  14148. * @param fullDetails define if full details about this mesh must be used
  14149. * @returns a descriptive string representing this mesh
  14150. */
  14151. toString(fullDetails?: boolean): string;
  14152. /** @hidden */
  14153. _unBindEffect(): void;
  14154. /**
  14155. * Gets a boolean indicating if this mesh has LOD
  14156. */
  14157. readonly hasLODLevels: boolean;
  14158. /**
  14159. * Gets the list of MeshLODLevel associated with the current mesh
  14160. * @returns an array of MeshLODLevel
  14161. */
  14162. getLODLevels(): MeshLODLevel[];
  14163. private _sortLODLevels;
  14164. /**
  14165. * Add a mesh as LOD level triggered at the given distance.
  14166. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14167. * @param distance The distance from the center of the object to show this level
  14168. * @param mesh The mesh to be added as LOD level (can be null)
  14169. * @return This mesh (for chaining)
  14170. */
  14171. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  14172. /**
  14173. * Returns the LOD level mesh at the passed distance or null if not found.
  14174. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14175. * @param distance The distance from the center of the object to show this level
  14176. * @returns a Mesh or `null`
  14177. */
  14178. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  14179. /**
  14180. * Remove a mesh from the LOD array
  14181. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14182. * @param mesh defines the mesh to be removed
  14183. * @return This mesh (for chaining)
  14184. */
  14185. removeLODLevel(mesh: Mesh): Mesh;
  14186. /**
  14187. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  14188. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14189. * @param camera defines the camera to use to compute distance
  14190. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  14191. * @return This mesh (for chaining)
  14192. */
  14193. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  14194. /**
  14195. * Gets the mesh internal Geometry object
  14196. */
  14197. readonly geometry: Nullable<Geometry>;
  14198. /**
  14199. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  14200. * @returns the total number of vertices
  14201. */
  14202. getTotalVertices(): number;
  14203. /**
  14204. * Returns the content of an associated vertex buffer
  14205. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14206. * - VertexBuffer.PositionKind
  14207. * - VertexBuffer.UVKind
  14208. * - VertexBuffer.UV2Kind
  14209. * - VertexBuffer.UV3Kind
  14210. * - VertexBuffer.UV4Kind
  14211. * - VertexBuffer.UV5Kind
  14212. * - VertexBuffer.UV6Kind
  14213. * - VertexBuffer.ColorKind
  14214. * - VertexBuffer.MatricesIndicesKind
  14215. * - VertexBuffer.MatricesIndicesExtraKind
  14216. * - VertexBuffer.MatricesWeightsKind
  14217. * - VertexBuffer.MatricesWeightsExtraKind
  14218. * @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
  14219. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  14220. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  14221. */
  14222. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  14223. /**
  14224. * Returns the mesh VertexBuffer object from the requested `kind`
  14225. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14226. * - VertexBuffer.PositionKind
  14227. * - VertexBuffer.NormalKind
  14228. * - VertexBuffer.UVKind
  14229. * - VertexBuffer.UV2Kind
  14230. * - VertexBuffer.UV3Kind
  14231. * - VertexBuffer.UV4Kind
  14232. * - VertexBuffer.UV5Kind
  14233. * - VertexBuffer.UV6Kind
  14234. * - VertexBuffer.ColorKind
  14235. * - VertexBuffer.MatricesIndicesKind
  14236. * - VertexBuffer.MatricesIndicesExtraKind
  14237. * - VertexBuffer.MatricesWeightsKind
  14238. * - VertexBuffer.MatricesWeightsExtraKind
  14239. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  14240. */
  14241. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  14242. /**
  14243. * Tests if a specific vertex buffer is associated with this mesh
  14244. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  14245. * - VertexBuffer.PositionKind
  14246. * - VertexBuffer.NormalKind
  14247. * - VertexBuffer.UVKind
  14248. * - VertexBuffer.UV2Kind
  14249. * - VertexBuffer.UV3Kind
  14250. * - VertexBuffer.UV4Kind
  14251. * - VertexBuffer.UV5Kind
  14252. * - VertexBuffer.UV6Kind
  14253. * - VertexBuffer.ColorKind
  14254. * - VertexBuffer.MatricesIndicesKind
  14255. * - VertexBuffer.MatricesIndicesExtraKind
  14256. * - VertexBuffer.MatricesWeightsKind
  14257. * - VertexBuffer.MatricesWeightsExtraKind
  14258. * @returns a boolean
  14259. */
  14260. isVerticesDataPresent(kind: string): boolean;
  14261. /**
  14262. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  14263. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  14264. * - VertexBuffer.PositionKind
  14265. * - VertexBuffer.UVKind
  14266. * - VertexBuffer.UV2Kind
  14267. * - VertexBuffer.UV3Kind
  14268. * - VertexBuffer.UV4Kind
  14269. * - VertexBuffer.UV5Kind
  14270. * - VertexBuffer.UV6Kind
  14271. * - VertexBuffer.ColorKind
  14272. * - VertexBuffer.MatricesIndicesKind
  14273. * - VertexBuffer.MatricesIndicesExtraKind
  14274. * - VertexBuffer.MatricesWeightsKind
  14275. * - VertexBuffer.MatricesWeightsExtraKind
  14276. * @returns a boolean
  14277. */
  14278. isVertexBufferUpdatable(kind: string): boolean;
  14279. /**
  14280. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  14281. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14282. * - VertexBuffer.PositionKind
  14283. * - VertexBuffer.NormalKind
  14284. * - VertexBuffer.UVKind
  14285. * - VertexBuffer.UV2Kind
  14286. * - VertexBuffer.UV3Kind
  14287. * - VertexBuffer.UV4Kind
  14288. * - VertexBuffer.UV5Kind
  14289. * - VertexBuffer.UV6Kind
  14290. * - VertexBuffer.ColorKind
  14291. * - VertexBuffer.MatricesIndicesKind
  14292. * - VertexBuffer.MatricesIndicesExtraKind
  14293. * - VertexBuffer.MatricesWeightsKind
  14294. * - VertexBuffer.MatricesWeightsExtraKind
  14295. * @returns an array of strings
  14296. */
  14297. getVerticesDataKinds(): string[];
  14298. /**
  14299. * Returns a positive integer : the total number of indices in this mesh geometry.
  14300. * @returns the numner of indices or zero if the mesh has no geometry.
  14301. */
  14302. getTotalIndices(): number;
  14303. /**
  14304. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  14305. * @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.
  14306. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  14307. * @returns the indices array or an empty array if the mesh has no geometry
  14308. */
  14309. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  14310. readonly isBlocked: boolean;
  14311. /**
  14312. * Determine if the current mesh is ready to be rendered
  14313. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  14314. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  14315. * @returns true if all associated assets are ready (material, textures, shaders)
  14316. */
  14317. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  14318. /**
  14319. * 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.
  14320. */
  14321. readonly areNormalsFrozen: boolean;
  14322. /**
  14323. * 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.
  14324. * @returns the current mesh
  14325. */
  14326. freezeNormals(): Mesh;
  14327. /**
  14328. * 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
  14329. * @returns the current mesh
  14330. */
  14331. unfreezeNormals(): Mesh;
  14332. /**
  14333. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  14334. */
  14335. overridenInstanceCount: number;
  14336. /** @hidden */
  14337. _preActivate(): Mesh;
  14338. /** @hidden */
  14339. _preActivateForIntermediateRendering(renderId: number): Mesh;
  14340. /** @hidden */
  14341. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  14342. /**
  14343. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  14344. * This means the mesh underlying bounding box and sphere are recomputed.
  14345. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  14346. * @returns the current mesh
  14347. */
  14348. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  14349. /** @hidden */
  14350. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  14351. /**
  14352. * This function will subdivide the mesh into multiple submeshes
  14353. * @param count defines the expected number of submeshes
  14354. */
  14355. subdivide(count: number): void;
  14356. /**
  14357. * Copy a FloatArray into a specific associated vertex buffer
  14358. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  14359. * - VertexBuffer.PositionKind
  14360. * - VertexBuffer.UVKind
  14361. * - VertexBuffer.UV2Kind
  14362. * - VertexBuffer.UV3Kind
  14363. * - VertexBuffer.UV4Kind
  14364. * - VertexBuffer.UV5Kind
  14365. * - VertexBuffer.UV6Kind
  14366. * - VertexBuffer.ColorKind
  14367. * - VertexBuffer.MatricesIndicesKind
  14368. * - VertexBuffer.MatricesIndicesExtraKind
  14369. * - VertexBuffer.MatricesWeightsKind
  14370. * - VertexBuffer.MatricesWeightsExtraKind
  14371. * @param data defines the data source
  14372. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  14373. * @param stride defines the data stride size (can be null)
  14374. * @returns the current mesh
  14375. */
  14376. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  14377. /**
  14378. * Flags an associated vertex buffer as updatable
  14379. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  14380. * - VertexBuffer.PositionKind
  14381. * - VertexBuffer.UVKind
  14382. * - VertexBuffer.UV2Kind
  14383. * - VertexBuffer.UV3Kind
  14384. * - VertexBuffer.UV4Kind
  14385. * - VertexBuffer.UV5Kind
  14386. * - VertexBuffer.UV6Kind
  14387. * - VertexBuffer.ColorKind
  14388. * - VertexBuffer.MatricesIndicesKind
  14389. * - VertexBuffer.MatricesIndicesExtraKind
  14390. * - VertexBuffer.MatricesWeightsKind
  14391. * - VertexBuffer.MatricesWeightsExtraKind
  14392. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  14393. */
  14394. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  14395. /**
  14396. * Sets the mesh global Vertex Buffer
  14397. * @param buffer defines the buffer to use
  14398. * @returns the current mesh
  14399. */
  14400. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  14401. /**
  14402. * Update a specific associated vertex buffer
  14403. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  14404. * - VertexBuffer.PositionKind
  14405. * - VertexBuffer.UVKind
  14406. * - VertexBuffer.UV2Kind
  14407. * - VertexBuffer.UV3Kind
  14408. * - VertexBuffer.UV4Kind
  14409. * - VertexBuffer.UV5Kind
  14410. * - VertexBuffer.UV6Kind
  14411. * - VertexBuffer.ColorKind
  14412. * - VertexBuffer.MatricesIndicesKind
  14413. * - VertexBuffer.MatricesIndicesExtraKind
  14414. * - VertexBuffer.MatricesWeightsKind
  14415. * - VertexBuffer.MatricesWeightsExtraKind
  14416. * @param data defines the data source
  14417. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  14418. * @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)
  14419. * @returns the current mesh
  14420. */
  14421. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  14422. /**
  14423. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  14424. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  14425. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  14426. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  14427. * @returns the current mesh
  14428. */
  14429. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  14430. /**
  14431. * Creates a un-shared specific occurence of the geometry for the mesh.
  14432. * @returns the current mesh
  14433. */
  14434. makeGeometryUnique(): Mesh;
  14435. /**
  14436. * Set the index buffer of this mesh
  14437. * @param indices defines the source data
  14438. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  14439. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  14440. * @returns the current mesh
  14441. */
  14442. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  14443. /**
  14444. * Update the current index buffer
  14445. * @param indices defines the source data
  14446. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  14447. * @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)
  14448. * @returns the current mesh
  14449. */
  14450. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  14451. /**
  14452. * Invert the geometry to move from a right handed system to a left handed one.
  14453. * @returns the current mesh
  14454. */
  14455. toLeftHanded(): Mesh;
  14456. /** @hidden */
  14457. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  14458. /** @hidden */
  14459. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  14460. /**
  14461. * Registers for this mesh a javascript function called just before the rendering process
  14462. * @param func defines the function to call before rendering this mesh
  14463. * @returns the current mesh
  14464. */
  14465. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  14466. /**
  14467. * Disposes a previously registered javascript function called before the rendering
  14468. * @param func defines the function to remove
  14469. * @returns the current mesh
  14470. */
  14471. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  14472. /**
  14473. * Registers for this mesh a javascript function called just after the rendering is complete
  14474. * @param func defines the function to call after rendering this mesh
  14475. * @returns the current mesh
  14476. */
  14477. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  14478. /**
  14479. * Disposes a previously registered javascript function called after the rendering.
  14480. * @param func defines the function to remove
  14481. * @returns the current mesh
  14482. */
  14483. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  14484. /** @hidden */
  14485. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  14486. /** @hidden */
  14487. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  14488. /** @hidden */
  14489. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  14490. /** @hidden */
  14491. _rebuild(): void;
  14492. /** @hidden */
  14493. _freeze(): void;
  14494. /** @hidden */
  14495. _unFreeze(): void;
  14496. /**
  14497. * 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
  14498. * @param subMesh defines the subMesh to render
  14499. * @param enableAlphaMode defines if alpha mode can be changed
  14500. * @returns the current mesh
  14501. */
  14502. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  14503. private _onBeforeDraw;
  14504. /**
  14505. * Renormalize the mesh and patch it up if there are no weights
  14506. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  14507. * However in the case of zero weights then we set just a single influence to 1.
  14508. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  14509. */
  14510. cleanMatrixWeights(): void;
  14511. private normalizeSkinFourWeights;
  14512. private normalizeSkinWeightsAndExtra;
  14513. /**
  14514. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  14515. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  14516. * the user know there was an issue with importing the mesh
  14517. * @returns a validation object with skinned, valid and report string
  14518. */
  14519. validateSkinning(): {
  14520. skinned: boolean;
  14521. valid: boolean;
  14522. report: string;
  14523. };
  14524. /** @hidden */
  14525. _checkDelayState(): Mesh;
  14526. private _queueLoad;
  14527. /**
  14528. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  14529. * A mesh is in the frustum if its bounding box intersects the frustum
  14530. * @param frustumPlanes defines the frustum to test
  14531. * @returns true if the mesh is in the frustum planes
  14532. */
  14533. isInFrustum(frustumPlanes: Plane[]): boolean;
  14534. /**
  14535. * Sets the mesh material by the material or multiMaterial `id` property
  14536. * @param id is a string identifying the material or the multiMaterial
  14537. * @returns the current mesh
  14538. */
  14539. setMaterialByID(id: string): Mesh;
  14540. /**
  14541. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  14542. * @returns an array of IAnimatable
  14543. */
  14544. getAnimatables(): IAnimatable[];
  14545. /**
  14546. * Modifies the mesh geometry according to the passed transformation matrix.
  14547. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  14548. * The mesh normals are modified using the same transformation.
  14549. * Note that, under the hood, this method sets a new VertexBuffer each call.
  14550. * @param transform defines the transform matrix to use
  14551. * @see http://doc.babylonjs.com/resources/baking_transformations
  14552. * @returns the current mesh
  14553. */
  14554. bakeTransformIntoVertices(transform: Matrix): Mesh;
  14555. /**
  14556. * Modifies the mesh geometry according to its own current World Matrix.
  14557. * The mesh World Matrix is then reset.
  14558. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  14559. * Note that, under the hood, this method sets a new VertexBuffer each call.
  14560. * @see http://doc.babylonjs.com/resources/baking_transformations
  14561. * @returns the current mesh
  14562. */
  14563. bakeCurrentTransformIntoVertices(): Mesh;
  14564. /** @hidden */
  14565. readonly _positions: Nullable<Vector3[]>;
  14566. /** @hidden */
  14567. _resetPointsArrayCache(): Mesh;
  14568. /** @hidden */
  14569. _generatePointsArray(): boolean;
  14570. /**
  14571. * Returns a new Mesh object generated from the current mesh properties.
  14572. * This method must not get confused with createInstance()
  14573. * @param name is a string, the name given to the new mesh
  14574. * @param newParent can be any Node object (default `null`)
  14575. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  14576. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  14577. * @returns a new mesh
  14578. */
  14579. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  14580. /**
  14581. * Releases resources associated with this mesh.
  14582. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14583. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14584. */
  14585. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14586. /**
  14587. * Modifies the mesh geometry according to a displacement map.
  14588. * 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.
  14589. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  14590. * @param url is a string, the URL from the image file is to be downloaded.
  14591. * @param minHeight is the lower limit of the displacement.
  14592. * @param maxHeight is the upper limit of the displacement.
  14593. * @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.
  14594. * @param uvOffset is an optional vector2 used to offset UV.
  14595. * @param uvScale is an optional vector2 used to scale UV.
  14596. * @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.
  14597. * @returns the Mesh.
  14598. */
  14599. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  14600. /**
  14601. * Modifies the mesh geometry according to a displacementMap buffer.
  14602. * 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.
  14603. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  14604. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  14605. * @param heightMapWidth is the width of the buffer image.
  14606. * @param heightMapHeight is the height of the buffer image.
  14607. * @param minHeight is the lower limit of the displacement.
  14608. * @param maxHeight is the upper limit of the displacement.
  14609. * @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.
  14610. * @param uvOffset is an optional vector2 used to offset UV.
  14611. * @param uvScale is an optional vector2 used to scale UV.
  14612. * @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.
  14613. * @returns the Mesh.
  14614. */
  14615. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  14616. /**
  14617. * Modify the mesh to get a flat shading rendering.
  14618. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  14619. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  14620. * @returns current mesh
  14621. */
  14622. convertToFlatShadedMesh(): Mesh;
  14623. /**
  14624. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  14625. * In other words, more vertices, no more indices and a single bigger VBO.
  14626. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  14627. * @returns current mesh
  14628. */
  14629. convertToUnIndexedMesh(): Mesh;
  14630. /**
  14631. * Inverses facet orientations.
  14632. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14633. * @param flipNormals will also inverts the normals
  14634. * @returns current mesh
  14635. */
  14636. flipFaces(flipNormals?: boolean): Mesh;
  14637. /**
  14638. * Increase the number of facets and hence vertices in a mesh
  14639. * Vertex normals are interpolated from existing vertex normals
  14640. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14641. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  14642. */
  14643. increaseVertices(numberPerEdge: number): void;
  14644. /**
  14645. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  14646. * This will undo any application of covertToFlatShadedMesh
  14647. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14648. */
  14649. forceSharedVertices(): void;
  14650. /** @hidden */
  14651. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  14652. /** @hidden */
  14653. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  14654. /**
  14655. * Creates a new InstancedMesh object from the mesh model.
  14656. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  14657. * @param name defines the name of the new instance
  14658. * @returns a new InstancedMesh
  14659. */
  14660. createInstance(name: string): InstancedMesh;
  14661. /**
  14662. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  14663. * After this call, all the mesh instances have the same submeshes than the current mesh.
  14664. * @returns the current mesh
  14665. */
  14666. synchronizeInstances(): Mesh;
  14667. /**
  14668. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  14669. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  14670. * This should be used together with the simplification to avoid disappearing triangles.
  14671. * @param successCallback an optional success callback to be called after the optimization finished.
  14672. * @returns the current mesh
  14673. */
  14674. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  14675. /**
  14676. * Serialize current mesh
  14677. * @param serializationObject defines the object which will receive the serialization data
  14678. */
  14679. serialize(serializationObject: any): void;
  14680. /** @hidden */
  14681. _syncGeometryWithMorphTargetManager(): void;
  14682. /** @hidden */
  14683. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  14684. /**
  14685. * Returns a new Mesh object parsed from the source provided.
  14686. * @param parsedMesh is the source
  14687. * @param scene defines the hosting scene
  14688. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  14689. * @returns a new Mesh
  14690. */
  14691. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  14692. /**
  14693. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  14694. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  14695. * @param name defines the name of the mesh to create
  14696. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  14697. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  14698. * @param closePath creates a seam between the first and the last points of each path of the path array
  14699. * @param offset is taken in account only if the `pathArray` is containing a single path
  14700. * @param scene defines the hosting scene
  14701. * @param updatable defines if the mesh must be flagged as updatable
  14702. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14703. * @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)
  14704. * @returns a new Mesh
  14705. */
  14706. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  14707. /**
  14708. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  14709. * @param name defines the name of the mesh to create
  14710. * @param radius sets the radius size (float) of the polygon (default 0.5)
  14711. * @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
  14712. * @param scene defines the hosting scene
  14713. * @param updatable defines if the mesh must be flagged as updatable
  14714. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14715. * @returns a new Mesh
  14716. */
  14717. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  14718. /**
  14719. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  14720. * @param name defines the name of the mesh to create
  14721. * @param size sets the size (float) of each box side (default 1)
  14722. * @param scene defines the hosting scene
  14723. * @param updatable defines if the mesh must be flagged as updatable
  14724. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14725. * @returns a new Mesh
  14726. */
  14727. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  14728. /**
  14729. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  14730. * @param name defines the name of the mesh to create
  14731. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  14732. * @param diameter sets the diameter size (float) of the sphere (default 1)
  14733. * @param scene defines the hosting scene
  14734. * @param updatable defines if the mesh must be flagged as updatable
  14735. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14736. * @returns a new Mesh
  14737. */
  14738. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  14739. /**
  14740. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  14741. * @param name defines the name of the mesh to create
  14742. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  14743. * @param diameter sets the diameter size (float) of the sphere (default 1)
  14744. * @param scene defines the hosting scene
  14745. * @returns a new Mesh
  14746. */
  14747. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  14748. /**
  14749. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  14750. * @param name defines the name of the mesh to create
  14751. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  14752. * @param diameterTop set the top cap diameter (floats, default 1)
  14753. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  14754. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  14755. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  14756. * @param scene defines the hosting scene
  14757. * @param updatable defines if the mesh must be flagged as updatable
  14758. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14759. * @returns a new Mesh
  14760. */
  14761. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  14762. /**
  14763. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  14764. * @param name defines the name of the mesh to create
  14765. * @param diameter sets the diameter size (float) of the torus (default 1)
  14766. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  14767. * @param tessellation sets the number of torus sides (postive integer, default 16)
  14768. * @param scene defines the hosting scene
  14769. * @param updatable defines if the mesh must be flagged as updatable
  14770. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14771. * @returns a new Mesh
  14772. */
  14773. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  14774. /**
  14775. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  14776. * @param name defines the name of the mesh to create
  14777. * @param radius sets the global radius size (float) of the torus knot (default 2)
  14778. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  14779. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  14780. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  14781. * @param p the number of windings on X axis (positive integers, default 2)
  14782. * @param q the number of windings on Y axis (positive integers, default 3)
  14783. * @param scene defines the hosting scene
  14784. * @param updatable defines if the mesh must be flagged as updatable
  14785. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14786. * @returns a new Mesh
  14787. */
  14788. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  14789. /**
  14790. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  14791. * @param name defines the name of the mesh to create
  14792. * @param points is an array successive Vector3
  14793. * @param scene defines the hosting scene
  14794. * @param updatable defines if the mesh must be flagged as updatable
  14795. * @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).
  14796. * @returns a new Mesh
  14797. */
  14798. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  14799. /**
  14800. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  14801. * @param name defines the name of the mesh to create
  14802. * @param points is an array successive Vector3
  14803. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  14804. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  14805. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  14806. * @param scene defines the hosting scene
  14807. * @param updatable defines if the mesh must be flagged as updatable
  14808. * @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)
  14809. * @returns a new Mesh
  14810. */
  14811. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  14812. /**
  14813. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  14814. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  14815. * 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.
  14816. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  14817. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  14818. * Remember you can only change the shape positions, not their number when updating a polygon.
  14819. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  14820. * @param name defines the name of the mesh to create
  14821. * @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
  14822. * @param scene defines the hosting scene
  14823. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  14824. * @param updatable defines if the mesh must be flagged as updatable
  14825. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14826. * @param earcutInjection can be used to inject your own earcut reference
  14827. * @returns a new Mesh
  14828. */
  14829. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  14830. /**
  14831. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  14832. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  14833. * @param name defines the name of the mesh to create
  14834. * @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
  14835. * @param depth defines the height of extrusion
  14836. * @param scene defines the hosting scene
  14837. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  14838. * @param updatable defines if the mesh must be flagged as updatable
  14839. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14840. * @param earcutInjection can be used to inject your own earcut reference
  14841. * @returns a new Mesh
  14842. */
  14843. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  14844. /**
  14845. * Creates an extruded shape mesh.
  14846. * 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
  14847. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  14848. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  14849. * @param name defines the name of the mesh to create
  14850. * @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
  14851. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  14852. * @param scale is the value to scale the shape
  14853. * @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
  14854. * @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
  14855. * @param scene defines the hosting scene
  14856. * @param updatable defines if the mesh must be flagged as updatable
  14857. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14858. * @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)
  14859. * @returns a new Mesh
  14860. */
  14861. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  14862. /**
  14863. * Creates an custom extruded shape mesh.
  14864. * The custom extrusion is a parametric shape.
  14865. * It has no predefined shape. Its final shape will depend on the input parameters.
  14866. * Please consider using the same method from the MeshBuilder class instead
  14867. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  14868. * @param name defines the name of the mesh to create
  14869. * @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
  14870. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  14871. * @param scaleFunction is a custom Javascript function called on each path point
  14872. * @param rotationFunction is a custom Javascript function called on each path point
  14873. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  14874. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  14875. * @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
  14876. * @param scene defines the hosting scene
  14877. * @param updatable defines if the mesh must be flagged as updatable
  14878. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14879. * @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)
  14880. * @returns a new Mesh
  14881. */
  14882. 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;
  14883. /**
  14884. * Creates lathe mesh.
  14885. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  14886. * Please consider using the same method from the MeshBuilder class instead
  14887. * @param name defines the name of the mesh to create
  14888. * @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
  14889. * @param radius is the radius value of the lathe
  14890. * @param tessellation is the side number of the lathe.
  14891. * @param scene defines the hosting scene
  14892. * @param updatable defines if the mesh must be flagged as updatable
  14893. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14894. * @returns a new Mesh
  14895. */
  14896. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  14897. /**
  14898. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  14899. * @param name defines the name of the mesh to create
  14900. * @param size sets the size (float) of both sides of the plane at once (default 1)
  14901. * @param scene defines the hosting scene
  14902. * @param updatable defines if the mesh must be flagged as updatable
  14903. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14904. * @returns a new Mesh
  14905. */
  14906. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  14907. /**
  14908. * Creates a ground mesh.
  14909. * Please consider using the same method from the MeshBuilder class instead
  14910. * @param name defines the name of the mesh to create
  14911. * @param width set the width of the ground
  14912. * @param height set the height of the ground
  14913. * @param subdivisions sets the number of subdivisions per side
  14914. * @param scene defines the hosting scene
  14915. * @param updatable defines if the mesh must be flagged as updatable
  14916. * @returns a new Mesh
  14917. */
  14918. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  14919. /**
  14920. * Creates a tiled ground mesh.
  14921. * Please consider using the same method from the MeshBuilder class instead
  14922. * @param name defines the name of the mesh to create
  14923. * @param xmin set the ground minimum X coordinate
  14924. * @param zmin set the ground minimum Y coordinate
  14925. * @param xmax set the ground maximum X coordinate
  14926. * @param zmax set the ground maximum Z coordinate
  14927. * @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
  14928. * @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
  14929. * @param scene defines the hosting scene
  14930. * @param updatable defines if the mesh must be flagged as updatable
  14931. * @returns a new Mesh
  14932. */
  14933. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  14934. w: number;
  14935. h: number;
  14936. }, precision: {
  14937. w: number;
  14938. h: number;
  14939. }, scene: Scene, updatable?: boolean): Mesh;
  14940. /**
  14941. * Creates a ground mesh from a height map.
  14942. * Please consider using the same method from the MeshBuilder class instead
  14943. * @see http://doc.babylonjs.com/babylon101/height_map
  14944. * @param name defines the name of the mesh to create
  14945. * @param url sets the URL of the height map image resource
  14946. * @param width set the ground width size
  14947. * @param height set the ground height size
  14948. * @param subdivisions sets the number of subdivision per side
  14949. * @param minHeight is the minimum altitude on the ground
  14950. * @param maxHeight is the maximum altitude on the ground
  14951. * @param scene defines the hosting scene
  14952. * @param updatable defines if the mesh must be flagged as updatable
  14953. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  14954. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  14955. * @returns a new Mesh
  14956. */
  14957. 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;
  14958. /**
  14959. * Creates a tube mesh.
  14960. * The tube is a parametric shape.
  14961. * It has no predefined shape. Its final shape will depend on the input parameters.
  14962. * Please consider using the same method from the MeshBuilder class instead
  14963. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  14964. * @param name defines the name of the mesh to create
  14965. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  14966. * @param radius sets the tube radius size
  14967. * @param tessellation is the number of sides on the tubular surface
  14968. * @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
  14969. * @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
  14970. * @param scene defines the hosting scene
  14971. * @param updatable defines if the mesh must be flagged as updatable
  14972. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14973. * @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)
  14974. * @returns a new Mesh
  14975. */
  14976. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  14977. (i: number, distance: number): number;
  14978. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  14979. /**
  14980. * Creates a polyhedron mesh.
  14981. * Please consider using the same method from the MeshBuilder class instead.
  14982. * * 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
  14983. * * The parameter `size` (positive float, default 1) sets the polygon size
  14984. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  14985. * * 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`
  14986. * * 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
  14987. * * 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)`)
  14988. * * 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
  14989. * * 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
  14990. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  14991. * * 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
  14992. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  14993. * @param name defines the name of the mesh to create
  14994. * @param options defines the options used to create the mesh
  14995. * @param scene defines the hosting scene
  14996. * @returns a new Mesh
  14997. */
  14998. static CreatePolyhedron(name: string, options: {
  14999. type?: number;
  15000. size?: number;
  15001. sizeX?: number;
  15002. sizeY?: number;
  15003. sizeZ?: number;
  15004. custom?: any;
  15005. faceUV?: Vector4[];
  15006. faceColors?: Color4[];
  15007. updatable?: boolean;
  15008. sideOrientation?: number;
  15009. }, scene: Scene): Mesh;
  15010. /**
  15011. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  15012. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  15013. * * 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`)
  15014. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  15015. * * 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
  15016. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  15017. * * 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
  15018. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  15019. * @param name defines the name of the mesh
  15020. * @param options defines the options used to create the mesh
  15021. * @param scene defines the hosting scene
  15022. * @returns a new Mesh
  15023. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  15024. */
  15025. static CreateIcoSphere(name: string, options: {
  15026. radius?: number;
  15027. flat?: boolean;
  15028. subdivisions?: number;
  15029. sideOrientation?: number;
  15030. updatable?: boolean;
  15031. }, scene: Scene): Mesh;
  15032. /**
  15033. * Creates a decal mesh.
  15034. * Please consider using the same method from the MeshBuilder class instead.
  15035. * A decal is a mesh usually applied as a model onto the surface of another mesh
  15036. * @param name defines the name of the mesh
  15037. * @param sourceMesh defines the mesh receiving the decal
  15038. * @param position sets the position of the decal in world coordinates
  15039. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  15040. * @param size sets the decal scaling
  15041. * @param angle sets the angle to rotate the decal
  15042. * @returns a new Mesh
  15043. */
  15044. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  15045. /**
  15046. * Prepare internal position array for software CPU skinning
  15047. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  15048. */
  15049. setPositionsForCPUSkinning(): Float32Array;
  15050. /**
  15051. * Prepare internal normal array for software CPU skinning
  15052. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  15053. */
  15054. setNormalsForCPUSkinning(): Float32Array;
  15055. /**
  15056. * Updates the vertex buffer by applying transformation from the bones
  15057. * @param skeleton defines the skeleton to apply to current mesh
  15058. * @returns the current mesh
  15059. */
  15060. applySkeleton(skeleton: Skeleton): Mesh;
  15061. /**
  15062. * 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
  15063. * @param meshes defines the list of meshes to scan
  15064. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  15065. */
  15066. static MinMax(meshes: AbstractMesh[]): {
  15067. min: Vector3;
  15068. max: Vector3;
  15069. };
  15070. /**
  15071. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  15072. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  15073. * @returns a vector3
  15074. */
  15075. static Center(meshesOrMinMaxVector: {
  15076. min: Vector3;
  15077. max: Vector3;
  15078. } | AbstractMesh[]): Vector3;
  15079. /**
  15080. * Merge the array of meshes into a single mesh for performance reasons.
  15081. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  15082. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  15083. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  15084. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  15085. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  15086. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  15087. * @returns a new mesh
  15088. */
  15089. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  15090. /** @hidden */
  15091. addInstance(instance: InstancedMesh): void;
  15092. /** @hidden */
  15093. removeInstance(instance: InstancedMesh): void;
  15094. }
  15095. }
  15096. declare module BABYLON {
  15097. /**
  15098. * Interface used to define Action
  15099. */
  15100. export interface IAction {
  15101. /**
  15102. * Trigger for the action
  15103. */
  15104. trigger: number;
  15105. /** Options of the trigger */
  15106. triggerOptions: any;
  15107. /**
  15108. * Gets the trigger parameters
  15109. * @returns the trigger parameters
  15110. */
  15111. getTriggerParameter(): any;
  15112. /**
  15113. * Internal only - executes current action event
  15114. * @hidden
  15115. */
  15116. _executeCurrent(evt?: ActionEvent): void;
  15117. /**
  15118. * Serialize placeholder for child classes
  15119. * @param parent of child
  15120. * @returns the serialized object
  15121. */
  15122. serialize(parent: any): any;
  15123. /**
  15124. * Internal only
  15125. * @hidden
  15126. */
  15127. _prepare(): void;
  15128. /**
  15129. * Internal only - manager for action
  15130. * @hidden
  15131. */
  15132. _actionManager: AbstractActionManager;
  15133. /**
  15134. * Adds action to chain of actions, may be a DoNothingAction
  15135. * @param action defines the next action to execute
  15136. * @returns The action passed in
  15137. * @see https://www.babylonjs-playground.com/#1T30HR#0
  15138. */
  15139. then(action: IAction): IAction;
  15140. }
  15141. /**
  15142. * The action to be carried out following a trigger
  15143. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  15144. */
  15145. export class Action implements IAction {
  15146. /** the trigger, with or without parameters, for the action */
  15147. triggerOptions: any;
  15148. /**
  15149. * Trigger for the action
  15150. */
  15151. trigger: number;
  15152. /**
  15153. * Internal only - manager for action
  15154. * @hidden
  15155. */
  15156. _actionManager: ActionManager;
  15157. private _nextActiveAction;
  15158. private _child;
  15159. private _condition?;
  15160. private _triggerParameter;
  15161. /**
  15162. * An event triggered prior to action being executed.
  15163. */
  15164. onBeforeExecuteObservable: Observable<Action>;
  15165. /**
  15166. * Creates a new Action
  15167. * @param triggerOptions the trigger, with or without parameters, for the action
  15168. * @param condition an optional determinant of action
  15169. */
  15170. constructor(
  15171. /** the trigger, with or without parameters, for the action */
  15172. triggerOptions: any, condition?: Condition);
  15173. /**
  15174. * Internal only
  15175. * @hidden
  15176. */
  15177. _prepare(): void;
  15178. /**
  15179. * Gets the trigger parameters
  15180. * @returns the trigger parameters
  15181. */
  15182. getTriggerParameter(): any;
  15183. /**
  15184. * Internal only - executes current action event
  15185. * @hidden
  15186. */
  15187. _executeCurrent(evt?: ActionEvent): void;
  15188. /**
  15189. * Execute placeholder for child classes
  15190. * @param evt optional action event
  15191. */
  15192. execute(evt?: ActionEvent): void;
  15193. /**
  15194. * Skips to next active action
  15195. */
  15196. skipToNextActiveAction(): void;
  15197. /**
  15198. * Adds action to chain of actions, may be a DoNothingAction
  15199. * @param action defines the next action to execute
  15200. * @returns The action passed in
  15201. * @see https://www.babylonjs-playground.com/#1T30HR#0
  15202. */
  15203. then(action: Action): Action;
  15204. /**
  15205. * Internal only
  15206. * @hidden
  15207. */
  15208. _getProperty(propertyPath: string): string;
  15209. /**
  15210. * Internal only
  15211. * @hidden
  15212. */
  15213. _getEffectiveTarget(target: any, propertyPath: string): any;
  15214. /**
  15215. * Serialize placeholder for child classes
  15216. * @param parent of child
  15217. * @returns the serialized object
  15218. */
  15219. serialize(parent: any): any;
  15220. /**
  15221. * Internal only called by serialize
  15222. * @hidden
  15223. */
  15224. protected _serialize(serializedAction: any, parent?: any): any;
  15225. /**
  15226. * Internal only
  15227. * @hidden
  15228. */
  15229. static _SerializeValueAsString: (value: any) => string;
  15230. /**
  15231. * Internal only
  15232. * @hidden
  15233. */
  15234. static _GetTargetProperty: (target: Scene | Node) => {
  15235. name: string;
  15236. targetType: string;
  15237. value: string;
  15238. };
  15239. }
  15240. }
  15241. declare module BABYLON {
  15242. /**
  15243. * A Condition applied to an Action
  15244. */
  15245. export class Condition {
  15246. /**
  15247. * Internal only - manager for action
  15248. * @hidden
  15249. */
  15250. _actionManager: ActionManager;
  15251. /**
  15252. * Internal only
  15253. * @hidden
  15254. */
  15255. _evaluationId: number;
  15256. /**
  15257. * Internal only
  15258. * @hidden
  15259. */
  15260. _currentResult: boolean;
  15261. /**
  15262. * Creates a new Condition
  15263. * @param actionManager the manager of the action the condition is applied to
  15264. */
  15265. constructor(actionManager: ActionManager);
  15266. /**
  15267. * Check if the current condition is valid
  15268. * @returns a boolean
  15269. */
  15270. isValid(): boolean;
  15271. /**
  15272. * Internal only
  15273. * @hidden
  15274. */
  15275. _getProperty(propertyPath: string): string;
  15276. /**
  15277. * Internal only
  15278. * @hidden
  15279. */
  15280. _getEffectiveTarget(target: any, propertyPath: string): any;
  15281. /**
  15282. * Serialize placeholder for child classes
  15283. * @returns the serialized object
  15284. */
  15285. serialize(): any;
  15286. /**
  15287. * Internal only
  15288. * @hidden
  15289. */
  15290. protected _serialize(serializedCondition: any): any;
  15291. }
  15292. /**
  15293. * Defines specific conditional operators as extensions of Condition
  15294. */
  15295. export class ValueCondition extends Condition {
  15296. /** path to specify the property of the target the conditional operator uses */
  15297. propertyPath: string;
  15298. /** the value compared by the conditional operator against the current value of the property */
  15299. value: any;
  15300. /** the conditional operator, default ValueCondition.IsEqual */
  15301. operator: number;
  15302. /**
  15303. * Internal only
  15304. * @hidden
  15305. */
  15306. private static _IsEqual;
  15307. /**
  15308. * Internal only
  15309. * @hidden
  15310. */
  15311. private static _IsDifferent;
  15312. /**
  15313. * Internal only
  15314. * @hidden
  15315. */
  15316. private static _IsGreater;
  15317. /**
  15318. * Internal only
  15319. * @hidden
  15320. */
  15321. private static _IsLesser;
  15322. /**
  15323. * returns the number for IsEqual
  15324. */
  15325. static readonly IsEqual: number;
  15326. /**
  15327. * Returns the number for IsDifferent
  15328. */
  15329. static readonly IsDifferent: number;
  15330. /**
  15331. * Returns the number for IsGreater
  15332. */
  15333. static readonly IsGreater: number;
  15334. /**
  15335. * Returns the number for IsLesser
  15336. */
  15337. static readonly IsLesser: number;
  15338. /**
  15339. * Internal only The action manager for the condition
  15340. * @hidden
  15341. */
  15342. _actionManager: ActionManager;
  15343. /**
  15344. * Internal only
  15345. * @hidden
  15346. */
  15347. private _target;
  15348. /**
  15349. * Internal only
  15350. * @hidden
  15351. */
  15352. private _effectiveTarget;
  15353. /**
  15354. * Internal only
  15355. * @hidden
  15356. */
  15357. private _property;
  15358. /**
  15359. * Creates a new ValueCondition
  15360. * @param actionManager manager for the action the condition applies to
  15361. * @param target for the action
  15362. * @param propertyPath path to specify the property of the target the conditional operator uses
  15363. * @param value the value compared by the conditional operator against the current value of the property
  15364. * @param operator the conditional operator, default ValueCondition.IsEqual
  15365. */
  15366. constructor(actionManager: ActionManager, target: any,
  15367. /** path to specify the property of the target the conditional operator uses */
  15368. propertyPath: string,
  15369. /** the value compared by the conditional operator against the current value of the property */
  15370. value: any,
  15371. /** the conditional operator, default ValueCondition.IsEqual */
  15372. operator?: number);
  15373. /**
  15374. * Compares the given value with the property value for the specified conditional operator
  15375. * @returns the result of the comparison
  15376. */
  15377. isValid(): boolean;
  15378. /**
  15379. * Serialize the ValueCondition into a JSON compatible object
  15380. * @returns serialization object
  15381. */
  15382. serialize(): any;
  15383. /**
  15384. * Gets the name of the conditional operator for the ValueCondition
  15385. * @param operator the conditional operator
  15386. * @returns the name
  15387. */
  15388. static GetOperatorName(operator: number): string;
  15389. }
  15390. /**
  15391. * Defines a predicate condition as an extension of Condition
  15392. */
  15393. export class PredicateCondition extends Condition {
  15394. /** defines the predicate function used to validate the condition */
  15395. predicate: () => boolean;
  15396. /**
  15397. * Internal only - manager for action
  15398. * @hidden
  15399. */
  15400. _actionManager: ActionManager;
  15401. /**
  15402. * Creates a new PredicateCondition
  15403. * @param actionManager manager for the action the condition applies to
  15404. * @param predicate defines the predicate function used to validate the condition
  15405. */
  15406. constructor(actionManager: ActionManager,
  15407. /** defines the predicate function used to validate the condition */
  15408. predicate: () => boolean);
  15409. /**
  15410. * @returns the validity of the predicate condition
  15411. */
  15412. isValid(): boolean;
  15413. }
  15414. /**
  15415. * Defines a state condition as an extension of Condition
  15416. */
  15417. export class StateCondition extends Condition {
  15418. /** Value to compare with target state */
  15419. value: string;
  15420. /**
  15421. * Internal only - manager for action
  15422. * @hidden
  15423. */
  15424. _actionManager: ActionManager;
  15425. /**
  15426. * Internal only
  15427. * @hidden
  15428. */
  15429. private _target;
  15430. /**
  15431. * Creates a new StateCondition
  15432. * @param actionManager manager for the action the condition applies to
  15433. * @param target of the condition
  15434. * @param value to compare with target state
  15435. */
  15436. constructor(actionManager: ActionManager, target: any,
  15437. /** Value to compare with target state */
  15438. value: string);
  15439. /**
  15440. * Gets a boolean indicating if the current condition is met
  15441. * @returns the validity of the state
  15442. */
  15443. isValid(): boolean;
  15444. /**
  15445. * Serialize the StateCondition into a JSON compatible object
  15446. * @returns serialization object
  15447. */
  15448. serialize(): any;
  15449. }
  15450. }
  15451. declare module BABYLON {
  15452. /**
  15453. * This defines an action responsible to toggle a boolean once triggered.
  15454. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15455. */
  15456. export class SwitchBooleanAction extends Action {
  15457. /**
  15458. * The path to the boolean property in the target object
  15459. */
  15460. propertyPath: string;
  15461. private _target;
  15462. private _effectiveTarget;
  15463. private _property;
  15464. /**
  15465. * Instantiate the action
  15466. * @param triggerOptions defines the trigger options
  15467. * @param target defines the object containing the boolean
  15468. * @param propertyPath defines the path to the boolean property in the target object
  15469. * @param condition defines the trigger related conditions
  15470. */
  15471. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  15472. /** @hidden */
  15473. _prepare(): void;
  15474. /**
  15475. * Execute the action toggle the boolean value.
  15476. */
  15477. execute(): void;
  15478. /**
  15479. * Serializes the actions and its related information.
  15480. * @param parent defines the object to serialize in
  15481. * @returns the serialized object
  15482. */
  15483. serialize(parent: any): any;
  15484. }
  15485. /**
  15486. * This defines an action responsible to set a the state field of the target
  15487. * to a desired value once triggered.
  15488. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15489. */
  15490. export class SetStateAction extends Action {
  15491. /**
  15492. * The value to store in the state field.
  15493. */
  15494. value: string;
  15495. private _target;
  15496. /**
  15497. * Instantiate the action
  15498. * @param triggerOptions defines the trigger options
  15499. * @param target defines the object containing the state property
  15500. * @param value defines the value to store in the state field
  15501. * @param condition defines the trigger related conditions
  15502. */
  15503. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  15504. /**
  15505. * Execute the action and store the value on the target state property.
  15506. */
  15507. execute(): void;
  15508. /**
  15509. * Serializes the actions and its related information.
  15510. * @param parent defines the object to serialize in
  15511. * @returns the serialized object
  15512. */
  15513. serialize(parent: any): any;
  15514. }
  15515. /**
  15516. * This defines an action responsible to set a property of the target
  15517. * to a desired value once triggered.
  15518. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15519. */
  15520. export class SetValueAction extends Action {
  15521. /**
  15522. * The path of the property to set in the target.
  15523. */
  15524. propertyPath: string;
  15525. /**
  15526. * The value to set in the property
  15527. */
  15528. value: any;
  15529. private _target;
  15530. private _effectiveTarget;
  15531. private _property;
  15532. /**
  15533. * Instantiate the action
  15534. * @param triggerOptions defines the trigger options
  15535. * @param target defines the object containing the property
  15536. * @param propertyPath defines the path of the property to set in the target
  15537. * @param value defines the value to set in the property
  15538. * @param condition defines the trigger related conditions
  15539. */
  15540. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  15541. /** @hidden */
  15542. _prepare(): void;
  15543. /**
  15544. * Execute the action and set the targetted property to the desired value.
  15545. */
  15546. execute(): void;
  15547. /**
  15548. * Serializes the actions and its related information.
  15549. * @param parent defines the object to serialize in
  15550. * @returns the serialized object
  15551. */
  15552. serialize(parent: any): any;
  15553. }
  15554. /**
  15555. * This defines an action responsible to increment the target value
  15556. * to a desired value once triggered.
  15557. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15558. */
  15559. export class IncrementValueAction extends Action {
  15560. /**
  15561. * The path of the property to increment in the target.
  15562. */
  15563. propertyPath: string;
  15564. /**
  15565. * The value we should increment the property by.
  15566. */
  15567. value: any;
  15568. private _target;
  15569. private _effectiveTarget;
  15570. private _property;
  15571. /**
  15572. * Instantiate the action
  15573. * @param triggerOptions defines the trigger options
  15574. * @param target defines the object containing the property
  15575. * @param propertyPath defines the path of the property to increment in the target
  15576. * @param value defines the value value we should increment the property by
  15577. * @param condition defines the trigger related conditions
  15578. */
  15579. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  15580. /** @hidden */
  15581. _prepare(): void;
  15582. /**
  15583. * Execute the action and increment the target of the value amount.
  15584. */
  15585. execute(): void;
  15586. /**
  15587. * Serializes the actions and its related information.
  15588. * @param parent defines the object to serialize in
  15589. * @returns the serialized object
  15590. */
  15591. serialize(parent: any): any;
  15592. }
  15593. /**
  15594. * This defines an action responsible to start an animation once triggered.
  15595. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15596. */
  15597. export class PlayAnimationAction extends Action {
  15598. /**
  15599. * Where the animation should start (animation frame)
  15600. */
  15601. from: number;
  15602. /**
  15603. * Where the animation should stop (animation frame)
  15604. */
  15605. to: number;
  15606. /**
  15607. * Define if the animation should loop or stop after the first play.
  15608. */
  15609. loop?: boolean;
  15610. private _target;
  15611. /**
  15612. * Instantiate the action
  15613. * @param triggerOptions defines the trigger options
  15614. * @param target defines the target animation or animation name
  15615. * @param from defines from where the animation should start (animation frame)
  15616. * @param end defines where the animation should stop (animation frame)
  15617. * @param loop defines if the animation should loop or stop after the first play
  15618. * @param condition defines the trigger related conditions
  15619. */
  15620. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  15621. /** @hidden */
  15622. _prepare(): void;
  15623. /**
  15624. * Execute the action and play the animation.
  15625. */
  15626. execute(): void;
  15627. /**
  15628. * Serializes the actions and its related information.
  15629. * @param parent defines the object to serialize in
  15630. * @returns the serialized object
  15631. */
  15632. serialize(parent: any): any;
  15633. }
  15634. /**
  15635. * This defines an action responsible to stop an animation once triggered.
  15636. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15637. */
  15638. export class StopAnimationAction extends Action {
  15639. private _target;
  15640. /**
  15641. * Instantiate the action
  15642. * @param triggerOptions defines the trigger options
  15643. * @param target defines the target animation or animation name
  15644. * @param condition defines the trigger related conditions
  15645. */
  15646. constructor(triggerOptions: any, target: any, condition?: Condition);
  15647. /** @hidden */
  15648. _prepare(): void;
  15649. /**
  15650. * Execute the action and stop the animation.
  15651. */
  15652. execute(): void;
  15653. /**
  15654. * Serializes the actions and its related information.
  15655. * @param parent defines the object to serialize in
  15656. * @returns the serialized object
  15657. */
  15658. serialize(parent: any): any;
  15659. }
  15660. /**
  15661. * This defines an action responsible that does nothing once triggered.
  15662. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15663. */
  15664. export class DoNothingAction extends Action {
  15665. /**
  15666. * Instantiate the action
  15667. * @param triggerOptions defines the trigger options
  15668. * @param condition defines the trigger related conditions
  15669. */
  15670. constructor(triggerOptions?: any, condition?: Condition);
  15671. /**
  15672. * Execute the action and do nothing.
  15673. */
  15674. execute(): void;
  15675. /**
  15676. * Serializes the actions and its related information.
  15677. * @param parent defines the object to serialize in
  15678. * @returns the serialized object
  15679. */
  15680. serialize(parent: any): any;
  15681. }
  15682. /**
  15683. * This defines an action responsible to trigger several actions once triggered.
  15684. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15685. */
  15686. export class CombineAction extends Action {
  15687. /**
  15688. * The list of aggregated animations to run.
  15689. */
  15690. children: Action[];
  15691. /**
  15692. * Instantiate the action
  15693. * @param triggerOptions defines the trigger options
  15694. * @param children defines the list of aggregated animations to run
  15695. * @param condition defines the trigger related conditions
  15696. */
  15697. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  15698. /** @hidden */
  15699. _prepare(): void;
  15700. /**
  15701. * Execute the action and executes all the aggregated actions.
  15702. */
  15703. execute(evt: ActionEvent): void;
  15704. /**
  15705. * Serializes the actions and its related information.
  15706. * @param parent defines the object to serialize in
  15707. * @returns the serialized object
  15708. */
  15709. serialize(parent: any): any;
  15710. }
  15711. /**
  15712. * This defines an action responsible to run code (external event) once triggered.
  15713. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15714. */
  15715. export class ExecuteCodeAction extends Action {
  15716. /**
  15717. * The callback function to run.
  15718. */
  15719. func: (evt: ActionEvent) => void;
  15720. /**
  15721. * Instantiate the action
  15722. * @param triggerOptions defines the trigger options
  15723. * @param func defines the callback function to run
  15724. * @param condition defines the trigger related conditions
  15725. */
  15726. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  15727. /**
  15728. * Execute the action and run the attached code.
  15729. */
  15730. execute(evt: ActionEvent): void;
  15731. }
  15732. /**
  15733. * This defines an action responsible to set the parent property of the target once triggered.
  15734. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15735. */
  15736. export class SetParentAction extends Action {
  15737. private _parent;
  15738. private _target;
  15739. /**
  15740. * Instantiate the action
  15741. * @param triggerOptions defines the trigger options
  15742. * @param target defines the target containing the parent property
  15743. * @param parent defines from where the animation should start (animation frame)
  15744. * @param condition defines the trigger related conditions
  15745. */
  15746. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  15747. /** @hidden */
  15748. _prepare(): void;
  15749. /**
  15750. * Execute the action and set the parent property.
  15751. */
  15752. execute(): void;
  15753. /**
  15754. * Serializes the actions and its related information.
  15755. * @param parent defines the object to serialize in
  15756. * @returns the serialized object
  15757. */
  15758. serialize(parent: any): any;
  15759. }
  15760. }
  15761. declare module BABYLON {
  15762. /**
  15763. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  15764. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  15765. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15766. */
  15767. export class ActionManager extends AbstractActionManager {
  15768. /**
  15769. * Nothing
  15770. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15771. */
  15772. static readonly NothingTrigger: number;
  15773. /**
  15774. * On pick
  15775. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15776. */
  15777. static readonly OnPickTrigger: number;
  15778. /**
  15779. * On left pick
  15780. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15781. */
  15782. static readonly OnLeftPickTrigger: number;
  15783. /**
  15784. * On right pick
  15785. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15786. */
  15787. static readonly OnRightPickTrigger: number;
  15788. /**
  15789. * On center pick
  15790. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15791. */
  15792. static readonly OnCenterPickTrigger: number;
  15793. /**
  15794. * On pick down
  15795. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15796. */
  15797. static readonly OnPickDownTrigger: number;
  15798. /**
  15799. * On double pick
  15800. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15801. */
  15802. static readonly OnDoublePickTrigger: number;
  15803. /**
  15804. * On pick up
  15805. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15806. */
  15807. static readonly OnPickUpTrigger: number;
  15808. /**
  15809. * On pick out.
  15810. * This trigger will only be raised if you also declared a OnPickDown
  15811. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15812. */
  15813. static readonly OnPickOutTrigger: number;
  15814. /**
  15815. * On long press
  15816. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15817. */
  15818. static readonly OnLongPressTrigger: number;
  15819. /**
  15820. * On pointer over
  15821. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15822. */
  15823. static readonly OnPointerOverTrigger: number;
  15824. /**
  15825. * On pointer out
  15826. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15827. */
  15828. static readonly OnPointerOutTrigger: number;
  15829. /**
  15830. * On every frame
  15831. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15832. */
  15833. static readonly OnEveryFrameTrigger: number;
  15834. /**
  15835. * On intersection enter
  15836. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15837. */
  15838. static readonly OnIntersectionEnterTrigger: number;
  15839. /**
  15840. * On intersection exit
  15841. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15842. */
  15843. static readonly OnIntersectionExitTrigger: number;
  15844. /**
  15845. * On key down
  15846. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15847. */
  15848. static readonly OnKeyDownTrigger: number;
  15849. /**
  15850. * On key up
  15851. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  15852. */
  15853. static readonly OnKeyUpTrigger: number;
  15854. private _scene;
  15855. /**
  15856. * Creates a new action manager
  15857. * @param scene defines the hosting scene
  15858. */
  15859. constructor(scene: Scene);
  15860. /**
  15861. * Releases all associated resources
  15862. */
  15863. dispose(): void;
  15864. /**
  15865. * Gets hosting scene
  15866. * @returns the hosting scene
  15867. */
  15868. getScene(): Scene;
  15869. /**
  15870. * Does this action manager handles actions of any of the given triggers
  15871. * @param triggers defines the triggers to be tested
  15872. * @return a boolean indicating whether one (or more) of the triggers is handled
  15873. */
  15874. hasSpecificTriggers(triggers: number[]): boolean;
  15875. /**
  15876. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  15877. * speed.
  15878. * @param triggerA defines the trigger to be tested
  15879. * @param triggerB defines the trigger to be tested
  15880. * @return a boolean indicating whether one (or more) of the triggers is handled
  15881. */
  15882. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  15883. /**
  15884. * Does this action manager handles actions of a given trigger
  15885. * @param trigger defines the trigger to be tested
  15886. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  15887. * @return whether the trigger is handled
  15888. */
  15889. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  15890. /**
  15891. * Does this action manager has pointer triggers
  15892. */
  15893. readonly hasPointerTriggers: boolean;
  15894. /**
  15895. * Does this action manager has pick triggers
  15896. */
  15897. readonly hasPickTriggers: boolean;
  15898. /**
  15899. * Registers an action to this action manager
  15900. * @param action defines the action to be registered
  15901. * @return the action amended (prepared) after registration
  15902. */
  15903. registerAction(action: IAction): Nullable<IAction>;
  15904. /**
  15905. * Unregisters an action to this action manager
  15906. * @param action defines the action to be unregistered
  15907. * @return a boolean indicating whether the action has been unregistered
  15908. */
  15909. unregisterAction(action: IAction): Boolean;
  15910. /**
  15911. * Process a specific trigger
  15912. * @param trigger defines the trigger to process
  15913. * @param evt defines the event details to be processed
  15914. */
  15915. processTrigger(trigger: number, evt?: IActionEvent): void;
  15916. /** @hidden */
  15917. _getEffectiveTarget(target: any, propertyPath: string): any;
  15918. /** @hidden */
  15919. _getProperty(propertyPath: string): string;
  15920. /**
  15921. * Serialize this manager to a JSON object
  15922. * @param name defines the property name to store this manager
  15923. * @returns a JSON representation of this manager
  15924. */
  15925. serialize(name: string): any;
  15926. /**
  15927. * Creates a new ActionManager from a JSON data
  15928. * @param parsedActions defines the JSON data to read from
  15929. * @param object defines the hosting mesh
  15930. * @param scene defines the hosting scene
  15931. */
  15932. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  15933. /**
  15934. * Get a trigger name by index
  15935. * @param trigger defines the trigger index
  15936. * @returns a trigger name
  15937. */
  15938. static GetTriggerName(trigger: number): string;
  15939. }
  15940. }
  15941. declare module BABYLON {
  15942. /**
  15943. * Class representing a ray with position and direction
  15944. */
  15945. export class Ray {
  15946. /** origin point */
  15947. origin: Vector3;
  15948. /** direction */
  15949. direction: Vector3;
  15950. /** length of the ray */
  15951. length: number;
  15952. private static readonly TmpVector3;
  15953. private _tmpRay;
  15954. /**
  15955. * Creates a new ray
  15956. * @param origin origin point
  15957. * @param direction direction
  15958. * @param length length of the ray
  15959. */
  15960. constructor(
  15961. /** origin point */
  15962. origin: Vector3,
  15963. /** direction */
  15964. direction: Vector3,
  15965. /** length of the ray */
  15966. length?: number);
  15967. /**
  15968. * Checks if the ray intersects a box
  15969. * @param minimum bound of the box
  15970. * @param maximum bound of the box
  15971. * @param intersectionTreshold extra extend to be added to the box in all direction
  15972. * @returns if the box was hit
  15973. */
  15974. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  15975. /**
  15976. * Checks if the ray intersects a box
  15977. * @param box the bounding box to check
  15978. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  15979. * @returns if the box was hit
  15980. */
  15981. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  15982. /**
  15983. * If the ray hits a sphere
  15984. * @param sphere the bounding sphere to check
  15985. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  15986. * @returns true if it hits the sphere
  15987. */
  15988. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  15989. /**
  15990. * If the ray hits a triange
  15991. * @param vertex0 triangle vertex
  15992. * @param vertex1 triangle vertex
  15993. * @param vertex2 triangle vertex
  15994. * @returns intersection information if hit
  15995. */
  15996. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  15997. /**
  15998. * Checks if ray intersects a plane
  15999. * @param plane the plane to check
  16000. * @returns the distance away it was hit
  16001. */
  16002. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  16003. /**
  16004. * Calculate the intercept of a ray on a given axis
  16005. * @param axis to check 'x' | 'y' | 'z'
  16006. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  16007. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  16008. */
  16009. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  16010. /**
  16011. * Checks if ray intersects a mesh
  16012. * @param mesh the mesh to check
  16013. * @param fastCheck if only the bounding box should checked
  16014. * @returns picking info of the intersecton
  16015. */
  16016. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  16017. /**
  16018. * Checks if ray intersects a mesh
  16019. * @param meshes the meshes to check
  16020. * @param fastCheck if only the bounding box should checked
  16021. * @param results array to store result in
  16022. * @returns Array of picking infos
  16023. */
  16024. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  16025. private _comparePickingInfo;
  16026. private static smallnum;
  16027. private static rayl;
  16028. /**
  16029. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  16030. * @param sega the first point of the segment to test the intersection against
  16031. * @param segb the second point of the segment to test the intersection against
  16032. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  16033. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  16034. */
  16035. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  16036. /**
  16037. * Update the ray from viewport position
  16038. * @param x position
  16039. * @param y y position
  16040. * @param viewportWidth viewport width
  16041. * @param viewportHeight viewport height
  16042. * @param world world matrix
  16043. * @param view view matrix
  16044. * @param projection projection matrix
  16045. * @returns this ray updated
  16046. */
  16047. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  16048. /**
  16049. * Creates a ray with origin and direction of 0,0,0
  16050. * @returns the new ray
  16051. */
  16052. static Zero(): Ray;
  16053. /**
  16054. * Creates a new ray from screen space and viewport
  16055. * @param x position
  16056. * @param y y position
  16057. * @param viewportWidth viewport width
  16058. * @param viewportHeight viewport height
  16059. * @param world world matrix
  16060. * @param view view matrix
  16061. * @param projection projection matrix
  16062. * @returns new ray
  16063. */
  16064. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  16065. /**
  16066. * 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
  16067. * transformed to the given world matrix.
  16068. * @param origin The origin point
  16069. * @param end The end point
  16070. * @param world a matrix to transform the ray to. Default is the identity matrix.
  16071. * @returns the new ray
  16072. */
  16073. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  16074. /**
  16075. * Transforms a ray by a matrix
  16076. * @param ray ray to transform
  16077. * @param matrix matrix to apply
  16078. * @returns the resulting new ray
  16079. */
  16080. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  16081. /**
  16082. * Transforms a ray by a matrix
  16083. * @param ray ray to transform
  16084. * @param matrix matrix to apply
  16085. * @param result ray to store result in
  16086. */
  16087. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  16088. /**
  16089. * Unproject a ray from screen space to object space
  16090. * @param sourceX defines the screen space x coordinate to use
  16091. * @param sourceY defines the screen space y coordinate to use
  16092. * @param viewportWidth defines the current width of the viewport
  16093. * @param viewportHeight defines the current height of the viewport
  16094. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  16095. * @param view defines the view matrix to use
  16096. * @param projection defines the projection matrix to use
  16097. */
  16098. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  16099. }
  16100. /**
  16101. * Type used to define predicate used to select faces when a mesh intersection is detected
  16102. */
  16103. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  16104. interface Scene {
  16105. /** @hidden */
  16106. _tempPickingRay: Nullable<Ray>;
  16107. /** @hidden */
  16108. _cachedRayForTransform: Ray;
  16109. /** @hidden */
  16110. _pickWithRayInverseMatrix: Matrix;
  16111. /** @hidden */
  16112. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  16113. /** @hidden */
  16114. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  16115. }
  16116. }
  16117. declare module BABYLON {
  16118. interface Scene {
  16119. /** @hidden */
  16120. _pointerOverSprite: Nullable<Sprite>;
  16121. /** @hidden */
  16122. _pickedDownSprite: Nullable<Sprite>;
  16123. /** @hidden */
  16124. _tempSpritePickingRay: Nullable<Ray>;
  16125. /**
  16126. * All of the sprite managers added to this scene
  16127. * @see http://doc.babylonjs.com/babylon101/sprites
  16128. */
  16129. spriteManagers: Array<ISpriteManager>;
  16130. /**
  16131. * An event triggered when sprites rendering is about to start
  16132. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  16133. */
  16134. onBeforeSpritesRenderingObservable: Observable<Scene>;
  16135. /**
  16136. * An event triggered when sprites rendering is done
  16137. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  16138. */
  16139. onAfterSpritesRenderingObservable: Observable<Scene>;
  16140. /** @hidden */
  16141. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  16142. /** Launch a ray to try to pick a sprite in the scene
  16143. * @param x position on screen
  16144. * @param y position on screen
  16145. * @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
  16146. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  16147. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  16148. * @returns a PickingInfo
  16149. */
  16150. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  16151. /** Use the given ray to pick a sprite in the scene
  16152. * @param ray The ray (in world space) to use to pick meshes
  16153. * @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
  16154. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  16155. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  16156. * @returns a PickingInfo
  16157. */
  16158. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  16159. /**
  16160. * Force the sprite under the pointer
  16161. * @param sprite defines the sprite to use
  16162. */
  16163. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  16164. /**
  16165. * Gets the sprite under the pointer
  16166. * @returns a Sprite or null if no sprite is under the pointer
  16167. */
  16168. getPointerOverSprite(): Nullable<Sprite>;
  16169. }
  16170. /**
  16171. * Defines the sprite scene component responsible to manage sprites
  16172. * in a given scene.
  16173. */
  16174. export class SpriteSceneComponent implements ISceneComponent {
  16175. /**
  16176. * The component name helpfull to identify the component in the list of scene components.
  16177. */
  16178. readonly name: string;
  16179. /**
  16180. * The scene the component belongs to.
  16181. */
  16182. scene: Scene;
  16183. /** @hidden */
  16184. private _spritePredicate;
  16185. /**
  16186. * Creates a new instance of the component for the given scene
  16187. * @param scene Defines the scene to register the component in
  16188. */
  16189. constructor(scene: Scene);
  16190. /**
  16191. * Registers the component in a given scene
  16192. */
  16193. register(): void;
  16194. /**
  16195. * Rebuilds the elements related to this component in case of
  16196. * context lost for instance.
  16197. */
  16198. rebuild(): void;
  16199. /**
  16200. * Disposes the component and the associated ressources.
  16201. */
  16202. dispose(): void;
  16203. private _pickSpriteButKeepRay;
  16204. private _pointerMove;
  16205. private _pointerDown;
  16206. private _pointerUp;
  16207. }
  16208. }
  16209. declare module BABYLON {
  16210. /** @hidden */
  16211. export var fogFragmentDeclaration: {
  16212. name: string;
  16213. shader: string;
  16214. };
  16215. }
  16216. declare module BABYLON {
  16217. /** @hidden */
  16218. export var fogFragment: {
  16219. name: string;
  16220. shader: string;
  16221. };
  16222. }
  16223. declare module BABYLON {
  16224. /** @hidden */
  16225. export var spritesPixelShader: {
  16226. name: string;
  16227. shader: string;
  16228. };
  16229. }
  16230. declare module BABYLON {
  16231. /** @hidden */
  16232. export var fogVertexDeclaration: {
  16233. name: string;
  16234. shader: string;
  16235. };
  16236. }
  16237. declare module BABYLON {
  16238. /** @hidden */
  16239. export var spritesVertexShader: {
  16240. name: string;
  16241. shader: string;
  16242. };
  16243. }
  16244. declare module BABYLON {
  16245. /**
  16246. * Defines the minimum interface to fullfil in order to be a sprite manager.
  16247. */
  16248. export interface ISpriteManager extends IDisposable {
  16249. /**
  16250. * Restricts the camera to viewing objects with the same layerMask.
  16251. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  16252. */
  16253. layerMask: number;
  16254. /**
  16255. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  16256. */
  16257. isPickable: boolean;
  16258. /**
  16259. * Specifies the rendering group id for this mesh (0 by default)
  16260. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  16261. */
  16262. renderingGroupId: number;
  16263. /**
  16264. * Defines the list of sprites managed by the manager.
  16265. */
  16266. sprites: Array<Sprite>;
  16267. /**
  16268. * Tests the intersection of a sprite with a specific ray.
  16269. * @param ray The ray we are sending to test the collision
  16270. * @param camera The camera space we are sending rays in
  16271. * @param predicate A predicate allowing excluding sprites from the list of object to test
  16272. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  16273. * @returns picking info or null.
  16274. */
  16275. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  16276. /**
  16277. * Renders the list of sprites on screen.
  16278. */
  16279. render(): void;
  16280. }
  16281. /**
  16282. * Class used to manage multiple sprites on the same spritesheet
  16283. * @see http://doc.babylonjs.com/babylon101/sprites
  16284. */
  16285. export class SpriteManager implements ISpriteManager {
  16286. /** defines the manager's name */
  16287. name: string;
  16288. /** Gets the list of sprites */
  16289. sprites: Sprite[];
  16290. /** Gets or sets the rendering group id (0 by default) */
  16291. renderingGroupId: number;
  16292. /** Gets or sets camera layer mask */
  16293. layerMask: number;
  16294. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  16295. fogEnabled: boolean;
  16296. /** Gets or sets a boolean indicating if the sprites are pickable */
  16297. isPickable: boolean;
  16298. /** Defines the default width of a cell in the spritesheet */
  16299. cellWidth: number;
  16300. /** Defines the default height of a cell in the spritesheet */
  16301. cellHeight: number;
  16302. /**
  16303. * An event triggered when the manager is disposed.
  16304. */
  16305. onDisposeObservable: Observable<SpriteManager>;
  16306. private _onDisposeObserver;
  16307. /**
  16308. * Callback called when the manager is disposed
  16309. */
  16310. onDispose: () => void;
  16311. private _capacity;
  16312. private _spriteTexture;
  16313. private _epsilon;
  16314. private _scene;
  16315. private _vertexData;
  16316. private _buffer;
  16317. private _vertexBuffers;
  16318. private _indexBuffer;
  16319. private _effectBase;
  16320. private _effectFog;
  16321. /**
  16322. * Gets or sets the spritesheet texture
  16323. */
  16324. texture: Texture;
  16325. /**
  16326. * Creates a new sprite manager
  16327. * @param name defines the manager's name
  16328. * @param imgUrl defines the sprite sheet url
  16329. * @param capacity defines the maximum allowed number of sprites
  16330. * @param cellSize defines the size of a sprite cell
  16331. * @param scene defines the hosting scene
  16332. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  16333. * @param samplingMode defines the smapling mode to use with spritesheet
  16334. */
  16335. constructor(
  16336. /** defines the manager's name */
  16337. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  16338. private _appendSpriteVertex;
  16339. /**
  16340. * Intersects the sprites with a ray
  16341. * @param ray defines the ray to intersect with
  16342. * @param camera defines the current active camera
  16343. * @param predicate defines a predicate used to select candidate sprites
  16344. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  16345. * @returns null if no hit or a PickingInfo
  16346. */
  16347. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  16348. /**
  16349. * Render all child sprites
  16350. */
  16351. render(): void;
  16352. /**
  16353. * Release associated resources
  16354. */
  16355. dispose(): void;
  16356. }
  16357. }
  16358. declare module BABYLON {
  16359. /**
  16360. * Class used to represent a sprite
  16361. * @see http://doc.babylonjs.com/babylon101/sprites
  16362. */
  16363. export class Sprite {
  16364. /** defines the name */
  16365. name: string;
  16366. /** Gets or sets the current world position */
  16367. position: Vector3;
  16368. /** Gets or sets the main color */
  16369. color: Color4;
  16370. /** Gets or sets the width */
  16371. width: number;
  16372. /** Gets or sets the height */
  16373. height: number;
  16374. /** Gets or sets rotation angle */
  16375. angle: number;
  16376. /** Gets or sets the cell index in the sprite sheet */
  16377. cellIndex: number;
  16378. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  16379. invertU: number;
  16380. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  16381. invertV: number;
  16382. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  16383. disposeWhenFinishedAnimating: boolean;
  16384. /** Gets the list of attached animations */
  16385. animations: Animation[];
  16386. /** Gets or sets a boolean indicating if the sprite can be picked */
  16387. isPickable: boolean;
  16388. /**
  16389. * Gets or sets the associated action manager
  16390. */
  16391. actionManager: Nullable<ActionManager>;
  16392. private _animationStarted;
  16393. private _loopAnimation;
  16394. private _fromIndex;
  16395. private _toIndex;
  16396. private _delay;
  16397. private _direction;
  16398. private _manager;
  16399. private _time;
  16400. private _onAnimationEnd;
  16401. /**
  16402. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  16403. */
  16404. isVisible: boolean;
  16405. /**
  16406. * Gets or sets the sprite size
  16407. */
  16408. size: number;
  16409. /**
  16410. * Creates a new Sprite
  16411. * @param name defines the name
  16412. * @param manager defines the manager
  16413. */
  16414. constructor(
  16415. /** defines the name */
  16416. name: string, manager: ISpriteManager);
  16417. /**
  16418. * Starts an animation
  16419. * @param from defines the initial key
  16420. * @param to defines the end key
  16421. * @param loop defines if the animation must loop
  16422. * @param delay defines the start delay (in ms)
  16423. * @param onAnimationEnd defines a callback to call when animation ends
  16424. */
  16425. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  16426. /** Stops current animation (if any) */
  16427. stopAnimation(): void;
  16428. /** @hidden */
  16429. _animate(deltaTime: number): void;
  16430. /** Release associated resources */
  16431. dispose(): void;
  16432. }
  16433. }
  16434. declare module BABYLON {
  16435. /**
  16436. * Information about the result of picking within a scene
  16437. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  16438. */
  16439. export class PickingInfo {
  16440. /** @hidden */
  16441. _pickingUnavailable: boolean;
  16442. /**
  16443. * If the pick collided with an object
  16444. */
  16445. hit: boolean;
  16446. /**
  16447. * Distance away where the pick collided
  16448. */
  16449. distance: number;
  16450. /**
  16451. * The location of pick collision
  16452. */
  16453. pickedPoint: Nullable<Vector3>;
  16454. /**
  16455. * The mesh corresponding the the pick collision
  16456. */
  16457. pickedMesh: Nullable<AbstractMesh>;
  16458. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  16459. bu: number;
  16460. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  16461. bv: number;
  16462. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  16463. faceId: number;
  16464. /** Id of the the submesh that was picked */
  16465. subMeshId: number;
  16466. /** If a sprite was picked, this will be the sprite the pick collided with */
  16467. pickedSprite: Nullable<Sprite>;
  16468. /**
  16469. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  16470. */
  16471. originMesh: Nullable<AbstractMesh>;
  16472. /**
  16473. * The ray that was used to perform the picking.
  16474. */
  16475. ray: Nullable<Ray>;
  16476. /**
  16477. * Gets the normal correspodning to the face the pick collided with
  16478. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  16479. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  16480. * @returns The normal correspodning to the face the pick collided with
  16481. */
  16482. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  16483. /**
  16484. * Gets the texture coordinates of where the pick occured
  16485. * @returns the vector containing the coordnates of the texture
  16486. */
  16487. getTextureCoordinates(): Nullable<Vector2>;
  16488. }
  16489. }
  16490. declare module BABYLON {
  16491. /**
  16492. * Gather the list of pointer event types as constants.
  16493. */
  16494. export class PointerEventTypes {
  16495. /**
  16496. * 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.
  16497. */
  16498. static readonly POINTERDOWN: number;
  16499. /**
  16500. * The pointerup event is fired when a pointer is no longer active.
  16501. */
  16502. static readonly POINTERUP: number;
  16503. /**
  16504. * The pointermove event is fired when a pointer changes coordinates.
  16505. */
  16506. static readonly POINTERMOVE: number;
  16507. /**
  16508. * The pointerwheel event is fired when a mouse wheel has been rotated.
  16509. */
  16510. static readonly POINTERWHEEL: number;
  16511. /**
  16512. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  16513. */
  16514. static readonly POINTERPICK: number;
  16515. /**
  16516. * The pointertap event is fired when a the object has been touched and released without drag.
  16517. */
  16518. static readonly POINTERTAP: number;
  16519. /**
  16520. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  16521. */
  16522. static readonly POINTERDOUBLETAP: number;
  16523. }
  16524. /**
  16525. * Base class of pointer info types.
  16526. */
  16527. export class PointerInfoBase {
  16528. /**
  16529. * Defines the type of event (PointerEventTypes)
  16530. */
  16531. type: number;
  16532. /**
  16533. * Defines the related dom event
  16534. */
  16535. event: PointerEvent | MouseWheelEvent;
  16536. /**
  16537. * Instantiates the base class of pointers info.
  16538. * @param type Defines the type of event (PointerEventTypes)
  16539. * @param event Defines the related dom event
  16540. */
  16541. constructor(
  16542. /**
  16543. * Defines the type of event (PointerEventTypes)
  16544. */
  16545. type: number,
  16546. /**
  16547. * Defines the related dom event
  16548. */
  16549. event: PointerEvent | MouseWheelEvent);
  16550. }
  16551. /**
  16552. * This class is used to store pointer related info for the onPrePointerObservable event.
  16553. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  16554. */
  16555. export class PointerInfoPre extends PointerInfoBase {
  16556. /**
  16557. * Ray from a pointer if availible (eg. 6dof controller)
  16558. */
  16559. ray: Nullable<Ray>;
  16560. /**
  16561. * Defines the local position of the pointer on the canvas.
  16562. */
  16563. localPosition: Vector2;
  16564. /**
  16565. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  16566. */
  16567. skipOnPointerObservable: boolean;
  16568. /**
  16569. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  16570. * @param type Defines the type of event (PointerEventTypes)
  16571. * @param event Defines the related dom event
  16572. * @param localX Defines the local x coordinates of the pointer when the event occured
  16573. * @param localY Defines the local y coordinates of the pointer when the event occured
  16574. */
  16575. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  16576. }
  16577. /**
  16578. * This type contains all the data related to a pointer event in Babylon.js.
  16579. * 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.
  16580. */
  16581. export class PointerInfo extends PointerInfoBase {
  16582. /**
  16583. * Defines the picking info associated to the info (if any)\
  16584. */
  16585. pickInfo: Nullable<PickingInfo>;
  16586. /**
  16587. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  16588. * @param type Defines the type of event (PointerEventTypes)
  16589. * @param event Defines the related dom event
  16590. * @param pickInfo Defines the picking info associated to the info (if any)\
  16591. */
  16592. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  16593. /**
  16594. * Defines the picking info associated to the info (if any)\
  16595. */
  16596. pickInfo: Nullable<PickingInfo>);
  16597. }
  16598. /**
  16599. * Data relating to a touch event on the screen.
  16600. */
  16601. export interface PointerTouch {
  16602. /**
  16603. * X coordinate of touch.
  16604. */
  16605. x: number;
  16606. /**
  16607. * Y coordinate of touch.
  16608. */
  16609. y: number;
  16610. /**
  16611. * Id of touch. Unique for each finger.
  16612. */
  16613. pointerId: number;
  16614. /**
  16615. * Event type passed from DOM.
  16616. */
  16617. type: any;
  16618. }
  16619. }
  16620. declare module BABYLON {
  16621. /**
  16622. * Manage the mouse inputs to control the movement of a free camera.
  16623. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16624. */
  16625. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  16626. /**
  16627. * Define if touch is enabled in the mouse input
  16628. */
  16629. touchEnabled: boolean;
  16630. /**
  16631. * Defines the camera the input is attached to.
  16632. */
  16633. camera: FreeCamera;
  16634. /**
  16635. * Defines the buttons associated with the input to handle camera move.
  16636. */
  16637. buttons: number[];
  16638. /**
  16639. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  16640. */
  16641. angularSensibility: number;
  16642. private _pointerInput;
  16643. private _onMouseMove;
  16644. private _observer;
  16645. private previousPosition;
  16646. /**
  16647. * Observable for when a pointer move event occurs containing the move offset
  16648. */
  16649. onPointerMovedObservable: Observable<{
  16650. offsetX: number;
  16651. offsetY: number;
  16652. }>;
  16653. /**
  16654. * @hidden
  16655. * If the camera should be rotated automatically based on pointer movement
  16656. */
  16657. _allowCameraRotation: boolean;
  16658. /**
  16659. * Manage the mouse inputs to control the movement of a free camera.
  16660. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16661. * @param touchEnabled Defines if touch is enabled or not
  16662. */
  16663. constructor(
  16664. /**
  16665. * Define if touch is enabled in the mouse input
  16666. */
  16667. touchEnabled?: boolean);
  16668. /**
  16669. * Attach the input controls to a specific dom element to get the input from.
  16670. * @param element Defines the element the controls should be listened from
  16671. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  16672. */
  16673. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  16674. /**
  16675. * Called on JS contextmenu event.
  16676. * Override this method to provide functionality.
  16677. */
  16678. protected onContextMenu(evt: PointerEvent): void;
  16679. /**
  16680. * Detach the current controls from the specified dom element.
  16681. * @param element Defines the element to stop listening the inputs from
  16682. */
  16683. detachControl(element: Nullable<HTMLElement>): void;
  16684. /**
  16685. * Gets the class name of the current intput.
  16686. * @returns the class name
  16687. */
  16688. getClassName(): string;
  16689. /**
  16690. * Get the friendly name associated with the input class.
  16691. * @returns the input friendly name
  16692. */
  16693. getSimpleName(): string;
  16694. }
  16695. }
  16696. declare module BABYLON {
  16697. /**
  16698. * Manage the touch inputs to control the movement of a free camera.
  16699. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16700. */
  16701. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  16702. /**
  16703. * Defines the camera the input is attached to.
  16704. */
  16705. camera: FreeCamera;
  16706. /**
  16707. * Defines the touch sensibility for rotation.
  16708. * The higher the faster.
  16709. */
  16710. touchAngularSensibility: number;
  16711. /**
  16712. * Defines the touch sensibility for move.
  16713. * The higher the faster.
  16714. */
  16715. touchMoveSensibility: number;
  16716. private _offsetX;
  16717. private _offsetY;
  16718. private _pointerPressed;
  16719. private _pointerInput;
  16720. private _observer;
  16721. private _onLostFocus;
  16722. /**
  16723. * Attach the input controls to a specific dom element to get the input from.
  16724. * @param element Defines the element the controls should be listened from
  16725. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  16726. */
  16727. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  16728. /**
  16729. * Detach the current controls from the specified dom element.
  16730. * @param element Defines the element to stop listening the inputs from
  16731. */
  16732. detachControl(element: Nullable<HTMLElement>): void;
  16733. /**
  16734. * Update the current camera state depending on the inputs that have been used this frame.
  16735. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  16736. */
  16737. checkInputs(): void;
  16738. /**
  16739. * Gets the class name of the current intput.
  16740. * @returns the class name
  16741. */
  16742. getClassName(): string;
  16743. /**
  16744. * Get the friendly name associated with the input class.
  16745. * @returns the input friendly name
  16746. */
  16747. getSimpleName(): string;
  16748. }
  16749. }
  16750. declare module BABYLON {
  16751. /**
  16752. * Default Inputs manager for the FreeCamera.
  16753. * It groups all the default supported inputs for ease of use.
  16754. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16755. */
  16756. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  16757. /**
  16758. * @hidden
  16759. */
  16760. _mouseInput: Nullable<FreeCameraMouseInput>;
  16761. /**
  16762. * Instantiates a new FreeCameraInputsManager.
  16763. * @param camera Defines the camera the inputs belong to
  16764. */
  16765. constructor(camera: FreeCamera);
  16766. /**
  16767. * Add keyboard input support to the input manager.
  16768. * @returns the current input manager
  16769. */
  16770. addKeyboard(): FreeCameraInputsManager;
  16771. /**
  16772. * Add mouse input support to the input manager.
  16773. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  16774. * @returns the current input manager
  16775. */
  16776. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  16777. /**
  16778. * Removes the mouse input support from the manager
  16779. * @returns the current input manager
  16780. */
  16781. removeMouse(): FreeCameraInputsManager;
  16782. /**
  16783. * Add touch input support to the input manager.
  16784. * @returns the current input manager
  16785. */
  16786. addTouch(): FreeCameraInputsManager;
  16787. /**
  16788. * Remove all attached input methods from a camera
  16789. */
  16790. clear(): void;
  16791. }
  16792. }
  16793. declare module BABYLON {
  16794. /**
  16795. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  16796. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  16797. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  16798. */
  16799. export class FreeCamera extends TargetCamera {
  16800. /**
  16801. * Define the collision ellipsoid of the camera.
  16802. * This is helpful to simulate a camera body like the player body around the camera
  16803. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  16804. */
  16805. ellipsoid: Vector3;
  16806. /**
  16807. * Define an offset for the position of the ellipsoid around the camera.
  16808. * This can be helpful to determine the center of the body near the gravity center of the body
  16809. * instead of its head.
  16810. */
  16811. ellipsoidOffset: Vector3;
  16812. /**
  16813. * Enable or disable collisions of the camera with the rest of the scene objects.
  16814. */
  16815. checkCollisions: boolean;
  16816. /**
  16817. * Enable or disable gravity on the camera.
  16818. */
  16819. applyGravity: boolean;
  16820. /**
  16821. * Define the input manager associated to the camera.
  16822. */
  16823. inputs: FreeCameraInputsManager;
  16824. /**
  16825. * Gets the input sensibility for a mouse input. (default is 2000.0)
  16826. * Higher values reduce sensitivity.
  16827. */
  16828. /**
  16829. * Sets the input sensibility for a mouse input. (default is 2000.0)
  16830. * Higher values reduce sensitivity.
  16831. */
  16832. angularSensibility: number;
  16833. /**
  16834. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  16835. */
  16836. keysUp: number[];
  16837. /**
  16838. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  16839. */
  16840. keysDown: number[];
  16841. /**
  16842. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  16843. */
  16844. keysLeft: number[];
  16845. /**
  16846. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  16847. */
  16848. keysRight: number[];
  16849. /**
  16850. * Event raised when the camera collide with a mesh in the scene.
  16851. */
  16852. onCollide: (collidedMesh: AbstractMesh) => void;
  16853. private _collider;
  16854. private _needMoveForGravity;
  16855. private _oldPosition;
  16856. private _diffPosition;
  16857. private _newPosition;
  16858. /** @hidden */
  16859. _localDirection: Vector3;
  16860. /** @hidden */
  16861. _transformedDirection: Vector3;
  16862. /**
  16863. * Instantiates a Free Camera.
  16864. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  16865. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  16866. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  16867. * @param name Define the name of the camera in the scene
  16868. * @param position Define the start position of the camera in the scene
  16869. * @param scene Define the scene the camera belongs to
  16870. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  16871. */
  16872. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  16873. /**
  16874. * Attached controls to the current camera.
  16875. * @param element Defines the element the controls should be listened from
  16876. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  16877. */
  16878. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  16879. /**
  16880. * Detach the current controls from the camera.
  16881. * The camera will stop reacting to inputs.
  16882. * @param element Defines the element to stop listening the inputs from
  16883. */
  16884. detachControl(element: HTMLElement): void;
  16885. private _collisionMask;
  16886. /**
  16887. * Define a collision mask to limit the list of object the camera can collide with
  16888. */
  16889. collisionMask: number;
  16890. /** @hidden */
  16891. _collideWithWorld(displacement: Vector3): void;
  16892. private _onCollisionPositionChange;
  16893. /** @hidden */
  16894. _checkInputs(): void;
  16895. /** @hidden */
  16896. _decideIfNeedsToMove(): boolean;
  16897. /** @hidden */
  16898. _updatePosition(): void;
  16899. /**
  16900. * Destroy the camera and release the current resources hold by it.
  16901. */
  16902. dispose(): void;
  16903. /**
  16904. * Gets the current object class name.
  16905. * @return the class name
  16906. */
  16907. getClassName(): string;
  16908. }
  16909. }
  16910. declare module BABYLON {
  16911. /**
  16912. * Represents a gamepad control stick position
  16913. */
  16914. export class StickValues {
  16915. /**
  16916. * The x component of the control stick
  16917. */
  16918. x: number;
  16919. /**
  16920. * The y component of the control stick
  16921. */
  16922. y: number;
  16923. /**
  16924. * Initializes the gamepad x and y control stick values
  16925. * @param x The x component of the gamepad control stick value
  16926. * @param y The y component of the gamepad control stick value
  16927. */
  16928. constructor(
  16929. /**
  16930. * The x component of the control stick
  16931. */
  16932. x: number,
  16933. /**
  16934. * The y component of the control stick
  16935. */
  16936. y: number);
  16937. }
  16938. /**
  16939. * An interface which manages callbacks for gamepad button changes
  16940. */
  16941. export interface GamepadButtonChanges {
  16942. /**
  16943. * Called when a gamepad has been changed
  16944. */
  16945. changed: boolean;
  16946. /**
  16947. * Called when a gamepad press event has been triggered
  16948. */
  16949. pressChanged: boolean;
  16950. /**
  16951. * Called when a touch event has been triggered
  16952. */
  16953. touchChanged: boolean;
  16954. /**
  16955. * Called when a value has changed
  16956. */
  16957. valueChanged: boolean;
  16958. }
  16959. /**
  16960. * Represents a gamepad
  16961. */
  16962. export class Gamepad {
  16963. /**
  16964. * The id of the gamepad
  16965. */
  16966. id: string;
  16967. /**
  16968. * The index of the gamepad
  16969. */
  16970. index: number;
  16971. /**
  16972. * The browser gamepad
  16973. */
  16974. browserGamepad: any;
  16975. /**
  16976. * Specifies what type of gamepad this represents
  16977. */
  16978. type: number;
  16979. private _leftStick;
  16980. private _rightStick;
  16981. /** @hidden */
  16982. _isConnected: boolean;
  16983. private _leftStickAxisX;
  16984. private _leftStickAxisY;
  16985. private _rightStickAxisX;
  16986. private _rightStickAxisY;
  16987. /**
  16988. * Triggered when the left control stick has been changed
  16989. */
  16990. private _onleftstickchanged;
  16991. /**
  16992. * Triggered when the right control stick has been changed
  16993. */
  16994. private _onrightstickchanged;
  16995. /**
  16996. * Represents a gamepad controller
  16997. */
  16998. static GAMEPAD: number;
  16999. /**
  17000. * Represents a generic controller
  17001. */
  17002. static GENERIC: number;
  17003. /**
  17004. * Represents an XBox controller
  17005. */
  17006. static XBOX: number;
  17007. /**
  17008. * Represents a pose-enabled controller
  17009. */
  17010. static POSE_ENABLED: number;
  17011. /**
  17012. * Specifies whether the left control stick should be Y-inverted
  17013. */
  17014. protected _invertLeftStickY: boolean;
  17015. /**
  17016. * Specifies if the gamepad has been connected
  17017. */
  17018. readonly isConnected: boolean;
  17019. /**
  17020. * Initializes the gamepad
  17021. * @param id The id of the gamepad
  17022. * @param index The index of the gamepad
  17023. * @param browserGamepad The browser gamepad
  17024. * @param leftStickX The x component of the left joystick
  17025. * @param leftStickY The y component of the left joystick
  17026. * @param rightStickX The x component of the right joystick
  17027. * @param rightStickY The y component of the right joystick
  17028. */
  17029. constructor(
  17030. /**
  17031. * The id of the gamepad
  17032. */
  17033. id: string,
  17034. /**
  17035. * The index of the gamepad
  17036. */
  17037. index: number,
  17038. /**
  17039. * The browser gamepad
  17040. */
  17041. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  17042. /**
  17043. * Callback triggered when the left joystick has changed
  17044. * @param callback
  17045. */
  17046. onleftstickchanged(callback: (values: StickValues) => void): void;
  17047. /**
  17048. * Callback triggered when the right joystick has changed
  17049. * @param callback
  17050. */
  17051. onrightstickchanged(callback: (values: StickValues) => void): void;
  17052. /**
  17053. * Gets the left joystick
  17054. */
  17055. /**
  17056. * Sets the left joystick values
  17057. */
  17058. leftStick: StickValues;
  17059. /**
  17060. * Gets the right joystick
  17061. */
  17062. /**
  17063. * Sets the right joystick value
  17064. */
  17065. rightStick: StickValues;
  17066. /**
  17067. * Updates the gamepad joystick positions
  17068. */
  17069. update(): void;
  17070. /**
  17071. * Disposes the gamepad
  17072. */
  17073. dispose(): void;
  17074. }
  17075. /**
  17076. * Represents a generic gamepad
  17077. */
  17078. export class GenericPad extends Gamepad {
  17079. private _buttons;
  17080. private _onbuttondown;
  17081. private _onbuttonup;
  17082. /**
  17083. * Observable triggered when a button has been pressed
  17084. */
  17085. onButtonDownObservable: Observable<number>;
  17086. /**
  17087. * Observable triggered when a button has been released
  17088. */
  17089. onButtonUpObservable: Observable<number>;
  17090. /**
  17091. * Callback triggered when a button has been pressed
  17092. * @param callback Called when a button has been pressed
  17093. */
  17094. onbuttondown(callback: (buttonPressed: number) => void): void;
  17095. /**
  17096. * Callback triggered when a button has been released
  17097. * @param callback Called when a button has been released
  17098. */
  17099. onbuttonup(callback: (buttonReleased: number) => void): void;
  17100. /**
  17101. * Initializes the generic gamepad
  17102. * @param id The id of the generic gamepad
  17103. * @param index The index of the generic gamepad
  17104. * @param browserGamepad The browser gamepad
  17105. */
  17106. constructor(id: string, index: number, browserGamepad: any);
  17107. private _setButtonValue;
  17108. /**
  17109. * Updates the generic gamepad
  17110. */
  17111. update(): void;
  17112. /**
  17113. * Disposes the generic gamepad
  17114. */
  17115. dispose(): void;
  17116. }
  17117. }
  17118. declare module BABYLON {
  17119. /**
  17120. * Defines the types of pose enabled controllers that are supported
  17121. */
  17122. export enum PoseEnabledControllerType {
  17123. /**
  17124. * HTC Vive
  17125. */
  17126. VIVE = 0,
  17127. /**
  17128. * Oculus Rift
  17129. */
  17130. OCULUS = 1,
  17131. /**
  17132. * Windows mixed reality
  17133. */
  17134. WINDOWS = 2,
  17135. /**
  17136. * Samsung gear VR
  17137. */
  17138. GEAR_VR = 3,
  17139. /**
  17140. * Google Daydream
  17141. */
  17142. DAYDREAM = 4,
  17143. /**
  17144. * Generic
  17145. */
  17146. GENERIC = 5
  17147. }
  17148. /**
  17149. * Defines the MutableGamepadButton interface for the state of a gamepad button
  17150. */
  17151. export interface MutableGamepadButton {
  17152. /**
  17153. * Value of the button/trigger
  17154. */
  17155. value: number;
  17156. /**
  17157. * If the button/trigger is currently touched
  17158. */
  17159. touched: boolean;
  17160. /**
  17161. * If the button/trigger is currently pressed
  17162. */
  17163. pressed: boolean;
  17164. }
  17165. /**
  17166. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  17167. * @hidden
  17168. */
  17169. export interface ExtendedGamepadButton extends GamepadButton {
  17170. /**
  17171. * If the button/trigger is currently pressed
  17172. */
  17173. readonly pressed: boolean;
  17174. /**
  17175. * If the button/trigger is currently touched
  17176. */
  17177. readonly touched: boolean;
  17178. /**
  17179. * Value of the button/trigger
  17180. */
  17181. readonly value: number;
  17182. }
  17183. /** @hidden */
  17184. export interface _GamePadFactory {
  17185. /**
  17186. * Returns wether or not the current gamepad can be created for this type of controller.
  17187. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  17188. * @returns true if it can be created, otherwise false
  17189. */
  17190. canCreate(gamepadInfo: any): boolean;
  17191. /**
  17192. * Creates a new instance of the Gamepad.
  17193. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  17194. * @returns the new gamepad instance
  17195. */
  17196. create(gamepadInfo: any): Gamepad;
  17197. }
  17198. /**
  17199. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  17200. */
  17201. export class PoseEnabledControllerHelper {
  17202. /** @hidden */
  17203. static _ControllerFactories: _GamePadFactory[];
  17204. /** @hidden */
  17205. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  17206. /**
  17207. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  17208. * @param vrGamepad the gamepad to initialized
  17209. * @returns a vr controller of the type the gamepad identified as
  17210. */
  17211. static InitiateController(vrGamepad: any): Gamepad;
  17212. }
  17213. /**
  17214. * Defines the PoseEnabledController object that contains state of a vr capable controller
  17215. */
  17216. export class PoseEnabledController extends Gamepad implements PoseControlled {
  17217. private _deviceRoomPosition;
  17218. private _deviceRoomRotationQuaternion;
  17219. /**
  17220. * The device position in babylon space
  17221. */
  17222. devicePosition: Vector3;
  17223. /**
  17224. * The device rotation in babylon space
  17225. */
  17226. deviceRotationQuaternion: Quaternion;
  17227. /**
  17228. * The scale factor of the device in babylon space
  17229. */
  17230. deviceScaleFactor: number;
  17231. /**
  17232. * (Likely devicePosition should be used instead) The device position in its room space
  17233. */
  17234. position: Vector3;
  17235. /**
  17236. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  17237. */
  17238. rotationQuaternion: Quaternion;
  17239. /**
  17240. * The type of controller (Eg. Windows mixed reality)
  17241. */
  17242. controllerType: PoseEnabledControllerType;
  17243. protected _calculatedPosition: Vector3;
  17244. private _calculatedRotation;
  17245. /**
  17246. * The raw pose from the device
  17247. */
  17248. rawPose: DevicePose;
  17249. private _trackPosition;
  17250. private _maxRotationDistFromHeadset;
  17251. private _draggedRoomRotation;
  17252. /**
  17253. * @hidden
  17254. */
  17255. _disableTrackPosition(fixedPosition: Vector3): void;
  17256. /**
  17257. * Internal, the mesh attached to the controller
  17258. * @hidden
  17259. */
  17260. _mesh: Nullable<AbstractMesh>;
  17261. private _poseControlledCamera;
  17262. private _leftHandSystemQuaternion;
  17263. /**
  17264. * Internal, matrix used to convert room space to babylon space
  17265. * @hidden
  17266. */
  17267. _deviceToWorld: Matrix;
  17268. /**
  17269. * Node to be used when casting a ray from the controller
  17270. * @hidden
  17271. */
  17272. _pointingPoseNode: Nullable<TransformNode>;
  17273. /**
  17274. * Name of the child mesh that can be used to cast a ray from the controller
  17275. */
  17276. static readonly POINTING_POSE: string;
  17277. /**
  17278. * Creates a new PoseEnabledController from a gamepad
  17279. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  17280. */
  17281. constructor(browserGamepad: any);
  17282. private _workingMatrix;
  17283. /**
  17284. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  17285. */
  17286. update(): void;
  17287. /**
  17288. * Updates only the pose device and mesh without doing any button event checking
  17289. */
  17290. protected _updatePoseAndMesh(): void;
  17291. /**
  17292. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  17293. * @param poseData raw pose fromthe device
  17294. */
  17295. updateFromDevice(poseData: DevicePose): void;
  17296. /**
  17297. * @hidden
  17298. */
  17299. _meshAttachedObservable: Observable<AbstractMesh>;
  17300. /**
  17301. * Attaches a mesh to the controller
  17302. * @param mesh the mesh to be attached
  17303. */
  17304. attachToMesh(mesh: AbstractMesh): void;
  17305. /**
  17306. * Attaches the controllers mesh to a camera
  17307. * @param camera the camera the mesh should be attached to
  17308. */
  17309. attachToPoseControlledCamera(camera: TargetCamera): void;
  17310. /**
  17311. * Disposes of the controller
  17312. */
  17313. dispose(): void;
  17314. /**
  17315. * The mesh that is attached to the controller
  17316. */
  17317. readonly mesh: Nullable<AbstractMesh>;
  17318. /**
  17319. * Gets the ray of the controller in the direction the controller is pointing
  17320. * @param length the length the resulting ray should be
  17321. * @returns a ray in the direction the controller is pointing
  17322. */
  17323. getForwardRay(length?: number): Ray;
  17324. }
  17325. }
  17326. declare module BABYLON {
  17327. /**
  17328. * Defines the WebVRController object that represents controllers tracked in 3D space
  17329. */
  17330. export abstract class WebVRController extends PoseEnabledController {
  17331. /**
  17332. * Internal, the default controller model for the controller
  17333. */
  17334. protected _defaultModel: AbstractMesh;
  17335. /**
  17336. * Fired when the trigger state has changed
  17337. */
  17338. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  17339. /**
  17340. * Fired when the main button state has changed
  17341. */
  17342. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  17343. /**
  17344. * Fired when the secondary button state has changed
  17345. */
  17346. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  17347. /**
  17348. * Fired when the pad state has changed
  17349. */
  17350. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  17351. /**
  17352. * Fired when controllers stick values have changed
  17353. */
  17354. onPadValuesChangedObservable: Observable<StickValues>;
  17355. /**
  17356. * Array of button availible on the controller
  17357. */
  17358. protected _buttons: Array<MutableGamepadButton>;
  17359. private _onButtonStateChange;
  17360. /**
  17361. * Fired when a controller button's state has changed
  17362. * @param callback the callback containing the button that was modified
  17363. */
  17364. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  17365. /**
  17366. * X and Y axis corresponding to the controllers joystick
  17367. */
  17368. pad: StickValues;
  17369. /**
  17370. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  17371. */
  17372. hand: string;
  17373. /**
  17374. * The default controller model for the controller
  17375. */
  17376. readonly defaultModel: AbstractMesh;
  17377. /**
  17378. * Creates a new WebVRController from a gamepad
  17379. * @param vrGamepad the gamepad that the WebVRController should be created from
  17380. */
  17381. constructor(vrGamepad: any);
  17382. /**
  17383. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  17384. */
  17385. update(): void;
  17386. /**
  17387. * Function to be called when a button is modified
  17388. */
  17389. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  17390. /**
  17391. * Loads a mesh and attaches it to the controller
  17392. * @param scene the scene the mesh should be added to
  17393. * @param meshLoaded callback for when the mesh has been loaded
  17394. */
  17395. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  17396. private _setButtonValue;
  17397. private _changes;
  17398. private _checkChanges;
  17399. /**
  17400. * Disposes of th webVRCOntroller
  17401. */
  17402. dispose(): void;
  17403. }
  17404. }
  17405. declare module BABYLON {
  17406. /**
  17407. * The HemisphericLight simulates the ambient environment light,
  17408. * so the passed direction is the light reflection direction, not the incoming direction.
  17409. */
  17410. export class HemisphericLight extends Light {
  17411. /**
  17412. * The groundColor is the light in the opposite direction to the one specified during creation.
  17413. * 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.
  17414. */
  17415. groundColor: Color3;
  17416. /**
  17417. * The light reflection direction, not the incoming direction.
  17418. */
  17419. direction: Vector3;
  17420. /**
  17421. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  17422. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  17423. * The HemisphericLight can't cast shadows.
  17424. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17425. * @param name The friendly name of the light
  17426. * @param direction The direction of the light reflection
  17427. * @param scene The scene the light belongs to
  17428. */
  17429. constructor(name: string, direction: Vector3, scene: Scene);
  17430. protected _buildUniformLayout(): void;
  17431. /**
  17432. * Returns the string "HemisphericLight".
  17433. * @return The class name
  17434. */
  17435. getClassName(): string;
  17436. /**
  17437. * Sets the HemisphericLight direction towards the passed target (Vector3).
  17438. * Returns the updated direction.
  17439. * @param target The target the direction should point to
  17440. * @return The computed direction
  17441. */
  17442. setDirectionToTarget(target: Vector3): Vector3;
  17443. /**
  17444. * Returns the shadow generator associated to the light.
  17445. * @returns Always null for hemispheric lights because it does not support shadows.
  17446. */
  17447. getShadowGenerator(): Nullable<IShadowGenerator>;
  17448. /**
  17449. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  17450. * @param effect The effect to update
  17451. * @param lightIndex The index of the light in the effect to update
  17452. * @returns The hemispheric light
  17453. */
  17454. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  17455. /**
  17456. * Computes the world matrix of the node
  17457. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  17458. * @param useWasUpdatedFlag defines a reserved property
  17459. * @returns the world matrix
  17460. */
  17461. computeWorldMatrix(): Matrix;
  17462. /**
  17463. * Returns the integer 3.
  17464. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17465. */
  17466. getTypeID(): number;
  17467. /**
  17468. * Prepares the list of defines specific to the light type.
  17469. * @param defines the list of defines
  17470. * @param lightIndex defines the index of the light for the effect
  17471. */
  17472. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17473. }
  17474. }
  17475. declare module BABYLON {
  17476. /** @hidden */
  17477. export var vrMultiviewToSingleviewPixelShader: {
  17478. name: string;
  17479. shader: string;
  17480. };
  17481. }
  17482. declare module BABYLON {
  17483. /**
  17484. * Renders to multiple views with a single draw call
  17485. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  17486. */
  17487. export class MultiviewRenderTarget extends RenderTargetTexture {
  17488. /**
  17489. * Creates a multiview render target
  17490. * @param scene scene used with the render target
  17491. * @param size the size of the render target (used for each view)
  17492. */
  17493. constructor(scene: Scene, size?: number | {
  17494. width: number;
  17495. height: number;
  17496. } | {
  17497. ratio: number;
  17498. });
  17499. /**
  17500. * @hidden
  17501. * @param faceIndex the face index, if its a cube texture
  17502. */
  17503. _bindFrameBuffer(faceIndex?: number): void;
  17504. /**
  17505. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  17506. * @returns the view count
  17507. */
  17508. getViewCount(): number;
  17509. }
  17510. }
  17511. declare module BABYLON {
  17512. interface Engine {
  17513. /**
  17514. * Creates a new multiview render target
  17515. * @param width defines the width of the texture
  17516. * @param height defines the height of the texture
  17517. * @returns the created multiview texture
  17518. */
  17519. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  17520. /**
  17521. * Binds a multiview framebuffer to be drawn to
  17522. * @param multiviewTexture texture to bind
  17523. */
  17524. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  17525. }
  17526. interface Camera {
  17527. /**
  17528. * @hidden
  17529. * 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)
  17530. */
  17531. _useMultiviewToSingleView: boolean;
  17532. /**
  17533. * @hidden
  17534. * 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)
  17535. */
  17536. _multiviewTexture: Nullable<RenderTargetTexture>;
  17537. /**
  17538. * @hidden
  17539. * ensures the multiview texture of the camera exists and has the specified width/height
  17540. * @param width height to set on the multiview texture
  17541. * @param height width to set on the multiview texture
  17542. */
  17543. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  17544. }
  17545. interface Scene {
  17546. /** @hidden */
  17547. _transformMatrixR: Matrix;
  17548. /** @hidden */
  17549. _multiviewSceneUbo: Nullable<UniformBuffer>;
  17550. /** @hidden */
  17551. _createMultiviewUbo(): void;
  17552. /** @hidden */
  17553. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  17554. /** @hidden */
  17555. _renderMultiviewToSingleView(camera: Camera): void;
  17556. }
  17557. }
  17558. declare module BABYLON {
  17559. /**
  17560. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  17561. * This will not be used for webXR as it supports displaying texture arrays directly
  17562. */
  17563. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  17564. /**
  17565. * Initializes a VRMultiviewToSingleview
  17566. * @param name name of the post process
  17567. * @param camera camera to be applied to
  17568. * @param scaleFactor scaling factor to the size of the output texture
  17569. */
  17570. constructor(name: string, camera: Camera, scaleFactor: number);
  17571. }
  17572. }
  17573. declare module BABYLON {
  17574. interface Engine {
  17575. /** @hidden */
  17576. _vrDisplay: any;
  17577. /** @hidden */
  17578. _vrSupported: boolean;
  17579. /** @hidden */
  17580. _oldSize: Size;
  17581. /** @hidden */
  17582. _oldHardwareScaleFactor: number;
  17583. /** @hidden */
  17584. _vrExclusivePointerMode: boolean;
  17585. /** @hidden */
  17586. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  17587. /** @hidden */
  17588. _onVRDisplayPointerRestricted: () => void;
  17589. /** @hidden */
  17590. _onVRDisplayPointerUnrestricted: () => void;
  17591. /** @hidden */
  17592. _onVrDisplayConnect: Nullable<(display: any) => void>;
  17593. /** @hidden */
  17594. _onVrDisplayDisconnect: Nullable<() => void>;
  17595. /** @hidden */
  17596. _onVrDisplayPresentChange: Nullable<() => void>;
  17597. /**
  17598. * Observable signaled when VR display mode changes
  17599. */
  17600. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  17601. /**
  17602. * Observable signaled when VR request present is complete
  17603. */
  17604. onVRRequestPresentComplete: Observable<boolean>;
  17605. /**
  17606. * Observable signaled when VR request present starts
  17607. */
  17608. onVRRequestPresentStart: Observable<Engine>;
  17609. /**
  17610. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  17611. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  17612. */
  17613. isInVRExclusivePointerMode: boolean;
  17614. /**
  17615. * Gets a boolean indicating if a webVR device was detected
  17616. * @returns true if a webVR device was detected
  17617. */
  17618. isVRDevicePresent(): boolean;
  17619. /**
  17620. * Gets the current webVR device
  17621. * @returns the current webVR device (or null)
  17622. */
  17623. getVRDevice(): any;
  17624. /**
  17625. * Initializes a webVR display and starts listening to display change events
  17626. * The onVRDisplayChangedObservable will be notified upon these changes
  17627. * @returns A promise containing a VRDisplay and if vr is supported
  17628. */
  17629. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  17630. /** @hidden */
  17631. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  17632. /**
  17633. * Call this function to switch to webVR mode
  17634. * Will do nothing if webVR is not supported or if there is no webVR device
  17635. * @see http://doc.babylonjs.com/how_to/webvr_camera
  17636. */
  17637. enableVR(): void;
  17638. /** @hidden */
  17639. _onVRFullScreenTriggered(): void;
  17640. }
  17641. }
  17642. declare module BABYLON {
  17643. /**
  17644. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  17645. * IMPORTANT!! The data is right-hand data.
  17646. * @export
  17647. * @interface DevicePose
  17648. */
  17649. export interface DevicePose {
  17650. /**
  17651. * The position of the device, values in array are [x,y,z].
  17652. */
  17653. readonly position: Nullable<Float32Array>;
  17654. /**
  17655. * The linearVelocity of the device, values in array are [x,y,z].
  17656. */
  17657. readonly linearVelocity: Nullable<Float32Array>;
  17658. /**
  17659. * The linearAcceleration of the device, values in array are [x,y,z].
  17660. */
  17661. readonly linearAcceleration: Nullable<Float32Array>;
  17662. /**
  17663. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  17664. */
  17665. readonly orientation: Nullable<Float32Array>;
  17666. /**
  17667. * The angularVelocity of the device, values in array are [x,y,z].
  17668. */
  17669. readonly angularVelocity: Nullable<Float32Array>;
  17670. /**
  17671. * The angularAcceleration of the device, values in array are [x,y,z].
  17672. */
  17673. readonly angularAcceleration: Nullable<Float32Array>;
  17674. }
  17675. /**
  17676. * Interface representing a pose controlled object in Babylon.
  17677. * A pose controlled object has both regular pose values as well as pose values
  17678. * from an external device such as a VR head mounted display
  17679. */
  17680. export interface PoseControlled {
  17681. /**
  17682. * The position of the object in babylon space.
  17683. */
  17684. position: Vector3;
  17685. /**
  17686. * The rotation quaternion of the object in babylon space.
  17687. */
  17688. rotationQuaternion: Quaternion;
  17689. /**
  17690. * The position of the device in babylon space.
  17691. */
  17692. devicePosition?: Vector3;
  17693. /**
  17694. * The rotation quaternion of the device in babylon space.
  17695. */
  17696. deviceRotationQuaternion: Quaternion;
  17697. /**
  17698. * The raw pose coming from the device.
  17699. */
  17700. rawPose: Nullable<DevicePose>;
  17701. /**
  17702. * The scale of the device to be used when translating from device space to babylon space.
  17703. */
  17704. deviceScaleFactor: number;
  17705. /**
  17706. * Updates the poseControlled values based on the input device pose.
  17707. * @param poseData the pose data to update the object with
  17708. */
  17709. updateFromDevice(poseData: DevicePose): void;
  17710. }
  17711. /**
  17712. * Set of options to customize the webVRCamera
  17713. */
  17714. export interface WebVROptions {
  17715. /**
  17716. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  17717. */
  17718. trackPosition?: boolean;
  17719. /**
  17720. * Sets the scale of the vrDevice in babylon space. (default: 1)
  17721. */
  17722. positionScale?: number;
  17723. /**
  17724. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  17725. */
  17726. displayName?: string;
  17727. /**
  17728. * Should the native controller meshes be initialized. (default: true)
  17729. */
  17730. controllerMeshes?: boolean;
  17731. /**
  17732. * Creating a default HemiLight only on controllers. (default: true)
  17733. */
  17734. defaultLightingOnControllers?: boolean;
  17735. /**
  17736. * If you don't want to use the default VR button of the helper. (default: false)
  17737. */
  17738. useCustomVRButton?: boolean;
  17739. /**
  17740. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  17741. */
  17742. customVRButton?: HTMLButtonElement;
  17743. /**
  17744. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  17745. */
  17746. rayLength?: number;
  17747. /**
  17748. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  17749. */
  17750. defaultHeight?: number;
  17751. /**
  17752. * If multiview should be used if availible (default: false)
  17753. */
  17754. useMultiview?: boolean;
  17755. }
  17756. /**
  17757. * This represents a WebVR camera.
  17758. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  17759. * @example http://doc.babylonjs.com/how_to/webvr_camera
  17760. */
  17761. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  17762. private webVROptions;
  17763. /**
  17764. * @hidden
  17765. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  17766. */
  17767. _vrDevice: any;
  17768. /**
  17769. * The rawPose of the vrDevice.
  17770. */
  17771. rawPose: Nullable<DevicePose>;
  17772. private _onVREnabled;
  17773. private _specsVersion;
  17774. private _attached;
  17775. private _frameData;
  17776. protected _descendants: Array<Node>;
  17777. private _deviceRoomPosition;
  17778. /** @hidden */
  17779. _deviceRoomRotationQuaternion: Quaternion;
  17780. private _standingMatrix;
  17781. /**
  17782. * Represents device position in babylon space.
  17783. */
  17784. devicePosition: Vector3;
  17785. /**
  17786. * Represents device rotation in babylon space.
  17787. */
  17788. deviceRotationQuaternion: Quaternion;
  17789. /**
  17790. * The scale of the device to be used when translating from device space to babylon space.
  17791. */
  17792. deviceScaleFactor: number;
  17793. private _deviceToWorld;
  17794. private _worldToDevice;
  17795. /**
  17796. * References to the webVR controllers for the vrDevice.
  17797. */
  17798. controllers: Array<WebVRController>;
  17799. /**
  17800. * Emits an event when a controller is attached.
  17801. */
  17802. onControllersAttachedObservable: Observable<WebVRController[]>;
  17803. /**
  17804. * Emits an event when a controller's mesh has been loaded;
  17805. */
  17806. onControllerMeshLoadedObservable: Observable<WebVRController>;
  17807. /**
  17808. * Emits an event when the HMD's pose has been updated.
  17809. */
  17810. onPoseUpdatedFromDeviceObservable: Observable<any>;
  17811. private _poseSet;
  17812. /**
  17813. * If the rig cameras be used as parent instead of this camera.
  17814. */
  17815. rigParenting: boolean;
  17816. private _lightOnControllers;
  17817. private _defaultHeight?;
  17818. /**
  17819. * Instantiates a WebVRFreeCamera.
  17820. * @param name The name of the WebVRFreeCamera
  17821. * @param position The starting anchor position for the camera
  17822. * @param scene The scene the camera belongs to
  17823. * @param webVROptions a set of customizable options for the webVRCamera
  17824. */
  17825. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  17826. /**
  17827. * Gets the device distance from the ground in meters.
  17828. * @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.
  17829. */
  17830. deviceDistanceToRoomGround(): number;
  17831. /**
  17832. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  17833. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  17834. */
  17835. useStandingMatrix(callback?: (bool: boolean) => void): void;
  17836. /**
  17837. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  17838. * @returns A promise with a boolean set to if the standing matrix is supported.
  17839. */
  17840. useStandingMatrixAsync(): Promise<boolean>;
  17841. /**
  17842. * Disposes the camera
  17843. */
  17844. dispose(): void;
  17845. /**
  17846. * Gets a vrController by name.
  17847. * @param name The name of the controller to retreive
  17848. * @returns the controller matching the name specified or null if not found
  17849. */
  17850. getControllerByName(name: string): Nullable<WebVRController>;
  17851. private _leftController;
  17852. /**
  17853. * The controller corresponding to the users left hand.
  17854. */
  17855. readonly leftController: Nullable<WebVRController>;
  17856. private _rightController;
  17857. /**
  17858. * The controller corresponding to the users right hand.
  17859. */
  17860. readonly rightController: Nullable<WebVRController>;
  17861. /**
  17862. * Casts a ray forward from the vrCamera's gaze.
  17863. * @param length Length of the ray (default: 100)
  17864. * @returns the ray corresponding to the gaze
  17865. */
  17866. getForwardRay(length?: number): Ray;
  17867. /**
  17868. * @hidden
  17869. * Updates the camera based on device's frame data
  17870. */
  17871. _checkInputs(): void;
  17872. /**
  17873. * Updates the poseControlled values based on the input device pose.
  17874. * @param poseData Pose coming from the device
  17875. */
  17876. updateFromDevice(poseData: DevicePose): void;
  17877. private _htmlElementAttached;
  17878. private _detachIfAttached;
  17879. /**
  17880. * WebVR's attach control will start broadcasting frames to the device.
  17881. * Note that in certain browsers (chrome for example) this function must be called
  17882. * within a user-interaction callback. Example:
  17883. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  17884. *
  17885. * @param element html element to attach the vrDevice to
  17886. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  17887. */
  17888. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  17889. /**
  17890. * Detaches the camera from the html element and disables VR
  17891. *
  17892. * @param element html element to detach from
  17893. */
  17894. detachControl(element: HTMLElement): void;
  17895. /**
  17896. * @returns the name of this class
  17897. */
  17898. getClassName(): string;
  17899. /**
  17900. * Calls resetPose on the vrDisplay
  17901. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  17902. */
  17903. resetToCurrentRotation(): void;
  17904. /**
  17905. * @hidden
  17906. * Updates the rig cameras (left and right eye)
  17907. */
  17908. _updateRigCameras(): void;
  17909. private _workingVector;
  17910. private _oneVector;
  17911. private _workingMatrix;
  17912. private updateCacheCalled;
  17913. private _correctPositionIfNotTrackPosition;
  17914. /**
  17915. * @hidden
  17916. * Updates the cached values of the camera
  17917. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  17918. */
  17919. _updateCache(ignoreParentClass?: boolean): void;
  17920. /**
  17921. * @hidden
  17922. * Get current device position in babylon world
  17923. */
  17924. _computeDevicePosition(): void;
  17925. /**
  17926. * Updates the current device position and rotation in the babylon world
  17927. */
  17928. update(): void;
  17929. /**
  17930. * @hidden
  17931. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  17932. * @returns an identity matrix
  17933. */
  17934. _getViewMatrix(): Matrix;
  17935. private _tmpMatrix;
  17936. /**
  17937. * This function is called by the two RIG cameras.
  17938. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  17939. * @hidden
  17940. */
  17941. _getWebVRViewMatrix(): Matrix;
  17942. /** @hidden */
  17943. _getWebVRProjectionMatrix(): Matrix;
  17944. private _onGamepadConnectedObserver;
  17945. private _onGamepadDisconnectedObserver;
  17946. private _updateCacheWhenTrackingDisabledObserver;
  17947. /**
  17948. * Initializes the controllers and their meshes
  17949. */
  17950. initControllers(): void;
  17951. }
  17952. }
  17953. declare module BABYLON {
  17954. /**
  17955. * Size options for a post process
  17956. */
  17957. export type PostProcessOptions = {
  17958. width: number;
  17959. height: number;
  17960. };
  17961. /**
  17962. * PostProcess can be used to apply a shader to a texture after it has been rendered
  17963. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  17964. */
  17965. export class PostProcess {
  17966. /** Name of the PostProcess. */
  17967. name: string;
  17968. /**
  17969. * Gets or sets the unique id of the post process
  17970. */
  17971. uniqueId: number;
  17972. /**
  17973. * Width of the texture to apply the post process on
  17974. */
  17975. width: number;
  17976. /**
  17977. * Height of the texture to apply the post process on
  17978. */
  17979. height: number;
  17980. /**
  17981. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  17982. * @hidden
  17983. */
  17984. _outputTexture: Nullable<InternalTexture>;
  17985. /**
  17986. * Sampling mode used by the shader
  17987. * See https://doc.babylonjs.com/classes/3.1/texture
  17988. */
  17989. renderTargetSamplingMode: number;
  17990. /**
  17991. * Clear color to use when screen clearing
  17992. */
  17993. clearColor: Color4;
  17994. /**
  17995. * If the buffer needs to be cleared before applying the post process. (default: true)
  17996. * Should be set to false if shader will overwrite all previous pixels.
  17997. */
  17998. autoClear: boolean;
  17999. /**
  18000. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  18001. */
  18002. alphaMode: number;
  18003. /**
  18004. * Sets the setAlphaBlendConstants of the babylon engine
  18005. */
  18006. alphaConstants: Color4;
  18007. /**
  18008. * Animations to be used for the post processing
  18009. */
  18010. animations: Animation[];
  18011. /**
  18012. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  18013. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  18014. */
  18015. enablePixelPerfectMode: boolean;
  18016. /**
  18017. * Force the postprocess to be applied without taking in account viewport
  18018. */
  18019. forceFullscreenViewport: boolean;
  18020. /**
  18021. * List of inspectable custom properties (used by the Inspector)
  18022. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18023. */
  18024. inspectableCustomProperties: IInspectable[];
  18025. /**
  18026. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  18027. *
  18028. * | Value | Type | Description |
  18029. * | ----- | ----------------------------------- | ----------- |
  18030. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  18031. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  18032. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  18033. *
  18034. */
  18035. scaleMode: number;
  18036. /**
  18037. * Force textures to be a power of two (default: false)
  18038. */
  18039. alwaysForcePOT: boolean;
  18040. private _samples;
  18041. /**
  18042. * Number of sample textures (default: 1)
  18043. */
  18044. samples: number;
  18045. /**
  18046. * Modify the scale of the post process to be the same as the viewport (default: false)
  18047. */
  18048. adaptScaleToCurrentViewport: boolean;
  18049. private _camera;
  18050. private _scene;
  18051. private _engine;
  18052. private _options;
  18053. private _reusable;
  18054. private _textureType;
  18055. /**
  18056. * Smart array of input and output textures for the post process.
  18057. * @hidden
  18058. */
  18059. _textures: SmartArray<InternalTexture>;
  18060. /**
  18061. * The index in _textures that corresponds to the output texture.
  18062. * @hidden
  18063. */
  18064. _currentRenderTextureInd: number;
  18065. private _effect;
  18066. private _samplers;
  18067. private _fragmentUrl;
  18068. private _vertexUrl;
  18069. private _parameters;
  18070. private _scaleRatio;
  18071. protected _indexParameters: any;
  18072. private _shareOutputWithPostProcess;
  18073. private _texelSize;
  18074. private _forcedOutputTexture;
  18075. /**
  18076. * Returns the fragment url or shader name used in the post process.
  18077. * @returns the fragment url or name in the shader store.
  18078. */
  18079. getEffectName(): string;
  18080. /**
  18081. * An event triggered when the postprocess is activated.
  18082. */
  18083. onActivateObservable: Observable<Camera>;
  18084. private _onActivateObserver;
  18085. /**
  18086. * A function that is added to the onActivateObservable
  18087. */
  18088. onActivate: Nullable<(camera: Camera) => void>;
  18089. /**
  18090. * An event triggered when the postprocess changes its size.
  18091. */
  18092. onSizeChangedObservable: Observable<PostProcess>;
  18093. private _onSizeChangedObserver;
  18094. /**
  18095. * A function that is added to the onSizeChangedObservable
  18096. */
  18097. onSizeChanged: (postProcess: PostProcess) => void;
  18098. /**
  18099. * An event triggered when the postprocess applies its effect.
  18100. */
  18101. onApplyObservable: Observable<Effect>;
  18102. private _onApplyObserver;
  18103. /**
  18104. * A function that is added to the onApplyObservable
  18105. */
  18106. onApply: (effect: Effect) => void;
  18107. /**
  18108. * An event triggered before rendering the postprocess
  18109. */
  18110. onBeforeRenderObservable: Observable<Effect>;
  18111. private _onBeforeRenderObserver;
  18112. /**
  18113. * A function that is added to the onBeforeRenderObservable
  18114. */
  18115. onBeforeRender: (effect: Effect) => void;
  18116. /**
  18117. * An event triggered after rendering the postprocess
  18118. */
  18119. onAfterRenderObservable: Observable<Effect>;
  18120. private _onAfterRenderObserver;
  18121. /**
  18122. * A function that is added to the onAfterRenderObservable
  18123. */
  18124. onAfterRender: (efect: Effect) => void;
  18125. /**
  18126. * 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
  18127. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  18128. */
  18129. inputTexture: InternalTexture;
  18130. /**
  18131. * Gets the camera which post process is applied to.
  18132. * @returns The camera the post process is applied to.
  18133. */
  18134. getCamera(): Camera;
  18135. /**
  18136. * Gets the texel size of the postprocess.
  18137. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  18138. */
  18139. readonly texelSize: Vector2;
  18140. /**
  18141. * Creates a new instance PostProcess
  18142. * @param name The name of the PostProcess.
  18143. * @param fragmentUrl The url of the fragment shader to be used.
  18144. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  18145. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  18146. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  18147. * @param camera The camera to apply the render pass to.
  18148. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  18149. * @param engine The engine which the post process will be applied. (default: current engine)
  18150. * @param reusable If the post process can be reused on the same frame. (default: false)
  18151. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  18152. * @param textureType Type of textures used when performing the post process. (default: 0)
  18153. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  18154. * @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
  18155. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  18156. */
  18157. constructor(
  18158. /** Name of the PostProcess. */
  18159. 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);
  18160. /**
  18161. * Gets a string idenfifying the name of the class
  18162. * @returns "PostProcess" string
  18163. */
  18164. getClassName(): string;
  18165. /**
  18166. * Gets the engine which this post process belongs to.
  18167. * @returns The engine the post process was enabled with.
  18168. */
  18169. getEngine(): Engine;
  18170. /**
  18171. * The effect that is created when initializing the post process.
  18172. * @returns The created effect corresponding the the postprocess.
  18173. */
  18174. getEffect(): Effect;
  18175. /**
  18176. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  18177. * @param postProcess The post process to share the output with.
  18178. * @returns This post process.
  18179. */
  18180. shareOutputWith(postProcess: PostProcess): PostProcess;
  18181. /**
  18182. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  18183. * This should be called if the post process that shares output with this post process is disabled/disposed.
  18184. */
  18185. useOwnOutput(): void;
  18186. /**
  18187. * Updates the effect with the current post process compile time values and recompiles the shader.
  18188. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  18189. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  18190. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  18191. * @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
  18192. * @param onCompiled Called when the shader has been compiled.
  18193. * @param onError Called if there is an error when compiling a shader.
  18194. */
  18195. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18196. /**
  18197. * The post process is reusable if it can be used multiple times within one frame.
  18198. * @returns If the post process is reusable
  18199. */
  18200. isReusable(): boolean;
  18201. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  18202. markTextureDirty(): void;
  18203. /**
  18204. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  18205. * 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.
  18206. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  18207. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  18208. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  18209. * @returns The target texture that was bound to be written to.
  18210. */
  18211. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  18212. /**
  18213. * If the post process is supported.
  18214. */
  18215. readonly isSupported: boolean;
  18216. /**
  18217. * The aspect ratio of the output texture.
  18218. */
  18219. readonly aspectRatio: number;
  18220. /**
  18221. * Get a value indicating if the post-process is ready to be used
  18222. * @returns true if the post-process is ready (shader is compiled)
  18223. */
  18224. isReady(): boolean;
  18225. /**
  18226. * Binds all textures and uniforms to the shader, this will be run on every pass.
  18227. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  18228. */
  18229. apply(): Nullable<Effect>;
  18230. private _disposeTextures;
  18231. /**
  18232. * Disposes the post process.
  18233. * @param camera The camera to dispose the post process on.
  18234. */
  18235. dispose(camera?: Camera): void;
  18236. }
  18237. }
  18238. declare module BABYLON {
  18239. /** @hidden */
  18240. export var kernelBlurVaryingDeclaration: {
  18241. name: string;
  18242. shader: string;
  18243. };
  18244. }
  18245. declare module BABYLON {
  18246. /** @hidden */
  18247. export var kernelBlurFragment: {
  18248. name: string;
  18249. shader: string;
  18250. };
  18251. }
  18252. declare module BABYLON {
  18253. /** @hidden */
  18254. export var kernelBlurFragment2: {
  18255. name: string;
  18256. shader: string;
  18257. };
  18258. }
  18259. declare module BABYLON {
  18260. /** @hidden */
  18261. export var kernelBlurPixelShader: {
  18262. name: string;
  18263. shader: string;
  18264. };
  18265. }
  18266. declare module BABYLON {
  18267. /** @hidden */
  18268. export var kernelBlurVertex: {
  18269. name: string;
  18270. shader: string;
  18271. };
  18272. }
  18273. declare module BABYLON {
  18274. /** @hidden */
  18275. export var kernelBlurVertexShader: {
  18276. name: string;
  18277. shader: string;
  18278. };
  18279. }
  18280. declare module BABYLON {
  18281. /**
  18282. * The Blur Post Process which blurs an image based on a kernel and direction.
  18283. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  18284. */
  18285. export class BlurPostProcess extends PostProcess {
  18286. /** The direction in which to blur the image. */
  18287. direction: Vector2;
  18288. private blockCompilation;
  18289. protected _kernel: number;
  18290. protected _idealKernel: number;
  18291. protected _packedFloat: boolean;
  18292. private _staticDefines;
  18293. /**
  18294. * Sets the length in pixels of the blur sample region
  18295. */
  18296. /**
  18297. * Gets the length in pixels of the blur sample region
  18298. */
  18299. kernel: number;
  18300. /**
  18301. * Sets wether or not the blur needs to unpack/repack floats
  18302. */
  18303. /**
  18304. * Gets wether or not the blur is unpacking/repacking floats
  18305. */
  18306. packedFloat: boolean;
  18307. /**
  18308. * Creates a new instance BlurPostProcess
  18309. * @param name The name of the effect.
  18310. * @param direction The direction in which to blur the image.
  18311. * @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.
  18312. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  18313. * @param camera The camera to apply the render pass to.
  18314. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  18315. * @param engine The engine which the post process will be applied. (default: current engine)
  18316. * @param reusable If the post process can be reused on the same frame. (default: false)
  18317. * @param textureType Type of textures used when performing the post process. (default: 0)
  18318. * @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)
  18319. */
  18320. constructor(name: string,
  18321. /** The direction in which to blur the image. */
  18322. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  18323. /**
  18324. * Updates the effect with the current post process compile time values and recompiles the shader.
  18325. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  18326. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  18327. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  18328. * @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
  18329. * @param onCompiled Called when the shader has been compiled.
  18330. * @param onError Called if there is an error when compiling a shader.
  18331. */
  18332. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18333. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18334. /**
  18335. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  18336. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  18337. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  18338. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  18339. * The gaps between physical kernels are compensated for in the weighting of the samples
  18340. * @param idealKernel Ideal blur kernel.
  18341. * @return Nearest best kernel.
  18342. */
  18343. protected _nearestBestKernel(idealKernel: number): number;
  18344. /**
  18345. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  18346. * @param x The point on the Gaussian distribution to sample.
  18347. * @return the value of the Gaussian function at x.
  18348. */
  18349. protected _gaussianWeight(x: number): number;
  18350. /**
  18351. * Generates a string that can be used as a floating point number in GLSL.
  18352. * @param x Value to print.
  18353. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  18354. * @return GLSL float string.
  18355. */
  18356. protected _glslFloat(x: number, decimalFigures?: number): string;
  18357. }
  18358. }
  18359. declare module BABYLON {
  18360. /**
  18361. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18362. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18363. * You can then easily use it as a reflectionTexture on a flat surface.
  18364. * In case the surface is not a plane, please consider relying on reflection probes.
  18365. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18366. */
  18367. export class MirrorTexture extends RenderTargetTexture {
  18368. private scene;
  18369. /**
  18370. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18371. * 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.
  18372. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18373. */
  18374. mirrorPlane: Plane;
  18375. /**
  18376. * Define the blur ratio used to blur the reflection if needed.
  18377. */
  18378. blurRatio: number;
  18379. /**
  18380. * Define the adaptive blur kernel used to blur the reflection if needed.
  18381. * This will autocompute the closest best match for the `blurKernel`
  18382. */
  18383. adaptiveBlurKernel: number;
  18384. /**
  18385. * Define the blur kernel used to blur the reflection if needed.
  18386. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18387. */
  18388. blurKernel: number;
  18389. /**
  18390. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18391. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18392. */
  18393. blurKernelX: number;
  18394. /**
  18395. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18396. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18397. */
  18398. blurKernelY: number;
  18399. private _autoComputeBlurKernel;
  18400. protected _onRatioRescale(): void;
  18401. private _updateGammaSpace;
  18402. private _imageProcessingConfigChangeObserver;
  18403. private _transformMatrix;
  18404. private _mirrorMatrix;
  18405. private _savedViewMatrix;
  18406. private _blurX;
  18407. private _blurY;
  18408. private _adaptiveBlurKernel;
  18409. private _blurKernelX;
  18410. private _blurKernelY;
  18411. private _blurRatio;
  18412. /**
  18413. * Instantiates a Mirror Texture.
  18414. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18415. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18416. * You can then easily use it as a reflectionTexture on a flat surface.
  18417. * In case the surface is not a plane, please consider relying on reflection probes.
  18418. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18419. * @param name
  18420. * @param size
  18421. * @param scene
  18422. * @param generateMipMaps
  18423. * @param type
  18424. * @param samplingMode
  18425. * @param generateDepthBuffer
  18426. */
  18427. constructor(name: string, size: number | {
  18428. width: number;
  18429. height: number;
  18430. } | {
  18431. ratio: number;
  18432. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18433. private _preparePostProcesses;
  18434. /**
  18435. * Clone the mirror texture.
  18436. * @returns the cloned texture
  18437. */
  18438. clone(): MirrorTexture;
  18439. /**
  18440. * Serialize the texture to a JSON representation you could use in Parse later on
  18441. * @returns the serialized JSON representation
  18442. */
  18443. serialize(): any;
  18444. /**
  18445. * Dispose the texture and release its associated resources.
  18446. */
  18447. dispose(): void;
  18448. }
  18449. }
  18450. declare module BABYLON {
  18451. /**
  18452. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18453. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18454. */
  18455. export class Texture extends BaseTexture {
  18456. /** @hidden */
  18457. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  18458. /** @hidden */
  18459. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  18460. /** @hidden */
  18461. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  18462. /** nearest is mag = nearest and min = nearest and mip = linear */
  18463. static readonly NEAREST_SAMPLINGMODE: number;
  18464. /** nearest is mag = nearest and min = nearest and mip = linear */
  18465. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18466. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18467. static readonly BILINEAR_SAMPLINGMODE: number;
  18468. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18469. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18470. /** Trilinear is mag = linear and min = linear and mip = linear */
  18471. static readonly TRILINEAR_SAMPLINGMODE: number;
  18472. /** Trilinear is mag = linear and min = linear and mip = linear */
  18473. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18474. /** mag = nearest and min = nearest and mip = nearest */
  18475. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18476. /** mag = nearest and min = linear and mip = nearest */
  18477. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18478. /** mag = nearest and min = linear and mip = linear */
  18479. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18480. /** mag = nearest and min = linear and mip = none */
  18481. static readonly NEAREST_LINEAR: number;
  18482. /** mag = nearest and min = nearest and mip = none */
  18483. static readonly NEAREST_NEAREST: number;
  18484. /** mag = linear and min = nearest and mip = nearest */
  18485. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18486. /** mag = linear and min = nearest and mip = linear */
  18487. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18488. /** mag = linear and min = linear and mip = none */
  18489. static readonly LINEAR_LINEAR: number;
  18490. /** mag = linear and min = nearest and mip = none */
  18491. static readonly LINEAR_NEAREST: number;
  18492. /** Explicit coordinates mode */
  18493. static readonly EXPLICIT_MODE: number;
  18494. /** Spherical coordinates mode */
  18495. static readonly SPHERICAL_MODE: number;
  18496. /** Planar coordinates mode */
  18497. static readonly PLANAR_MODE: number;
  18498. /** Cubic coordinates mode */
  18499. static readonly CUBIC_MODE: number;
  18500. /** Projection coordinates mode */
  18501. static readonly PROJECTION_MODE: number;
  18502. /** Inverse Cubic coordinates mode */
  18503. static readonly SKYBOX_MODE: number;
  18504. /** Inverse Cubic coordinates mode */
  18505. static readonly INVCUBIC_MODE: number;
  18506. /** Equirectangular coordinates mode */
  18507. static readonly EQUIRECTANGULAR_MODE: number;
  18508. /** Equirectangular Fixed coordinates mode */
  18509. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18510. /** Equirectangular Fixed Mirrored coordinates mode */
  18511. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18512. /** Texture is not repeating outside of 0..1 UVs */
  18513. static readonly CLAMP_ADDRESSMODE: number;
  18514. /** Texture is repeating outside of 0..1 UVs */
  18515. static readonly WRAP_ADDRESSMODE: number;
  18516. /** Texture is repeating and mirrored */
  18517. static readonly MIRROR_ADDRESSMODE: number;
  18518. /**
  18519. * 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
  18520. */
  18521. static UseSerializedUrlIfAny: boolean;
  18522. /**
  18523. * Define the url of the texture.
  18524. */
  18525. url: Nullable<string>;
  18526. /**
  18527. * Define an offset on the texture to offset the u coordinates of the UVs
  18528. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18529. */
  18530. uOffset: number;
  18531. /**
  18532. * Define an offset on the texture to offset the v coordinates of the UVs
  18533. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18534. */
  18535. vOffset: number;
  18536. /**
  18537. * Define an offset on the texture to scale the u coordinates of the UVs
  18538. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18539. */
  18540. uScale: number;
  18541. /**
  18542. * Define an offset on the texture to scale the v coordinates of the UVs
  18543. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18544. */
  18545. vScale: number;
  18546. /**
  18547. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18548. * @see http://doc.babylonjs.com/how_to/more_materials
  18549. */
  18550. uAng: number;
  18551. /**
  18552. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18553. * @see http://doc.babylonjs.com/how_to/more_materials
  18554. */
  18555. vAng: number;
  18556. /**
  18557. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18558. * @see http://doc.babylonjs.com/how_to/more_materials
  18559. */
  18560. wAng: number;
  18561. /**
  18562. * Defines the center of rotation (U)
  18563. */
  18564. uRotationCenter: number;
  18565. /**
  18566. * Defines the center of rotation (V)
  18567. */
  18568. vRotationCenter: number;
  18569. /**
  18570. * Defines the center of rotation (W)
  18571. */
  18572. wRotationCenter: number;
  18573. /**
  18574. * Are mip maps generated for this texture or not.
  18575. */
  18576. readonly noMipmap: boolean;
  18577. /**
  18578. * List of inspectable custom properties (used by the Inspector)
  18579. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18580. */
  18581. inspectableCustomProperties: Nullable<IInspectable[]>;
  18582. private _noMipmap;
  18583. /** @hidden */
  18584. _invertY: boolean;
  18585. private _rowGenerationMatrix;
  18586. private _cachedTextureMatrix;
  18587. private _projectionModeMatrix;
  18588. private _t0;
  18589. private _t1;
  18590. private _t2;
  18591. private _cachedUOffset;
  18592. private _cachedVOffset;
  18593. private _cachedUScale;
  18594. private _cachedVScale;
  18595. private _cachedUAng;
  18596. private _cachedVAng;
  18597. private _cachedWAng;
  18598. private _cachedProjectionMatrixId;
  18599. private _cachedCoordinatesMode;
  18600. /** @hidden */
  18601. protected _initialSamplingMode: number;
  18602. /** @hidden */
  18603. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18604. private _deleteBuffer;
  18605. protected _format: Nullable<number>;
  18606. private _delayedOnLoad;
  18607. private _delayedOnError;
  18608. /**
  18609. * Observable triggered once the texture has been loaded.
  18610. */
  18611. onLoadObservable: Observable<Texture>;
  18612. protected _isBlocking: boolean;
  18613. /**
  18614. * Is the texture preventing material to render while loading.
  18615. * If false, a default texture will be used instead of the loading one during the preparation step.
  18616. */
  18617. isBlocking: boolean;
  18618. /**
  18619. * Get the current sampling mode associated with the texture.
  18620. */
  18621. readonly samplingMode: number;
  18622. /**
  18623. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18624. */
  18625. readonly invertY: boolean;
  18626. /**
  18627. * Instantiates a new texture.
  18628. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18629. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18630. * @param url define the url of the picture to load as a texture
  18631. * @param scene define the scene or engine the texture will belong to
  18632. * @param noMipmap define if the texture will require mip maps or not
  18633. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18634. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18635. * @param onLoad define a callback triggered when the texture has been loaded
  18636. * @param onError define a callback triggered when an error occurred during the loading session
  18637. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18638. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18639. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18640. */
  18641. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  18642. /**
  18643. * Update the url (and optional buffer) of this texture if url was null during construction.
  18644. * @param url the url of the texture
  18645. * @param buffer the buffer of the texture (defaults to null)
  18646. * @param onLoad callback called when the texture is loaded (defaults to null)
  18647. */
  18648. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18649. /**
  18650. * Finish the loading sequence of a texture flagged as delayed load.
  18651. * @hidden
  18652. */
  18653. delayLoad(): void;
  18654. private _prepareRowForTextureGeneration;
  18655. /**
  18656. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18657. * @returns the transform matrix of the texture.
  18658. */
  18659. getTextureMatrix(): Matrix;
  18660. /**
  18661. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18662. * @returns The reflection texture transform
  18663. */
  18664. getReflectionTextureMatrix(): Matrix;
  18665. /**
  18666. * Clones the texture.
  18667. * @returns the cloned texture
  18668. */
  18669. clone(): Texture;
  18670. /**
  18671. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18672. * @returns The JSON representation of the texture
  18673. */
  18674. serialize(): any;
  18675. /**
  18676. * Get the current class name of the texture useful for serialization or dynamic coding.
  18677. * @returns "Texture"
  18678. */
  18679. getClassName(): string;
  18680. /**
  18681. * Dispose the texture and release its associated resources.
  18682. */
  18683. dispose(): void;
  18684. /**
  18685. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18686. * @param parsedTexture Define the JSON representation of the texture
  18687. * @param scene Define the scene the parsed texture should be instantiated in
  18688. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18689. * @returns The parsed texture if successful
  18690. */
  18691. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18692. /**
  18693. * Creates a texture from its base 64 representation.
  18694. * @param data Define the base64 payload without the data: prefix
  18695. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18696. * @param scene Define the scene the texture should belong to
  18697. * @param noMipmap Forces the texture to not create mip map information if true
  18698. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18699. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18700. * @param onLoad define a callback triggered when the texture has been loaded
  18701. * @param onError define a callback triggered when an error occurred during the loading session
  18702. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18703. * @returns the created texture
  18704. */
  18705. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18706. /**
  18707. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18708. * @param data Define the base64 payload without the data: prefix
  18709. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18710. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18711. * @param scene Define the scene the texture should belong to
  18712. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18713. * @param noMipmap Forces the texture to not create mip map information if true
  18714. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18715. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18716. * @param onLoad define a callback triggered when the texture has been loaded
  18717. * @param onError define a callback triggered when an error occurred during the loading session
  18718. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18719. * @returns the created texture
  18720. */
  18721. 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;
  18722. }
  18723. }
  18724. declare module BABYLON {
  18725. /**
  18726. * PostProcessManager is used to manage one or more post processes or post process pipelines
  18727. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  18728. */
  18729. export class PostProcessManager {
  18730. private _scene;
  18731. private _indexBuffer;
  18732. private _vertexBuffers;
  18733. /**
  18734. * Creates a new instance PostProcess
  18735. * @param scene The scene that the post process is associated with.
  18736. */
  18737. constructor(scene: Scene);
  18738. private _prepareBuffers;
  18739. private _buildIndexBuffer;
  18740. /**
  18741. * Rebuilds the vertex buffers of the manager.
  18742. * @hidden
  18743. */
  18744. _rebuild(): void;
  18745. /**
  18746. * Prepares a frame to be run through a post process.
  18747. * @param sourceTexture The input texture to the post procesess. (default: null)
  18748. * @param postProcesses An array of post processes to be run. (default: null)
  18749. * @returns True if the post processes were able to be run.
  18750. * @hidden
  18751. */
  18752. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  18753. /**
  18754. * Manually render a set of post processes to a texture.
  18755. * @param postProcesses An array of post processes to be run.
  18756. * @param targetTexture The target texture to render to.
  18757. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  18758. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  18759. * @param lodLevel defines which lod of the texture to render to
  18760. */
  18761. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  18762. /**
  18763. * Finalize the result of the output of the postprocesses.
  18764. * @param doNotPresent If true the result will not be displayed to the screen.
  18765. * @param targetTexture The target texture to render to.
  18766. * @param faceIndex The index of the face to bind the target texture to.
  18767. * @param postProcesses The array of post processes to render.
  18768. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  18769. * @hidden
  18770. */
  18771. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  18772. /**
  18773. * Disposes of the post process manager.
  18774. */
  18775. dispose(): void;
  18776. }
  18777. }
  18778. declare module BABYLON {
  18779. interface AbstractScene {
  18780. /**
  18781. * The list of procedural textures added to the scene
  18782. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  18783. */
  18784. proceduralTextures: Array<ProceduralTexture>;
  18785. }
  18786. /**
  18787. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  18788. * in a given scene.
  18789. */
  18790. export class ProceduralTextureSceneComponent implements ISceneComponent {
  18791. /**
  18792. * The component name helpfull to identify the component in the list of scene components.
  18793. */
  18794. readonly name: string;
  18795. /**
  18796. * The scene the component belongs to.
  18797. */
  18798. scene: Scene;
  18799. /**
  18800. * Creates a new instance of the component for the given scene
  18801. * @param scene Defines the scene to register the component in
  18802. */
  18803. constructor(scene: Scene);
  18804. /**
  18805. * Registers the component in a given scene
  18806. */
  18807. register(): void;
  18808. /**
  18809. * Rebuilds the elements related to this component in case of
  18810. * context lost for instance.
  18811. */
  18812. rebuild(): void;
  18813. /**
  18814. * Disposes the component and the associated ressources.
  18815. */
  18816. dispose(): void;
  18817. private _beforeClear;
  18818. }
  18819. }
  18820. declare module BABYLON {
  18821. interface Engine {
  18822. /**
  18823. * Creates a new render target cube texture
  18824. * @param size defines the size of the texture
  18825. * @param options defines the options used to create the texture
  18826. * @returns a new render target cube texture stored in an InternalTexture
  18827. */
  18828. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  18829. }
  18830. }
  18831. declare module BABYLON {
  18832. /** @hidden */
  18833. export var proceduralVertexShader: {
  18834. name: string;
  18835. shader: string;
  18836. };
  18837. }
  18838. declare module BABYLON {
  18839. /**
  18840. * 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.
  18841. * This is the base class of any Procedural texture and contains most of the shareable code.
  18842. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  18843. */
  18844. export class ProceduralTexture extends Texture {
  18845. isCube: boolean;
  18846. /**
  18847. * Define if the texture is enabled or not (disabled texture will not render)
  18848. */
  18849. isEnabled: boolean;
  18850. /**
  18851. * Define if the texture must be cleared before rendering (default is true)
  18852. */
  18853. autoClear: boolean;
  18854. /**
  18855. * Callback called when the texture is generated
  18856. */
  18857. onGenerated: () => void;
  18858. /**
  18859. * Event raised when the texture is generated
  18860. */
  18861. onGeneratedObservable: Observable<ProceduralTexture>;
  18862. /** @hidden */
  18863. _generateMipMaps: boolean;
  18864. /** @hidden **/
  18865. _effect: Effect;
  18866. /** @hidden */
  18867. _textures: {
  18868. [key: string]: Texture;
  18869. };
  18870. private _size;
  18871. private _currentRefreshId;
  18872. private _refreshRate;
  18873. private _vertexBuffers;
  18874. private _indexBuffer;
  18875. private _uniforms;
  18876. private _samplers;
  18877. private _fragment;
  18878. private _floats;
  18879. private _ints;
  18880. private _floatsArrays;
  18881. private _colors3;
  18882. private _colors4;
  18883. private _vectors2;
  18884. private _vectors3;
  18885. private _matrices;
  18886. private _fallbackTexture;
  18887. private _fallbackTextureUsed;
  18888. private _engine;
  18889. private _cachedDefines;
  18890. private _contentUpdateId;
  18891. private _contentData;
  18892. /**
  18893. * Instantiates a new procedural texture.
  18894. * 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.
  18895. * This is the base class of any Procedural texture and contains most of the shareable code.
  18896. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  18897. * @param name Define the name of the texture
  18898. * @param size Define the size of the texture to create
  18899. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  18900. * @param scene Define the scene the texture belongs to
  18901. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  18902. * @param generateMipMaps Define if the texture should creates mip maps or not
  18903. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  18904. */
  18905. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  18906. /**
  18907. * The effect that is created when initializing the post process.
  18908. * @returns The created effect corresponding the the postprocess.
  18909. */
  18910. getEffect(): Effect;
  18911. /**
  18912. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  18913. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  18914. */
  18915. getContent(): Nullable<ArrayBufferView>;
  18916. private _createIndexBuffer;
  18917. /** @hidden */
  18918. _rebuild(): void;
  18919. /**
  18920. * Resets the texture in order to recreate its associated resources.
  18921. * This can be called in case of context loss
  18922. */
  18923. reset(): void;
  18924. protected _getDefines(): string;
  18925. /**
  18926. * Is the texture ready to be used ? (rendered at least once)
  18927. * @returns true if ready, otherwise, false.
  18928. */
  18929. isReady(): boolean;
  18930. /**
  18931. * Resets the refresh counter of the texture and start bak from scratch.
  18932. * Could be useful to regenerate the texture if it is setup to render only once.
  18933. */
  18934. resetRefreshCounter(): void;
  18935. /**
  18936. * Set the fragment shader to use in order to render the texture.
  18937. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  18938. */
  18939. setFragment(fragment: any): void;
  18940. /**
  18941. * Define the refresh rate of the texture or the rendering frequency.
  18942. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  18943. */
  18944. refreshRate: number;
  18945. /** @hidden */
  18946. _shouldRender(): boolean;
  18947. /**
  18948. * Get the size the texture is rendering at.
  18949. * @returns the size (texture is always squared)
  18950. */
  18951. getRenderSize(): number;
  18952. /**
  18953. * Resize the texture to new value.
  18954. * @param size Define the new size the texture should have
  18955. * @param generateMipMaps Define whether the new texture should create mip maps
  18956. */
  18957. resize(size: number, generateMipMaps: boolean): void;
  18958. private _checkUniform;
  18959. /**
  18960. * Set a texture in the shader program used to render.
  18961. * @param name Define the name of the uniform samplers as defined in the shader
  18962. * @param texture Define the texture to bind to this sampler
  18963. * @return the texture itself allowing "fluent" like uniform updates
  18964. */
  18965. setTexture(name: string, texture: Texture): ProceduralTexture;
  18966. /**
  18967. * Set a float in the shader.
  18968. * @param name Define the name of the uniform as defined in the shader
  18969. * @param value Define the value to give to the uniform
  18970. * @return the texture itself allowing "fluent" like uniform updates
  18971. */
  18972. setFloat(name: string, value: number): ProceduralTexture;
  18973. /**
  18974. * Set a int in the shader.
  18975. * @param name Define the name of the uniform as defined in the shader
  18976. * @param value Define the value to give to the uniform
  18977. * @return the texture itself allowing "fluent" like uniform updates
  18978. */
  18979. setInt(name: string, value: number): ProceduralTexture;
  18980. /**
  18981. * Set an array of floats in the shader.
  18982. * @param name Define the name of the uniform as defined in the shader
  18983. * @param value Define the value to give to the uniform
  18984. * @return the texture itself allowing "fluent" like uniform updates
  18985. */
  18986. setFloats(name: string, value: number[]): ProceduralTexture;
  18987. /**
  18988. * Set a vec3 in the shader from a Color3.
  18989. * @param name Define the name of the uniform as defined in the shader
  18990. * @param value Define the value to give to the uniform
  18991. * @return the texture itself allowing "fluent" like uniform updates
  18992. */
  18993. setColor3(name: string, value: Color3): ProceduralTexture;
  18994. /**
  18995. * Set a vec4 in the shader from a Color4.
  18996. * @param name Define the name of the uniform as defined in the shader
  18997. * @param value Define the value to give to the uniform
  18998. * @return the texture itself allowing "fluent" like uniform updates
  18999. */
  19000. setColor4(name: string, value: Color4): ProceduralTexture;
  19001. /**
  19002. * Set a vec2 in the shader from a Vector2.
  19003. * @param name Define the name of the uniform as defined in the shader
  19004. * @param value Define the value to give to the uniform
  19005. * @return the texture itself allowing "fluent" like uniform updates
  19006. */
  19007. setVector2(name: string, value: Vector2): ProceduralTexture;
  19008. /**
  19009. * Set a vec3 in the shader from a Vector3.
  19010. * @param name Define the name of the uniform as defined in the shader
  19011. * @param value Define the value to give to the uniform
  19012. * @return the texture itself allowing "fluent" like uniform updates
  19013. */
  19014. setVector3(name: string, value: Vector3): ProceduralTexture;
  19015. /**
  19016. * Set a mat4 in the shader from a MAtrix.
  19017. * @param name Define the name of the uniform as defined in the shader
  19018. * @param value Define the value to give to the uniform
  19019. * @return the texture itself allowing "fluent" like uniform updates
  19020. */
  19021. setMatrix(name: string, value: Matrix): ProceduralTexture;
  19022. /**
  19023. * Render the texture to its associated render target.
  19024. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  19025. */
  19026. render(useCameraPostProcess?: boolean): void;
  19027. /**
  19028. * Clone the texture.
  19029. * @returns the cloned texture
  19030. */
  19031. clone(): ProceduralTexture;
  19032. /**
  19033. * Dispose the texture and release its asoociated resources.
  19034. */
  19035. dispose(): void;
  19036. }
  19037. }
  19038. declare module BABYLON {
  19039. /**
  19040. * This represents the base class for particle system in Babylon.
  19041. * 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.
  19042. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  19043. * @example https://doc.babylonjs.com/babylon101/particles
  19044. */
  19045. export class BaseParticleSystem {
  19046. /**
  19047. * Source color is added to the destination color without alpha affecting the result
  19048. */
  19049. static BLENDMODE_ONEONE: number;
  19050. /**
  19051. * Blend current color and particle color using particle’s alpha
  19052. */
  19053. static BLENDMODE_STANDARD: number;
  19054. /**
  19055. * Add current color and particle color multiplied by particle’s alpha
  19056. */
  19057. static BLENDMODE_ADD: number;
  19058. /**
  19059. * Multiply current color with particle color
  19060. */
  19061. static BLENDMODE_MULTIPLY: number;
  19062. /**
  19063. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  19064. */
  19065. static BLENDMODE_MULTIPLYADD: number;
  19066. /**
  19067. * List of animations used by the particle system.
  19068. */
  19069. animations: Animation[];
  19070. /**
  19071. * The id of the Particle system.
  19072. */
  19073. id: string;
  19074. /**
  19075. * The friendly name of the Particle system.
  19076. */
  19077. name: string;
  19078. /**
  19079. * The rendering group used by the Particle system to chose when to render.
  19080. */
  19081. renderingGroupId: number;
  19082. /**
  19083. * The emitter represents the Mesh or position we are attaching the particle system to.
  19084. */
  19085. emitter: Nullable<AbstractMesh | Vector3>;
  19086. /**
  19087. * The maximum number of particles to emit per frame
  19088. */
  19089. emitRate: number;
  19090. /**
  19091. * If you want to launch only a few particles at once, that can be done, as well.
  19092. */
  19093. manualEmitCount: number;
  19094. /**
  19095. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  19096. */
  19097. updateSpeed: number;
  19098. /**
  19099. * The amount of time the particle system is running (depends of the overall update speed).
  19100. */
  19101. targetStopDuration: number;
  19102. /**
  19103. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  19104. */
  19105. disposeOnStop: boolean;
  19106. /**
  19107. * Minimum power of emitting particles.
  19108. */
  19109. minEmitPower: number;
  19110. /**
  19111. * Maximum power of emitting particles.
  19112. */
  19113. maxEmitPower: number;
  19114. /**
  19115. * Minimum life time of emitting particles.
  19116. */
  19117. minLifeTime: number;
  19118. /**
  19119. * Maximum life time of emitting particles.
  19120. */
  19121. maxLifeTime: number;
  19122. /**
  19123. * Minimum Size of emitting particles.
  19124. */
  19125. minSize: number;
  19126. /**
  19127. * Maximum Size of emitting particles.
  19128. */
  19129. maxSize: number;
  19130. /**
  19131. * Minimum scale of emitting particles on X axis.
  19132. */
  19133. minScaleX: number;
  19134. /**
  19135. * Maximum scale of emitting particles on X axis.
  19136. */
  19137. maxScaleX: number;
  19138. /**
  19139. * Minimum scale of emitting particles on Y axis.
  19140. */
  19141. minScaleY: number;
  19142. /**
  19143. * Maximum scale of emitting particles on Y axis.
  19144. */
  19145. maxScaleY: number;
  19146. /**
  19147. * Gets or sets the minimal initial rotation in radians.
  19148. */
  19149. minInitialRotation: number;
  19150. /**
  19151. * Gets or sets the maximal initial rotation in radians.
  19152. */
  19153. maxInitialRotation: number;
  19154. /**
  19155. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  19156. */
  19157. minAngularSpeed: number;
  19158. /**
  19159. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  19160. */
  19161. maxAngularSpeed: number;
  19162. /**
  19163. * The texture used to render each particle. (this can be a spritesheet)
  19164. */
  19165. particleTexture: Nullable<Texture>;
  19166. /**
  19167. * The layer mask we are rendering the particles through.
  19168. */
  19169. layerMask: number;
  19170. /**
  19171. * This can help using your own shader to render the particle system.
  19172. * The according effect will be created
  19173. */
  19174. customShader: any;
  19175. /**
  19176. * By default particle system starts as soon as they are created. This prevents the
  19177. * automatic start to happen and let you decide when to start emitting particles.
  19178. */
  19179. preventAutoStart: boolean;
  19180. private _noiseTexture;
  19181. /**
  19182. * Gets or sets a texture used to add random noise to particle positions
  19183. */
  19184. noiseTexture: Nullable<ProceduralTexture>;
  19185. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  19186. noiseStrength: Vector3;
  19187. /**
  19188. * Callback triggered when the particle animation is ending.
  19189. */
  19190. onAnimationEnd: Nullable<() => void>;
  19191. /**
  19192. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  19193. */
  19194. blendMode: number;
  19195. /**
  19196. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  19197. * to override the particles.
  19198. */
  19199. forceDepthWrite: boolean;
  19200. /** 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 */
  19201. preWarmCycles: number;
  19202. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  19203. preWarmStepOffset: number;
  19204. /**
  19205. * 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)
  19206. */
  19207. spriteCellChangeSpeed: number;
  19208. /**
  19209. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  19210. */
  19211. startSpriteCellID: number;
  19212. /**
  19213. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  19214. */
  19215. endSpriteCellID: number;
  19216. /**
  19217. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  19218. */
  19219. spriteCellWidth: number;
  19220. /**
  19221. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  19222. */
  19223. spriteCellHeight: number;
  19224. /**
  19225. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  19226. */
  19227. spriteRandomStartCell: boolean;
  19228. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  19229. translationPivot: Vector2;
  19230. /** @hidden */
  19231. protected _isAnimationSheetEnabled: boolean;
  19232. /**
  19233. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  19234. */
  19235. beginAnimationOnStart: boolean;
  19236. /**
  19237. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  19238. */
  19239. beginAnimationFrom: number;
  19240. /**
  19241. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  19242. */
  19243. beginAnimationTo: number;
  19244. /**
  19245. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  19246. */
  19247. beginAnimationLoop: boolean;
  19248. /**
  19249. * Gets or sets a world offset applied to all particles
  19250. */
  19251. worldOffset: Vector3;
  19252. /**
  19253. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  19254. */
  19255. isAnimationSheetEnabled: boolean;
  19256. /**
  19257. * Get hosting scene
  19258. * @returns the scene
  19259. */
  19260. getScene(): Scene;
  19261. /**
  19262. * You can use gravity if you want to give an orientation to your particles.
  19263. */
  19264. gravity: Vector3;
  19265. protected _colorGradients: Nullable<Array<ColorGradient>>;
  19266. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  19267. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  19268. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  19269. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  19270. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  19271. protected _dragGradients: Nullable<Array<FactorGradient>>;
  19272. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  19273. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  19274. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  19275. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  19276. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  19277. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  19278. /**
  19279. * Defines the delay in milliseconds before starting the system (0 by default)
  19280. */
  19281. startDelay: number;
  19282. /**
  19283. * Gets the current list of drag gradients.
  19284. * You must use addDragGradient and removeDragGradient to udpate this list
  19285. * @returns the list of drag gradients
  19286. */
  19287. getDragGradients(): Nullable<Array<FactorGradient>>;
  19288. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  19289. limitVelocityDamping: number;
  19290. /**
  19291. * Gets the current list of limit velocity gradients.
  19292. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19293. * @returns the list of limit velocity gradients
  19294. */
  19295. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19296. /**
  19297. * Gets the current list of color gradients.
  19298. * You must use addColorGradient and removeColorGradient to udpate this list
  19299. * @returns the list of color gradients
  19300. */
  19301. getColorGradients(): Nullable<Array<ColorGradient>>;
  19302. /**
  19303. * Gets the current list of size gradients.
  19304. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19305. * @returns the list of size gradients
  19306. */
  19307. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19308. /**
  19309. * Gets the current list of color remap gradients.
  19310. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19311. * @returns the list of color remap gradients
  19312. */
  19313. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19314. /**
  19315. * Gets the current list of alpha remap gradients.
  19316. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19317. * @returns the list of alpha remap gradients
  19318. */
  19319. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19320. /**
  19321. * Gets the current list of life time gradients.
  19322. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19323. * @returns the list of life time gradients
  19324. */
  19325. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19326. /**
  19327. * Gets the current list of angular speed gradients.
  19328. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19329. * @returns the list of angular speed gradients
  19330. */
  19331. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19332. /**
  19333. * Gets the current list of velocity gradients.
  19334. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19335. * @returns the list of velocity gradients
  19336. */
  19337. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19338. /**
  19339. * Gets the current list of start size gradients.
  19340. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19341. * @returns the list of start size gradients
  19342. */
  19343. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19344. /**
  19345. * Gets the current list of emit rate gradients.
  19346. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19347. * @returns the list of emit rate gradients
  19348. */
  19349. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19350. /**
  19351. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19352. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19353. */
  19354. direction1: Vector3;
  19355. /**
  19356. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19357. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19358. */
  19359. direction2: Vector3;
  19360. /**
  19361. * 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.
  19362. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19363. */
  19364. minEmitBox: Vector3;
  19365. /**
  19366. * 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.
  19367. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19368. */
  19369. maxEmitBox: Vector3;
  19370. /**
  19371. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  19372. */
  19373. color1: Color4;
  19374. /**
  19375. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  19376. */
  19377. color2: Color4;
  19378. /**
  19379. * Color the particle will have at the end of its lifetime
  19380. */
  19381. colorDead: Color4;
  19382. /**
  19383. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  19384. */
  19385. textureMask: Color4;
  19386. /**
  19387. * The particle emitter type defines the emitter used by the particle system.
  19388. * It can be for example box, sphere, or cone...
  19389. */
  19390. particleEmitterType: IParticleEmitterType;
  19391. /** @hidden */
  19392. _isSubEmitter: boolean;
  19393. /**
  19394. * Gets or sets the billboard mode to use when isBillboardBased = true.
  19395. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  19396. */
  19397. billboardMode: number;
  19398. protected _isBillboardBased: boolean;
  19399. /**
  19400. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  19401. */
  19402. isBillboardBased: boolean;
  19403. /**
  19404. * The scene the particle system belongs to.
  19405. */
  19406. protected _scene: Scene;
  19407. /**
  19408. * Local cache of defines for image processing.
  19409. */
  19410. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  19411. /**
  19412. * Default configuration related to image processing available in the standard Material.
  19413. */
  19414. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19415. /**
  19416. * Gets the image processing configuration used either in this material.
  19417. */
  19418. /**
  19419. * Sets the Default image processing configuration used either in the this material.
  19420. *
  19421. * If sets to null, the scene one is in use.
  19422. */
  19423. imageProcessingConfiguration: ImageProcessingConfiguration;
  19424. /**
  19425. * Attaches a new image processing configuration to the Standard Material.
  19426. * @param configuration
  19427. */
  19428. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  19429. /** @hidden */
  19430. protected _reset(): void;
  19431. /** @hidden */
  19432. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  19433. /**
  19434. * Instantiates a particle system.
  19435. * 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.
  19436. * @param name The name of the particle system
  19437. */
  19438. constructor(name: string);
  19439. /**
  19440. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19441. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19442. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19443. * @returns the emitter
  19444. */
  19445. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19446. /**
  19447. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19448. * @param radius The radius of the hemisphere to emit from
  19449. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19450. * @returns the emitter
  19451. */
  19452. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  19453. /**
  19454. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19455. * @param radius The radius of the sphere to emit from
  19456. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19457. * @returns the emitter
  19458. */
  19459. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  19460. /**
  19461. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19462. * @param radius The radius of the sphere to emit from
  19463. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19464. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19465. * @returns the emitter
  19466. */
  19467. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  19468. /**
  19469. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19470. * @param radius The radius of the emission cylinder
  19471. * @param height The height of the emission cylinder
  19472. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19473. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19474. * @returns the emitter
  19475. */
  19476. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  19477. /**
  19478. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19479. * @param radius The radius of the cylinder to emit from
  19480. * @param height The height of the emission cylinder
  19481. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19482. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19483. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19484. * @returns the emitter
  19485. */
  19486. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  19487. /**
  19488. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19489. * @param radius The radius of the cone to emit from
  19490. * @param angle The base angle of the cone
  19491. * @returns the emitter
  19492. */
  19493. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  19494. /**
  19495. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19496. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19497. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19498. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19499. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19500. * @returns the emitter
  19501. */
  19502. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19503. }
  19504. }
  19505. declare module BABYLON {
  19506. /**
  19507. * Type of sub emitter
  19508. */
  19509. export enum SubEmitterType {
  19510. /**
  19511. * Attached to the particle over it's lifetime
  19512. */
  19513. ATTACHED = 0,
  19514. /**
  19515. * Created when the particle dies
  19516. */
  19517. END = 1
  19518. }
  19519. /**
  19520. * Sub emitter class used to emit particles from an existing particle
  19521. */
  19522. export class SubEmitter {
  19523. /**
  19524. * the particle system to be used by the sub emitter
  19525. */
  19526. particleSystem: ParticleSystem;
  19527. /**
  19528. * Type of the submitter (Default: END)
  19529. */
  19530. type: SubEmitterType;
  19531. /**
  19532. * 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)
  19533. * Note: This only is supported when using an emitter of type Mesh
  19534. */
  19535. inheritDirection: boolean;
  19536. /**
  19537. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  19538. */
  19539. inheritedVelocityAmount: number;
  19540. /**
  19541. * Creates a sub emitter
  19542. * @param particleSystem the particle system to be used by the sub emitter
  19543. */
  19544. constructor(
  19545. /**
  19546. * the particle system to be used by the sub emitter
  19547. */
  19548. particleSystem: ParticleSystem);
  19549. /**
  19550. * Clones the sub emitter
  19551. * @returns the cloned sub emitter
  19552. */
  19553. clone(): SubEmitter;
  19554. /**
  19555. * Serialize current object to a JSON object
  19556. * @returns the serialized object
  19557. */
  19558. serialize(): any;
  19559. /** @hidden */
  19560. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  19561. /**
  19562. * Creates a new SubEmitter from a serialized JSON version
  19563. * @param serializationObject defines the JSON object to read from
  19564. * @param scene defines the hosting scene
  19565. * @param rootUrl defines the rootUrl for data loading
  19566. * @returns a new SubEmitter
  19567. */
  19568. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  19569. /** Release associated resources */
  19570. dispose(): void;
  19571. }
  19572. }
  19573. declare module BABYLON {
  19574. /** @hidden */
  19575. export var imageProcessingDeclaration: {
  19576. name: string;
  19577. shader: string;
  19578. };
  19579. }
  19580. declare module BABYLON {
  19581. /** @hidden */
  19582. export var imageProcessingFunctions: {
  19583. name: string;
  19584. shader: string;
  19585. };
  19586. }
  19587. declare module BABYLON {
  19588. /** @hidden */
  19589. export var particlesPixelShader: {
  19590. name: string;
  19591. shader: string;
  19592. };
  19593. }
  19594. declare module BABYLON {
  19595. /** @hidden */
  19596. export var particlesVertexShader: {
  19597. name: string;
  19598. shader: string;
  19599. };
  19600. }
  19601. declare module BABYLON {
  19602. /**
  19603. * This represents a particle system in Babylon.
  19604. * 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.
  19605. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  19606. * @example https://doc.babylonjs.com/babylon101/particles
  19607. */
  19608. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  19609. /**
  19610. * Billboard mode will only apply to Y axis
  19611. */
  19612. static readonly BILLBOARDMODE_Y: number;
  19613. /**
  19614. * Billboard mode will apply to all axes
  19615. */
  19616. static readonly BILLBOARDMODE_ALL: number;
  19617. /**
  19618. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  19619. */
  19620. static readonly BILLBOARDMODE_STRETCHED: number;
  19621. /**
  19622. * This function can be defined to provide custom update for active particles.
  19623. * This function will be called instead of regular update (age, position, color, etc.).
  19624. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  19625. */
  19626. updateFunction: (particles: Particle[]) => void;
  19627. private _emitterWorldMatrix;
  19628. /**
  19629. * This function can be defined to specify initial direction for every new particle.
  19630. * It by default use the emitterType defined function
  19631. */
  19632. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  19633. /**
  19634. * This function can be defined to specify initial position for every new particle.
  19635. * It by default use the emitterType defined function
  19636. */
  19637. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  19638. /**
  19639. * @hidden
  19640. */
  19641. _inheritedVelocityOffset: Vector3;
  19642. /**
  19643. * An event triggered when the system is disposed
  19644. */
  19645. onDisposeObservable: Observable<ParticleSystem>;
  19646. private _onDisposeObserver;
  19647. /**
  19648. * Sets a callback that will be triggered when the system is disposed
  19649. */
  19650. onDispose: () => void;
  19651. private _particles;
  19652. private _epsilon;
  19653. private _capacity;
  19654. private _stockParticles;
  19655. private _newPartsExcess;
  19656. private _vertexData;
  19657. private _vertexBuffer;
  19658. private _vertexBuffers;
  19659. private _spriteBuffer;
  19660. private _indexBuffer;
  19661. private _effect;
  19662. private _customEffect;
  19663. private _cachedDefines;
  19664. private _scaledColorStep;
  19665. private _colorDiff;
  19666. private _scaledDirection;
  19667. private _scaledGravity;
  19668. private _currentRenderId;
  19669. private _alive;
  19670. private _useInstancing;
  19671. private _started;
  19672. private _stopped;
  19673. private _actualFrame;
  19674. private _scaledUpdateSpeed;
  19675. private _vertexBufferSize;
  19676. /** @hidden */
  19677. _currentEmitRateGradient: Nullable<FactorGradient>;
  19678. /** @hidden */
  19679. _currentEmitRate1: number;
  19680. /** @hidden */
  19681. _currentEmitRate2: number;
  19682. /** @hidden */
  19683. _currentStartSizeGradient: Nullable<FactorGradient>;
  19684. /** @hidden */
  19685. _currentStartSize1: number;
  19686. /** @hidden */
  19687. _currentStartSize2: number;
  19688. private readonly _rawTextureWidth;
  19689. private _rampGradientsTexture;
  19690. private _useRampGradients;
  19691. /** Gets or sets a boolean indicating that ramp gradients must be used
  19692. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19693. */
  19694. useRampGradients: boolean;
  19695. /**
  19696. * 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.
  19697. * 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: [])
  19698. */
  19699. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  19700. private _subEmitters;
  19701. /**
  19702. * @hidden
  19703. * If the particle systems emitter should be disposed when the particle system is disposed
  19704. */
  19705. _disposeEmitterOnDispose: boolean;
  19706. /**
  19707. * The current active Sub-systems, this property is used by the root particle system only.
  19708. */
  19709. activeSubSystems: Array<ParticleSystem>;
  19710. private _rootParticleSystem;
  19711. /**
  19712. * Gets the current list of active particles
  19713. */
  19714. readonly particles: Particle[];
  19715. /**
  19716. * Returns the string "ParticleSystem"
  19717. * @returns a string containing the class name
  19718. */
  19719. getClassName(): string;
  19720. /**
  19721. * Instantiates a particle system.
  19722. * 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.
  19723. * @param name The name of the particle system
  19724. * @param capacity The max number of particles alive at the same time
  19725. * @param scene The scene the particle system belongs to
  19726. * @param customEffect a custom effect used to change the way particles are rendered by default
  19727. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  19728. * @param epsilon Offset used to render the particles
  19729. */
  19730. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  19731. private _addFactorGradient;
  19732. private _removeFactorGradient;
  19733. /**
  19734. * Adds a new life time gradient
  19735. * @param gradient defines the gradient to use (between 0 and 1)
  19736. * @param factor defines the life time factor to affect to the specified gradient
  19737. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19738. * @returns the current particle system
  19739. */
  19740. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19741. /**
  19742. * Remove a specific life time gradient
  19743. * @param gradient defines the gradient to remove
  19744. * @returns the current particle system
  19745. */
  19746. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19747. /**
  19748. * Adds a new size gradient
  19749. * @param gradient defines the gradient to use (between 0 and 1)
  19750. * @param factor defines the size factor to affect to the specified gradient
  19751. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19752. * @returns the current particle system
  19753. */
  19754. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19755. /**
  19756. * Remove a specific size gradient
  19757. * @param gradient defines the gradient to remove
  19758. * @returns the current particle system
  19759. */
  19760. removeSizeGradient(gradient: number): IParticleSystem;
  19761. /**
  19762. * Adds a new color remap gradient
  19763. * @param gradient defines the gradient to use (between 0 and 1)
  19764. * @param min defines the color remap minimal range
  19765. * @param max defines the color remap maximal range
  19766. * @returns the current particle system
  19767. */
  19768. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19769. /**
  19770. * Remove a specific color remap gradient
  19771. * @param gradient defines the gradient to remove
  19772. * @returns the current particle system
  19773. */
  19774. removeColorRemapGradient(gradient: number): IParticleSystem;
  19775. /**
  19776. * Adds a new alpha remap gradient
  19777. * @param gradient defines the gradient to use (between 0 and 1)
  19778. * @param min defines the alpha remap minimal range
  19779. * @param max defines the alpha remap maximal range
  19780. * @returns the current particle system
  19781. */
  19782. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19783. /**
  19784. * Remove a specific alpha remap gradient
  19785. * @param gradient defines the gradient to remove
  19786. * @returns the current particle system
  19787. */
  19788. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  19789. /**
  19790. * Adds a new angular speed gradient
  19791. * @param gradient defines the gradient to use (between 0 and 1)
  19792. * @param factor defines the angular speed to affect to the specified gradient
  19793. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19794. * @returns the current particle system
  19795. */
  19796. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19797. /**
  19798. * Remove a specific angular speed gradient
  19799. * @param gradient defines the gradient to remove
  19800. * @returns the current particle system
  19801. */
  19802. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  19803. /**
  19804. * Adds a new velocity gradient
  19805. * @param gradient defines the gradient to use (between 0 and 1)
  19806. * @param factor defines the velocity to affect to the specified gradient
  19807. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19808. * @returns the current particle system
  19809. */
  19810. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19811. /**
  19812. * Remove a specific velocity gradient
  19813. * @param gradient defines the gradient to remove
  19814. * @returns the current particle system
  19815. */
  19816. removeVelocityGradient(gradient: number): IParticleSystem;
  19817. /**
  19818. * Adds a new limit velocity gradient
  19819. * @param gradient defines the gradient to use (between 0 and 1)
  19820. * @param factor defines the limit velocity value to affect to the specified gradient
  19821. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19822. * @returns the current particle system
  19823. */
  19824. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19825. /**
  19826. * Remove a specific limit velocity gradient
  19827. * @param gradient defines the gradient to remove
  19828. * @returns the current particle system
  19829. */
  19830. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19831. /**
  19832. * Adds a new drag gradient
  19833. * @param gradient defines the gradient to use (between 0 and 1)
  19834. * @param factor defines the drag value to affect to the specified gradient
  19835. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19836. * @returns the current particle system
  19837. */
  19838. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19839. /**
  19840. * Remove a specific drag gradient
  19841. * @param gradient defines the gradient to remove
  19842. * @returns the current particle system
  19843. */
  19844. removeDragGradient(gradient: number): IParticleSystem;
  19845. /**
  19846. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19847. * @param gradient defines the gradient to use (between 0 and 1)
  19848. * @param factor defines the emit rate value to affect to the specified gradient
  19849. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19850. * @returns the current particle system
  19851. */
  19852. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19853. /**
  19854. * Remove a specific emit rate gradient
  19855. * @param gradient defines the gradient to remove
  19856. * @returns the current particle system
  19857. */
  19858. removeEmitRateGradient(gradient: number): IParticleSystem;
  19859. /**
  19860. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19861. * @param gradient defines the gradient to use (between 0 and 1)
  19862. * @param factor defines the start size value to affect to the specified gradient
  19863. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19864. * @returns the current particle system
  19865. */
  19866. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19867. /**
  19868. * Remove a specific start size gradient
  19869. * @param gradient defines the gradient to remove
  19870. * @returns the current particle system
  19871. */
  19872. removeStartSizeGradient(gradient: number): IParticleSystem;
  19873. private _createRampGradientTexture;
  19874. /**
  19875. * Gets the current list of ramp gradients.
  19876. * You must use addRampGradient and removeRampGradient to udpate this list
  19877. * @returns the list of ramp gradients
  19878. */
  19879. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19880. /**
  19881. * Adds a new ramp gradient used to remap particle colors
  19882. * @param gradient defines the gradient to use (between 0 and 1)
  19883. * @param color defines the color to affect to the specified gradient
  19884. * @returns the current particle system
  19885. */
  19886. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  19887. /**
  19888. * Remove a specific ramp gradient
  19889. * @param gradient defines the gradient to remove
  19890. * @returns the current particle system
  19891. */
  19892. removeRampGradient(gradient: number): ParticleSystem;
  19893. /**
  19894. * Adds a new color gradient
  19895. * @param gradient defines the gradient to use (between 0 and 1)
  19896. * @param color1 defines the color to affect to the specified gradient
  19897. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  19898. * @returns this particle system
  19899. */
  19900. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  19901. /**
  19902. * Remove a specific color gradient
  19903. * @param gradient defines the gradient to remove
  19904. * @returns this particle system
  19905. */
  19906. removeColorGradient(gradient: number): IParticleSystem;
  19907. private _fetchR;
  19908. protected _reset(): void;
  19909. private _resetEffect;
  19910. private _createVertexBuffers;
  19911. private _createIndexBuffer;
  19912. /**
  19913. * Gets the maximum number of particles active at the same time.
  19914. * @returns The max number of active particles.
  19915. */
  19916. getCapacity(): number;
  19917. /**
  19918. * Gets whether there are still active particles in the system.
  19919. * @returns True if it is alive, otherwise false.
  19920. */
  19921. isAlive(): boolean;
  19922. /**
  19923. * Gets if the system has been started. (Note: this will still be true after stop is called)
  19924. * @returns True if it has been started, otherwise false.
  19925. */
  19926. isStarted(): boolean;
  19927. private _prepareSubEmitterInternalArray;
  19928. /**
  19929. * Starts the particle system and begins to emit
  19930. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  19931. */
  19932. start(delay?: number): void;
  19933. /**
  19934. * Stops the particle system.
  19935. * @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.
  19936. */
  19937. stop(stopSubEmitters?: boolean): void;
  19938. /**
  19939. * Remove all active particles
  19940. */
  19941. reset(): void;
  19942. /**
  19943. * @hidden (for internal use only)
  19944. */
  19945. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  19946. /**
  19947. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  19948. * Its lifetime will start back at 0.
  19949. */
  19950. recycleParticle: (particle: Particle) => void;
  19951. private _stopSubEmitters;
  19952. private _createParticle;
  19953. private _removeFromRoot;
  19954. private _emitFromParticle;
  19955. private _update;
  19956. /** @hidden */
  19957. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  19958. /** @hidden */
  19959. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  19960. /** @hidden */
  19961. private _getEffect;
  19962. /**
  19963. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  19964. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  19965. */
  19966. animate(preWarmOnly?: boolean): void;
  19967. private _appendParticleVertices;
  19968. /**
  19969. * Rebuilds the particle system.
  19970. */
  19971. rebuild(): void;
  19972. /**
  19973. * Is this system ready to be used/rendered
  19974. * @return true if the system is ready
  19975. */
  19976. isReady(): boolean;
  19977. private _render;
  19978. /**
  19979. * Renders the particle system in its current state.
  19980. * @returns the current number of particles
  19981. */
  19982. render(): number;
  19983. /**
  19984. * Disposes the particle system and free the associated resources
  19985. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  19986. */
  19987. dispose(disposeTexture?: boolean): void;
  19988. /**
  19989. * Clones the particle system.
  19990. * @param name The name of the cloned object
  19991. * @param newEmitter The new emitter to use
  19992. * @returns the cloned particle system
  19993. */
  19994. clone(name: string, newEmitter: any): ParticleSystem;
  19995. /**
  19996. * Serializes the particle system to a JSON object.
  19997. * @returns the JSON object
  19998. */
  19999. serialize(): any;
  20000. /** @hidden */
  20001. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  20002. /** @hidden */
  20003. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  20004. /**
  20005. * Parses a JSON object to create a particle system.
  20006. * @param parsedParticleSystem The JSON object to parse
  20007. * @param scene The scene to create the particle system in
  20008. * @param rootUrl The root url to use to load external dependencies like texture
  20009. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  20010. * @returns the Parsed particle system
  20011. */
  20012. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  20013. }
  20014. }
  20015. declare module BABYLON {
  20016. /**
  20017. * A particle represents one of the element emitted by a particle system.
  20018. * This is mainly define by its coordinates, direction, velocity and age.
  20019. */
  20020. export class Particle {
  20021. /**
  20022. * The particle system the particle belongs to.
  20023. */
  20024. particleSystem: ParticleSystem;
  20025. private static _Count;
  20026. /**
  20027. * Unique ID of the particle
  20028. */
  20029. id: number;
  20030. /**
  20031. * The world position of the particle in the scene.
  20032. */
  20033. position: Vector3;
  20034. /**
  20035. * The world direction of the particle in the scene.
  20036. */
  20037. direction: Vector3;
  20038. /**
  20039. * The color of the particle.
  20040. */
  20041. color: Color4;
  20042. /**
  20043. * The color change of the particle per step.
  20044. */
  20045. colorStep: Color4;
  20046. /**
  20047. * Defines how long will the life of the particle be.
  20048. */
  20049. lifeTime: number;
  20050. /**
  20051. * The current age of the particle.
  20052. */
  20053. age: number;
  20054. /**
  20055. * The current size of the particle.
  20056. */
  20057. size: number;
  20058. /**
  20059. * The current scale of the particle.
  20060. */
  20061. scale: Vector2;
  20062. /**
  20063. * The current angle of the particle.
  20064. */
  20065. angle: number;
  20066. /**
  20067. * Defines how fast is the angle changing.
  20068. */
  20069. angularSpeed: number;
  20070. /**
  20071. * Defines the cell index used by the particle to be rendered from a sprite.
  20072. */
  20073. cellIndex: number;
  20074. /**
  20075. * The information required to support color remapping
  20076. */
  20077. remapData: Vector4;
  20078. /** @hidden */
  20079. _randomCellOffset?: number;
  20080. /** @hidden */
  20081. _initialDirection: Nullable<Vector3>;
  20082. /** @hidden */
  20083. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  20084. /** @hidden */
  20085. _initialStartSpriteCellID: number;
  20086. /** @hidden */
  20087. _initialEndSpriteCellID: number;
  20088. /** @hidden */
  20089. _currentColorGradient: Nullable<ColorGradient>;
  20090. /** @hidden */
  20091. _currentColor1: Color4;
  20092. /** @hidden */
  20093. _currentColor2: Color4;
  20094. /** @hidden */
  20095. _currentSizeGradient: Nullable<FactorGradient>;
  20096. /** @hidden */
  20097. _currentSize1: number;
  20098. /** @hidden */
  20099. _currentSize2: number;
  20100. /** @hidden */
  20101. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  20102. /** @hidden */
  20103. _currentAngularSpeed1: number;
  20104. /** @hidden */
  20105. _currentAngularSpeed2: number;
  20106. /** @hidden */
  20107. _currentVelocityGradient: Nullable<FactorGradient>;
  20108. /** @hidden */
  20109. _currentVelocity1: number;
  20110. /** @hidden */
  20111. _currentVelocity2: number;
  20112. /** @hidden */
  20113. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  20114. /** @hidden */
  20115. _currentLimitVelocity1: number;
  20116. /** @hidden */
  20117. _currentLimitVelocity2: number;
  20118. /** @hidden */
  20119. _currentDragGradient: Nullable<FactorGradient>;
  20120. /** @hidden */
  20121. _currentDrag1: number;
  20122. /** @hidden */
  20123. _currentDrag2: number;
  20124. /** @hidden */
  20125. _randomNoiseCoordinates1: Vector3;
  20126. /** @hidden */
  20127. _randomNoiseCoordinates2: Vector3;
  20128. /**
  20129. * Creates a new instance Particle
  20130. * @param particleSystem the particle system the particle belongs to
  20131. */
  20132. constructor(
  20133. /**
  20134. * The particle system the particle belongs to.
  20135. */
  20136. particleSystem: ParticleSystem);
  20137. private updateCellInfoFromSystem;
  20138. /**
  20139. * Defines how the sprite cell index is updated for the particle
  20140. */
  20141. updateCellIndex(): void;
  20142. /** @hidden */
  20143. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  20144. /** @hidden */
  20145. _inheritParticleInfoToSubEmitters(): void;
  20146. /** @hidden */
  20147. _reset(): void;
  20148. /**
  20149. * Copy the properties of particle to another one.
  20150. * @param other the particle to copy the information to.
  20151. */
  20152. copyTo(other: Particle): void;
  20153. }
  20154. }
  20155. declare module BABYLON {
  20156. /**
  20157. * Particle emitter represents a volume emitting particles.
  20158. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  20159. */
  20160. export interface IParticleEmitterType {
  20161. /**
  20162. * Called by the particle System when the direction is computed for the created particle.
  20163. * @param worldMatrix is the world matrix of the particle system
  20164. * @param directionToUpdate is the direction vector to update with the result
  20165. * @param particle is the particle we are computed the direction for
  20166. */
  20167. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20168. /**
  20169. * Called by the particle System when the position is computed for the created particle.
  20170. * @param worldMatrix is the world matrix of the particle system
  20171. * @param positionToUpdate is the position vector to update with the result
  20172. * @param particle is the particle we are computed the position for
  20173. */
  20174. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20175. /**
  20176. * Clones the current emitter and returns a copy of it
  20177. * @returns the new emitter
  20178. */
  20179. clone(): IParticleEmitterType;
  20180. /**
  20181. * Called by the GPUParticleSystem to setup the update shader
  20182. * @param effect defines the update shader
  20183. */
  20184. applyToShader(effect: Effect): void;
  20185. /**
  20186. * Returns a string to use to update the GPU particles update shader
  20187. * @returns the effect defines string
  20188. */
  20189. getEffectDefines(): string;
  20190. /**
  20191. * Returns a string representing the class name
  20192. * @returns a string containing the class name
  20193. */
  20194. getClassName(): string;
  20195. /**
  20196. * Serializes the particle system to a JSON object.
  20197. * @returns the JSON object
  20198. */
  20199. serialize(): any;
  20200. /**
  20201. * Parse properties from a JSON object
  20202. * @param serializationObject defines the JSON object
  20203. */
  20204. parse(serializationObject: any): void;
  20205. }
  20206. }
  20207. declare module BABYLON {
  20208. /**
  20209. * Particle emitter emitting particles from the inside of a box.
  20210. * It emits the particles randomly between 2 given directions.
  20211. */
  20212. export class BoxParticleEmitter implements IParticleEmitterType {
  20213. /**
  20214. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  20215. */
  20216. direction1: Vector3;
  20217. /**
  20218. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  20219. */
  20220. direction2: Vector3;
  20221. /**
  20222. * 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.
  20223. */
  20224. minEmitBox: Vector3;
  20225. /**
  20226. * 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.
  20227. */
  20228. maxEmitBox: Vector3;
  20229. /**
  20230. * Creates a new instance BoxParticleEmitter
  20231. */
  20232. constructor();
  20233. /**
  20234. * Called by the particle System when the direction is computed for the created particle.
  20235. * @param worldMatrix is the world matrix of the particle system
  20236. * @param directionToUpdate is the direction vector to update with the result
  20237. * @param particle is the particle we are computed the direction for
  20238. */
  20239. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20240. /**
  20241. * Called by the particle System when the position is computed for the created particle.
  20242. * @param worldMatrix is the world matrix of the particle system
  20243. * @param positionToUpdate is the position vector to update with the result
  20244. * @param particle is the particle we are computed the position for
  20245. */
  20246. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20247. /**
  20248. * Clones the current emitter and returns a copy of it
  20249. * @returns the new emitter
  20250. */
  20251. clone(): BoxParticleEmitter;
  20252. /**
  20253. * Called by the GPUParticleSystem to setup the update shader
  20254. * @param effect defines the update shader
  20255. */
  20256. applyToShader(effect: Effect): void;
  20257. /**
  20258. * Returns a string to use to update the GPU particles update shader
  20259. * @returns a string containng the defines string
  20260. */
  20261. getEffectDefines(): string;
  20262. /**
  20263. * Returns the string "BoxParticleEmitter"
  20264. * @returns a string containing the class name
  20265. */
  20266. getClassName(): string;
  20267. /**
  20268. * Serializes the particle system to a JSON object.
  20269. * @returns the JSON object
  20270. */
  20271. serialize(): any;
  20272. /**
  20273. * Parse properties from a JSON object
  20274. * @param serializationObject defines the JSON object
  20275. */
  20276. parse(serializationObject: any): void;
  20277. }
  20278. }
  20279. declare module BABYLON {
  20280. /**
  20281. * Particle emitter emitting particles from the inside of a cone.
  20282. * It emits the particles alongside the cone volume from the base to the particle.
  20283. * The emission direction might be randomized.
  20284. */
  20285. export class ConeParticleEmitter implements IParticleEmitterType {
  20286. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  20287. directionRandomizer: number;
  20288. private _radius;
  20289. private _angle;
  20290. private _height;
  20291. /**
  20292. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  20293. */
  20294. radiusRange: number;
  20295. /**
  20296. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  20297. */
  20298. heightRange: number;
  20299. /**
  20300. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  20301. */
  20302. emitFromSpawnPointOnly: boolean;
  20303. /**
  20304. * Gets or sets the radius of the emission cone
  20305. */
  20306. radius: number;
  20307. /**
  20308. * Gets or sets the angle of the emission cone
  20309. */
  20310. angle: number;
  20311. private _buildHeight;
  20312. /**
  20313. * Creates a new instance ConeParticleEmitter
  20314. * @param radius the radius of the emission cone (1 by default)
  20315. * @param angle the cone base angle (PI by default)
  20316. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  20317. */
  20318. constructor(radius?: number, angle?: number,
  20319. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  20320. directionRandomizer?: number);
  20321. /**
  20322. * Called by the particle System when the direction is computed for the created particle.
  20323. * @param worldMatrix is the world matrix of the particle system
  20324. * @param directionToUpdate is the direction vector to update with the result
  20325. * @param particle is the particle we are computed the direction for
  20326. */
  20327. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20328. /**
  20329. * Called by the particle System when the position is computed for the created particle.
  20330. * @param worldMatrix is the world matrix of the particle system
  20331. * @param positionToUpdate is the position vector to update with the result
  20332. * @param particle is the particle we are computed the position for
  20333. */
  20334. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20335. /**
  20336. * Clones the current emitter and returns a copy of it
  20337. * @returns the new emitter
  20338. */
  20339. clone(): ConeParticleEmitter;
  20340. /**
  20341. * Called by the GPUParticleSystem to setup the update shader
  20342. * @param effect defines the update shader
  20343. */
  20344. applyToShader(effect: Effect): void;
  20345. /**
  20346. * Returns a string to use to update the GPU particles update shader
  20347. * @returns a string containng the defines string
  20348. */
  20349. getEffectDefines(): string;
  20350. /**
  20351. * Returns the string "ConeParticleEmitter"
  20352. * @returns a string containing the class name
  20353. */
  20354. getClassName(): string;
  20355. /**
  20356. * Serializes the particle system to a JSON object.
  20357. * @returns the JSON object
  20358. */
  20359. serialize(): any;
  20360. /**
  20361. * Parse properties from a JSON object
  20362. * @param serializationObject defines the JSON object
  20363. */
  20364. parse(serializationObject: any): void;
  20365. }
  20366. }
  20367. declare module BABYLON {
  20368. /**
  20369. * Particle emitter emitting particles from the inside of a cylinder.
  20370. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  20371. */
  20372. export class CylinderParticleEmitter implements IParticleEmitterType {
  20373. /**
  20374. * The radius of the emission cylinder.
  20375. */
  20376. radius: number;
  20377. /**
  20378. * The height of the emission cylinder.
  20379. */
  20380. height: number;
  20381. /**
  20382. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20383. */
  20384. radiusRange: number;
  20385. /**
  20386. * How much to randomize the particle direction [0-1].
  20387. */
  20388. directionRandomizer: number;
  20389. /**
  20390. * Creates a new instance CylinderParticleEmitter
  20391. * @param radius the radius of the emission cylinder (1 by default)
  20392. * @param height the height of the emission cylinder (1 by default)
  20393. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20394. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  20395. */
  20396. constructor(
  20397. /**
  20398. * The radius of the emission cylinder.
  20399. */
  20400. radius?: number,
  20401. /**
  20402. * The height of the emission cylinder.
  20403. */
  20404. height?: number,
  20405. /**
  20406. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20407. */
  20408. radiusRange?: number,
  20409. /**
  20410. * How much to randomize the particle direction [0-1].
  20411. */
  20412. directionRandomizer?: number);
  20413. /**
  20414. * Called by the particle System when the direction is computed for the created particle.
  20415. * @param worldMatrix is the world matrix of the particle system
  20416. * @param directionToUpdate is the direction vector to update with the result
  20417. * @param particle is the particle we are computed the direction for
  20418. */
  20419. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20420. /**
  20421. * Called by the particle System when the position is computed for the created particle.
  20422. * @param worldMatrix is the world matrix of the particle system
  20423. * @param positionToUpdate is the position vector to update with the result
  20424. * @param particle is the particle we are computed the position for
  20425. */
  20426. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20427. /**
  20428. * Clones the current emitter and returns a copy of it
  20429. * @returns the new emitter
  20430. */
  20431. clone(): CylinderParticleEmitter;
  20432. /**
  20433. * Called by the GPUParticleSystem to setup the update shader
  20434. * @param effect defines the update shader
  20435. */
  20436. applyToShader(effect: Effect): void;
  20437. /**
  20438. * Returns a string to use to update the GPU particles update shader
  20439. * @returns a string containng the defines string
  20440. */
  20441. getEffectDefines(): string;
  20442. /**
  20443. * Returns the string "CylinderParticleEmitter"
  20444. * @returns a string containing the class name
  20445. */
  20446. getClassName(): string;
  20447. /**
  20448. * Serializes the particle system to a JSON object.
  20449. * @returns the JSON object
  20450. */
  20451. serialize(): any;
  20452. /**
  20453. * Parse properties from a JSON object
  20454. * @param serializationObject defines the JSON object
  20455. */
  20456. parse(serializationObject: any): void;
  20457. }
  20458. /**
  20459. * Particle emitter emitting particles from the inside of a cylinder.
  20460. * It emits the particles randomly between two vectors.
  20461. */
  20462. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  20463. /**
  20464. * The min limit of the emission direction.
  20465. */
  20466. direction1: Vector3;
  20467. /**
  20468. * The max limit of the emission direction.
  20469. */
  20470. direction2: Vector3;
  20471. /**
  20472. * Creates a new instance CylinderDirectedParticleEmitter
  20473. * @param radius the radius of the emission cylinder (1 by default)
  20474. * @param height the height of the emission cylinder (1 by default)
  20475. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20476. * @param direction1 the min limit of the emission direction (up vector by default)
  20477. * @param direction2 the max limit of the emission direction (up vector by default)
  20478. */
  20479. constructor(radius?: number, height?: number, radiusRange?: number,
  20480. /**
  20481. * The min limit of the emission direction.
  20482. */
  20483. direction1?: Vector3,
  20484. /**
  20485. * The max limit of the emission direction.
  20486. */
  20487. direction2?: Vector3);
  20488. /**
  20489. * Called by the particle System when the direction is computed for the created particle.
  20490. * @param worldMatrix is the world matrix of the particle system
  20491. * @param directionToUpdate is the direction vector to update with the result
  20492. * @param particle is the particle we are computed the direction for
  20493. */
  20494. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20495. /**
  20496. * Clones the current emitter and returns a copy of it
  20497. * @returns the new emitter
  20498. */
  20499. clone(): CylinderDirectedParticleEmitter;
  20500. /**
  20501. * Called by the GPUParticleSystem to setup the update shader
  20502. * @param effect defines the update shader
  20503. */
  20504. applyToShader(effect: Effect): void;
  20505. /**
  20506. * Returns a string to use to update the GPU particles update shader
  20507. * @returns a string containng the defines string
  20508. */
  20509. getEffectDefines(): string;
  20510. /**
  20511. * Returns the string "CylinderDirectedParticleEmitter"
  20512. * @returns a string containing the class name
  20513. */
  20514. getClassName(): string;
  20515. /**
  20516. * Serializes the particle system to a JSON object.
  20517. * @returns the JSON object
  20518. */
  20519. serialize(): any;
  20520. /**
  20521. * Parse properties from a JSON object
  20522. * @param serializationObject defines the JSON object
  20523. */
  20524. parse(serializationObject: any): void;
  20525. }
  20526. }
  20527. declare module BABYLON {
  20528. /**
  20529. * Particle emitter emitting particles from the inside of a hemisphere.
  20530. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  20531. */
  20532. export class HemisphericParticleEmitter implements IParticleEmitterType {
  20533. /**
  20534. * The radius of the emission hemisphere.
  20535. */
  20536. radius: number;
  20537. /**
  20538. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20539. */
  20540. radiusRange: number;
  20541. /**
  20542. * How much to randomize the particle direction [0-1].
  20543. */
  20544. directionRandomizer: number;
  20545. /**
  20546. * Creates a new instance HemisphericParticleEmitter
  20547. * @param radius the radius of the emission hemisphere (1 by default)
  20548. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20549. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  20550. */
  20551. constructor(
  20552. /**
  20553. * The radius of the emission hemisphere.
  20554. */
  20555. radius?: number,
  20556. /**
  20557. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20558. */
  20559. radiusRange?: number,
  20560. /**
  20561. * How much to randomize the particle direction [0-1].
  20562. */
  20563. directionRandomizer?: number);
  20564. /**
  20565. * Called by the particle System when the direction is computed for the created particle.
  20566. * @param worldMatrix is the world matrix of the particle system
  20567. * @param directionToUpdate is the direction vector to update with the result
  20568. * @param particle is the particle we are computed the direction for
  20569. */
  20570. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20571. /**
  20572. * Called by the particle System when the position is computed for the created particle.
  20573. * @param worldMatrix is the world matrix of the particle system
  20574. * @param positionToUpdate is the position vector to update with the result
  20575. * @param particle is the particle we are computed the position for
  20576. */
  20577. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20578. /**
  20579. * Clones the current emitter and returns a copy of it
  20580. * @returns the new emitter
  20581. */
  20582. clone(): HemisphericParticleEmitter;
  20583. /**
  20584. * Called by the GPUParticleSystem to setup the update shader
  20585. * @param effect defines the update shader
  20586. */
  20587. applyToShader(effect: Effect): void;
  20588. /**
  20589. * Returns a string to use to update the GPU particles update shader
  20590. * @returns a string containng the defines string
  20591. */
  20592. getEffectDefines(): string;
  20593. /**
  20594. * Returns the string "HemisphericParticleEmitter"
  20595. * @returns a string containing the class name
  20596. */
  20597. getClassName(): string;
  20598. /**
  20599. * Serializes the particle system to a JSON object.
  20600. * @returns the JSON object
  20601. */
  20602. serialize(): any;
  20603. /**
  20604. * Parse properties from a JSON object
  20605. * @param serializationObject defines the JSON object
  20606. */
  20607. parse(serializationObject: any): void;
  20608. }
  20609. }
  20610. declare module BABYLON {
  20611. /**
  20612. * Particle emitter emitting particles from a point.
  20613. * It emits the particles randomly between 2 given directions.
  20614. */
  20615. export class PointParticleEmitter implements IParticleEmitterType {
  20616. /**
  20617. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  20618. */
  20619. direction1: Vector3;
  20620. /**
  20621. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  20622. */
  20623. direction2: Vector3;
  20624. /**
  20625. * Creates a new instance PointParticleEmitter
  20626. */
  20627. constructor();
  20628. /**
  20629. * Called by the particle System when the direction is computed for the created particle.
  20630. * @param worldMatrix is the world matrix of the particle system
  20631. * @param directionToUpdate is the direction vector to update with the result
  20632. * @param particle is the particle we are computed the direction for
  20633. */
  20634. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20635. /**
  20636. * Called by the particle System when the position is computed for the created particle.
  20637. * @param worldMatrix is the world matrix of the particle system
  20638. * @param positionToUpdate is the position vector to update with the result
  20639. * @param particle is the particle we are computed the position for
  20640. */
  20641. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20642. /**
  20643. * Clones the current emitter and returns a copy of it
  20644. * @returns the new emitter
  20645. */
  20646. clone(): PointParticleEmitter;
  20647. /**
  20648. * Called by the GPUParticleSystem to setup the update shader
  20649. * @param effect defines the update shader
  20650. */
  20651. applyToShader(effect: Effect): void;
  20652. /**
  20653. * Returns a string to use to update the GPU particles update shader
  20654. * @returns a string containng the defines string
  20655. */
  20656. getEffectDefines(): string;
  20657. /**
  20658. * Returns the string "PointParticleEmitter"
  20659. * @returns a string containing the class name
  20660. */
  20661. getClassName(): string;
  20662. /**
  20663. * Serializes the particle system to a JSON object.
  20664. * @returns the JSON object
  20665. */
  20666. serialize(): any;
  20667. /**
  20668. * Parse properties from a JSON object
  20669. * @param serializationObject defines the JSON object
  20670. */
  20671. parse(serializationObject: any): void;
  20672. }
  20673. }
  20674. declare module BABYLON {
  20675. /**
  20676. * Particle emitter emitting particles from the inside of a sphere.
  20677. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  20678. */
  20679. export class SphereParticleEmitter implements IParticleEmitterType {
  20680. /**
  20681. * The radius of the emission sphere.
  20682. */
  20683. radius: number;
  20684. /**
  20685. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20686. */
  20687. radiusRange: number;
  20688. /**
  20689. * How much to randomize the particle direction [0-1].
  20690. */
  20691. directionRandomizer: number;
  20692. /**
  20693. * Creates a new instance SphereParticleEmitter
  20694. * @param radius the radius of the emission sphere (1 by default)
  20695. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20696. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  20697. */
  20698. constructor(
  20699. /**
  20700. * The radius of the emission sphere.
  20701. */
  20702. radius?: number,
  20703. /**
  20704. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20705. */
  20706. radiusRange?: number,
  20707. /**
  20708. * How much to randomize the particle direction [0-1].
  20709. */
  20710. directionRandomizer?: number);
  20711. /**
  20712. * Called by the particle System when the direction is computed for the created particle.
  20713. * @param worldMatrix is the world matrix of the particle system
  20714. * @param directionToUpdate is the direction vector to update with the result
  20715. * @param particle is the particle we are computed the direction for
  20716. */
  20717. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20718. /**
  20719. * Called by the particle System when the position is computed for the created particle.
  20720. * @param worldMatrix is the world matrix of the particle system
  20721. * @param positionToUpdate is the position vector to update with the result
  20722. * @param particle is the particle we are computed the position for
  20723. */
  20724. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20725. /**
  20726. * Clones the current emitter and returns a copy of it
  20727. * @returns the new emitter
  20728. */
  20729. clone(): SphereParticleEmitter;
  20730. /**
  20731. * Called by the GPUParticleSystem to setup the update shader
  20732. * @param effect defines the update shader
  20733. */
  20734. applyToShader(effect: Effect): void;
  20735. /**
  20736. * Returns a string to use to update the GPU particles update shader
  20737. * @returns a string containng the defines string
  20738. */
  20739. getEffectDefines(): string;
  20740. /**
  20741. * Returns the string "SphereParticleEmitter"
  20742. * @returns a string containing the class name
  20743. */
  20744. getClassName(): string;
  20745. /**
  20746. * Serializes the particle system to a JSON object.
  20747. * @returns the JSON object
  20748. */
  20749. serialize(): any;
  20750. /**
  20751. * Parse properties from a JSON object
  20752. * @param serializationObject defines the JSON object
  20753. */
  20754. parse(serializationObject: any): void;
  20755. }
  20756. /**
  20757. * Particle emitter emitting particles from the inside of a sphere.
  20758. * It emits the particles randomly between two vectors.
  20759. */
  20760. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  20761. /**
  20762. * The min limit of the emission direction.
  20763. */
  20764. direction1: Vector3;
  20765. /**
  20766. * The max limit of the emission direction.
  20767. */
  20768. direction2: Vector3;
  20769. /**
  20770. * Creates a new instance SphereDirectedParticleEmitter
  20771. * @param radius the radius of the emission sphere (1 by default)
  20772. * @param direction1 the min limit of the emission direction (up vector by default)
  20773. * @param direction2 the max limit of the emission direction (up vector by default)
  20774. */
  20775. constructor(radius?: number,
  20776. /**
  20777. * The min limit of the emission direction.
  20778. */
  20779. direction1?: Vector3,
  20780. /**
  20781. * The max limit of the emission direction.
  20782. */
  20783. direction2?: Vector3);
  20784. /**
  20785. * Called by the particle System when the direction is computed for the created particle.
  20786. * @param worldMatrix is the world matrix of the particle system
  20787. * @param directionToUpdate is the direction vector to update with the result
  20788. * @param particle is the particle we are computed the direction for
  20789. */
  20790. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20791. /**
  20792. * Clones the current emitter and returns a copy of it
  20793. * @returns the new emitter
  20794. */
  20795. clone(): SphereDirectedParticleEmitter;
  20796. /**
  20797. * Called by the GPUParticleSystem to setup the update shader
  20798. * @param effect defines the update shader
  20799. */
  20800. applyToShader(effect: Effect): void;
  20801. /**
  20802. * Returns a string to use to update the GPU particles update shader
  20803. * @returns a string containng the defines string
  20804. */
  20805. getEffectDefines(): string;
  20806. /**
  20807. * Returns the string "SphereDirectedParticleEmitter"
  20808. * @returns a string containing the class name
  20809. */
  20810. getClassName(): string;
  20811. /**
  20812. * Serializes the particle system to a JSON object.
  20813. * @returns the JSON object
  20814. */
  20815. serialize(): any;
  20816. /**
  20817. * Parse properties from a JSON object
  20818. * @param serializationObject defines the JSON object
  20819. */
  20820. parse(serializationObject: any): void;
  20821. }
  20822. }
  20823. declare module BABYLON {
  20824. /**
  20825. * Interface representing a particle system in Babylon.js.
  20826. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  20827. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  20828. */
  20829. export interface IParticleSystem {
  20830. /**
  20831. * List of animations used by the particle system.
  20832. */
  20833. animations: Animation[];
  20834. /**
  20835. * The id of the Particle system.
  20836. */
  20837. id: string;
  20838. /**
  20839. * The name of the Particle system.
  20840. */
  20841. name: string;
  20842. /**
  20843. * The emitter represents the Mesh or position we are attaching the particle system to.
  20844. */
  20845. emitter: Nullable<AbstractMesh | Vector3>;
  20846. /**
  20847. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  20848. */
  20849. isBillboardBased: boolean;
  20850. /**
  20851. * The rendering group used by the Particle system to chose when to render.
  20852. */
  20853. renderingGroupId: number;
  20854. /**
  20855. * The layer mask we are rendering the particles through.
  20856. */
  20857. layerMask: number;
  20858. /**
  20859. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  20860. */
  20861. updateSpeed: number;
  20862. /**
  20863. * The amount of time the particle system is running (depends of the overall update speed).
  20864. */
  20865. targetStopDuration: number;
  20866. /**
  20867. * The texture used to render each particle. (this can be a spritesheet)
  20868. */
  20869. particleTexture: Nullable<Texture>;
  20870. /**
  20871. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  20872. */
  20873. blendMode: number;
  20874. /**
  20875. * Minimum life time of emitting particles.
  20876. */
  20877. minLifeTime: number;
  20878. /**
  20879. * Maximum life time of emitting particles.
  20880. */
  20881. maxLifeTime: number;
  20882. /**
  20883. * Minimum Size of emitting particles.
  20884. */
  20885. minSize: number;
  20886. /**
  20887. * Maximum Size of emitting particles.
  20888. */
  20889. maxSize: number;
  20890. /**
  20891. * Minimum scale of emitting particles on X axis.
  20892. */
  20893. minScaleX: number;
  20894. /**
  20895. * Maximum scale of emitting particles on X axis.
  20896. */
  20897. maxScaleX: number;
  20898. /**
  20899. * Minimum scale of emitting particles on Y axis.
  20900. */
  20901. minScaleY: number;
  20902. /**
  20903. * Maximum scale of emitting particles on Y axis.
  20904. */
  20905. maxScaleY: number;
  20906. /**
  20907. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  20908. */
  20909. color1: Color4;
  20910. /**
  20911. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  20912. */
  20913. color2: Color4;
  20914. /**
  20915. * Color the particle will have at the end of its lifetime.
  20916. */
  20917. colorDead: Color4;
  20918. /**
  20919. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  20920. */
  20921. emitRate: number;
  20922. /**
  20923. * You can use gravity if you want to give an orientation to your particles.
  20924. */
  20925. gravity: Vector3;
  20926. /**
  20927. * Minimum power of emitting particles.
  20928. */
  20929. minEmitPower: number;
  20930. /**
  20931. * Maximum power of emitting particles.
  20932. */
  20933. maxEmitPower: number;
  20934. /**
  20935. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  20936. */
  20937. minAngularSpeed: number;
  20938. /**
  20939. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  20940. */
  20941. maxAngularSpeed: number;
  20942. /**
  20943. * Gets or sets the minimal initial rotation in radians.
  20944. */
  20945. minInitialRotation: number;
  20946. /**
  20947. * Gets or sets the maximal initial rotation in radians.
  20948. */
  20949. maxInitialRotation: number;
  20950. /**
  20951. * The particle emitter type defines the emitter used by the particle system.
  20952. * It can be for example box, sphere, or cone...
  20953. */
  20954. particleEmitterType: Nullable<IParticleEmitterType>;
  20955. /**
  20956. * Defines the delay in milliseconds before starting the system (0 by default)
  20957. */
  20958. startDelay: number;
  20959. /**
  20960. * 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
  20961. */
  20962. preWarmCycles: number;
  20963. /**
  20964. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  20965. */
  20966. preWarmStepOffset: number;
  20967. /**
  20968. * 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)
  20969. */
  20970. spriteCellChangeSpeed: number;
  20971. /**
  20972. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  20973. */
  20974. startSpriteCellID: number;
  20975. /**
  20976. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  20977. */
  20978. endSpriteCellID: number;
  20979. /**
  20980. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  20981. */
  20982. spriteCellWidth: number;
  20983. /**
  20984. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  20985. */
  20986. spriteCellHeight: number;
  20987. /**
  20988. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  20989. */
  20990. spriteRandomStartCell: boolean;
  20991. /**
  20992. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  20993. */
  20994. isAnimationSheetEnabled: boolean;
  20995. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  20996. translationPivot: Vector2;
  20997. /**
  20998. * Gets or sets a texture used to add random noise to particle positions
  20999. */
  21000. noiseTexture: Nullable<BaseTexture>;
  21001. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  21002. noiseStrength: Vector3;
  21003. /**
  21004. * Gets or sets the billboard mode to use when isBillboardBased = true.
  21005. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  21006. */
  21007. billboardMode: number;
  21008. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  21009. limitVelocityDamping: number;
  21010. /**
  21011. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  21012. */
  21013. beginAnimationOnStart: boolean;
  21014. /**
  21015. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  21016. */
  21017. beginAnimationFrom: number;
  21018. /**
  21019. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  21020. */
  21021. beginAnimationTo: number;
  21022. /**
  21023. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  21024. */
  21025. beginAnimationLoop: boolean;
  21026. /**
  21027. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  21028. */
  21029. disposeOnStop: boolean;
  21030. /**
  21031. * Gets the maximum number of particles active at the same time.
  21032. * @returns The max number of active particles.
  21033. */
  21034. getCapacity(): number;
  21035. /**
  21036. * Gets if the system has been started. (Note: this will still be true after stop is called)
  21037. * @returns True if it has been started, otherwise false.
  21038. */
  21039. isStarted(): boolean;
  21040. /**
  21041. * Animates the particle system for this frame.
  21042. */
  21043. animate(): void;
  21044. /**
  21045. * Renders the particle system in its current state.
  21046. * @returns the current number of particles
  21047. */
  21048. render(): number;
  21049. /**
  21050. * Dispose the particle system and frees its associated resources.
  21051. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  21052. */
  21053. dispose(disposeTexture?: boolean): void;
  21054. /**
  21055. * Clones the particle system.
  21056. * @param name The name of the cloned object
  21057. * @param newEmitter The new emitter to use
  21058. * @returns the cloned particle system
  21059. */
  21060. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  21061. /**
  21062. * Serializes the particle system to a JSON object.
  21063. * @returns the JSON object
  21064. */
  21065. serialize(): any;
  21066. /**
  21067. * Rebuild the particle system
  21068. */
  21069. rebuild(): void;
  21070. /**
  21071. * Starts the particle system and begins to emit
  21072. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  21073. */
  21074. start(delay?: number): void;
  21075. /**
  21076. * Stops the particle system.
  21077. */
  21078. stop(): void;
  21079. /**
  21080. * Remove all active particles
  21081. */
  21082. reset(): void;
  21083. /**
  21084. * Is this system ready to be used/rendered
  21085. * @return true if the system is ready
  21086. */
  21087. isReady(): boolean;
  21088. /**
  21089. * Adds a new color gradient
  21090. * @param gradient defines the gradient to use (between 0 and 1)
  21091. * @param color1 defines the color to affect to the specified gradient
  21092. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  21093. * @returns the current particle system
  21094. */
  21095. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  21096. /**
  21097. * Remove a specific color gradient
  21098. * @param gradient defines the gradient to remove
  21099. * @returns the current particle system
  21100. */
  21101. removeColorGradient(gradient: number): IParticleSystem;
  21102. /**
  21103. * Adds a new size gradient
  21104. * @param gradient defines the gradient to use (between 0 and 1)
  21105. * @param factor defines the size factor to affect to the specified gradient
  21106. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21107. * @returns the current particle system
  21108. */
  21109. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21110. /**
  21111. * Remove a specific size gradient
  21112. * @param gradient defines the gradient to remove
  21113. * @returns the current particle system
  21114. */
  21115. removeSizeGradient(gradient: number): IParticleSystem;
  21116. /**
  21117. * Gets the current list of color gradients.
  21118. * You must use addColorGradient and removeColorGradient to udpate this list
  21119. * @returns the list of color gradients
  21120. */
  21121. getColorGradients(): Nullable<Array<ColorGradient>>;
  21122. /**
  21123. * Gets the current list of size gradients.
  21124. * You must use addSizeGradient and removeSizeGradient to udpate this list
  21125. * @returns the list of size gradients
  21126. */
  21127. getSizeGradients(): Nullable<Array<FactorGradient>>;
  21128. /**
  21129. * Gets the current list of angular speed gradients.
  21130. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  21131. * @returns the list of angular speed gradients
  21132. */
  21133. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  21134. /**
  21135. * Adds a new angular speed gradient
  21136. * @param gradient defines the gradient to use (between 0 and 1)
  21137. * @param factor defines the angular speed to affect to the specified gradient
  21138. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21139. * @returns the current particle system
  21140. */
  21141. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21142. /**
  21143. * Remove a specific angular speed gradient
  21144. * @param gradient defines the gradient to remove
  21145. * @returns the current particle system
  21146. */
  21147. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  21148. /**
  21149. * Gets the current list of velocity gradients.
  21150. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  21151. * @returns the list of velocity gradients
  21152. */
  21153. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  21154. /**
  21155. * Adds a new velocity gradient
  21156. * @param gradient defines the gradient to use (between 0 and 1)
  21157. * @param factor defines the velocity to affect to the specified gradient
  21158. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21159. * @returns the current particle system
  21160. */
  21161. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21162. /**
  21163. * Remove a specific velocity gradient
  21164. * @param gradient defines the gradient to remove
  21165. * @returns the current particle system
  21166. */
  21167. removeVelocityGradient(gradient: number): IParticleSystem;
  21168. /**
  21169. * Gets the current list of limit velocity gradients.
  21170. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  21171. * @returns the list of limit velocity gradients
  21172. */
  21173. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  21174. /**
  21175. * Adds a new limit velocity gradient
  21176. * @param gradient defines the gradient to use (between 0 and 1)
  21177. * @param factor defines the limit velocity to affect to the specified gradient
  21178. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21179. * @returns the current particle system
  21180. */
  21181. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21182. /**
  21183. * Remove a specific limit velocity gradient
  21184. * @param gradient defines the gradient to remove
  21185. * @returns the current particle system
  21186. */
  21187. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  21188. /**
  21189. * Adds a new drag gradient
  21190. * @param gradient defines the gradient to use (between 0 and 1)
  21191. * @param factor defines the drag to affect to the specified gradient
  21192. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21193. * @returns the current particle system
  21194. */
  21195. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21196. /**
  21197. * Remove a specific drag gradient
  21198. * @param gradient defines the gradient to remove
  21199. * @returns the current particle system
  21200. */
  21201. removeDragGradient(gradient: number): IParticleSystem;
  21202. /**
  21203. * Gets the current list of drag gradients.
  21204. * You must use addDragGradient and removeDragGradient to udpate this list
  21205. * @returns the list of drag gradients
  21206. */
  21207. getDragGradients(): Nullable<Array<FactorGradient>>;
  21208. /**
  21209. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  21210. * @param gradient defines the gradient to use (between 0 and 1)
  21211. * @param factor defines the emit rate to affect to the specified gradient
  21212. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21213. * @returns the current particle system
  21214. */
  21215. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21216. /**
  21217. * Remove a specific emit rate gradient
  21218. * @param gradient defines the gradient to remove
  21219. * @returns the current particle system
  21220. */
  21221. removeEmitRateGradient(gradient: number): IParticleSystem;
  21222. /**
  21223. * Gets the current list of emit rate gradients.
  21224. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  21225. * @returns the list of emit rate gradients
  21226. */
  21227. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  21228. /**
  21229. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  21230. * @param gradient defines the gradient to use (between 0 and 1)
  21231. * @param factor defines the start size to affect to the specified gradient
  21232. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21233. * @returns the current particle system
  21234. */
  21235. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21236. /**
  21237. * Remove a specific start size gradient
  21238. * @param gradient defines the gradient to remove
  21239. * @returns the current particle system
  21240. */
  21241. removeStartSizeGradient(gradient: number): IParticleSystem;
  21242. /**
  21243. * Gets the current list of start size gradients.
  21244. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  21245. * @returns the list of start size gradients
  21246. */
  21247. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  21248. /**
  21249. * Adds a new life time gradient
  21250. * @param gradient defines the gradient to use (between 0 and 1)
  21251. * @param factor defines the life time factor to affect to the specified gradient
  21252. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21253. * @returns the current particle system
  21254. */
  21255. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21256. /**
  21257. * Remove a specific life time gradient
  21258. * @param gradient defines the gradient to remove
  21259. * @returns the current particle system
  21260. */
  21261. removeLifeTimeGradient(gradient: number): IParticleSystem;
  21262. /**
  21263. * Gets the current list of life time gradients.
  21264. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  21265. * @returns the list of life time gradients
  21266. */
  21267. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  21268. /**
  21269. * Gets the current list of color gradients.
  21270. * You must use addColorGradient and removeColorGradient to udpate this list
  21271. * @returns the list of color gradients
  21272. */
  21273. getColorGradients(): Nullable<Array<ColorGradient>>;
  21274. /**
  21275. * Adds a new ramp gradient used to remap particle colors
  21276. * @param gradient defines the gradient to use (between 0 and 1)
  21277. * @param color defines the color to affect to the specified gradient
  21278. * @returns the current particle system
  21279. */
  21280. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  21281. /**
  21282. * Gets the current list of ramp gradients.
  21283. * You must use addRampGradient and removeRampGradient to udpate this list
  21284. * @returns the list of ramp gradients
  21285. */
  21286. getRampGradients(): Nullable<Array<Color3Gradient>>;
  21287. /** Gets or sets a boolean indicating that ramp gradients must be used
  21288. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  21289. */
  21290. useRampGradients: boolean;
  21291. /**
  21292. * Adds a new color remap gradient
  21293. * @param gradient defines the gradient to use (between 0 and 1)
  21294. * @param min defines the color remap minimal range
  21295. * @param max defines the color remap maximal range
  21296. * @returns the current particle system
  21297. */
  21298. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  21299. /**
  21300. * Gets the current list of color remap gradients.
  21301. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  21302. * @returns the list of color remap gradients
  21303. */
  21304. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  21305. /**
  21306. * Adds a new alpha remap gradient
  21307. * @param gradient defines the gradient to use (between 0 and 1)
  21308. * @param min defines the alpha remap minimal range
  21309. * @param max defines the alpha remap maximal range
  21310. * @returns the current particle system
  21311. */
  21312. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  21313. /**
  21314. * Gets the current list of alpha remap gradients.
  21315. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  21316. * @returns the list of alpha remap gradients
  21317. */
  21318. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  21319. /**
  21320. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  21321. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  21322. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  21323. * @returns the emitter
  21324. */
  21325. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  21326. /**
  21327. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  21328. * @param radius The radius of the hemisphere to emit from
  21329. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  21330. * @returns the emitter
  21331. */
  21332. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  21333. /**
  21334. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  21335. * @param radius The radius of the sphere to emit from
  21336. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  21337. * @returns the emitter
  21338. */
  21339. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  21340. /**
  21341. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  21342. * @param radius The radius of the sphere to emit from
  21343. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  21344. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  21345. * @returns the emitter
  21346. */
  21347. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  21348. /**
  21349. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  21350. * @param radius The radius of the emission cylinder
  21351. * @param height The height of the emission cylinder
  21352. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  21353. * @param directionRandomizer How much to randomize the particle direction [0-1]
  21354. * @returns the emitter
  21355. */
  21356. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  21357. /**
  21358. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  21359. * @param radius The radius of the cylinder to emit from
  21360. * @param height The height of the emission cylinder
  21361. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  21362. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  21363. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  21364. * @returns the emitter
  21365. */
  21366. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  21367. /**
  21368. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  21369. * @param radius The radius of the cone to emit from
  21370. * @param angle The base angle of the cone
  21371. * @returns the emitter
  21372. */
  21373. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  21374. /**
  21375. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  21376. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  21377. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  21378. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  21379. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  21380. * @returns the emitter
  21381. */
  21382. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  21383. /**
  21384. * Get hosting scene
  21385. * @returns the scene
  21386. */
  21387. getScene(): Scene;
  21388. }
  21389. }
  21390. declare module BABYLON {
  21391. /** @hidden */
  21392. export var linePixelShader: {
  21393. name: string;
  21394. shader: string;
  21395. };
  21396. }
  21397. declare module BABYLON {
  21398. /** @hidden */
  21399. export var lineVertexShader: {
  21400. name: string;
  21401. shader: string;
  21402. };
  21403. }
  21404. declare module BABYLON {
  21405. interface AbstractMesh {
  21406. /**
  21407. * Gets the edgesRenderer associated with the mesh
  21408. */
  21409. edgesRenderer: Nullable<EdgesRenderer>;
  21410. }
  21411. interface LinesMesh {
  21412. /**
  21413. * Enables the edge rendering mode on the mesh.
  21414. * This mode makes the mesh edges visible
  21415. * @param epsilon defines the maximal distance between two angles to detect a face
  21416. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  21417. * @returns the currentAbstractMesh
  21418. * @see https://www.babylonjs-playground.com/#19O9TU#0
  21419. */
  21420. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  21421. }
  21422. interface InstancedLinesMesh {
  21423. /**
  21424. * Enables the edge rendering mode on the mesh.
  21425. * This mode makes the mesh edges visible
  21426. * @param epsilon defines the maximal distance between two angles to detect a face
  21427. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  21428. * @returns the current InstancedLinesMesh
  21429. * @see https://www.babylonjs-playground.com/#19O9TU#0
  21430. */
  21431. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  21432. }
  21433. /**
  21434. * Defines the minimum contract an Edges renderer should follow.
  21435. */
  21436. export interface IEdgesRenderer extends IDisposable {
  21437. /**
  21438. * Gets or sets a boolean indicating if the edgesRenderer is active
  21439. */
  21440. isEnabled: boolean;
  21441. /**
  21442. * Renders the edges of the attached mesh,
  21443. */
  21444. render(): void;
  21445. /**
  21446. * Checks wether or not the edges renderer is ready to render.
  21447. * @return true if ready, otherwise false.
  21448. */
  21449. isReady(): boolean;
  21450. }
  21451. /**
  21452. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  21453. */
  21454. export class EdgesRenderer implements IEdgesRenderer {
  21455. /**
  21456. * Define the size of the edges with an orthographic camera
  21457. */
  21458. edgesWidthScalerForOrthographic: number;
  21459. /**
  21460. * Define the size of the edges with a perspective camera
  21461. */
  21462. edgesWidthScalerForPerspective: number;
  21463. protected _source: AbstractMesh;
  21464. protected _linesPositions: number[];
  21465. protected _linesNormals: number[];
  21466. protected _linesIndices: number[];
  21467. protected _epsilon: number;
  21468. protected _indicesCount: number;
  21469. protected _lineShader: ShaderMaterial;
  21470. protected _ib: DataBuffer;
  21471. protected _buffers: {
  21472. [key: string]: Nullable<VertexBuffer>;
  21473. };
  21474. protected _checkVerticesInsteadOfIndices: boolean;
  21475. private _meshRebuildObserver;
  21476. private _meshDisposeObserver;
  21477. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  21478. isEnabled: boolean;
  21479. /**
  21480. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  21481. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  21482. * @param source Mesh used to create edges
  21483. * @param epsilon sum of angles in adjacency to check for edge
  21484. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  21485. * @param generateEdgesLines - should generate Lines or only prepare resources.
  21486. */
  21487. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  21488. protected _prepareRessources(): void;
  21489. /** @hidden */
  21490. _rebuild(): void;
  21491. /**
  21492. * Releases the required resources for the edges renderer
  21493. */
  21494. dispose(): void;
  21495. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  21496. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  21497. /**
  21498. * Checks if the pair of p0 and p1 is en edge
  21499. * @param faceIndex
  21500. * @param edge
  21501. * @param faceNormals
  21502. * @param p0
  21503. * @param p1
  21504. * @private
  21505. */
  21506. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  21507. /**
  21508. * push line into the position, normal and index buffer
  21509. * @protected
  21510. */
  21511. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  21512. /**
  21513. * Generates lines edges from adjacencjes
  21514. * @private
  21515. */
  21516. _generateEdgesLines(): void;
  21517. /**
  21518. * Checks wether or not the edges renderer is ready to render.
  21519. * @return true if ready, otherwise false.
  21520. */
  21521. isReady(): boolean;
  21522. /**
  21523. * Renders the edges of the attached mesh,
  21524. */
  21525. render(): void;
  21526. }
  21527. /**
  21528. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  21529. */
  21530. export class LineEdgesRenderer extends EdgesRenderer {
  21531. /**
  21532. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  21533. * @param source LineMesh used to generate edges
  21534. * @param epsilon not important (specified angle for edge detection)
  21535. * @param checkVerticesInsteadOfIndices not important for LineMesh
  21536. */
  21537. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  21538. /**
  21539. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  21540. */
  21541. _generateEdgesLines(): void;
  21542. }
  21543. }
  21544. declare module BABYLON {
  21545. /**
  21546. * This represents the object necessary to create a rendering group.
  21547. * This is exclusively used and created by the rendering manager.
  21548. * To modify the behavior, you use the available helpers in your scene or meshes.
  21549. * @hidden
  21550. */
  21551. export class RenderingGroup {
  21552. index: number;
  21553. private static _zeroVector;
  21554. private _scene;
  21555. private _opaqueSubMeshes;
  21556. private _transparentSubMeshes;
  21557. private _alphaTestSubMeshes;
  21558. private _depthOnlySubMeshes;
  21559. private _particleSystems;
  21560. private _spriteManagers;
  21561. private _opaqueSortCompareFn;
  21562. private _alphaTestSortCompareFn;
  21563. private _transparentSortCompareFn;
  21564. private _renderOpaque;
  21565. private _renderAlphaTest;
  21566. private _renderTransparent;
  21567. /** @hidden */
  21568. _edgesRenderers: SmartArray<IEdgesRenderer>;
  21569. onBeforeTransparentRendering: () => void;
  21570. /**
  21571. * Set the opaque sort comparison function.
  21572. * If null the sub meshes will be render in the order they were created
  21573. */
  21574. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  21575. /**
  21576. * Set the alpha test sort comparison function.
  21577. * If null the sub meshes will be render in the order they were created
  21578. */
  21579. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  21580. /**
  21581. * Set the transparent sort comparison function.
  21582. * If null the sub meshes will be render in the order they were created
  21583. */
  21584. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  21585. /**
  21586. * Creates a new rendering group.
  21587. * @param index The rendering group index
  21588. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  21589. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  21590. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  21591. */
  21592. 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>);
  21593. /**
  21594. * Render all the sub meshes contained in the group.
  21595. * @param customRenderFunction Used to override the default render behaviour of the group.
  21596. * @returns true if rendered some submeshes.
  21597. */
  21598. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  21599. /**
  21600. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  21601. * @param subMeshes The submeshes to render
  21602. */
  21603. private renderOpaqueSorted;
  21604. /**
  21605. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  21606. * @param subMeshes The submeshes to render
  21607. */
  21608. private renderAlphaTestSorted;
  21609. /**
  21610. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  21611. * @param subMeshes The submeshes to render
  21612. */
  21613. private renderTransparentSorted;
  21614. /**
  21615. * Renders the submeshes in a specified order.
  21616. * @param subMeshes The submeshes to sort before render
  21617. * @param sortCompareFn The comparison function use to sort
  21618. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  21619. * @param transparent Specifies to activate blending if true
  21620. */
  21621. private static renderSorted;
  21622. /**
  21623. * Renders the submeshes in the order they were dispatched (no sort applied).
  21624. * @param subMeshes The submeshes to render
  21625. */
  21626. private static renderUnsorted;
  21627. /**
  21628. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  21629. * are rendered back to front if in the same alpha index.
  21630. *
  21631. * @param a The first submesh
  21632. * @param b The second submesh
  21633. * @returns The result of the comparison
  21634. */
  21635. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  21636. /**
  21637. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  21638. * are rendered back to front.
  21639. *
  21640. * @param a The first submesh
  21641. * @param b The second submesh
  21642. * @returns The result of the comparison
  21643. */
  21644. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  21645. /**
  21646. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  21647. * are rendered front to back (prevent overdraw).
  21648. *
  21649. * @param a The first submesh
  21650. * @param b The second submesh
  21651. * @returns The result of the comparison
  21652. */
  21653. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  21654. /**
  21655. * Resets the different lists of submeshes to prepare a new frame.
  21656. */
  21657. prepare(): void;
  21658. dispose(): void;
  21659. /**
  21660. * Inserts the submesh in its correct queue depending on its material.
  21661. * @param subMesh The submesh to dispatch
  21662. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  21663. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  21664. */
  21665. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  21666. dispatchSprites(spriteManager: ISpriteManager): void;
  21667. dispatchParticles(particleSystem: IParticleSystem): void;
  21668. private _renderParticles;
  21669. private _renderSprites;
  21670. }
  21671. }
  21672. declare module BABYLON {
  21673. /**
  21674. * Interface describing the different options available in the rendering manager
  21675. * regarding Auto Clear between groups.
  21676. */
  21677. export interface IRenderingManagerAutoClearSetup {
  21678. /**
  21679. * Defines whether or not autoclear is enable.
  21680. */
  21681. autoClear: boolean;
  21682. /**
  21683. * Defines whether or not to autoclear the depth buffer.
  21684. */
  21685. depth: boolean;
  21686. /**
  21687. * Defines whether or not to autoclear the stencil buffer.
  21688. */
  21689. stencil: boolean;
  21690. }
  21691. /**
  21692. * This class is used by the onRenderingGroupObservable
  21693. */
  21694. export class RenderingGroupInfo {
  21695. /**
  21696. * The Scene that being rendered
  21697. */
  21698. scene: Scene;
  21699. /**
  21700. * The camera currently used for the rendering pass
  21701. */
  21702. camera: Nullable<Camera>;
  21703. /**
  21704. * The ID of the renderingGroup being processed
  21705. */
  21706. renderingGroupId: number;
  21707. }
  21708. /**
  21709. * This is the manager responsible of all the rendering for meshes sprites and particles.
  21710. * It is enable to manage the different groups as well as the different necessary sort functions.
  21711. * This should not be used directly aside of the few static configurations
  21712. */
  21713. export class RenderingManager {
  21714. /**
  21715. * The max id used for rendering groups (not included)
  21716. */
  21717. static MAX_RENDERINGGROUPS: number;
  21718. /**
  21719. * The min id used for rendering groups (included)
  21720. */
  21721. static MIN_RENDERINGGROUPS: number;
  21722. /**
  21723. * Used to globally prevent autoclearing scenes.
  21724. */
  21725. static AUTOCLEAR: boolean;
  21726. /**
  21727. * @hidden
  21728. */
  21729. _useSceneAutoClearSetup: boolean;
  21730. private _scene;
  21731. private _renderingGroups;
  21732. private _depthStencilBufferAlreadyCleaned;
  21733. private _autoClearDepthStencil;
  21734. private _customOpaqueSortCompareFn;
  21735. private _customAlphaTestSortCompareFn;
  21736. private _customTransparentSortCompareFn;
  21737. private _renderingGroupInfo;
  21738. /**
  21739. * Instantiates a new rendering group for a particular scene
  21740. * @param scene Defines the scene the groups belongs to
  21741. */
  21742. constructor(scene: Scene);
  21743. private _clearDepthStencilBuffer;
  21744. /**
  21745. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  21746. * @hidden
  21747. */
  21748. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  21749. /**
  21750. * Resets the different information of the group to prepare a new frame
  21751. * @hidden
  21752. */
  21753. reset(): void;
  21754. /**
  21755. * Dispose and release the group and its associated resources.
  21756. * @hidden
  21757. */
  21758. dispose(): void;
  21759. /**
  21760. * Clear the info related to rendering groups preventing retention points during dispose.
  21761. */
  21762. freeRenderingGroups(): void;
  21763. private _prepareRenderingGroup;
  21764. /**
  21765. * Add a sprite manager to the rendering manager in order to render it this frame.
  21766. * @param spriteManager Define the sprite manager to render
  21767. */
  21768. dispatchSprites(spriteManager: ISpriteManager): void;
  21769. /**
  21770. * Add a particle system to the rendering manager in order to render it this frame.
  21771. * @param particleSystem Define the particle system to render
  21772. */
  21773. dispatchParticles(particleSystem: IParticleSystem): void;
  21774. /**
  21775. * Add a submesh to the manager in order to render it this frame
  21776. * @param subMesh The submesh to dispatch
  21777. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  21778. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  21779. */
  21780. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  21781. /**
  21782. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  21783. * This allowed control for front to back rendering or reversly depending of the special needs.
  21784. *
  21785. * @param renderingGroupId The rendering group id corresponding to its index
  21786. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  21787. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  21788. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  21789. */
  21790. 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;
  21791. /**
  21792. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  21793. *
  21794. * @param renderingGroupId The rendering group id corresponding to its index
  21795. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  21796. * @param depth Automatically clears depth between groups if true and autoClear is true.
  21797. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  21798. */
  21799. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  21800. /**
  21801. * Gets the current auto clear configuration for one rendering group of the rendering
  21802. * manager.
  21803. * @param index the rendering group index to get the information for
  21804. * @returns The auto clear setup for the requested rendering group
  21805. */
  21806. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  21807. }
  21808. }
  21809. declare module BABYLON {
  21810. /**
  21811. * This Helps creating a texture that will be created from a camera in your scene.
  21812. * It is basically a dynamic texture that could be used to create special effects for instance.
  21813. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  21814. */
  21815. export class RenderTargetTexture extends Texture {
  21816. isCube: boolean;
  21817. /**
  21818. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  21819. */
  21820. static readonly REFRESHRATE_RENDER_ONCE: number;
  21821. /**
  21822. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  21823. */
  21824. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  21825. /**
  21826. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  21827. * the central point of your effect and can save a lot of performances.
  21828. */
  21829. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  21830. /**
  21831. * Use this predicate to dynamically define the list of mesh you want to render.
  21832. * If set, the renderList property will be overwritten.
  21833. */
  21834. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  21835. private _renderList;
  21836. /**
  21837. * Use this list to define the list of mesh you want to render.
  21838. */
  21839. renderList: Nullable<Array<AbstractMesh>>;
  21840. private _hookArray;
  21841. /**
  21842. * Define if particles should be rendered in your texture.
  21843. */
  21844. renderParticles: boolean;
  21845. /**
  21846. * Define if sprites should be rendered in your texture.
  21847. */
  21848. renderSprites: boolean;
  21849. /**
  21850. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  21851. */
  21852. coordinatesMode: number;
  21853. /**
  21854. * Define the camera used to render the texture.
  21855. */
  21856. activeCamera: Nullable<Camera>;
  21857. /**
  21858. * Override the render function of the texture with your own one.
  21859. */
  21860. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  21861. /**
  21862. * Define if camera post processes should be use while rendering the texture.
  21863. */
  21864. useCameraPostProcesses: boolean;
  21865. /**
  21866. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  21867. */
  21868. ignoreCameraViewport: boolean;
  21869. private _postProcessManager;
  21870. private _postProcesses;
  21871. private _resizeObserver;
  21872. /**
  21873. * An event triggered when the texture is unbind.
  21874. */
  21875. onBeforeBindObservable: Observable<RenderTargetTexture>;
  21876. /**
  21877. * An event triggered when the texture is unbind.
  21878. */
  21879. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  21880. private _onAfterUnbindObserver;
  21881. /**
  21882. * Set a after unbind callback in the texture.
  21883. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  21884. */
  21885. onAfterUnbind: () => void;
  21886. /**
  21887. * An event triggered before rendering the texture
  21888. */
  21889. onBeforeRenderObservable: Observable<number>;
  21890. private _onBeforeRenderObserver;
  21891. /**
  21892. * Set a before render callback in the texture.
  21893. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  21894. */
  21895. onBeforeRender: (faceIndex: number) => void;
  21896. /**
  21897. * An event triggered after rendering the texture
  21898. */
  21899. onAfterRenderObservable: Observable<number>;
  21900. private _onAfterRenderObserver;
  21901. /**
  21902. * Set a after render callback in the texture.
  21903. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  21904. */
  21905. onAfterRender: (faceIndex: number) => void;
  21906. /**
  21907. * An event triggered after the texture clear
  21908. */
  21909. onClearObservable: Observable<Engine>;
  21910. private _onClearObserver;
  21911. /**
  21912. * Set a clear callback in the texture.
  21913. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  21914. */
  21915. onClear: (Engine: Engine) => void;
  21916. /**
  21917. * Define the clear color of the Render Target if it should be different from the scene.
  21918. */
  21919. clearColor: Color4;
  21920. protected _size: number | {
  21921. width: number;
  21922. height: number;
  21923. };
  21924. protected _initialSizeParameter: number | {
  21925. width: number;
  21926. height: number;
  21927. } | {
  21928. ratio: number;
  21929. };
  21930. protected _sizeRatio: Nullable<number>;
  21931. /** @hidden */
  21932. _generateMipMaps: boolean;
  21933. protected _renderingManager: RenderingManager;
  21934. /** @hidden */
  21935. _waitingRenderList: string[];
  21936. protected _doNotChangeAspectRatio: boolean;
  21937. protected _currentRefreshId: number;
  21938. protected _refreshRate: number;
  21939. protected _textureMatrix: Matrix;
  21940. protected _samples: number;
  21941. protected _renderTargetOptions: RenderTargetCreationOptions;
  21942. /**
  21943. * Gets render target creation options that were used.
  21944. */
  21945. readonly renderTargetOptions: RenderTargetCreationOptions;
  21946. protected _engine: Engine;
  21947. protected _onRatioRescale(): void;
  21948. /**
  21949. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  21950. * It must define where the camera used to render the texture is set
  21951. */
  21952. boundingBoxPosition: Vector3;
  21953. private _boundingBoxSize;
  21954. /**
  21955. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  21956. * When defined, the cubemap will switch to local mode
  21957. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  21958. * @example https://www.babylonjs-playground.com/#RNASML
  21959. */
  21960. boundingBoxSize: Vector3;
  21961. /**
  21962. * In case the RTT has been created with a depth texture, get the associated
  21963. * depth texture.
  21964. * Otherwise, return null.
  21965. */
  21966. depthStencilTexture: Nullable<InternalTexture>;
  21967. /**
  21968. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  21969. * or used a shadow, depth texture...
  21970. * @param name The friendly name of the texture
  21971. * @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)
  21972. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  21973. * @param generateMipMaps True if mip maps need to be generated after render.
  21974. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  21975. * @param type The type of the buffer in the RTT (int, half float, float...)
  21976. * @param isCube True if a cube texture needs to be created
  21977. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  21978. * @param generateDepthBuffer True to generate a depth buffer
  21979. * @param generateStencilBuffer True to generate a stencil buffer
  21980. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  21981. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  21982. * @param delayAllocation if the texture allocation should be delayed (default: false)
  21983. */
  21984. constructor(name: string, size: number | {
  21985. width: number;
  21986. height: number;
  21987. } | {
  21988. ratio: number;
  21989. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  21990. /**
  21991. * Creates a depth stencil texture.
  21992. * This is only available in WebGL 2 or with the depth texture extension available.
  21993. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  21994. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  21995. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  21996. */
  21997. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  21998. private _processSizeParameter;
  21999. /**
  22000. * Define the number of samples to use in case of MSAA.
  22001. * It defaults to one meaning no MSAA has been enabled.
  22002. */
  22003. samples: number;
  22004. /**
  22005. * Resets the refresh counter of the texture and start bak from scratch.
  22006. * Could be useful to regenerate the texture if it is setup to render only once.
  22007. */
  22008. resetRefreshCounter(): void;
  22009. /**
  22010. * Define the refresh rate of the texture or the rendering frequency.
  22011. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  22012. */
  22013. refreshRate: number;
  22014. /**
  22015. * Adds a post process to the render target rendering passes.
  22016. * @param postProcess define the post process to add
  22017. */
  22018. addPostProcess(postProcess: PostProcess): void;
  22019. /**
  22020. * Clear all the post processes attached to the render target
  22021. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  22022. */
  22023. clearPostProcesses(dispose?: boolean): void;
  22024. /**
  22025. * Remove one of the post process from the list of attached post processes to the texture
  22026. * @param postProcess define the post process to remove from the list
  22027. */
  22028. removePostProcess(postProcess: PostProcess): void;
  22029. /** @hidden */
  22030. _shouldRender(): boolean;
  22031. /**
  22032. * Gets the actual render size of the texture.
  22033. * @returns the width of the render size
  22034. */
  22035. getRenderSize(): number;
  22036. /**
  22037. * Gets the actual render width of the texture.
  22038. * @returns the width of the render size
  22039. */
  22040. getRenderWidth(): number;
  22041. /**
  22042. * Gets the actual render height of the texture.
  22043. * @returns the height of the render size
  22044. */
  22045. getRenderHeight(): number;
  22046. /**
  22047. * Get if the texture can be rescaled or not.
  22048. */
  22049. readonly canRescale: boolean;
  22050. /**
  22051. * Resize the texture using a ratio.
  22052. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  22053. */
  22054. scale(ratio: number): void;
  22055. /**
  22056. * Get the texture reflection matrix used to rotate/transform the reflection.
  22057. * @returns the reflection matrix
  22058. */
  22059. getReflectionTextureMatrix(): Matrix;
  22060. /**
  22061. * Resize the texture to a new desired size.
  22062. * Be carrefull as it will recreate all the data in the new texture.
  22063. * @param size Define the new size. It can be:
  22064. * - a number for squared texture,
  22065. * - an object containing { width: number, height: number }
  22066. * - or an object containing a ratio { ratio: number }
  22067. */
  22068. resize(size: number | {
  22069. width: number;
  22070. height: number;
  22071. } | {
  22072. ratio: number;
  22073. }): void;
  22074. /**
  22075. * Renders all the objects from the render list into the texture.
  22076. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  22077. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  22078. */
  22079. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  22080. private _bestReflectionRenderTargetDimension;
  22081. /**
  22082. * @hidden
  22083. * @param faceIndex face index to bind to if this is a cubetexture
  22084. */
  22085. _bindFrameBuffer(faceIndex?: number): void;
  22086. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  22087. private renderToTarget;
  22088. /**
  22089. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  22090. * This allowed control for front to back rendering or reversly depending of the special needs.
  22091. *
  22092. * @param renderingGroupId The rendering group id corresponding to its index
  22093. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  22094. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  22095. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  22096. */
  22097. 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;
  22098. /**
  22099. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  22100. *
  22101. * @param renderingGroupId The rendering group id corresponding to its index
  22102. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  22103. */
  22104. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  22105. /**
  22106. * Clones the texture.
  22107. * @returns the cloned texture
  22108. */
  22109. clone(): RenderTargetTexture;
  22110. /**
  22111. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  22112. * @returns The JSON representation of the texture
  22113. */
  22114. serialize(): any;
  22115. /**
  22116. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  22117. */
  22118. disposeFramebufferObjects(): void;
  22119. /**
  22120. * Dispose the texture and release its associated resources.
  22121. */
  22122. dispose(): void;
  22123. /** @hidden */
  22124. _rebuild(): void;
  22125. /**
  22126. * Clear the info related to rendering groups preventing retention point in material dispose.
  22127. */
  22128. freeRenderingGroups(): void;
  22129. /**
  22130. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  22131. * @returns the view count
  22132. */
  22133. getViewCount(): number;
  22134. }
  22135. }
  22136. declare module BABYLON {
  22137. /**
  22138. * Base class for the main features of a material in Babylon.js
  22139. */
  22140. export class Material implements IAnimatable {
  22141. /**
  22142. * Returns the triangle fill mode
  22143. */
  22144. static readonly TriangleFillMode: number;
  22145. /**
  22146. * Returns the wireframe mode
  22147. */
  22148. static readonly WireFrameFillMode: number;
  22149. /**
  22150. * Returns the point fill mode
  22151. */
  22152. static readonly PointFillMode: number;
  22153. /**
  22154. * Returns the point list draw mode
  22155. */
  22156. static readonly PointListDrawMode: number;
  22157. /**
  22158. * Returns the line list draw mode
  22159. */
  22160. static readonly LineListDrawMode: number;
  22161. /**
  22162. * Returns the line loop draw mode
  22163. */
  22164. static readonly LineLoopDrawMode: number;
  22165. /**
  22166. * Returns the line strip draw mode
  22167. */
  22168. static readonly LineStripDrawMode: number;
  22169. /**
  22170. * Returns the triangle strip draw mode
  22171. */
  22172. static readonly TriangleStripDrawMode: number;
  22173. /**
  22174. * Returns the triangle fan draw mode
  22175. */
  22176. static readonly TriangleFanDrawMode: number;
  22177. /**
  22178. * Stores the clock-wise side orientation
  22179. */
  22180. static readonly ClockWiseSideOrientation: number;
  22181. /**
  22182. * Stores the counter clock-wise side orientation
  22183. */
  22184. static readonly CounterClockWiseSideOrientation: number;
  22185. /**
  22186. * The dirty texture flag value
  22187. */
  22188. static readonly TextureDirtyFlag: number;
  22189. /**
  22190. * The dirty light flag value
  22191. */
  22192. static readonly LightDirtyFlag: number;
  22193. /**
  22194. * The dirty fresnel flag value
  22195. */
  22196. static readonly FresnelDirtyFlag: number;
  22197. /**
  22198. * The dirty attribute flag value
  22199. */
  22200. static readonly AttributesDirtyFlag: number;
  22201. /**
  22202. * The dirty misc flag value
  22203. */
  22204. static readonly MiscDirtyFlag: number;
  22205. /**
  22206. * The all dirty flag value
  22207. */
  22208. static readonly AllDirtyFlag: number;
  22209. /**
  22210. * The ID of the material
  22211. */
  22212. id: string;
  22213. /**
  22214. * Gets or sets the unique id of the material
  22215. */
  22216. uniqueId: number;
  22217. /**
  22218. * The name of the material
  22219. */
  22220. name: string;
  22221. /**
  22222. * Gets or sets user defined metadata
  22223. */
  22224. metadata: any;
  22225. /**
  22226. * For internal use only. Please do not use.
  22227. */
  22228. reservedDataStore: any;
  22229. /**
  22230. * Specifies if the ready state should be checked on each call
  22231. */
  22232. checkReadyOnEveryCall: boolean;
  22233. /**
  22234. * Specifies if the ready state should be checked once
  22235. */
  22236. checkReadyOnlyOnce: boolean;
  22237. /**
  22238. * The state of the material
  22239. */
  22240. state: string;
  22241. /**
  22242. * The alpha value of the material
  22243. */
  22244. protected _alpha: number;
  22245. /**
  22246. * List of inspectable custom properties (used by the Inspector)
  22247. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22248. */
  22249. inspectableCustomProperties: IInspectable[];
  22250. /**
  22251. * Sets the alpha value of the material
  22252. */
  22253. /**
  22254. * Gets the alpha value of the material
  22255. */
  22256. alpha: number;
  22257. /**
  22258. * Specifies if back face culling is enabled
  22259. */
  22260. protected _backFaceCulling: boolean;
  22261. /**
  22262. * Sets the back-face culling state
  22263. */
  22264. /**
  22265. * Gets the back-face culling state
  22266. */
  22267. backFaceCulling: boolean;
  22268. /**
  22269. * Stores the value for side orientation
  22270. */
  22271. sideOrientation: number;
  22272. /**
  22273. * Callback triggered when the material is compiled
  22274. */
  22275. onCompiled: Nullable<(effect: Effect) => void>;
  22276. /**
  22277. * Callback triggered when an error occurs
  22278. */
  22279. onError: Nullable<(effect: Effect, errors: string) => void>;
  22280. /**
  22281. * Callback triggered to get the render target textures
  22282. */
  22283. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  22284. /**
  22285. * Gets a boolean indicating that current material needs to register RTT
  22286. */
  22287. readonly hasRenderTargetTextures: boolean;
  22288. /**
  22289. * Specifies if the material should be serialized
  22290. */
  22291. doNotSerialize: boolean;
  22292. /**
  22293. * @hidden
  22294. */
  22295. _storeEffectOnSubMeshes: boolean;
  22296. /**
  22297. * Stores the animations for the material
  22298. */
  22299. animations: Nullable<Array<Animation>>;
  22300. /**
  22301. * An event triggered when the material is disposed
  22302. */
  22303. onDisposeObservable: Observable<Material>;
  22304. /**
  22305. * An observer which watches for dispose events
  22306. */
  22307. private _onDisposeObserver;
  22308. private _onUnBindObservable;
  22309. /**
  22310. * Called during a dispose event
  22311. */
  22312. onDispose: () => void;
  22313. private _onBindObservable;
  22314. /**
  22315. * An event triggered when the material is bound
  22316. */
  22317. readonly onBindObservable: Observable<AbstractMesh>;
  22318. /**
  22319. * An observer which watches for bind events
  22320. */
  22321. private _onBindObserver;
  22322. /**
  22323. * Called during a bind event
  22324. */
  22325. onBind: (Mesh: AbstractMesh) => void;
  22326. /**
  22327. * An event triggered when the material is unbound
  22328. */
  22329. readonly onUnBindObservable: Observable<Material>;
  22330. /**
  22331. * Stores the value of the alpha mode
  22332. */
  22333. private _alphaMode;
  22334. /**
  22335. * Sets the value of the alpha mode.
  22336. *
  22337. * | Value | Type | Description |
  22338. * | --- | --- | --- |
  22339. * | 0 | ALPHA_DISABLE | |
  22340. * | 1 | ALPHA_ADD | |
  22341. * | 2 | ALPHA_COMBINE | |
  22342. * | 3 | ALPHA_SUBTRACT | |
  22343. * | 4 | ALPHA_MULTIPLY | |
  22344. * | 5 | ALPHA_MAXIMIZED | |
  22345. * | 6 | ALPHA_ONEONE | |
  22346. * | 7 | ALPHA_PREMULTIPLIED | |
  22347. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22348. * | 9 | ALPHA_INTERPOLATE | |
  22349. * | 10 | ALPHA_SCREENMODE | |
  22350. *
  22351. */
  22352. /**
  22353. * Gets the value of the alpha mode
  22354. */
  22355. alphaMode: number;
  22356. /**
  22357. * Stores the state of the need depth pre-pass value
  22358. */
  22359. private _needDepthPrePass;
  22360. /**
  22361. * Sets the need depth pre-pass value
  22362. */
  22363. /**
  22364. * Gets the depth pre-pass value
  22365. */
  22366. needDepthPrePass: boolean;
  22367. /**
  22368. * Specifies if depth writing should be disabled
  22369. */
  22370. disableDepthWrite: boolean;
  22371. /**
  22372. * Specifies if depth writing should be forced
  22373. */
  22374. forceDepthWrite: boolean;
  22375. /**
  22376. * Specifies if there should be a separate pass for culling
  22377. */
  22378. separateCullingPass: boolean;
  22379. /**
  22380. * Stores the state specifing if fog should be enabled
  22381. */
  22382. private _fogEnabled;
  22383. /**
  22384. * Sets the state for enabling fog
  22385. */
  22386. /**
  22387. * Gets the value of the fog enabled state
  22388. */
  22389. fogEnabled: boolean;
  22390. /**
  22391. * Stores the size of points
  22392. */
  22393. pointSize: number;
  22394. /**
  22395. * Stores the z offset value
  22396. */
  22397. zOffset: number;
  22398. /**
  22399. * Gets a value specifying if wireframe mode is enabled
  22400. */
  22401. /**
  22402. * Sets the state of wireframe mode
  22403. */
  22404. wireframe: boolean;
  22405. /**
  22406. * Gets the value specifying if point clouds are enabled
  22407. */
  22408. /**
  22409. * Sets the state of point cloud mode
  22410. */
  22411. pointsCloud: boolean;
  22412. /**
  22413. * Gets the material fill mode
  22414. */
  22415. /**
  22416. * Sets the material fill mode
  22417. */
  22418. fillMode: number;
  22419. /**
  22420. * @hidden
  22421. * Stores the effects for the material
  22422. */
  22423. _effect: Nullable<Effect>;
  22424. /**
  22425. * @hidden
  22426. * Specifies if the material was previously ready
  22427. */
  22428. _wasPreviouslyReady: boolean;
  22429. /**
  22430. * Specifies if uniform buffers should be used
  22431. */
  22432. private _useUBO;
  22433. /**
  22434. * Stores a reference to the scene
  22435. */
  22436. private _scene;
  22437. /**
  22438. * Stores the fill mode state
  22439. */
  22440. private _fillMode;
  22441. /**
  22442. * Specifies if the depth write state should be cached
  22443. */
  22444. private _cachedDepthWriteState;
  22445. /**
  22446. * Stores the uniform buffer
  22447. */
  22448. protected _uniformBuffer: UniformBuffer;
  22449. /** @hidden */
  22450. _indexInSceneMaterialArray: number;
  22451. /** @hidden */
  22452. meshMap: Nullable<{
  22453. [id: string]: AbstractMesh | undefined;
  22454. }>;
  22455. /**
  22456. * Creates a material instance
  22457. * @param name defines the name of the material
  22458. * @param scene defines the scene to reference
  22459. * @param doNotAdd specifies if the material should be added to the scene
  22460. */
  22461. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22462. /**
  22463. * Returns a string representation of the current material
  22464. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22465. * @returns a string with material information
  22466. */
  22467. toString(fullDetails?: boolean): string;
  22468. /**
  22469. * Gets the class name of the material
  22470. * @returns a string with the class name of the material
  22471. */
  22472. getClassName(): string;
  22473. /**
  22474. * Specifies if updates for the material been locked
  22475. */
  22476. readonly isFrozen: boolean;
  22477. /**
  22478. * Locks updates for the material
  22479. */
  22480. freeze(): void;
  22481. /**
  22482. * Unlocks updates for the material
  22483. */
  22484. unfreeze(): void;
  22485. /**
  22486. * Specifies if the material is ready to be used
  22487. * @param mesh defines the mesh to check
  22488. * @param useInstances specifies if instances should be used
  22489. * @returns a boolean indicating if the material is ready to be used
  22490. */
  22491. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22492. /**
  22493. * Specifies that the submesh is ready to be used
  22494. * @param mesh defines the mesh to check
  22495. * @param subMesh defines which submesh to check
  22496. * @param useInstances specifies that instances should be used
  22497. * @returns a boolean indicating that the submesh is ready or not
  22498. */
  22499. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22500. /**
  22501. * Returns the material effect
  22502. * @returns the effect associated with the material
  22503. */
  22504. getEffect(): Nullable<Effect>;
  22505. /**
  22506. * Returns the current scene
  22507. * @returns a Scene
  22508. */
  22509. getScene(): Scene;
  22510. /**
  22511. * Specifies if the material will require alpha blending
  22512. * @returns a boolean specifying if alpha blending is needed
  22513. */
  22514. needAlphaBlending(): boolean;
  22515. /**
  22516. * Specifies if the mesh will require alpha blending
  22517. * @param mesh defines the mesh to check
  22518. * @returns a boolean specifying if alpha blending is needed for the mesh
  22519. */
  22520. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22521. /**
  22522. * Specifies if this material should be rendered in alpha test mode
  22523. * @returns a boolean specifying if an alpha test is needed.
  22524. */
  22525. needAlphaTesting(): boolean;
  22526. /**
  22527. * Gets the texture used for the alpha test
  22528. * @returns the texture to use for alpha testing
  22529. */
  22530. getAlphaTestTexture(): Nullable<BaseTexture>;
  22531. /**
  22532. * Marks the material to indicate that it needs to be re-calculated
  22533. */
  22534. markDirty(): void;
  22535. /** @hidden */
  22536. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22537. /**
  22538. * Binds the material to the mesh
  22539. * @param world defines the world transformation matrix
  22540. * @param mesh defines the mesh to bind the material to
  22541. */
  22542. bind(world: Matrix, mesh?: Mesh): void;
  22543. /**
  22544. * Binds the submesh to the material
  22545. * @param world defines the world transformation matrix
  22546. * @param mesh defines the mesh containing the submesh
  22547. * @param subMesh defines the submesh to bind the material to
  22548. */
  22549. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22550. /**
  22551. * Binds the world matrix to the material
  22552. * @param world defines the world transformation matrix
  22553. */
  22554. bindOnlyWorldMatrix(world: Matrix): void;
  22555. /**
  22556. * Binds the scene's uniform buffer to the effect.
  22557. * @param effect defines the effect to bind to the scene uniform buffer
  22558. * @param sceneUbo defines the uniform buffer storing scene data
  22559. */
  22560. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22561. /**
  22562. * Binds the view matrix to the effect
  22563. * @param effect defines the effect to bind the view matrix to
  22564. */
  22565. bindView(effect: Effect): void;
  22566. /**
  22567. * Binds the view projection matrix to the effect
  22568. * @param effect defines the effect to bind the view projection matrix to
  22569. */
  22570. bindViewProjection(effect: Effect): void;
  22571. /**
  22572. * Specifies if material alpha testing should be turned on for the mesh
  22573. * @param mesh defines the mesh to check
  22574. */
  22575. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22576. /**
  22577. * Processes to execute after binding the material to a mesh
  22578. * @param mesh defines the rendered mesh
  22579. */
  22580. protected _afterBind(mesh?: Mesh): void;
  22581. /**
  22582. * Unbinds the material from the mesh
  22583. */
  22584. unbind(): void;
  22585. /**
  22586. * Gets the active textures from the material
  22587. * @returns an array of textures
  22588. */
  22589. getActiveTextures(): BaseTexture[];
  22590. /**
  22591. * Specifies if the material uses a texture
  22592. * @param texture defines the texture to check against the material
  22593. * @returns a boolean specifying if the material uses the texture
  22594. */
  22595. hasTexture(texture: BaseTexture): boolean;
  22596. /**
  22597. * Makes a duplicate of the material, and gives it a new name
  22598. * @param name defines the new name for the duplicated material
  22599. * @returns the cloned material
  22600. */
  22601. clone(name: string): Nullable<Material>;
  22602. /**
  22603. * Gets the meshes bound to the material
  22604. * @returns an array of meshes bound to the material
  22605. */
  22606. getBindedMeshes(): AbstractMesh[];
  22607. /**
  22608. * Force shader compilation
  22609. * @param mesh defines the mesh associated with this material
  22610. * @param onCompiled defines a function to execute once the material is compiled
  22611. * @param options defines the options to configure the compilation
  22612. */
  22613. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  22614. clipPlane: boolean;
  22615. }>): void;
  22616. /**
  22617. * Force shader compilation
  22618. * @param mesh defines the mesh that will use this material
  22619. * @param options defines additional options for compiling the shaders
  22620. * @returns a promise that resolves when the compilation completes
  22621. */
  22622. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  22623. clipPlane: boolean;
  22624. }>): Promise<void>;
  22625. private static readonly _AllDirtyCallBack;
  22626. private static readonly _ImageProcessingDirtyCallBack;
  22627. private static readonly _TextureDirtyCallBack;
  22628. private static readonly _FresnelDirtyCallBack;
  22629. private static readonly _MiscDirtyCallBack;
  22630. private static readonly _LightsDirtyCallBack;
  22631. private static readonly _AttributeDirtyCallBack;
  22632. private static _FresnelAndMiscDirtyCallBack;
  22633. private static _TextureAndMiscDirtyCallBack;
  22634. private static readonly _DirtyCallbackArray;
  22635. private static readonly _RunDirtyCallBacks;
  22636. /**
  22637. * Marks a define in the material to indicate that it needs to be re-computed
  22638. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22639. */
  22640. markAsDirty(flag: number): void;
  22641. /**
  22642. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22643. * @param func defines a function which checks material defines against the submeshes
  22644. */
  22645. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22646. /**
  22647. * Indicates that we need to re-calculated for all submeshes
  22648. */
  22649. protected _markAllSubMeshesAsAllDirty(): void;
  22650. /**
  22651. * Indicates that image processing needs to be re-calculated for all submeshes
  22652. */
  22653. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22654. /**
  22655. * Indicates that textures need to be re-calculated for all submeshes
  22656. */
  22657. protected _markAllSubMeshesAsTexturesDirty(): void;
  22658. /**
  22659. * Indicates that fresnel needs to be re-calculated for all submeshes
  22660. */
  22661. protected _markAllSubMeshesAsFresnelDirty(): void;
  22662. /**
  22663. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22664. */
  22665. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22666. /**
  22667. * Indicates that lights need to be re-calculated for all submeshes
  22668. */
  22669. protected _markAllSubMeshesAsLightsDirty(): void;
  22670. /**
  22671. * Indicates that attributes need to be re-calculated for all submeshes
  22672. */
  22673. protected _markAllSubMeshesAsAttributesDirty(): void;
  22674. /**
  22675. * Indicates that misc needs to be re-calculated for all submeshes
  22676. */
  22677. protected _markAllSubMeshesAsMiscDirty(): void;
  22678. /**
  22679. * Indicates that textures and misc need to be re-calculated for all submeshes
  22680. */
  22681. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22682. /**
  22683. * Disposes the material
  22684. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22685. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22686. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22687. */
  22688. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22689. /** @hidden */
  22690. private releaseVertexArrayObject;
  22691. /**
  22692. * Serializes this material
  22693. * @returns the serialized material object
  22694. */
  22695. serialize(): any;
  22696. /**
  22697. * Creates a material from parsed material data
  22698. * @param parsedMaterial defines parsed material data
  22699. * @param scene defines the hosting scene
  22700. * @param rootUrl defines the root URL to use to load textures
  22701. * @returns a new material
  22702. */
  22703. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  22704. }
  22705. }
  22706. declare module BABYLON {
  22707. /**
  22708. * Base class for submeshes
  22709. */
  22710. export class BaseSubMesh {
  22711. /** @hidden */
  22712. _materialDefines: Nullable<MaterialDefines>;
  22713. /** @hidden */
  22714. _materialEffect: Nullable<Effect>;
  22715. /**
  22716. * Gets associated effect
  22717. */
  22718. readonly effect: Nullable<Effect>;
  22719. /**
  22720. * Sets associated effect (effect used to render this submesh)
  22721. * @param effect defines the effect to associate with
  22722. * @param defines defines the set of defines used to compile this effect
  22723. */
  22724. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22725. }
  22726. /**
  22727. * Defines a subdivision inside a mesh
  22728. */
  22729. export class SubMesh extends BaseSubMesh implements ICullable {
  22730. /** the material index to use */
  22731. materialIndex: number;
  22732. /** vertex index start */
  22733. verticesStart: number;
  22734. /** vertices count */
  22735. verticesCount: number;
  22736. /** index start */
  22737. indexStart: number;
  22738. /** indices count */
  22739. indexCount: number;
  22740. /** @hidden */
  22741. _linesIndexCount: number;
  22742. private _mesh;
  22743. private _renderingMesh;
  22744. private _boundingInfo;
  22745. private _linesIndexBuffer;
  22746. /** @hidden */
  22747. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22748. /** @hidden */
  22749. _trianglePlanes: Plane[];
  22750. /** @hidden */
  22751. _lastColliderTransformMatrix: Nullable<Matrix>;
  22752. /** @hidden */
  22753. _renderId: number;
  22754. /** @hidden */
  22755. _alphaIndex: number;
  22756. /** @hidden */
  22757. _distanceToCamera: number;
  22758. /** @hidden */
  22759. _id: number;
  22760. private _currentMaterial;
  22761. /**
  22762. * Add a new submesh to a mesh
  22763. * @param materialIndex defines the material index to use
  22764. * @param verticesStart defines vertex index start
  22765. * @param verticesCount defines vertices count
  22766. * @param indexStart defines index start
  22767. * @param indexCount defines indices count
  22768. * @param mesh defines the parent mesh
  22769. * @param renderingMesh defines an optional rendering mesh
  22770. * @param createBoundingBox defines if bounding box should be created for this submesh
  22771. * @returns the new submesh
  22772. */
  22773. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22774. /**
  22775. * Creates a new submesh
  22776. * @param materialIndex defines the material index to use
  22777. * @param verticesStart defines vertex index start
  22778. * @param verticesCount defines vertices count
  22779. * @param indexStart defines index start
  22780. * @param indexCount defines indices count
  22781. * @param mesh defines the parent mesh
  22782. * @param renderingMesh defines an optional rendering mesh
  22783. * @param createBoundingBox defines if bounding box should be created for this submesh
  22784. */
  22785. constructor(
  22786. /** the material index to use */
  22787. materialIndex: number,
  22788. /** vertex index start */
  22789. verticesStart: number,
  22790. /** vertices count */
  22791. verticesCount: number,
  22792. /** index start */
  22793. indexStart: number,
  22794. /** indices count */
  22795. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22796. /**
  22797. * Returns true if this submesh covers the entire parent mesh
  22798. * @ignorenaming
  22799. */
  22800. readonly IsGlobal: boolean;
  22801. /**
  22802. * Returns the submesh BoudingInfo object
  22803. * @returns current bounding info (or mesh's one if the submesh is global)
  22804. */
  22805. getBoundingInfo(): BoundingInfo;
  22806. /**
  22807. * Sets the submesh BoundingInfo
  22808. * @param boundingInfo defines the new bounding info to use
  22809. * @returns the SubMesh
  22810. */
  22811. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22812. /**
  22813. * Returns the mesh of the current submesh
  22814. * @return the parent mesh
  22815. */
  22816. getMesh(): AbstractMesh;
  22817. /**
  22818. * Returns the rendering mesh of the submesh
  22819. * @returns the rendering mesh (could be different from parent mesh)
  22820. */
  22821. getRenderingMesh(): Mesh;
  22822. /**
  22823. * Returns the submesh material
  22824. * @returns null or the current material
  22825. */
  22826. getMaterial(): Nullable<Material>;
  22827. /**
  22828. * Sets a new updated BoundingInfo object to the submesh
  22829. * @param data defines an optional position array to use to determine the bounding info
  22830. * @returns the SubMesh
  22831. */
  22832. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22833. /** @hidden */
  22834. _checkCollision(collider: Collider): boolean;
  22835. /**
  22836. * Updates the submesh BoundingInfo
  22837. * @param world defines the world matrix to use to update the bounding info
  22838. * @returns the submesh
  22839. */
  22840. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22841. /**
  22842. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22843. * @param frustumPlanes defines the frustum planes
  22844. * @returns true if the submesh is intersecting with the frustum
  22845. */
  22846. isInFrustum(frustumPlanes: Plane[]): boolean;
  22847. /**
  22848. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22849. * @param frustumPlanes defines the frustum planes
  22850. * @returns true if the submesh is inside the frustum
  22851. */
  22852. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22853. /**
  22854. * Renders the submesh
  22855. * @param enableAlphaMode defines if alpha needs to be used
  22856. * @returns the submesh
  22857. */
  22858. render(enableAlphaMode: boolean): SubMesh;
  22859. /**
  22860. * @hidden
  22861. */
  22862. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22863. /**
  22864. * Checks if the submesh intersects with a ray
  22865. * @param ray defines the ray to test
  22866. * @returns true is the passed ray intersects the submesh bounding box
  22867. */
  22868. canIntersects(ray: Ray): boolean;
  22869. /**
  22870. * Intersects current submesh with a ray
  22871. * @param ray defines the ray to test
  22872. * @param positions defines mesh's positions array
  22873. * @param indices defines mesh's indices array
  22874. * @param fastCheck defines if only bounding info should be used
  22875. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22876. * @returns intersection info or null if no intersection
  22877. */
  22878. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22879. /** @hidden */
  22880. private _intersectLines;
  22881. /** @hidden */
  22882. private _intersectUnIndexedLines;
  22883. /** @hidden */
  22884. private _intersectTriangles;
  22885. /** @hidden */
  22886. private _intersectUnIndexedTriangles;
  22887. /** @hidden */
  22888. _rebuild(): void;
  22889. /**
  22890. * Creates a new submesh from the passed mesh
  22891. * @param newMesh defines the new hosting mesh
  22892. * @param newRenderingMesh defines an optional rendering mesh
  22893. * @returns the new submesh
  22894. */
  22895. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22896. /**
  22897. * Release associated resources
  22898. */
  22899. dispose(): void;
  22900. /**
  22901. * Gets the class name
  22902. * @returns the string "SubMesh".
  22903. */
  22904. getClassName(): string;
  22905. /**
  22906. * Creates a new submesh from indices data
  22907. * @param materialIndex the index of the main mesh material
  22908. * @param startIndex the index where to start the copy in the mesh indices array
  22909. * @param indexCount the number of indices to copy then from the startIndex
  22910. * @param mesh the main mesh to create the submesh from
  22911. * @param renderingMesh the optional rendering mesh
  22912. * @returns a new submesh
  22913. */
  22914. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22915. }
  22916. }
  22917. declare module BABYLON {
  22918. /**
  22919. * Class used to store geometry data (vertex buffers + index buffer)
  22920. */
  22921. export class Geometry implements IGetSetVerticesData {
  22922. /**
  22923. * Gets or sets the ID of the geometry
  22924. */
  22925. id: string;
  22926. /**
  22927. * Gets or sets the unique ID of the geometry
  22928. */
  22929. uniqueId: number;
  22930. /**
  22931. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22932. */
  22933. delayLoadState: number;
  22934. /**
  22935. * Gets the file containing the data to load when running in delay load state
  22936. */
  22937. delayLoadingFile: Nullable<string>;
  22938. /**
  22939. * Callback called when the geometry is updated
  22940. */
  22941. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22942. private _scene;
  22943. private _engine;
  22944. private _meshes;
  22945. private _totalVertices;
  22946. /** @hidden */
  22947. _indices: IndicesArray;
  22948. /** @hidden */
  22949. _vertexBuffers: {
  22950. [key: string]: VertexBuffer;
  22951. };
  22952. private _isDisposed;
  22953. private _extend;
  22954. private _boundingBias;
  22955. /** @hidden */
  22956. _delayInfo: Array<string>;
  22957. private _indexBuffer;
  22958. private _indexBufferIsUpdatable;
  22959. /** @hidden */
  22960. _boundingInfo: Nullable<BoundingInfo>;
  22961. /** @hidden */
  22962. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22963. /** @hidden */
  22964. _softwareSkinningFrameId: number;
  22965. private _vertexArrayObjects;
  22966. private _updatable;
  22967. /** @hidden */
  22968. _positions: Nullable<Vector3[]>;
  22969. /**
  22970. * 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
  22971. */
  22972. /**
  22973. * 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
  22974. */
  22975. boundingBias: Vector2;
  22976. /**
  22977. * Static function used to attach a new empty geometry to a mesh
  22978. * @param mesh defines the mesh to attach the geometry to
  22979. * @returns the new Geometry
  22980. */
  22981. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22982. /**
  22983. * Creates a new geometry
  22984. * @param id defines the unique ID
  22985. * @param scene defines the hosting scene
  22986. * @param vertexData defines the VertexData used to get geometry data
  22987. * @param updatable defines if geometry must be updatable (false by default)
  22988. * @param mesh defines the mesh that will be associated with the geometry
  22989. */
  22990. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22991. /**
  22992. * Gets the current extend of the geometry
  22993. */
  22994. readonly extend: {
  22995. minimum: Vector3;
  22996. maximum: Vector3;
  22997. };
  22998. /**
  22999. * Gets the hosting scene
  23000. * @returns the hosting Scene
  23001. */
  23002. getScene(): Scene;
  23003. /**
  23004. * Gets the hosting engine
  23005. * @returns the hosting Engine
  23006. */
  23007. getEngine(): Engine;
  23008. /**
  23009. * Defines if the geometry is ready to use
  23010. * @returns true if the geometry is ready to be used
  23011. */
  23012. isReady(): boolean;
  23013. /**
  23014. * Gets a value indicating that the geometry should not be serialized
  23015. */
  23016. readonly doNotSerialize: boolean;
  23017. /** @hidden */
  23018. _rebuild(): void;
  23019. /**
  23020. * Affects all geometry data in one call
  23021. * @param vertexData defines the geometry data
  23022. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  23023. */
  23024. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  23025. /**
  23026. * Set specific vertex data
  23027. * @param kind defines the data kind (Position, normal, etc...)
  23028. * @param data defines the vertex data to use
  23029. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23030. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23031. */
  23032. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  23033. /**
  23034. * Removes a specific vertex data
  23035. * @param kind defines the data kind (Position, normal, etc...)
  23036. */
  23037. removeVerticesData(kind: string): void;
  23038. /**
  23039. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  23040. * @param buffer defines the vertex buffer to use
  23041. * @param totalVertices defines the total number of vertices for position kind (could be null)
  23042. */
  23043. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  23044. /**
  23045. * Update a specific vertex buffer
  23046. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  23047. * It will do nothing if the buffer is not updatable
  23048. * @param kind defines the data kind (Position, normal, etc...)
  23049. * @param data defines the data to use
  23050. * @param offset defines the offset in the target buffer where to store the data
  23051. * @param useBytes set to true if the offset is in bytes
  23052. */
  23053. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  23054. /**
  23055. * Update a specific vertex buffer
  23056. * This function will create a new buffer if the current one is not updatable
  23057. * @param kind defines the data kind (Position, normal, etc...)
  23058. * @param data defines the data to use
  23059. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  23060. */
  23061. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  23062. private _updateBoundingInfo;
  23063. /** @hidden */
  23064. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  23065. /**
  23066. * Gets total number of vertices
  23067. * @returns the total number of vertices
  23068. */
  23069. getTotalVertices(): number;
  23070. /**
  23071. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23072. * @param kind defines the data kind (Position, normal, etc...)
  23073. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23074. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23075. * @returns a float array containing vertex data
  23076. */
  23077. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23078. /**
  23079. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  23080. * @param kind defines the data kind (Position, normal, etc...)
  23081. * @returns true if the vertex buffer with the specified kind is updatable
  23082. */
  23083. isVertexBufferUpdatable(kind: string): boolean;
  23084. /**
  23085. * Gets a specific vertex buffer
  23086. * @param kind defines the data kind (Position, normal, etc...)
  23087. * @returns a VertexBuffer
  23088. */
  23089. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23090. /**
  23091. * Returns all vertex buffers
  23092. * @return an object holding all vertex buffers indexed by kind
  23093. */
  23094. getVertexBuffers(): Nullable<{
  23095. [key: string]: VertexBuffer;
  23096. }>;
  23097. /**
  23098. * Gets a boolean indicating if specific vertex buffer is present
  23099. * @param kind defines the data kind (Position, normal, etc...)
  23100. * @returns true if data is present
  23101. */
  23102. isVerticesDataPresent(kind: string): boolean;
  23103. /**
  23104. * Gets a list of all attached data kinds (Position, normal, etc...)
  23105. * @returns a list of string containing all kinds
  23106. */
  23107. getVerticesDataKinds(): string[];
  23108. /**
  23109. * Update index buffer
  23110. * @param indices defines the indices to store in the index buffer
  23111. * @param offset defines the offset in the target buffer where to store the data
  23112. * @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)
  23113. */
  23114. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  23115. /**
  23116. * Creates a new index buffer
  23117. * @param indices defines the indices to store in the index buffer
  23118. * @param totalVertices defines the total number of vertices (could be null)
  23119. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23120. */
  23121. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  23122. /**
  23123. * Return the total number of indices
  23124. * @returns the total number of indices
  23125. */
  23126. getTotalIndices(): number;
  23127. /**
  23128. * Gets the index buffer array
  23129. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23130. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23131. * @returns the index buffer array
  23132. */
  23133. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23134. /**
  23135. * Gets the index buffer
  23136. * @return the index buffer
  23137. */
  23138. getIndexBuffer(): Nullable<DataBuffer>;
  23139. /** @hidden */
  23140. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  23141. /**
  23142. * Release the associated resources for a specific mesh
  23143. * @param mesh defines the source mesh
  23144. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  23145. */
  23146. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  23147. /**
  23148. * Apply current geometry to a given mesh
  23149. * @param mesh defines the mesh to apply geometry to
  23150. */
  23151. applyToMesh(mesh: Mesh): void;
  23152. private _updateExtend;
  23153. private _applyToMesh;
  23154. private notifyUpdate;
  23155. /**
  23156. * Load the geometry if it was flagged as delay loaded
  23157. * @param scene defines the hosting scene
  23158. * @param onLoaded defines a callback called when the geometry is loaded
  23159. */
  23160. load(scene: Scene, onLoaded?: () => void): void;
  23161. private _queueLoad;
  23162. /**
  23163. * Invert the geometry to move from a right handed system to a left handed one.
  23164. */
  23165. toLeftHanded(): void;
  23166. /** @hidden */
  23167. _resetPointsArrayCache(): void;
  23168. /** @hidden */
  23169. _generatePointsArray(): boolean;
  23170. /**
  23171. * Gets a value indicating if the geometry is disposed
  23172. * @returns true if the geometry was disposed
  23173. */
  23174. isDisposed(): boolean;
  23175. private _disposeVertexArrayObjects;
  23176. /**
  23177. * Free all associated resources
  23178. */
  23179. dispose(): void;
  23180. /**
  23181. * Clone the current geometry into a new geometry
  23182. * @param id defines the unique ID of the new geometry
  23183. * @returns a new geometry object
  23184. */
  23185. copy(id: string): Geometry;
  23186. /**
  23187. * Serialize the current geometry info (and not the vertices data) into a JSON object
  23188. * @return a JSON representation of the current geometry data (without the vertices data)
  23189. */
  23190. serialize(): any;
  23191. private toNumberArray;
  23192. /**
  23193. * Serialize all vertices data into a JSON oject
  23194. * @returns a JSON representation of the current geometry data
  23195. */
  23196. serializeVerticeData(): any;
  23197. /**
  23198. * Extracts a clone of a mesh geometry
  23199. * @param mesh defines the source mesh
  23200. * @param id defines the unique ID of the new geometry object
  23201. * @returns the new geometry object
  23202. */
  23203. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  23204. /**
  23205. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  23206. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23207. * Be aware Math.random() could cause collisions, but:
  23208. * "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"
  23209. * @returns a string containing a new GUID
  23210. */
  23211. static RandomId(): string;
  23212. /** @hidden */
  23213. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  23214. private static _CleanMatricesWeights;
  23215. /**
  23216. * Create a new geometry from persisted data (Using .babylon file format)
  23217. * @param parsedVertexData defines the persisted data
  23218. * @param scene defines the hosting scene
  23219. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23220. * @returns the new geometry object
  23221. */
  23222. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23223. }
  23224. }
  23225. declare module BABYLON {
  23226. /**
  23227. * Define an interface for all classes that will get and set the data on vertices
  23228. */
  23229. export interface IGetSetVerticesData {
  23230. /**
  23231. * Gets a boolean indicating if specific vertex data is present
  23232. * @param kind defines the vertex data kind to use
  23233. * @returns true is data kind is present
  23234. */
  23235. isVerticesDataPresent(kind: string): boolean;
  23236. /**
  23237. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23238. * @param kind defines the data kind (Position, normal, etc...)
  23239. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23240. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23241. * @returns a float array containing vertex data
  23242. */
  23243. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23244. /**
  23245. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23246. * @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.
  23247. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23248. * @returns the indices array or an empty array if the mesh has no geometry
  23249. */
  23250. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23251. /**
  23252. * Set specific vertex data
  23253. * @param kind defines the data kind (Position, normal, etc...)
  23254. * @param data defines the vertex data to use
  23255. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23256. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23257. */
  23258. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23259. /**
  23260. * Update a specific associated vertex buffer
  23261. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23262. * - VertexBuffer.PositionKind
  23263. * - VertexBuffer.UVKind
  23264. * - VertexBuffer.UV2Kind
  23265. * - VertexBuffer.UV3Kind
  23266. * - VertexBuffer.UV4Kind
  23267. * - VertexBuffer.UV5Kind
  23268. * - VertexBuffer.UV6Kind
  23269. * - VertexBuffer.ColorKind
  23270. * - VertexBuffer.MatricesIndicesKind
  23271. * - VertexBuffer.MatricesIndicesExtraKind
  23272. * - VertexBuffer.MatricesWeightsKind
  23273. * - VertexBuffer.MatricesWeightsExtraKind
  23274. * @param data defines the data source
  23275. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23276. * @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)
  23277. */
  23278. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23279. /**
  23280. * Creates a new index buffer
  23281. * @param indices defines the indices to store in the index buffer
  23282. * @param totalVertices defines the total number of vertices (could be null)
  23283. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23284. */
  23285. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23286. }
  23287. /**
  23288. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23289. */
  23290. export class VertexData {
  23291. /**
  23292. * Mesh side orientation : usually the external or front surface
  23293. */
  23294. static readonly FRONTSIDE: number;
  23295. /**
  23296. * Mesh side orientation : usually the internal or back surface
  23297. */
  23298. static readonly BACKSIDE: number;
  23299. /**
  23300. * Mesh side orientation : both internal and external or front and back surfaces
  23301. */
  23302. static readonly DOUBLESIDE: number;
  23303. /**
  23304. * Mesh side orientation : by default, `FRONTSIDE`
  23305. */
  23306. static readonly DEFAULTSIDE: number;
  23307. /**
  23308. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23309. */
  23310. positions: Nullable<FloatArray>;
  23311. /**
  23312. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23313. */
  23314. normals: Nullable<FloatArray>;
  23315. /**
  23316. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23317. */
  23318. tangents: Nullable<FloatArray>;
  23319. /**
  23320. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23321. */
  23322. uvs: Nullable<FloatArray>;
  23323. /**
  23324. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23325. */
  23326. uvs2: Nullable<FloatArray>;
  23327. /**
  23328. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23329. */
  23330. uvs3: Nullable<FloatArray>;
  23331. /**
  23332. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23333. */
  23334. uvs4: Nullable<FloatArray>;
  23335. /**
  23336. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23337. */
  23338. uvs5: Nullable<FloatArray>;
  23339. /**
  23340. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23341. */
  23342. uvs6: Nullable<FloatArray>;
  23343. /**
  23344. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23345. */
  23346. colors: Nullable<FloatArray>;
  23347. /**
  23348. * 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).
  23349. */
  23350. matricesIndices: Nullable<FloatArray>;
  23351. /**
  23352. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23353. */
  23354. matricesWeights: Nullable<FloatArray>;
  23355. /**
  23356. * An array extending the number of possible indices
  23357. */
  23358. matricesIndicesExtra: Nullable<FloatArray>;
  23359. /**
  23360. * An array extending the number of possible weights when the number of indices is extended
  23361. */
  23362. matricesWeightsExtra: Nullable<FloatArray>;
  23363. /**
  23364. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23365. */
  23366. indices: Nullable<IndicesArray>;
  23367. /**
  23368. * Uses the passed data array to set the set the values for the specified kind of data
  23369. * @param data a linear array of floating numbers
  23370. * @param kind the type of data that is being set, eg positions, colors etc
  23371. */
  23372. set(data: FloatArray, kind: string): void;
  23373. /**
  23374. * Associates the vertexData to the passed Mesh.
  23375. * Sets it as updatable or not (default `false`)
  23376. * @param mesh the mesh the vertexData is applied to
  23377. * @param updatable when used and having the value true allows new data to update the vertexData
  23378. * @returns the VertexData
  23379. */
  23380. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23381. /**
  23382. * Associates the vertexData to the passed Geometry.
  23383. * Sets it as updatable or not (default `false`)
  23384. * @param geometry the geometry the vertexData is applied to
  23385. * @param updatable when used and having the value true allows new data to update the vertexData
  23386. * @returns VertexData
  23387. */
  23388. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23389. /**
  23390. * Updates the associated mesh
  23391. * @param mesh the mesh to be updated
  23392. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23393. * @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
  23394. * @returns VertexData
  23395. */
  23396. updateMesh(mesh: Mesh): VertexData;
  23397. /**
  23398. * Updates the associated geometry
  23399. * @param geometry the geometry to be updated
  23400. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23401. * @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
  23402. * @returns VertexData.
  23403. */
  23404. updateGeometry(geometry: Geometry): VertexData;
  23405. private _applyTo;
  23406. private _update;
  23407. /**
  23408. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23409. * @param matrix the transforming matrix
  23410. * @returns the VertexData
  23411. */
  23412. transform(matrix: Matrix): VertexData;
  23413. /**
  23414. * Merges the passed VertexData into the current one
  23415. * @param other the VertexData to be merged into the current one
  23416. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23417. * @returns the modified VertexData
  23418. */
  23419. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23420. private _mergeElement;
  23421. private _validate;
  23422. /**
  23423. * Serializes the VertexData
  23424. * @returns a serialized object
  23425. */
  23426. serialize(): any;
  23427. /**
  23428. * Extracts the vertexData from a mesh
  23429. * @param mesh the mesh from which to extract the VertexData
  23430. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23431. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23432. * @returns the object VertexData associated to the passed mesh
  23433. */
  23434. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23435. /**
  23436. * Extracts the vertexData from the geometry
  23437. * @param geometry the geometry from which to extract the VertexData
  23438. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23439. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23440. * @returns the object VertexData associated to the passed mesh
  23441. */
  23442. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23443. private static _ExtractFrom;
  23444. /**
  23445. * Creates the VertexData for a Ribbon
  23446. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23447. * * pathArray array of paths, each of which an array of successive Vector3
  23448. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23449. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23450. * * 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
  23451. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23452. * * 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)
  23453. * * 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)
  23454. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23455. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23456. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23457. * @returns the VertexData of the ribbon
  23458. */
  23459. static CreateRibbon(options: {
  23460. pathArray: Vector3[][];
  23461. closeArray?: boolean;
  23462. closePath?: boolean;
  23463. offset?: number;
  23464. sideOrientation?: number;
  23465. frontUVs?: Vector4;
  23466. backUVs?: Vector4;
  23467. invertUV?: boolean;
  23468. uvs?: Vector2[];
  23469. colors?: Color4[];
  23470. }): VertexData;
  23471. /**
  23472. * Creates the VertexData for a box
  23473. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23474. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23475. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23476. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23477. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23478. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23479. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23480. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23481. * * 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)
  23482. * * 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)
  23483. * @returns the VertexData of the box
  23484. */
  23485. static CreateBox(options: {
  23486. size?: number;
  23487. width?: number;
  23488. height?: number;
  23489. depth?: number;
  23490. faceUV?: Vector4[];
  23491. faceColors?: Color4[];
  23492. sideOrientation?: number;
  23493. frontUVs?: Vector4;
  23494. backUVs?: Vector4;
  23495. }): VertexData;
  23496. /**
  23497. * Creates the VertexData for a tiled box
  23498. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23499. * * faceTiles sets the pattern, tile size and number of tiles for a face
  23500. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23501. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23502. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23503. * @returns the VertexData of the box
  23504. */
  23505. static CreateTiledBox(options: {
  23506. pattern?: number;
  23507. width?: number;
  23508. height?: number;
  23509. depth?: number;
  23510. tileSize?: number;
  23511. tileWidth?: number;
  23512. tileHeight?: number;
  23513. alignHorizontal?: number;
  23514. alignVertical?: number;
  23515. faceUV?: Vector4[];
  23516. faceColors?: Color4[];
  23517. sideOrientation?: number;
  23518. }): VertexData;
  23519. /**
  23520. * Creates the VertexData for a tiled plane
  23521. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23522. * * pattern a limited pattern arrangement depending on the number
  23523. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  23524. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  23525. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  23526. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23527. * * 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)
  23528. * * 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)
  23529. * @returns the VertexData of the tiled plane
  23530. */
  23531. static CreateTiledPlane(options: {
  23532. pattern?: number;
  23533. tileSize?: number;
  23534. tileWidth?: number;
  23535. tileHeight?: number;
  23536. size?: number;
  23537. width?: number;
  23538. height?: number;
  23539. alignHorizontal?: number;
  23540. alignVertical?: number;
  23541. sideOrientation?: number;
  23542. frontUVs?: Vector4;
  23543. backUVs?: Vector4;
  23544. }): VertexData;
  23545. /**
  23546. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23547. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23548. * * segments sets the number of horizontal strips optional, default 32
  23549. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23550. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23551. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23552. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23553. * * 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
  23554. * * 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
  23555. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23556. * * 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)
  23557. * * 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)
  23558. * @returns the VertexData of the ellipsoid
  23559. */
  23560. static CreateSphere(options: {
  23561. segments?: number;
  23562. diameter?: number;
  23563. diameterX?: number;
  23564. diameterY?: number;
  23565. diameterZ?: number;
  23566. arc?: number;
  23567. slice?: number;
  23568. sideOrientation?: number;
  23569. frontUVs?: Vector4;
  23570. backUVs?: Vector4;
  23571. }): VertexData;
  23572. /**
  23573. * Creates the VertexData for a cylinder, cone or prism
  23574. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23575. * * height sets the height (y direction) of the cylinder, optional, default 2
  23576. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23577. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23578. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23579. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23580. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23581. * * 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
  23582. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23583. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23584. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23585. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23586. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23587. * * 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)
  23588. * * 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)
  23589. * @returns the VertexData of the cylinder, cone or prism
  23590. */
  23591. static CreateCylinder(options: {
  23592. height?: number;
  23593. diameterTop?: number;
  23594. diameterBottom?: number;
  23595. diameter?: number;
  23596. tessellation?: number;
  23597. subdivisions?: number;
  23598. arc?: number;
  23599. faceColors?: Color4[];
  23600. faceUV?: Vector4[];
  23601. hasRings?: boolean;
  23602. enclose?: boolean;
  23603. sideOrientation?: number;
  23604. frontUVs?: Vector4;
  23605. backUVs?: Vector4;
  23606. }): VertexData;
  23607. /**
  23608. * Creates the VertexData for a torus
  23609. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23610. * * diameter the diameter of the torus, optional default 1
  23611. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23612. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23613. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23614. * * 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)
  23615. * * 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)
  23616. * @returns the VertexData of the torus
  23617. */
  23618. static CreateTorus(options: {
  23619. diameter?: number;
  23620. thickness?: number;
  23621. tessellation?: number;
  23622. sideOrientation?: number;
  23623. frontUVs?: Vector4;
  23624. backUVs?: Vector4;
  23625. }): VertexData;
  23626. /**
  23627. * Creates the VertexData of the LineSystem
  23628. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23629. * - lines an array of lines, each line being an array of successive Vector3
  23630. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23631. * @returns the VertexData of the LineSystem
  23632. */
  23633. static CreateLineSystem(options: {
  23634. lines: Vector3[][];
  23635. colors?: Nullable<Color4[][]>;
  23636. }): VertexData;
  23637. /**
  23638. * Create the VertexData for a DashedLines
  23639. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23640. * - points an array successive Vector3
  23641. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23642. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23643. * - dashNb the intended total number of dashes, optional, default 200
  23644. * @returns the VertexData for the DashedLines
  23645. */
  23646. static CreateDashedLines(options: {
  23647. points: Vector3[];
  23648. dashSize?: number;
  23649. gapSize?: number;
  23650. dashNb?: number;
  23651. }): VertexData;
  23652. /**
  23653. * Creates the VertexData for a Ground
  23654. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23655. * - width the width (x direction) of the ground, optional, default 1
  23656. * - height the height (z direction) of the ground, optional, default 1
  23657. * - subdivisions the number of subdivisions per side, optional, default 1
  23658. * @returns the VertexData of the Ground
  23659. */
  23660. static CreateGround(options: {
  23661. width?: number;
  23662. height?: number;
  23663. subdivisions?: number;
  23664. subdivisionsX?: number;
  23665. subdivisionsY?: number;
  23666. }): VertexData;
  23667. /**
  23668. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23669. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23670. * * xmin the ground minimum X coordinate, optional, default -1
  23671. * * zmin the ground minimum Z coordinate, optional, default -1
  23672. * * xmax the ground maximum X coordinate, optional, default 1
  23673. * * zmax the ground maximum Z coordinate, optional, default 1
  23674. * * 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}
  23675. * * 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}
  23676. * @returns the VertexData of the TiledGround
  23677. */
  23678. static CreateTiledGround(options: {
  23679. xmin: number;
  23680. zmin: number;
  23681. xmax: number;
  23682. zmax: number;
  23683. subdivisions?: {
  23684. w: number;
  23685. h: number;
  23686. };
  23687. precision?: {
  23688. w: number;
  23689. h: number;
  23690. };
  23691. }): VertexData;
  23692. /**
  23693. * Creates the VertexData of the Ground designed from a heightmap
  23694. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23695. * * width the width (x direction) of the ground
  23696. * * height the height (z direction) of the ground
  23697. * * subdivisions the number of subdivisions per side
  23698. * * minHeight the minimum altitude on the ground, optional, default 0
  23699. * * maxHeight the maximum altitude on the ground, optional default 1
  23700. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23701. * * buffer the array holding the image color data
  23702. * * bufferWidth the width of image
  23703. * * bufferHeight the height of image
  23704. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23705. * @returns the VertexData of the Ground designed from a heightmap
  23706. */
  23707. static CreateGroundFromHeightMap(options: {
  23708. width: number;
  23709. height: number;
  23710. subdivisions: number;
  23711. minHeight: number;
  23712. maxHeight: number;
  23713. colorFilter: Color3;
  23714. buffer: Uint8Array;
  23715. bufferWidth: number;
  23716. bufferHeight: number;
  23717. alphaFilter: number;
  23718. }): VertexData;
  23719. /**
  23720. * Creates the VertexData for a Plane
  23721. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23722. * * size sets the width and height of the plane to the value of size, optional default 1
  23723. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23724. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23725. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23726. * * 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)
  23727. * * 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)
  23728. * @returns the VertexData of the box
  23729. */
  23730. static CreatePlane(options: {
  23731. size?: number;
  23732. width?: number;
  23733. height?: number;
  23734. sideOrientation?: number;
  23735. frontUVs?: Vector4;
  23736. backUVs?: Vector4;
  23737. }): VertexData;
  23738. /**
  23739. * Creates the VertexData of the Disc or regular Polygon
  23740. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23741. * * radius the radius of the disc, optional default 0.5
  23742. * * tessellation the number of polygon sides, optional, default 64
  23743. * * 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
  23744. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23745. * * 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)
  23746. * * 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)
  23747. * @returns the VertexData of the box
  23748. */
  23749. static CreateDisc(options: {
  23750. radius?: number;
  23751. tessellation?: number;
  23752. arc?: number;
  23753. sideOrientation?: number;
  23754. frontUVs?: Vector4;
  23755. backUVs?: Vector4;
  23756. }): VertexData;
  23757. /**
  23758. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23759. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23760. * @param polygon a mesh built from polygonTriangulation.build()
  23761. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23762. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23763. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23764. * @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)
  23765. * @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)
  23766. * @returns the VertexData of the Polygon
  23767. */
  23768. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23769. /**
  23770. * Creates the VertexData of the IcoSphere
  23771. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23772. * * radius the radius of the IcoSphere, optional default 1
  23773. * * radiusX allows stretching in the x direction, optional, default radius
  23774. * * radiusY allows stretching in the y direction, optional, default radius
  23775. * * radiusZ allows stretching in the z direction, optional, default radius
  23776. * * flat when true creates a flat shaded mesh, optional, default true
  23777. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23778. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23779. * * 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)
  23780. * * 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)
  23781. * @returns the VertexData of the IcoSphere
  23782. */
  23783. static CreateIcoSphere(options: {
  23784. radius?: number;
  23785. radiusX?: number;
  23786. radiusY?: number;
  23787. radiusZ?: number;
  23788. flat?: boolean;
  23789. subdivisions?: number;
  23790. sideOrientation?: number;
  23791. frontUVs?: Vector4;
  23792. backUVs?: Vector4;
  23793. }): VertexData;
  23794. /**
  23795. * Creates the VertexData for a Polyhedron
  23796. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23797. * * type provided types are:
  23798. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23799. * * 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)
  23800. * * size the size of the IcoSphere, optional default 1
  23801. * * sizeX allows stretching in the x direction, optional, default size
  23802. * * sizeY allows stretching in the y direction, optional, default size
  23803. * * sizeZ allows stretching in the z direction, optional, default size
  23804. * * 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
  23805. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23806. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23807. * * flat when true creates a flat shaded mesh, optional, default true
  23808. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23809. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23810. * * 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)
  23811. * * 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)
  23812. * @returns the VertexData of the Polyhedron
  23813. */
  23814. static CreatePolyhedron(options: {
  23815. type?: number;
  23816. size?: number;
  23817. sizeX?: number;
  23818. sizeY?: number;
  23819. sizeZ?: number;
  23820. custom?: any;
  23821. faceUV?: Vector4[];
  23822. faceColors?: Color4[];
  23823. flat?: boolean;
  23824. sideOrientation?: number;
  23825. frontUVs?: Vector4;
  23826. backUVs?: Vector4;
  23827. }): VertexData;
  23828. /**
  23829. * Creates the VertexData for a TorusKnot
  23830. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23831. * * radius the radius of the torus knot, optional, default 2
  23832. * * tube the thickness of the tube, optional, default 0.5
  23833. * * radialSegments the number of sides on each tube segments, optional, default 32
  23834. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23835. * * p the number of windings around the z axis, optional, default 2
  23836. * * q the number of windings around the x axis, optional, default 3
  23837. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23838. * * 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)
  23839. * * 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)
  23840. * @returns the VertexData of the Torus Knot
  23841. */
  23842. static CreateTorusKnot(options: {
  23843. radius?: number;
  23844. tube?: number;
  23845. radialSegments?: number;
  23846. tubularSegments?: number;
  23847. p?: number;
  23848. q?: number;
  23849. sideOrientation?: number;
  23850. frontUVs?: Vector4;
  23851. backUVs?: Vector4;
  23852. }): VertexData;
  23853. /**
  23854. * Compute normals for given positions and indices
  23855. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23856. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23857. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23858. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23859. * * facetNormals : optional array of facet normals (vector3)
  23860. * * facetPositions : optional array of facet positions (vector3)
  23861. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23862. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23863. * * bInfo : optional bounding info, required for facetPartitioning computation
  23864. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23865. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23866. * * useRightHandedSystem: optional boolean to for right handed system computation
  23867. * * depthSort : optional boolean to enable the facet depth sort computation
  23868. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23869. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23870. */
  23871. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23872. facetNormals?: any;
  23873. facetPositions?: any;
  23874. facetPartitioning?: any;
  23875. ratio?: number;
  23876. bInfo?: any;
  23877. bbSize?: Vector3;
  23878. subDiv?: any;
  23879. useRightHandedSystem?: boolean;
  23880. depthSort?: boolean;
  23881. distanceTo?: Vector3;
  23882. depthSortedFacets?: any;
  23883. }): void;
  23884. /** @hidden */
  23885. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23886. /**
  23887. * Applies VertexData created from the imported parameters to the geometry
  23888. * @param parsedVertexData the parsed data from an imported file
  23889. * @param geometry the geometry to apply the VertexData to
  23890. */
  23891. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23892. }
  23893. }
  23894. declare module BABYLON {
  23895. /**
  23896. * Class containing static functions to help procedurally build meshes
  23897. */
  23898. export class DiscBuilder {
  23899. /**
  23900. * Creates a plane polygonal mesh. By default, this is a disc
  23901. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23902. * * 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
  23903. * * 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
  23904. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23905. * * 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
  23906. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23907. * @param name defines the name of the mesh
  23908. * @param options defines the options used to create the mesh
  23909. * @param scene defines the hosting scene
  23910. * @returns the plane polygonal mesh
  23911. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23912. */
  23913. static CreateDisc(name: string, options: {
  23914. radius?: number;
  23915. tessellation?: number;
  23916. arc?: number;
  23917. updatable?: boolean;
  23918. sideOrientation?: number;
  23919. frontUVs?: Vector4;
  23920. backUVs?: Vector4;
  23921. }, scene?: Nullable<Scene>): Mesh;
  23922. }
  23923. }
  23924. declare module BABYLON {
  23925. /**
  23926. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23927. *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.
  23928. * The SPS is also a particle system. It provides some methods to manage the particles.
  23929. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23930. *
  23931. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23932. */
  23933. export class SolidParticleSystem implements IDisposable {
  23934. /**
  23935. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23936. * Example : var p = SPS.particles[i];
  23937. */
  23938. particles: SolidParticle[];
  23939. /**
  23940. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23941. */
  23942. nbParticles: number;
  23943. /**
  23944. * If the particles must ever face the camera (default false). Useful for planar particles.
  23945. */
  23946. billboard: boolean;
  23947. /**
  23948. * Recompute normals when adding a shape
  23949. */
  23950. recomputeNormals: boolean;
  23951. /**
  23952. * This a counter ofr your own usage. It's not set by any SPS functions.
  23953. */
  23954. counter: number;
  23955. /**
  23956. * The SPS name. This name is also given to the underlying mesh.
  23957. */
  23958. name: string;
  23959. /**
  23960. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23961. */
  23962. mesh: Mesh;
  23963. /**
  23964. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23965. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23966. */
  23967. vars: any;
  23968. /**
  23969. * This array is populated when the SPS is set as 'pickable'.
  23970. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23971. * Each element of this array is an object `{idx: int, faceId: int}`.
  23972. * `idx` is the picked particle index in the `SPS.particles` array
  23973. * `faceId` is the picked face index counted within this particle.
  23974. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23975. */
  23976. pickedParticles: {
  23977. idx: number;
  23978. faceId: number;
  23979. }[];
  23980. /**
  23981. * This array is populated when `enableDepthSort` is set to true.
  23982. * Each element of this array is an instance of the class DepthSortedParticle.
  23983. */
  23984. depthSortedParticles: DepthSortedParticle[];
  23985. /**
  23986. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23987. * @hidden
  23988. */
  23989. _bSphereOnly: boolean;
  23990. /**
  23991. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23992. * @hidden
  23993. */
  23994. _bSphereRadiusFactor: number;
  23995. private _scene;
  23996. private _positions;
  23997. private _indices;
  23998. private _normals;
  23999. private _colors;
  24000. private _uvs;
  24001. private _indices32;
  24002. private _positions32;
  24003. private _normals32;
  24004. private _fixedNormal32;
  24005. private _colors32;
  24006. private _uvs32;
  24007. private _index;
  24008. private _updatable;
  24009. private _pickable;
  24010. private _isVisibilityBoxLocked;
  24011. private _alwaysVisible;
  24012. private _depthSort;
  24013. private _shapeCounter;
  24014. private _copy;
  24015. private _color;
  24016. private _computeParticleColor;
  24017. private _computeParticleTexture;
  24018. private _computeParticleRotation;
  24019. private _computeParticleVertex;
  24020. private _computeBoundingBox;
  24021. private _depthSortParticles;
  24022. private _camera;
  24023. private _mustUnrotateFixedNormals;
  24024. private _particlesIntersect;
  24025. private _needs32Bits;
  24026. /**
  24027. * Creates a SPS (Solid Particle System) object.
  24028. * @param name (String) is the SPS name, this will be the underlying mesh name.
  24029. * @param scene (Scene) is the scene in which the SPS is added.
  24030. * @param options defines the options of the sps e.g.
  24031. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  24032. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  24033. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  24034. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  24035. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  24036. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  24037. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  24038. */
  24039. constructor(name: string, scene: Scene, options?: {
  24040. updatable?: boolean;
  24041. isPickable?: boolean;
  24042. enableDepthSort?: boolean;
  24043. particleIntersection?: boolean;
  24044. boundingSphereOnly?: boolean;
  24045. bSphereRadiusFactor?: number;
  24046. });
  24047. /**
  24048. * Builds the SPS underlying mesh. Returns a standard Mesh.
  24049. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  24050. * @returns the created mesh
  24051. */
  24052. buildMesh(): Mesh;
  24053. /**
  24054. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  24055. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  24056. * Thus the particles generated from `digest()` have their property `position` set yet.
  24057. * @param mesh ( Mesh ) is the mesh to be digested
  24058. * @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
  24059. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  24060. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  24061. * @returns the current SPS
  24062. */
  24063. digest(mesh: Mesh, options?: {
  24064. facetNb?: number;
  24065. number?: number;
  24066. delta?: number;
  24067. }): SolidParticleSystem;
  24068. private _unrotateFixedNormals;
  24069. private _resetCopy;
  24070. private _meshBuilder;
  24071. private _posToShape;
  24072. private _uvsToShapeUV;
  24073. private _addParticle;
  24074. /**
  24075. * Adds some particles to the SPS from the model shape. Returns the shape id.
  24076. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  24077. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  24078. * @param nb (positive integer) the number of particles to be created from this model
  24079. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  24080. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  24081. * @returns the number of shapes in the system
  24082. */
  24083. addShape(mesh: Mesh, nb: number, options?: {
  24084. positionFunction?: any;
  24085. vertexFunction?: any;
  24086. }): number;
  24087. private _rebuildParticle;
  24088. /**
  24089. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  24090. * @returns the SPS.
  24091. */
  24092. rebuildMesh(): SolidParticleSystem;
  24093. /**
  24094. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  24095. * This method calls `updateParticle()` for each particle of the SPS.
  24096. * For an animated SPS, it is usually called within the render loop.
  24097. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  24098. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  24099. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  24100. * @returns the SPS.
  24101. */
  24102. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  24103. /**
  24104. * Disposes the SPS.
  24105. */
  24106. dispose(): void;
  24107. /**
  24108. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  24109. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24110. * @returns the SPS.
  24111. */
  24112. refreshVisibleSize(): SolidParticleSystem;
  24113. /**
  24114. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  24115. * @param size the size (float) of the visibility box
  24116. * note : this doesn't lock the SPS mesh bounding box.
  24117. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24118. */
  24119. setVisibilityBox(size: number): void;
  24120. /**
  24121. * Gets whether the SPS as always visible or not
  24122. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24123. */
  24124. /**
  24125. * Sets the SPS as always visible or not
  24126. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24127. */
  24128. isAlwaysVisible: boolean;
  24129. /**
  24130. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24131. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24132. */
  24133. /**
  24134. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24135. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24136. */
  24137. isVisibilityBoxLocked: boolean;
  24138. /**
  24139. * Tells to `setParticles()` to compute the particle rotations or not.
  24140. * Default value : true. The SPS is faster when it's set to false.
  24141. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24142. */
  24143. /**
  24144. * Gets if `setParticles()` computes the particle rotations or not.
  24145. * Default value : true. The SPS is faster when it's set to false.
  24146. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24147. */
  24148. computeParticleRotation: boolean;
  24149. /**
  24150. * Tells to `setParticles()` to compute the particle colors or not.
  24151. * Default value : true. The SPS is faster when it's set to false.
  24152. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24153. */
  24154. /**
  24155. * Gets if `setParticles()` computes the particle colors or not.
  24156. * Default value : true. The SPS is faster when it's set to false.
  24157. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24158. */
  24159. computeParticleColor: boolean;
  24160. /**
  24161. * Gets if `setParticles()` computes the particle textures or not.
  24162. * Default value : true. The SPS is faster when it's set to false.
  24163. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24164. */
  24165. computeParticleTexture: boolean;
  24166. /**
  24167. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24168. * Default value : false. The SPS is faster when it's set to false.
  24169. * Note : the particle custom vertex positions aren't stored values.
  24170. */
  24171. /**
  24172. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24173. * Default value : false. The SPS is faster when it's set to false.
  24174. * Note : the particle custom vertex positions aren't stored values.
  24175. */
  24176. computeParticleVertex: boolean;
  24177. /**
  24178. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24179. */
  24180. /**
  24181. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24182. */
  24183. computeBoundingBox: boolean;
  24184. /**
  24185. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24186. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24187. * Default : `true`
  24188. */
  24189. /**
  24190. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24191. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24192. * Default : `true`
  24193. */
  24194. depthSortParticles: boolean;
  24195. /**
  24196. * This function does nothing. It may be overwritten to set all the particle first values.
  24197. * The SPS doesn't call this function, you may have to call it by your own.
  24198. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24199. */
  24200. initParticles(): void;
  24201. /**
  24202. * This function does nothing. It may be overwritten to recycle a particle.
  24203. * The SPS doesn't call this function, you may have to call it by your own.
  24204. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24205. * @param particle The particle to recycle
  24206. * @returns the recycled particle
  24207. */
  24208. recycleParticle(particle: SolidParticle): SolidParticle;
  24209. /**
  24210. * Updates a particle : this function should be overwritten by the user.
  24211. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24212. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24213. * @example : just set a particle position or velocity and recycle conditions
  24214. * @param particle The particle to update
  24215. * @returns the updated particle
  24216. */
  24217. updateParticle(particle: SolidParticle): SolidParticle;
  24218. /**
  24219. * Updates a vertex of a particle : it can be overwritten by the user.
  24220. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24221. * @param particle the current particle
  24222. * @param vertex the current index of the current particle
  24223. * @param pt the index of the current vertex in the particle shape
  24224. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  24225. * @example : just set a vertex particle position
  24226. * @returns the updated vertex
  24227. */
  24228. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  24229. /**
  24230. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24231. * This does nothing and may be overwritten by the user.
  24232. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24233. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24234. * @param update the boolean update value actually passed to setParticles()
  24235. */
  24236. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24237. /**
  24238. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24239. * This will be passed three parameters.
  24240. * This does nothing and may be overwritten by the user.
  24241. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24242. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24243. * @param update the boolean update value actually passed to setParticles()
  24244. */
  24245. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24246. }
  24247. }
  24248. declare module BABYLON {
  24249. /**
  24250. * Represents one particle of a solid particle system.
  24251. */
  24252. export class SolidParticle {
  24253. /**
  24254. * particle global index
  24255. */
  24256. idx: number;
  24257. /**
  24258. * The color of the particle
  24259. */
  24260. color: Nullable<Color4>;
  24261. /**
  24262. * The world space position of the particle.
  24263. */
  24264. position: Vector3;
  24265. /**
  24266. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24267. */
  24268. rotation: Vector3;
  24269. /**
  24270. * The world space rotation quaternion of the particle.
  24271. */
  24272. rotationQuaternion: Nullable<Quaternion>;
  24273. /**
  24274. * The scaling of the particle.
  24275. */
  24276. scaling: Vector3;
  24277. /**
  24278. * The uvs of the particle.
  24279. */
  24280. uvs: Vector4;
  24281. /**
  24282. * The current speed of the particle.
  24283. */
  24284. velocity: Vector3;
  24285. /**
  24286. * The pivot point in the particle local space.
  24287. */
  24288. pivot: Vector3;
  24289. /**
  24290. * Must the particle be translated from its pivot point in its local space ?
  24291. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24292. * Default : false
  24293. */
  24294. translateFromPivot: boolean;
  24295. /**
  24296. * Is the particle active or not ?
  24297. */
  24298. alive: boolean;
  24299. /**
  24300. * Is the particle visible or not ?
  24301. */
  24302. isVisible: boolean;
  24303. /**
  24304. * Index of this particle in the global "positions" array (Internal use)
  24305. * @hidden
  24306. */
  24307. _pos: number;
  24308. /**
  24309. * @hidden Index of this particle in the global "indices" array (Internal use)
  24310. */
  24311. _ind: number;
  24312. /**
  24313. * @hidden ModelShape of this particle (Internal use)
  24314. */
  24315. _model: ModelShape;
  24316. /**
  24317. * ModelShape id of this particle
  24318. */
  24319. shapeId: number;
  24320. /**
  24321. * Index of the particle in its shape id (Internal use)
  24322. */
  24323. idxInShape: number;
  24324. /**
  24325. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24326. */
  24327. _modelBoundingInfo: BoundingInfo;
  24328. /**
  24329. * @hidden Particle BoundingInfo object (Internal use)
  24330. */
  24331. _boundingInfo: BoundingInfo;
  24332. /**
  24333. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24334. */
  24335. _sps: SolidParticleSystem;
  24336. /**
  24337. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24338. */
  24339. _stillInvisible: boolean;
  24340. /**
  24341. * @hidden Last computed particle rotation matrix
  24342. */
  24343. _rotationMatrix: number[];
  24344. /**
  24345. * Parent particle Id, if any.
  24346. * Default null.
  24347. */
  24348. parentId: Nullable<number>;
  24349. /**
  24350. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24351. * The possible values are :
  24352. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24353. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24354. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24355. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24356. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24357. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24358. * */
  24359. cullingStrategy: number;
  24360. /**
  24361. * @hidden Internal global position in the SPS.
  24362. */
  24363. _globalPosition: Vector3;
  24364. /**
  24365. * Creates a Solid Particle object.
  24366. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24367. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24368. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24369. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24370. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24371. * @param shapeId (integer) is the model shape identifier in the SPS.
  24372. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24373. * @param sps defines the sps it is associated to
  24374. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24375. */
  24376. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24377. /**
  24378. * Legacy support, changed scale to scaling
  24379. */
  24380. /**
  24381. * Legacy support, changed scale to scaling
  24382. */
  24383. scale: Vector3;
  24384. /**
  24385. * Legacy support, changed quaternion to rotationQuaternion
  24386. */
  24387. /**
  24388. * Legacy support, changed quaternion to rotationQuaternion
  24389. */
  24390. quaternion: Nullable<Quaternion>;
  24391. /**
  24392. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  24393. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  24394. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  24395. * @returns true if it intersects
  24396. */
  24397. intersectsMesh(target: Mesh | SolidParticle): boolean;
  24398. /**
  24399. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  24400. * A particle is in the frustum if its bounding box intersects the frustum
  24401. * @param frustumPlanes defines the frustum to test
  24402. * @returns true if the particle is in the frustum planes
  24403. */
  24404. isInFrustum(frustumPlanes: Plane[]): boolean;
  24405. /**
  24406. * get the rotation matrix of the particle
  24407. * @hidden
  24408. */
  24409. getRotationMatrix(m: Matrix): void;
  24410. }
  24411. /**
  24412. * Represents the shape of the model used by one particle of a solid particle system.
  24413. * SPS internal tool, don't use it manually.
  24414. */
  24415. export class ModelShape {
  24416. /**
  24417. * The shape id
  24418. * @hidden
  24419. */
  24420. shapeID: number;
  24421. /**
  24422. * flat array of model positions (internal use)
  24423. * @hidden
  24424. */
  24425. _shape: Vector3[];
  24426. /**
  24427. * flat array of model UVs (internal use)
  24428. * @hidden
  24429. */
  24430. _shapeUV: number[];
  24431. /**
  24432. * length of the shape in the model indices array (internal use)
  24433. * @hidden
  24434. */
  24435. _indicesLength: number;
  24436. /**
  24437. * Custom position function (internal use)
  24438. * @hidden
  24439. */
  24440. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  24441. /**
  24442. * Custom vertex function (internal use)
  24443. * @hidden
  24444. */
  24445. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  24446. /**
  24447. * 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.
  24448. * SPS internal tool, don't use it manually.
  24449. * @hidden
  24450. */
  24451. 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>);
  24452. }
  24453. /**
  24454. * Represents a Depth Sorted Particle in the solid particle system.
  24455. */
  24456. export class DepthSortedParticle {
  24457. /**
  24458. * Index of the particle in the "indices" array
  24459. */
  24460. ind: number;
  24461. /**
  24462. * Length of the particle shape in the "indices" array
  24463. */
  24464. indicesLength: number;
  24465. /**
  24466. * Squared distance from the particle to the camera
  24467. */
  24468. sqDistance: number;
  24469. }
  24470. }
  24471. declare module BABYLON {
  24472. /**
  24473. * @hidden
  24474. */
  24475. export class _MeshCollisionData {
  24476. _checkCollisions: boolean;
  24477. _collisionMask: number;
  24478. _collisionGroup: number;
  24479. _collider: Nullable<Collider>;
  24480. _oldPositionForCollisions: Vector3;
  24481. _diffPositionForCollisions: Vector3;
  24482. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  24483. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  24484. }
  24485. }
  24486. declare module BABYLON {
  24487. /** @hidden */
  24488. class _FacetDataStorage {
  24489. facetPositions: Vector3[];
  24490. facetNormals: Vector3[];
  24491. facetPartitioning: number[][];
  24492. facetNb: number;
  24493. partitioningSubdivisions: number;
  24494. partitioningBBoxRatio: number;
  24495. facetDataEnabled: boolean;
  24496. facetParameters: any;
  24497. bbSize: Vector3;
  24498. subDiv: {
  24499. max: number;
  24500. X: number;
  24501. Y: number;
  24502. Z: number;
  24503. };
  24504. facetDepthSort: boolean;
  24505. facetDepthSortEnabled: boolean;
  24506. depthSortedIndices: IndicesArray;
  24507. depthSortedFacets: {
  24508. ind: number;
  24509. sqDistance: number;
  24510. }[];
  24511. facetDepthSortFunction: (f1: {
  24512. ind: number;
  24513. sqDistance: number;
  24514. }, f2: {
  24515. ind: number;
  24516. sqDistance: number;
  24517. }) => number;
  24518. facetDepthSortFrom: Vector3;
  24519. facetDepthSortOrigin: Vector3;
  24520. invertedMatrix: Matrix;
  24521. }
  24522. /**
  24523. * @hidden
  24524. **/
  24525. class _InternalAbstractMeshDataInfo {
  24526. _hasVertexAlpha: boolean;
  24527. _useVertexColors: boolean;
  24528. _numBoneInfluencers: number;
  24529. _applyFog: boolean;
  24530. _receiveShadows: boolean;
  24531. _facetData: _FacetDataStorage;
  24532. _visibility: number;
  24533. _skeleton: Nullable<Skeleton>;
  24534. _layerMask: number;
  24535. _computeBonesUsingShaders: boolean;
  24536. _isActive: boolean;
  24537. _onlyForInstances: boolean;
  24538. _isActiveIntermediate: boolean;
  24539. _onlyForInstancesIntermediate: boolean;
  24540. }
  24541. /**
  24542. * Class used to store all common mesh properties
  24543. */
  24544. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24545. /** No occlusion */
  24546. static OCCLUSION_TYPE_NONE: number;
  24547. /** Occlusion set to optimisitic */
  24548. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24549. /** Occlusion set to strict */
  24550. static OCCLUSION_TYPE_STRICT: number;
  24551. /** Use an accurante occlusion algorithm */
  24552. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24553. /** Use a conservative occlusion algorithm */
  24554. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24555. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  24556. * Test order :
  24557. * Is the bounding sphere outside the frustum ?
  24558. * If not, are the bounding box vertices outside the frustum ?
  24559. * It not, then the cullable object is in the frustum.
  24560. */
  24561. static readonly CULLINGSTRATEGY_STANDARD: number;
  24562. /** Culling strategy : Bounding Sphere Only.
  24563. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  24564. * It's also less accurate than the standard because some not visible objects can still be selected.
  24565. * Test : is the bounding sphere outside the frustum ?
  24566. * If not, then the cullable object is in the frustum.
  24567. */
  24568. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24569. /** Culling strategy : Optimistic Inclusion.
  24570. * This in an inclusion test first, then the standard exclusion test.
  24571. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  24572. * 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.
  24573. * Anyway, it's as accurate as the standard strategy.
  24574. * Test :
  24575. * Is the cullable object bounding sphere center in the frustum ?
  24576. * If not, apply the default culling strategy.
  24577. */
  24578. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  24579. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  24580. * This in an inclusion test first, then the bounding sphere only exclusion test.
  24581. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  24582. * 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.
  24583. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  24584. * Test :
  24585. * Is the cullable object bounding sphere center in the frustum ?
  24586. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  24587. */
  24588. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  24589. /**
  24590. * No billboard
  24591. */
  24592. static readonly BILLBOARDMODE_NONE: number;
  24593. /** Billboard on X axis */
  24594. static readonly BILLBOARDMODE_X: number;
  24595. /** Billboard on Y axis */
  24596. static readonly BILLBOARDMODE_Y: number;
  24597. /** Billboard on Z axis */
  24598. static readonly BILLBOARDMODE_Z: number;
  24599. /** Billboard on all axes */
  24600. static readonly BILLBOARDMODE_ALL: number;
  24601. /** @hidden */
  24602. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  24603. /**
  24604. * The culling strategy to use to check whether the mesh must be rendered or not.
  24605. * This value can be changed at any time and will be used on the next render mesh selection.
  24606. * The possible values are :
  24607. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24608. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24609. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24610. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24611. * Please read each static variable documentation to get details about the culling process.
  24612. * */
  24613. cullingStrategy: number;
  24614. /**
  24615. * Gets the number of facets in the mesh
  24616. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24617. */
  24618. readonly facetNb: number;
  24619. /**
  24620. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24621. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24622. */
  24623. partitioningSubdivisions: number;
  24624. /**
  24625. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24626. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24627. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24628. */
  24629. partitioningBBoxRatio: number;
  24630. /**
  24631. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24632. * Works only for updatable meshes.
  24633. * Doesn't work with multi-materials
  24634. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24635. */
  24636. mustDepthSortFacets: boolean;
  24637. /**
  24638. * The location (Vector3) where the facet depth sort must be computed from.
  24639. * By default, the active camera position.
  24640. * Used only when facet depth sort is enabled
  24641. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24642. */
  24643. facetDepthSortFrom: Vector3;
  24644. /**
  24645. * gets a boolean indicating if facetData is enabled
  24646. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24647. */
  24648. readonly isFacetDataEnabled: boolean;
  24649. /** @hidden */
  24650. _updateNonUniformScalingState(value: boolean): boolean;
  24651. /**
  24652. * An event triggered when this mesh collides with another one
  24653. */
  24654. onCollideObservable: Observable<AbstractMesh>;
  24655. /** Set a function to call when this mesh collides with another one */
  24656. onCollide: () => void;
  24657. /**
  24658. * An event triggered when the collision's position changes
  24659. */
  24660. onCollisionPositionChangeObservable: Observable<Vector3>;
  24661. /** Set a function to call when the collision's position changes */
  24662. onCollisionPositionChange: () => void;
  24663. /**
  24664. * An event triggered when material is changed
  24665. */
  24666. onMaterialChangedObservable: Observable<AbstractMesh>;
  24667. /**
  24668. * Gets or sets the orientation for POV movement & rotation
  24669. */
  24670. definedFacingForward: boolean;
  24671. /** @hidden */
  24672. _occlusionQuery: Nullable<WebGLQuery>;
  24673. /** @hidden */
  24674. _renderingGroup: Nullable<RenderingGroup>;
  24675. /**
  24676. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24677. */
  24678. /**
  24679. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24680. */
  24681. visibility: number;
  24682. /** Gets or sets the alpha index used to sort transparent meshes
  24683. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24684. */
  24685. alphaIndex: number;
  24686. /**
  24687. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24688. */
  24689. isVisible: boolean;
  24690. /**
  24691. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24692. */
  24693. isPickable: boolean;
  24694. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24695. showSubMeshesBoundingBox: boolean;
  24696. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24697. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24698. */
  24699. isBlocker: boolean;
  24700. /**
  24701. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24702. */
  24703. enablePointerMoveEvents: boolean;
  24704. /**
  24705. * Specifies the rendering group id for this mesh (0 by default)
  24706. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24707. */
  24708. renderingGroupId: number;
  24709. private _material;
  24710. /** Gets or sets current material */
  24711. material: Nullable<Material>;
  24712. /**
  24713. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24714. * @see http://doc.babylonjs.com/babylon101/shadows
  24715. */
  24716. receiveShadows: boolean;
  24717. /** Defines color to use when rendering outline */
  24718. outlineColor: Color3;
  24719. /** Define width to use when rendering outline */
  24720. outlineWidth: number;
  24721. /** Defines color to use when rendering overlay */
  24722. overlayColor: Color3;
  24723. /** Defines alpha to use when rendering overlay */
  24724. overlayAlpha: number;
  24725. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24726. hasVertexAlpha: boolean;
  24727. /** 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) */
  24728. useVertexColors: boolean;
  24729. /**
  24730. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24731. */
  24732. computeBonesUsingShaders: boolean;
  24733. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24734. numBoneInfluencers: number;
  24735. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24736. applyFog: boolean;
  24737. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24738. useOctreeForRenderingSelection: boolean;
  24739. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24740. useOctreeForPicking: boolean;
  24741. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24742. useOctreeForCollisions: boolean;
  24743. /**
  24744. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24745. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24746. */
  24747. layerMask: number;
  24748. /**
  24749. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24750. */
  24751. alwaysSelectAsActiveMesh: boolean;
  24752. /**
  24753. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  24754. */
  24755. doNotSyncBoundingInfo: boolean;
  24756. /**
  24757. * Gets or sets the current action manager
  24758. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24759. */
  24760. actionManager: Nullable<AbstractActionManager>;
  24761. private _meshCollisionData;
  24762. /**
  24763. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24764. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24765. */
  24766. ellipsoid: Vector3;
  24767. /**
  24768. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24769. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24770. */
  24771. ellipsoidOffset: Vector3;
  24772. /**
  24773. * Gets or sets a collision mask used to mask collisions (default is -1).
  24774. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24775. */
  24776. collisionMask: number;
  24777. /**
  24778. * Gets or sets the current collision group mask (-1 by default).
  24779. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24780. */
  24781. collisionGroup: number;
  24782. /**
  24783. * Defines edge width used when edgesRenderer is enabled
  24784. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24785. */
  24786. edgesWidth: number;
  24787. /**
  24788. * Defines edge color used when edgesRenderer is enabled
  24789. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24790. */
  24791. edgesColor: Color4;
  24792. /** @hidden */
  24793. _edgesRenderer: Nullable<IEdgesRenderer>;
  24794. /** @hidden */
  24795. _masterMesh: Nullable<AbstractMesh>;
  24796. /** @hidden */
  24797. _boundingInfo: Nullable<BoundingInfo>;
  24798. /** @hidden */
  24799. _renderId: number;
  24800. /**
  24801. * Gets or sets the list of subMeshes
  24802. * @see http://doc.babylonjs.com/how_to/multi_materials
  24803. */
  24804. subMeshes: SubMesh[];
  24805. /** @hidden */
  24806. _intersectionsInProgress: AbstractMesh[];
  24807. /** @hidden */
  24808. _unIndexed: boolean;
  24809. /** @hidden */
  24810. _lightSources: Light[];
  24811. /** Gets the list of lights affecting that mesh */
  24812. readonly lightSources: Light[];
  24813. /** @hidden */
  24814. readonly _positions: Nullable<Vector3[]>;
  24815. /** @hidden */
  24816. _waitingData: {
  24817. lods: Nullable<any>;
  24818. actions: Nullable<any>;
  24819. freezeWorldMatrix: Nullable<boolean>;
  24820. };
  24821. /** @hidden */
  24822. _bonesTransformMatrices: Nullable<Float32Array>;
  24823. /** @hidden */
  24824. _transformMatrixTexture: Nullable<RawTexture>;
  24825. /**
  24826. * Gets or sets a skeleton to apply skining transformations
  24827. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24828. */
  24829. skeleton: Nullable<Skeleton>;
  24830. /**
  24831. * An event triggered when the mesh is rebuilt.
  24832. */
  24833. onRebuildObservable: Observable<AbstractMesh>;
  24834. /**
  24835. * Creates a new AbstractMesh
  24836. * @param name defines the name of the mesh
  24837. * @param scene defines the hosting scene
  24838. */
  24839. constructor(name: string, scene?: Nullable<Scene>);
  24840. /**
  24841. * Returns the string "AbstractMesh"
  24842. * @returns "AbstractMesh"
  24843. */
  24844. getClassName(): string;
  24845. /**
  24846. * Gets a string representation of the current mesh
  24847. * @param fullDetails defines a boolean indicating if full details must be included
  24848. * @returns a string representation of the current mesh
  24849. */
  24850. toString(fullDetails?: boolean): string;
  24851. /**
  24852. * @hidden
  24853. */
  24854. protected _getEffectiveParent(): Nullable<Node>;
  24855. /** @hidden */
  24856. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24857. /** @hidden */
  24858. _rebuild(): void;
  24859. /** @hidden */
  24860. _resyncLightSources(): void;
  24861. /** @hidden */
  24862. _resyncLighSource(light: Light): void;
  24863. /** @hidden */
  24864. _unBindEffect(): void;
  24865. /** @hidden */
  24866. _removeLightSource(light: Light): void;
  24867. private _markSubMeshesAsDirty;
  24868. /** @hidden */
  24869. _markSubMeshesAsLightDirty(): void;
  24870. /** @hidden */
  24871. _markSubMeshesAsAttributesDirty(): void;
  24872. /** @hidden */
  24873. _markSubMeshesAsMiscDirty(): void;
  24874. /**
  24875. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24876. */
  24877. scaling: Vector3;
  24878. /**
  24879. * Returns true if the mesh is blocked. Implemented by child classes
  24880. */
  24881. readonly isBlocked: boolean;
  24882. /**
  24883. * Returns the mesh itself by default. Implemented by child classes
  24884. * @param camera defines the camera to use to pick the right LOD level
  24885. * @returns the currentAbstractMesh
  24886. */
  24887. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24888. /**
  24889. * Returns 0 by default. Implemented by child classes
  24890. * @returns an integer
  24891. */
  24892. getTotalVertices(): number;
  24893. /**
  24894. * Returns a positive integer : the total number of indices in this mesh geometry.
  24895. * @returns the numner of indices or zero if the mesh has no geometry.
  24896. */
  24897. getTotalIndices(): number;
  24898. /**
  24899. * Returns null by default. Implemented by child classes
  24900. * @returns null
  24901. */
  24902. getIndices(): Nullable<IndicesArray>;
  24903. /**
  24904. * Returns the array of the requested vertex data kind. Implemented by child classes
  24905. * @param kind defines the vertex data kind to use
  24906. * @returns null
  24907. */
  24908. getVerticesData(kind: string): Nullable<FloatArray>;
  24909. /**
  24910. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24911. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24912. * Note that a new underlying VertexBuffer object is created each call.
  24913. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24914. * @param kind defines vertex data kind:
  24915. * * VertexBuffer.PositionKind
  24916. * * VertexBuffer.UVKind
  24917. * * VertexBuffer.UV2Kind
  24918. * * VertexBuffer.UV3Kind
  24919. * * VertexBuffer.UV4Kind
  24920. * * VertexBuffer.UV5Kind
  24921. * * VertexBuffer.UV6Kind
  24922. * * VertexBuffer.ColorKind
  24923. * * VertexBuffer.MatricesIndicesKind
  24924. * * VertexBuffer.MatricesIndicesExtraKind
  24925. * * VertexBuffer.MatricesWeightsKind
  24926. * * VertexBuffer.MatricesWeightsExtraKind
  24927. * @param data defines the data source
  24928. * @param updatable defines if the data must be flagged as updatable (or static)
  24929. * @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
  24930. * @returns the current mesh
  24931. */
  24932. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24933. /**
  24934. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24935. * If the mesh has no geometry, it is simply returned as it is.
  24936. * @param kind defines vertex data kind:
  24937. * * VertexBuffer.PositionKind
  24938. * * VertexBuffer.UVKind
  24939. * * VertexBuffer.UV2Kind
  24940. * * VertexBuffer.UV3Kind
  24941. * * VertexBuffer.UV4Kind
  24942. * * VertexBuffer.UV5Kind
  24943. * * VertexBuffer.UV6Kind
  24944. * * VertexBuffer.ColorKind
  24945. * * VertexBuffer.MatricesIndicesKind
  24946. * * VertexBuffer.MatricesIndicesExtraKind
  24947. * * VertexBuffer.MatricesWeightsKind
  24948. * * VertexBuffer.MatricesWeightsExtraKind
  24949. * @param data defines the data source
  24950. * @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
  24951. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24952. * @returns the current mesh
  24953. */
  24954. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24955. /**
  24956. * Sets the mesh indices,
  24957. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24958. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24959. * @param totalVertices Defines the total number of vertices
  24960. * @returns the current mesh
  24961. */
  24962. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24963. /**
  24964. * Gets a boolean indicating if specific vertex data is present
  24965. * @param kind defines the vertex data kind to use
  24966. * @returns true is data kind is present
  24967. */
  24968. isVerticesDataPresent(kind: string): boolean;
  24969. /**
  24970. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  24971. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  24972. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  24973. * @returns a BoundingInfo
  24974. */
  24975. getBoundingInfo(): BoundingInfo;
  24976. /**
  24977. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24978. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  24979. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  24980. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  24981. * @returns the current mesh
  24982. */
  24983. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  24984. /**
  24985. * Overwrite the current bounding info
  24986. * @param boundingInfo defines the new bounding info
  24987. * @returns the current mesh
  24988. */
  24989. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24990. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24991. readonly useBones: boolean;
  24992. /** @hidden */
  24993. _preActivate(): void;
  24994. /** @hidden */
  24995. _preActivateForIntermediateRendering(renderId: number): void;
  24996. /** @hidden */
  24997. _activate(renderId: number, intermediateRendering: boolean): boolean;
  24998. /** @hidden */
  24999. _postActivate(): void;
  25000. /** @hidden */
  25001. _freeze(): void;
  25002. /** @hidden */
  25003. _unFreeze(): void;
  25004. /**
  25005. * Gets the current world matrix
  25006. * @returns a Matrix
  25007. */
  25008. getWorldMatrix(): Matrix;
  25009. /** @hidden */
  25010. _getWorldMatrixDeterminant(): number;
  25011. /**
  25012. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  25013. */
  25014. readonly isAnInstance: boolean;
  25015. /**
  25016. * Perform relative position change from the point of view of behind the front of the mesh.
  25017. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25018. * Supports definition of mesh facing forward or backward
  25019. * @param amountRight defines the distance on the right axis
  25020. * @param amountUp defines the distance on the up axis
  25021. * @param amountForward defines the distance on the forward axis
  25022. * @returns the current mesh
  25023. */
  25024. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  25025. /**
  25026. * Calculate relative position change from the point of view of behind the front of the mesh.
  25027. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25028. * Supports definition of mesh facing forward or backward
  25029. * @param amountRight defines the distance on the right axis
  25030. * @param amountUp defines the distance on the up axis
  25031. * @param amountForward defines the distance on the forward axis
  25032. * @returns the new displacement vector
  25033. */
  25034. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  25035. /**
  25036. * Perform relative rotation change from the point of view of behind the front of the mesh.
  25037. * Supports definition of mesh facing forward or backward
  25038. * @param flipBack defines the flip
  25039. * @param twirlClockwise defines the twirl
  25040. * @param tiltRight defines the tilt
  25041. * @returns the current mesh
  25042. */
  25043. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  25044. /**
  25045. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  25046. * Supports definition of mesh facing forward or backward.
  25047. * @param flipBack defines the flip
  25048. * @param twirlClockwise defines the twirl
  25049. * @param tiltRight defines the tilt
  25050. * @returns the new rotation vector
  25051. */
  25052. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  25053. /**
  25054. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25055. * This means the mesh underlying bounding box and sphere are recomputed.
  25056. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25057. * @returns the current mesh
  25058. */
  25059. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  25060. /** @hidden */
  25061. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  25062. /** @hidden */
  25063. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  25064. /** @hidden */
  25065. _updateBoundingInfo(): AbstractMesh;
  25066. /** @hidden */
  25067. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  25068. /** @hidden */
  25069. protected _afterComputeWorldMatrix(): void;
  25070. /** @hidden */
  25071. readonly _effectiveMesh: AbstractMesh;
  25072. /**
  25073. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25074. * A mesh is in the frustum if its bounding box intersects the frustum
  25075. * @param frustumPlanes defines the frustum to test
  25076. * @returns true if the mesh is in the frustum planes
  25077. */
  25078. isInFrustum(frustumPlanes: Plane[]): boolean;
  25079. /**
  25080. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  25081. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  25082. * @param frustumPlanes defines the frustum to test
  25083. * @returns true if the mesh is completely in the frustum planes
  25084. */
  25085. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25086. /**
  25087. * True if the mesh intersects another mesh or a SolidParticle object
  25088. * @param mesh defines a target mesh or SolidParticle to test
  25089. * @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)
  25090. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  25091. * @returns true if there is an intersection
  25092. */
  25093. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  25094. /**
  25095. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  25096. * @param point defines the point to test
  25097. * @returns true if there is an intersection
  25098. */
  25099. intersectsPoint(point: Vector3): boolean;
  25100. /**
  25101. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  25102. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25103. */
  25104. checkCollisions: boolean;
  25105. /**
  25106. * Gets Collider object used to compute collisions (not physics)
  25107. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25108. */
  25109. readonly collider: Nullable<Collider>;
  25110. /**
  25111. * Move the mesh using collision engine
  25112. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25113. * @param displacement defines the requested displacement vector
  25114. * @returns the current mesh
  25115. */
  25116. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25117. private _onCollisionPositionChange;
  25118. /** @hidden */
  25119. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25120. /** @hidden */
  25121. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25122. /** @hidden */
  25123. _checkCollision(collider: Collider): AbstractMesh;
  25124. /** @hidden */
  25125. _generatePointsArray(): boolean;
  25126. /**
  25127. * Checks if the passed Ray intersects with the mesh
  25128. * @param ray defines the ray to use
  25129. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25130. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25131. * @returns the picking info
  25132. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25133. */
  25134. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  25135. /**
  25136. * Clones the current mesh
  25137. * @param name defines the mesh name
  25138. * @param newParent defines the new mesh parent
  25139. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25140. * @returns the new mesh
  25141. */
  25142. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25143. /**
  25144. * Disposes all the submeshes of the current meshnp
  25145. * @returns the current mesh
  25146. */
  25147. releaseSubMeshes(): AbstractMesh;
  25148. /**
  25149. * Releases resources associated with this abstract mesh.
  25150. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25151. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25152. */
  25153. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25154. /**
  25155. * Adds the passed mesh as a child to the current mesh
  25156. * @param mesh defines the child mesh
  25157. * @returns the current mesh
  25158. */
  25159. addChild(mesh: AbstractMesh): AbstractMesh;
  25160. /**
  25161. * Removes the passed mesh from the current mesh children list
  25162. * @param mesh defines the child mesh
  25163. * @returns the current mesh
  25164. */
  25165. removeChild(mesh: AbstractMesh): AbstractMesh;
  25166. /** @hidden */
  25167. private _initFacetData;
  25168. /**
  25169. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25170. * This method can be called within the render loop.
  25171. * 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
  25172. * @returns the current mesh
  25173. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25174. */
  25175. updateFacetData(): AbstractMesh;
  25176. /**
  25177. * Returns the facetLocalNormals array.
  25178. * The normals are expressed in the mesh local spac
  25179. * @returns an array of Vector3
  25180. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25181. */
  25182. getFacetLocalNormals(): Vector3[];
  25183. /**
  25184. * Returns the facetLocalPositions array.
  25185. * The facet positions are expressed in the mesh local space
  25186. * @returns an array of Vector3
  25187. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25188. */
  25189. getFacetLocalPositions(): Vector3[];
  25190. /**
  25191. * Returns the facetLocalPartioning array
  25192. * @returns an array of array of numbers
  25193. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25194. */
  25195. getFacetLocalPartitioning(): number[][];
  25196. /**
  25197. * Returns the i-th facet position in the world system.
  25198. * This method allocates a new Vector3 per call
  25199. * @param i defines the facet index
  25200. * @returns a new Vector3
  25201. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25202. */
  25203. getFacetPosition(i: number): Vector3;
  25204. /**
  25205. * Sets the reference Vector3 with the i-th facet position in the world system
  25206. * @param i defines the facet index
  25207. * @param ref defines the target vector
  25208. * @returns the current mesh
  25209. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25210. */
  25211. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25212. /**
  25213. * Returns the i-th facet normal in the world system.
  25214. * This method allocates a new Vector3 per call
  25215. * @param i defines the facet index
  25216. * @returns a new Vector3
  25217. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25218. */
  25219. getFacetNormal(i: number): Vector3;
  25220. /**
  25221. * Sets the reference Vector3 with the i-th facet normal in the world system
  25222. * @param i defines the facet index
  25223. * @param ref defines the target vector
  25224. * @returns the current mesh
  25225. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25226. */
  25227. getFacetNormalToRef(i: number, ref: Vector3): this;
  25228. /**
  25229. * 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)
  25230. * @param x defines x coordinate
  25231. * @param y defines y coordinate
  25232. * @param z defines z coordinate
  25233. * @returns the array of facet indexes
  25234. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25235. */
  25236. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25237. /**
  25238. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25239. * @param projected sets as the (x,y,z) world projection on the facet
  25240. * @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
  25241. * @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
  25242. * @param x defines x coordinate
  25243. * @param y defines y coordinate
  25244. * @param z defines z coordinate
  25245. * @returns the face index if found (or null instead)
  25246. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25247. */
  25248. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25249. /**
  25250. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25251. * @param projected sets as the (x,y,z) local projection on the facet
  25252. * @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
  25253. * @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
  25254. * @param x defines x coordinate
  25255. * @param y defines y coordinate
  25256. * @param z defines z coordinate
  25257. * @returns the face index if found (or null instead)
  25258. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25259. */
  25260. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25261. /**
  25262. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25263. * @returns the parameters
  25264. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25265. */
  25266. getFacetDataParameters(): any;
  25267. /**
  25268. * Disables the feature FacetData and frees the related memory
  25269. * @returns the current mesh
  25270. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25271. */
  25272. disableFacetData(): AbstractMesh;
  25273. /**
  25274. * Updates the AbstractMesh indices array
  25275. * @param indices defines the data source
  25276. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25277. * @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)
  25278. * @returns the current mesh
  25279. */
  25280. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25281. /**
  25282. * Creates new normals data for the mesh
  25283. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25284. * @returns the current mesh
  25285. */
  25286. createNormals(updatable: boolean): AbstractMesh;
  25287. /**
  25288. * Align the mesh with a normal
  25289. * @param normal defines the normal to use
  25290. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25291. * @returns the current mesh
  25292. */
  25293. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25294. /** @hidden */
  25295. _checkOcclusionQuery(): boolean;
  25296. /**
  25297. * Disables the mesh edge rendering mode
  25298. * @returns the currentAbstractMesh
  25299. */
  25300. disableEdgesRendering(): AbstractMesh;
  25301. /**
  25302. * Enables the edge rendering mode on the mesh.
  25303. * This mode makes the mesh edges visible
  25304. * @param epsilon defines the maximal distance between two angles to detect a face
  25305. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  25306. * @returns the currentAbstractMesh
  25307. * @see https://www.babylonjs-playground.com/#19O9TU#0
  25308. */
  25309. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  25310. }
  25311. }
  25312. declare module BABYLON {
  25313. /**
  25314. * Interface used to define ActionEvent
  25315. */
  25316. export interface IActionEvent {
  25317. /** The mesh or sprite that triggered the action */
  25318. source: any;
  25319. /** The X mouse cursor position at the time of the event */
  25320. pointerX: number;
  25321. /** The Y mouse cursor position at the time of the event */
  25322. pointerY: number;
  25323. /** The mesh that is currently pointed at (can be null) */
  25324. meshUnderPointer: Nullable<AbstractMesh>;
  25325. /** the original (browser) event that triggered the ActionEvent */
  25326. sourceEvent?: any;
  25327. /** additional data for the event */
  25328. additionalData?: any;
  25329. }
  25330. /**
  25331. * ActionEvent is the event being sent when an action is triggered.
  25332. */
  25333. export class ActionEvent implements IActionEvent {
  25334. /** The mesh or sprite that triggered the action */
  25335. source: any;
  25336. /** The X mouse cursor position at the time of the event */
  25337. pointerX: number;
  25338. /** The Y mouse cursor position at the time of the event */
  25339. pointerY: number;
  25340. /** The mesh that is currently pointed at (can be null) */
  25341. meshUnderPointer: Nullable<AbstractMesh>;
  25342. /** the original (browser) event that triggered the ActionEvent */
  25343. sourceEvent?: any;
  25344. /** additional data for the event */
  25345. additionalData?: any;
  25346. /**
  25347. * Creates a new ActionEvent
  25348. * @param source The mesh or sprite that triggered the action
  25349. * @param pointerX The X mouse cursor position at the time of the event
  25350. * @param pointerY The Y mouse cursor position at the time of the event
  25351. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  25352. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  25353. * @param additionalData additional data for the event
  25354. */
  25355. constructor(
  25356. /** The mesh or sprite that triggered the action */
  25357. source: any,
  25358. /** The X mouse cursor position at the time of the event */
  25359. pointerX: number,
  25360. /** The Y mouse cursor position at the time of the event */
  25361. pointerY: number,
  25362. /** The mesh that is currently pointed at (can be null) */
  25363. meshUnderPointer: Nullable<AbstractMesh>,
  25364. /** the original (browser) event that triggered the ActionEvent */
  25365. sourceEvent?: any,
  25366. /** additional data for the event */
  25367. additionalData?: any);
  25368. /**
  25369. * Helper function to auto-create an ActionEvent from a source mesh.
  25370. * @param source The source mesh that triggered the event
  25371. * @param evt The original (browser) event
  25372. * @param additionalData additional data for the event
  25373. * @returns the new ActionEvent
  25374. */
  25375. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  25376. /**
  25377. * Helper function to auto-create an ActionEvent from a source sprite
  25378. * @param source The source sprite that triggered the event
  25379. * @param scene Scene associated with the sprite
  25380. * @param evt The original (browser) event
  25381. * @param additionalData additional data for the event
  25382. * @returns the new ActionEvent
  25383. */
  25384. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  25385. /**
  25386. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  25387. * @param scene the scene where the event occurred
  25388. * @param evt The original (browser) event
  25389. * @returns the new ActionEvent
  25390. */
  25391. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  25392. /**
  25393. * Helper function to auto-create an ActionEvent from a primitive
  25394. * @param prim defines the target primitive
  25395. * @param pointerPos defines the pointer position
  25396. * @param evt The original (browser) event
  25397. * @param additionalData additional data for the event
  25398. * @returns the new ActionEvent
  25399. */
  25400. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  25401. }
  25402. }
  25403. declare module BABYLON {
  25404. /**
  25405. * Abstract class used to decouple action Manager from scene and meshes.
  25406. * Do not instantiate.
  25407. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25408. */
  25409. export abstract class AbstractActionManager implements IDisposable {
  25410. /** Gets the list of active triggers */
  25411. static Triggers: {
  25412. [key: string]: number;
  25413. };
  25414. /** Gets the cursor to use when hovering items */
  25415. hoverCursor: string;
  25416. /** Gets the list of actions */
  25417. actions: IAction[];
  25418. /**
  25419. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  25420. */
  25421. isRecursive: boolean;
  25422. /**
  25423. * Releases all associated resources
  25424. */
  25425. abstract dispose(): void;
  25426. /**
  25427. * Does this action manager has pointer triggers
  25428. */
  25429. abstract readonly hasPointerTriggers: boolean;
  25430. /**
  25431. * Does this action manager has pick triggers
  25432. */
  25433. abstract readonly hasPickTriggers: boolean;
  25434. /**
  25435. * Process a specific trigger
  25436. * @param trigger defines the trigger to process
  25437. * @param evt defines the event details to be processed
  25438. */
  25439. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  25440. /**
  25441. * Does this action manager handles actions of any of the given triggers
  25442. * @param triggers defines the triggers to be tested
  25443. * @return a boolean indicating whether one (or more) of the triggers is handled
  25444. */
  25445. abstract hasSpecificTriggers(triggers: number[]): boolean;
  25446. /**
  25447. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  25448. * speed.
  25449. * @param triggerA defines the trigger to be tested
  25450. * @param triggerB defines the trigger to be tested
  25451. * @return a boolean indicating whether one (or more) of the triggers is handled
  25452. */
  25453. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  25454. /**
  25455. * Does this action manager handles actions of a given trigger
  25456. * @param trigger defines the trigger to be tested
  25457. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  25458. * @return whether the trigger is handled
  25459. */
  25460. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  25461. /**
  25462. * Serialize this manager to a JSON object
  25463. * @param name defines the property name to store this manager
  25464. * @returns a JSON representation of this manager
  25465. */
  25466. abstract serialize(name: string): any;
  25467. /**
  25468. * Registers an action to this action manager
  25469. * @param action defines the action to be registered
  25470. * @return the action amended (prepared) after registration
  25471. */
  25472. abstract registerAction(action: IAction): Nullable<IAction>;
  25473. /**
  25474. * Unregisters an action to this action manager
  25475. * @param action defines the action to be unregistered
  25476. * @return a boolean indicating whether the action has been unregistered
  25477. */
  25478. abstract unregisterAction(action: IAction): Boolean;
  25479. /**
  25480. * Does exist one action manager with at least one trigger
  25481. **/
  25482. static readonly HasTriggers: boolean;
  25483. /**
  25484. * Does exist one action manager with at least one pick trigger
  25485. **/
  25486. static readonly HasPickTriggers: boolean;
  25487. /**
  25488. * Does exist one action manager that handles actions of a given trigger
  25489. * @param trigger defines the trigger to be tested
  25490. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  25491. **/
  25492. static HasSpecificTrigger(trigger: number): boolean;
  25493. }
  25494. }
  25495. declare module BABYLON {
  25496. /**
  25497. * Defines how a node can be built from a string name.
  25498. */
  25499. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  25500. /**
  25501. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  25502. */
  25503. export class Node implements IBehaviorAware<Node> {
  25504. /** @hidden */
  25505. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  25506. private static _NodeConstructors;
  25507. /**
  25508. * Add a new node constructor
  25509. * @param type defines the type name of the node to construct
  25510. * @param constructorFunc defines the constructor function
  25511. */
  25512. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  25513. /**
  25514. * Returns a node constructor based on type name
  25515. * @param type defines the type name
  25516. * @param name defines the new node name
  25517. * @param scene defines the hosting scene
  25518. * @param options defines optional options to transmit to constructors
  25519. * @returns the new constructor or null
  25520. */
  25521. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  25522. /**
  25523. * Gets or sets the name of the node
  25524. */
  25525. name: string;
  25526. /**
  25527. * Gets or sets the id of the node
  25528. */
  25529. id: string;
  25530. /**
  25531. * Gets or sets the unique id of the node
  25532. */
  25533. uniqueId: number;
  25534. /**
  25535. * Gets or sets a string used to store user defined state for the node
  25536. */
  25537. state: string;
  25538. /**
  25539. * Gets or sets an object used to store user defined information for the node
  25540. */
  25541. metadata: any;
  25542. /**
  25543. * For internal use only. Please do not use.
  25544. */
  25545. reservedDataStore: any;
  25546. /**
  25547. * List of inspectable custom properties (used by the Inspector)
  25548. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25549. */
  25550. inspectableCustomProperties: IInspectable[];
  25551. /**
  25552. * Gets or sets a boolean used to define if the node must be serialized
  25553. */
  25554. doNotSerialize: boolean;
  25555. /** @hidden */
  25556. _isDisposed: boolean;
  25557. /**
  25558. * Gets a list of Animations associated with the node
  25559. */
  25560. animations: Animation[];
  25561. protected _ranges: {
  25562. [name: string]: Nullable<AnimationRange>;
  25563. };
  25564. /**
  25565. * Callback raised when the node is ready to be used
  25566. */
  25567. onReady: Nullable<(node: Node) => void>;
  25568. private _isEnabled;
  25569. private _isParentEnabled;
  25570. private _isReady;
  25571. /** @hidden */
  25572. _currentRenderId: number;
  25573. private _parentUpdateId;
  25574. /** @hidden */
  25575. _childUpdateId: number;
  25576. /** @hidden */
  25577. _waitingParentId: Nullable<string>;
  25578. /** @hidden */
  25579. _scene: Scene;
  25580. /** @hidden */
  25581. _cache: any;
  25582. private _parentNode;
  25583. private _children;
  25584. /** @hidden */
  25585. _worldMatrix: Matrix;
  25586. /** @hidden */
  25587. _worldMatrixDeterminant: number;
  25588. /** @hidden */
  25589. _worldMatrixDeterminantIsDirty: boolean;
  25590. /** @hidden */
  25591. private _sceneRootNodesIndex;
  25592. /**
  25593. * Gets a boolean indicating if the node has been disposed
  25594. * @returns true if the node was disposed
  25595. */
  25596. isDisposed(): boolean;
  25597. /**
  25598. * Gets or sets the parent of the node (without keeping the current position in the scene)
  25599. * @see https://doc.babylonjs.com/how_to/parenting
  25600. */
  25601. parent: Nullable<Node>;
  25602. private addToSceneRootNodes;
  25603. private removeFromSceneRootNodes;
  25604. private _animationPropertiesOverride;
  25605. /**
  25606. * Gets or sets the animation properties override
  25607. */
  25608. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  25609. /**
  25610. * Gets a string idenfifying the name of the class
  25611. * @returns "Node" string
  25612. */
  25613. getClassName(): string;
  25614. /** @hidden */
  25615. readonly _isNode: boolean;
  25616. /**
  25617. * An event triggered when the mesh is disposed
  25618. */
  25619. onDisposeObservable: Observable<Node>;
  25620. private _onDisposeObserver;
  25621. /**
  25622. * Sets a callback that will be raised when the node will be disposed
  25623. */
  25624. onDispose: () => void;
  25625. /**
  25626. * Creates a new Node
  25627. * @param name the name and id to be given to this node
  25628. * @param scene the scene this node will be added to
  25629. * @param addToRootNodes the node will be added to scene.rootNodes
  25630. */
  25631. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  25632. /**
  25633. * Gets the scene of the node
  25634. * @returns a scene
  25635. */
  25636. getScene(): Scene;
  25637. /**
  25638. * Gets the engine of the node
  25639. * @returns a Engine
  25640. */
  25641. getEngine(): Engine;
  25642. private _behaviors;
  25643. /**
  25644. * Attach a behavior to the node
  25645. * @see http://doc.babylonjs.com/features/behaviour
  25646. * @param behavior defines the behavior to attach
  25647. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  25648. * @returns the current Node
  25649. */
  25650. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  25651. /**
  25652. * Remove an attached behavior
  25653. * @see http://doc.babylonjs.com/features/behaviour
  25654. * @param behavior defines the behavior to attach
  25655. * @returns the current Node
  25656. */
  25657. removeBehavior(behavior: Behavior<Node>): Node;
  25658. /**
  25659. * Gets the list of attached behaviors
  25660. * @see http://doc.babylonjs.com/features/behaviour
  25661. */
  25662. readonly behaviors: Behavior<Node>[];
  25663. /**
  25664. * Gets an attached behavior by name
  25665. * @param name defines the name of the behavior to look for
  25666. * @see http://doc.babylonjs.com/features/behaviour
  25667. * @returns null if behavior was not found else the requested behavior
  25668. */
  25669. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  25670. /**
  25671. * Returns the latest update of the World matrix
  25672. * @returns a Matrix
  25673. */
  25674. getWorldMatrix(): Matrix;
  25675. /** @hidden */
  25676. _getWorldMatrixDeterminant(): number;
  25677. /**
  25678. * Returns directly the latest state of the mesh World matrix.
  25679. * A Matrix is returned.
  25680. */
  25681. readonly worldMatrixFromCache: Matrix;
  25682. /** @hidden */
  25683. _initCache(): void;
  25684. /** @hidden */
  25685. updateCache(force?: boolean): void;
  25686. /** @hidden */
  25687. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25688. /** @hidden */
  25689. _updateCache(ignoreParentClass?: boolean): void;
  25690. /** @hidden */
  25691. _isSynchronized(): boolean;
  25692. /** @hidden */
  25693. _markSyncedWithParent(): void;
  25694. /** @hidden */
  25695. isSynchronizedWithParent(): boolean;
  25696. /** @hidden */
  25697. isSynchronized(): boolean;
  25698. /**
  25699. * Is this node ready to be used/rendered
  25700. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25701. * @return true if the node is ready
  25702. */
  25703. isReady(completeCheck?: boolean): boolean;
  25704. /**
  25705. * Is this node enabled?
  25706. * 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
  25707. * @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
  25708. * @return whether this node (and its parent) is enabled
  25709. */
  25710. isEnabled(checkAncestors?: boolean): boolean;
  25711. /** @hidden */
  25712. protected _syncParentEnabledState(): void;
  25713. /**
  25714. * Set the enabled state of this node
  25715. * @param value defines the new enabled state
  25716. */
  25717. setEnabled(value: boolean): void;
  25718. /**
  25719. * Is this node a descendant of the given node?
  25720. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  25721. * @param ancestor defines the parent node to inspect
  25722. * @returns a boolean indicating if this node is a descendant of the given node
  25723. */
  25724. isDescendantOf(ancestor: Node): boolean;
  25725. /** @hidden */
  25726. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  25727. /**
  25728. * Will return all nodes that have this node as ascendant
  25729. * @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
  25730. * @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
  25731. * @return all children nodes of all types
  25732. */
  25733. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  25734. /**
  25735. * Get all child-meshes of this node
  25736. * @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)
  25737. * @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
  25738. * @returns an array of AbstractMesh
  25739. */
  25740. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  25741. /**
  25742. * Get all direct children of this node
  25743. * @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
  25744. * @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)
  25745. * @returns an array of Node
  25746. */
  25747. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  25748. /** @hidden */
  25749. _setReady(state: boolean): void;
  25750. /**
  25751. * Get an animation by name
  25752. * @param name defines the name of the animation to look for
  25753. * @returns null if not found else the requested animation
  25754. */
  25755. getAnimationByName(name: string): Nullable<Animation>;
  25756. /**
  25757. * Creates an animation range for this node
  25758. * @param name defines the name of the range
  25759. * @param from defines the starting key
  25760. * @param to defines the end key
  25761. */
  25762. createAnimationRange(name: string, from: number, to: number): void;
  25763. /**
  25764. * Delete a specific animation range
  25765. * @param name defines the name of the range to delete
  25766. * @param deleteFrames defines if animation frames from the range must be deleted as well
  25767. */
  25768. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25769. /**
  25770. * Get an animation range by name
  25771. * @param name defines the name of the animation range to look for
  25772. * @returns null if not found else the requested animation range
  25773. */
  25774. getAnimationRange(name: string): Nullable<AnimationRange>;
  25775. /**
  25776. * Gets the list of all animation ranges defined on this node
  25777. * @returns an array
  25778. */
  25779. getAnimationRanges(): Nullable<AnimationRange>[];
  25780. /**
  25781. * Will start the animation sequence
  25782. * @param name defines the range frames for animation sequence
  25783. * @param loop defines if the animation should loop (false by default)
  25784. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25785. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25786. * @returns the object created for this animation. If range does not exist, it will return null
  25787. */
  25788. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25789. /**
  25790. * Serialize animation ranges into a JSON compatible object
  25791. * @returns serialization object
  25792. */
  25793. serializeAnimationRanges(): any;
  25794. /**
  25795. * Computes the world matrix of the node
  25796. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25797. * @returns the world matrix
  25798. */
  25799. computeWorldMatrix(force?: boolean): Matrix;
  25800. /**
  25801. * Releases resources associated with this node.
  25802. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25803. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25804. */
  25805. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25806. /**
  25807. * Parse animation range data from a serialization object and store them into a given node
  25808. * @param node defines where to store the animation ranges
  25809. * @param parsedNode defines the serialization object to read data from
  25810. * @param scene defines the hosting scene
  25811. */
  25812. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25813. /**
  25814. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  25815. * @param includeDescendants Include bounding info from descendants as well (true by default)
  25816. * @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
  25817. * @returns the new bounding vectors
  25818. */
  25819. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  25820. min: Vector3;
  25821. max: Vector3;
  25822. };
  25823. }
  25824. }
  25825. declare module BABYLON {
  25826. /**
  25827. * @hidden
  25828. */
  25829. export class _IAnimationState {
  25830. key: number;
  25831. repeatCount: number;
  25832. workValue?: any;
  25833. loopMode?: number;
  25834. offsetValue?: any;
  25835. highLimitValue?: any;
  25836. }
  25837. /**
  25838. * Class used to store any kind of animation
  25839. */
  25840. export class Animation {
  25841. /**Name of the animation */
  25842. name: string;
  25843. /**Property to animate */
  25844. targetProperty: string;
  25845. /**The frames per second of the animation */
  25846. framePerSecond: number;
  25847. /**The data type of the animation */
  25848. dataType: number;
  25849. /**The loop mode of the animation */
  25850. loopMode?: number | undefined;
  25851. /**Specifies if blending should be enabled */
  25852. enableBlending?: boolean | undefined;
  25853. /**
  25854. * Use matrix interpolation instead of using direct key value when animating matrices
  25855. */
  25856. static AllowMatricesInterpolation: boolean;
  25857. /**
  25858. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25859. */
  25860. static AllowMatrixDecomposeForInterpolation: boolean;
  25861. /**
  25862. * Stores the key frames of the animation
  25863. */
  25864. private _keys;
  25865. /**
  25866. * Stores the easing function of the animation
  25867. */
  25868. private _easingFunction;
  25869. /**
  25870. * @hidden Internal use only
  25871. */
  25872. _runtimeAnimations: RuntimeAnimation[];
  25873. /**
  25874. * The set of event that will be linked to this animation
  25875. */
  25876. private _events;
  25877. /**
  25878. * Stores an array of target property paths
  25879. */
  25880. targetPropertyPath: string[];
  25881. /**
  25882. * Stores the blending speed of the animation
  25883. */
  25884. blendingSpeed: number;
  25885. /**
  25886. * Stores the animation ranges for the animation
  25887. */
  25888. private _ranges;
  25889. /**
  25890. * @hidden Internal use
  25891. */
  25892. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25893. /**
  25894. * Sets up an animation
  25895. * @param property The property to animate
  25896. * @param animationType The animation type to apply
  25897. * @param framePerSecond The frames per second of the animation
  25898. * @param easingFunction The easing function used in the animation
  25899. * @returns The created animation
  25900. */
  25901. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25902. /**
  25903. * Create and start an animation on a node
  25904. * @param name defines the name of the global animation that will be run on all nodes
  25905. * @param node defines the root node where the animation will take place
  25906. * @param targetProperty defines property to animate
  25907. * @param framePerSecond defines the number of frame per second yo use
  25908. * @param totalFrame defines the number of frames in total
  25909. * @param from defines the initial value
  25910. * @param to defines the final value
  25911. * @param loopMode defines which loop mode you want to use (off by default)
  25912. * @param easingFunction defines the easing function to use (linear by default)
  25913. * @param onAnimationEnd defines the callback to call when animation end
  25914. * @returns the animatable created for this animation
  25915. */
  25916. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25917. /**
  25918. * Create and start an animation on a node and its descendants
  25919. * @param name defines the name of the global animation that will be run on all nodes
  25920. * @param node defines the root node where the animation will take place
  25921. * @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
  25922. * @param targetProperty defines property to animate
  25923. * @param framePerSecond defines the number of frame per second to use
  25924. * @param totalFrame defines the number of frames in total
  25925. * @param from defines the initial value
  25926. * @param to defines the final value
  25927. * @param loopMode defines which loop mode you want to use (off by default)
  25928. * @param easingFunction defines the easing function to use (linear by default)
  25929. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25930. * @returns the list of animatables created for all nodes
  25931. * @example https://www.babylonjs-playground.com/#MH0VLI
  25932. */
  25933. 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[]>;
  25934. /**
  25935. * Creates a new animation, merges it with the existing animations and starts it
  25936. * @param name Name of the animation
  25937. * @param node Node which contains the scene that begins the animations
  25938. * @param targetProperty Specifies which property to animate
  25939. * @param framePerSecond The frames per second of the animation
  25940. * @param totalFrame The total number of frames
  25941. * @param from The frame at the beginning of the animation
  25942. * @param to The frame at the end of the animation
  25943. * @param loopMode Specifies the loop mode of the animation
  25944. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25945. * @param onAnimationEnd Callback to run once the animation is complete
  25946. * @returns Nullable animation
  25947. */
  25948. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25949. /**
  25950. * Transition property of an host to the target Value
  25951. * @param property The property to transition
  25952. * @param targetValue The target Value of the property
  25953. * @param host The object where the property to animate belongs
  25954. * @param scene Scene used to run the animation
  25955. * @param frameRate Framerate (in frame/s) to use
  25956. * @param transition The transition type we want to use
  25957. * @param duration The duration of the animation, in milliseconds
  25958. * @param onAnimationEnd Callback trigger at the end of the animation
  25959. * @returns Nullable animation
  25960. */
  25961. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25962. /**
  25963. * Return the array of runtime animations currently using this animation
  25964. */
  25965. readonly runtimeAnimations: RuntimeAnimation[];
  25966. /**
  25967. * Specifies if any of the runtime animations are currently running
  25968. */
  25969. readonly hasRunningRuntimeAnimations: boolean;
  25970. /**
  25971. * Initializes the animation
  25972. * @param name Name of the animation
  25973. * @param targetProperty Property to animate
  25974. * @param framePerSecond The frames per second of the animation
  25975. * @param dataType The data type of the animation
  25976. * @param loopMode The loop mode of the animation
  25977. * @param enableBlending Specifies if blending should be enabled
  25978. */
  25979. constructor(
  25980. /**Name of the animation */
  25981. name: string,
  25982. /**Property to animate */
  25983. targetProperty: string,
  25984. /**The frames per second of the animation */
  25985. framePerSecond: number,
  25986. /**The data type of the animation */
  25987. dataType: number,
  25988. /**The loop mode of the animation */
  25989. loopMode?: number | undefined,
  25990. /**Specifies if blending should be enabled */
  25991. enableBlending?: boolean | undefined);
  25992. /**
  25993. * Converts the animation to a string
  25994. * @param fullDetails support for multiple levels of logging within scene loading
  25995. * @returns String form of the animation
  25996. */
  25997. toString(fullDetails?: boolean): string;
  25998. /**
  25999. * Add an event to this animation
  26000. * @param event Event to add
  26001. */
  26002. addEvent(event: AnimationEvent): void;
  26003. /**
  26004. * Remove all events found at the given frame
  26005. * @param frame The frame to remove events from
  26006. */
  26007. removeEvents(frame: number): void;
  26008. /**
  26009. * Retrieves all the events from the animation
  26010. * @returns Events from the animation
  26011. */
  26012. getEvents(): AnimationEvent[];
  26013. /**
  26014. * Creates an animation range
  26015. * @param name Name of the animation range
  26016. * @param from Starting frame of the animation range
  26017. * @param to Ending frame of the animation
  26018. */
  26019. createRange(name: string, from: number, to: number): void;
  26020. /**
  26021. * Deletes an animation range by name
  26022. * @param name Name of the animation range to delete
  26023. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  26024. */
  26025. deleteRange(name: string, deleteFrames?: boolean): void;
  26026. /**
  26027. * Gets the animation range by name, or null if not defined
  26028. * @param name Name of the animation range
  26029. * @returns Nullable animation range
  26030. */
  26031. getRange(name: string): Nullable<AnimationRange>;
  26032. /**
  26033. * Gets the key frames from the animation
  26034. * @returns The key frames of the animation
  26035. */
  26036. getKeys(): Array<IAnimationKey>;
  26037. /**
  26038. * Gets the highest frame rate of the animation
  26039. * @returns Highest frame rate of the animation
  26040. */
  26041. getHighestFrame(): number;
  26042. /**
  26043. * Gets the easing function of the animation
  26044. * @returns Easing function of the animation
  26045. */
  26046. getEasingFunction(): IEasingFunction;
  26047. /**
  26048. * Sets the easing function of the animation
  26049. * @param easingFunction A custom mathematical formula for animation
  26050. */
  26051. setEasingFunction(easingFunction: EasingFunction): void;
  26052. /**
  26053. * Interpolates a scalar linearly
  26054. * @param startValue Start value of the animation curve
  26055. * @param endValue End value of the animation curve
  26056. * @param gradient Scalar amount to interpolate
  26057. * @returns Interpolated scalar value
  26058. */
  26059. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  26060. /**
  26061. * Interpolates a scalar cubically
  26062. * @param startValue Start value of the animation curve
  26063. * @param outTangent End tangent of the animation
  26064. * @param endValue End value of the animation curve
  26065. * @param inTangent Start tangent of the animation curve
  26066. * @param gradient Scalar amount to interpolate
  26067. * @returns Interpolated scalar value
  26068. */
  26069. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  26070. /**
  26071. * Interpolates a quaternion using a spherical linear interpolation
  26072. * @param startValue Start value of the animation curve
  26073. * @param endValue End value of the animation curve
  26074. * @param gradient Scalar amount to interpolate
  26075. * @returns Interpolated quaternion value
  26076. */
  26077. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  26078. /**
  26079. * Interpolates a quaternion cubically
  26080. * @param startValue Start value of the animation curve
  26081. * @param outTangent End tangent of the animation curve
  26082. * @param endValue End value of the animation curve
  26083. * @param inTangent Start tangent of the animation curve
  26084. * @param gradient Scalar amount to interpolate
  26085. * @returns Interpolated quaternion value
  26086. */
  26087. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  26088. /**
  26089. * Interpolates a Vector3 linearl
  26090. * @param startValue Start value of the animation curve
  26091. * @param endValue End value of the animation curve
  26092. * @param gradient Scalar amount to interpolate
  26093. * @returns Interpolated scalar value
  26094. */
  26095. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  26096. /**
  26097. * Interpolates a Vector3 cubically
  26098. * @param startValue Start value of the animation curve
  26099. * @param outTangent End tangent of the animation
  26100. * @param endValue End value of the animation curve
  26101. * @param inTangent Start tangent of the animation curve
  26102. * @param gradient Scalar amount to interpolate
  26103. * @returns InterpolatedVector3 value
  26104. */
  26105. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  26106. /**
  26107. * Interpolates a Vector2 linearly
  26108. * @param startValue Start value of the animation curve
  26109. * @param endValue End value of the animation curve
  26110. * @param gradient Scalar amount to interpolate
  26111. * @returns Interpolated Vector2 value
  26112. */
  26113. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  26114. /**
  26115. * Interpolates a Vector2 cubically
  26116. * @param startValue Start value of the animation curve
  26117. * @param outTangent End tangent of the animation
  26118. * @param endValue End value of the animation curve
  26119. * @param inTangent Start tangent of the animation curve
  26120. * @param gradient Scalar amount to interpolate
  26121. * @returns Interpolated Vector2 value
  26122. */
  26123. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  26124. /**
  26125. * Interpolates a size linearly
  26126. * @param startValue Start value of the animation curve
  26127. * @param endValue End value of the animation curve
  26128. * @param gradient Scalar amount to interpolate
  26129. * @returns Interpolated Size value
  26130. */
  26131. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  26132. /**
  26133. * Interpolates a Color3 linearly
  26134. * @param startValue Start value of the animation curve
  26135. * @param endValue End value of the animation curve
  26136. * @param gradient Scalar amount to interpolate
  26137. * @returns Interpolated Color3 value
  26138. */
  26139. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  26140. /**
  26141. * @hidden Internal use only
  26142. */
  26143. _getKeyValue(value: any): any;
  26144. /**
  26145. * @hidden Internal use only
  26146. */
  26147. _interpolate(currentFrame: number, state: _IAnimationState): any;
  26148. /**
  26149. * Defines the function to use to interpolate matrices
  26150. * @param startValue defines the start matrix
  26151. * @param endValue defines the end matrix
  26152. * @param gradient defines the gradient between both matrices
  26153. * @param result defines an optional target matrix where to store the interpolation
  26154. * @returns the interpolated matrix
  26155. */
  26156. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  26157. /**
  26158. * Makes a copy of the animation
  26159. * @returns Cloned animation
  26160. */
  26161. clone(): Animation;
  26162. /**
  26163. * Sets the key frames of the animation
  26164. * @param values The animation key frames to set
  26165. */
  26166. setKeys(values: Array<IAnimationKey>): void;
  26167. /**
  26168. * Serializes the animation to an object
  26169. * @returns Serialized object
  26170. */
  26171. serialize(): any;
  26172. /**
  26173. * Float animation type
  26174. */
  26175. private static _ANIMATIONTYPE_FLOAT;
  26176. /**
  26177. * Vector3 animation type
  26178. */
  26179. private static _ANIMATIONTYPE_VECTOR3;
  26180. /**
  26181. * Quaternion animation type
  26182. */
  26183. private static _ANIMATIONTYPE_QUATERNION;
  26184. /**
  26185. * Matrix animation type
  26186. */
  26187. private static _ANIMATIONTYPE_MATRIX;
  26188. /**
  26189. * Color3 animation type
  26190. */
  26191. private static _ANIMATIONTYPE_COLOR3;
  26192. /**
  26193. * Vector2 animation type
  26194. */
  26195. private static _ANIMATIONTYPE_VECTOR2;
  26196. /**
  26197. * Size animation type
  26198. */
  26199. private static _ANIMATIONTYPE_SIZE;
  26200. /**
  26201. * Relative Loop Mode
  26202. */
  26203. private static _ANIMATIONLOOPMODE_RELATIVE;
  26204. /**
  26205. * Cycle Loop Mode
  26206. */
  26207. private static _ANIMATIONLOOPMODE_CYCLE;
  26208. /**
  26209. * Constant Loop Mode
  26210. */
  26211. private static _ANIMATIONLOOPMODE_CONSTANT;
  26212. /**
  26213. * Get the float animation type
  26214. */
  26215. static readonly ANIMATIONTYPE_FLOAT: number;
  26216. /**
  26217. * Get the Vector3 animation type
  26218. */
  26219. static readonly ANIMATIONTYPE_VECTOR3: number;
  26220. /**
  26221. * Get the Vector2 animation type
  26222. */
  26223. static readonly ANIMATIONTYPE_VECTOR2: number;
  26224. /**
  26225. * Get the Size animation type
  26226. */
  26227. static readonly ANIMATIONTYPE_SIZE: number;
  26228. /**
  26229. * Get the Quaternion animation type
  26230. */
  26231. static readonly ANIMATIONTYPE_QUATERNION: number;
  26232. /**
  26233. * Get the Matrix animation type
  26234. */
  26235. static readonly ANIMATIONTYPE_MATRIX: number;
  26236. /**
  26237. * Get the Color3 animation type
  26238. */
  26239. static readonly ANIMATIONTYPE_COLOR3: number;
  26240. /**
  26241. * Get the Relative Loop Mode
  26242. */
  26243. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  26244. /**
  26245. * Get the Cycle Loop Mode
  26246. */
  26247. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  26248. /**
  26249. * Get the Constant Loop Mode
  26250. */
  26251. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  26252. /** @hidden */
  26253. static _UniversalLerp(left: any, right: any, amount: number): any;
  26254. /**
  26255. * Parses an animation object and creates an animation
  26256. * @param parsedAnimation Parsed animation object
  26257. * @returns Animation object
  26258. */
  26259. static Parse(parsedAnimation: any): Animation;
  26260. /**
  26261. * Appends the serialized animations from the source animations
  26262. * @param source Source containing the animations
  26263. * @param destination Target to store the animations
  26264. */
  26265. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26266. }
  26267. }
  26268. declare module BABYLON {
  26269. /**
  26270. * Base class of all the textures in babylon.
  26271. * It groups all the common properties the materials, post process, lights... might need
  26272. * in order to make a correct use of the texture.
  26273. */
  26274. export class BaseTexture implements IAnimatable {
  26275. /**
  26276. * Default anisotropic filtering level for the application.
  26277. * It is set to 4 as a good tradeoff between perf and quality.
  26278. */
  26279. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  26280. /**
  26281. * Gets or sets the unique id of the texture
  26282. */
  26283. uniqueId: number;
  26284. /**
  26285. * Define the name of the texture.
  26286. */
  26287. name: string;
  26288. /**
  26289. * Gets or sets an object used to store user defined information.
  26290. */
  26291. metadata: any;
  26292. /**
  26293. * For internal use only. Please do not use.
  26294. */
  26295. reservedDataStore: any;
  26296. private _hasAlpha;
  26297. /**
  26298. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  26299. */
  26300. hasAlpha: boolean;
  26301. /**
  26302. * Defines if the alpha value should be determined via the rgb values.
  26303. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  26304. */
  26305. getAlphaFromRGB: boolean;
  26306. /**
  26307. * Intensity or strength of the texture.
  26308. * It is commonly used by materials to fine tune the intensity of the texture
  26309. */
  26310. level: number;
  26311. /**
  26312. * Define the UV chanel to use starting from 0 and defaulting to 0.
  26313. * This is part of the texture as textures usually maps to one uv set.
  26314. */
  26315. coordinatesIndex: number;
  26316. private _coordinatesMode;
  26317. /**
  26318. * How a texture is mapped.
  26319. *
  26320. * | Value | Type | Description |
  26321. * | ----- | ----------------------------------- | ----------- |
  26322. * | 0 | EXPLICIT_MODE | |
  26323. * | 1 | SPHERICAL_MODE | |
  26324. * | 2 | PLANAR_MODE | |
  26325. * | 3 | CUBIC_MODE | |
  26326. * | 4 | PROJECTION_MODE | |
  26327. * | 5 | SKYBOX_MODE | |
  26328. * | 6 | INVCUBIC_MODE | |
  26329. * | 7 | EQUIRECTANGULAR_MODE | |
  26330. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  26331. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  26332. */
  26333. coordinatesMode: number;
  26334. /**
  26335. * | Value | Type | Description |
  26336. * | ----- | ------------------ | ----------- |
  26337. * | 0 | CLAMP_ADDRESSMODE | |
  26338. * | 1 | WRAP_ADDRESSMODE | |
  26339. * | 2 | MIRROR_ADDRESSMODE | |
  26340. */
  26341. wrapU: number;
  26342. /**
  26343. * | Value | Type | Description |
  26344. * | ----- | ------------------ | ----------- |
  26345. * | 0 | CLAMP_ADDRESSMODE | |
  26346. * | 1 | WRAP_ADDRESSMODE | |
  26347. * | 2 | MIRROR_ADDRESSMODE | |
  26348. */
  26349. wrapV: number;
  26350. /**
  26351. * | Value | Type | Description |
  26352. * | ----- | ------------------ | ----------- |
  26353. * | 0 | CLAMP_ADDRESSMODE | |
  26354. * | 1 | WRAP_ADDRESSMODE | |
  26355. * | 2 | MIRROR_ADDRESSMODE | |
  26356. */
  26357. wrapR: number;
  26358. /**
  26359. * With compliant hardware and browser (supporting anisotropic filtering)
  26360. * this defines the level of anisotropic filtering in the texture.
  26361. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  26362. */
  26363. anisotropicFilteringLevel: number;
  26364. /**
  26365. * Define if the texture is a cube texture or if false a 2d texture.
  26366. */
  26367. isCube: boolean;
  26368. /**
  26369. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  26370. */
  26371. is3D: boolean;
  26372. /**
  26373. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  26374. * HDR texture are usually stored in linear space.
  26375. * This only impacts the PBR and Background materials
  26376. */
  26377. gammaSpace: boolean;
  26378. /**
  26379. * Gets whether or not the texture contains RGBD data.
  26380. */
  26381. readonly isRGBD: boolean;
  26382. /**
  26383. * Is Z inverted in the texture (useful in a cube texture).
  26384. */
  26385. invertZ: boolean;
  26386. /**
  26387. * Are mip maps generated for this texture or not.
  26388. */
  26389. readonly noMipmap: boolean;
  26390. /**
  26391. * @hidden
  26392. */
  26393. lodLevelInAlpha: boolean;
  26394. /**
  26395. * With prefiltered texture, defined the offset used during the prefiltering steps.
  26396. */
  26397. lodGenerationOffset: number;
  26398. /**
  26399. * With prefiltered texture, defined the scale used during the prefiltering steps.
  26400. */
  26401. lodGenerationScale: number;
  26402. /**
  26403. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  26404. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  26405. * average roughness values.
  26406. */
  26407. linearSpecularLOD: boolean;
  26408. /**
  26409. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  26410. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  26411. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  26412. */
  26413. irradianceTexture: Nullable<BaseTexture>;
  26414. /**
  26415. * Define if the texture is a render target.
  26416. */
  26417. isRenderTarget: boolean;
  26418. /**
  26419. * Define the unique id of the texture in the scene.
  26420. */
  26421. readonly uid: string;
  26422. /**
  26423. * Return a string representation of the texture.
  26424. * @returns the texture as a string
  26425. */
  26426. toString(): string;
  26427. /**
  26428. * Get the class name of the texture.
  26429. * @returns "BaseTexture"
  26430. */
  26431. getClassName(): string;
  26432. /**
  26433. * Define the list of animation attached to the texture.
  26434. */
  26435. animations: Animation[];
  26436. /**
  26437. * An event triggered when the texture is disposed.
  26438. */
  26439. onDisposeObservable: Observable<BaseTexture>;
  26440. private _onDisposeObserver;
  26441. /**
  26442. * Callback triggered when the texture has been disposed.
  26443. * Kept for back compatibility, you can use the onDisposeObservable instead.
  26444. */
  26445. onDispose: () => void;
  26446. /**
  26447. * Define the current state of the loading sequence when in delayed load mode.
  26448. */
  26449. delayLoadState: number;
  26450. private _scene;
  26451. /** @hidden */
  26452. _texture: Nullable<InternalTexture>;
  26453. private _uid;
  26454. /**
  26455. * Define if the texture is preventinga material to render or not.
  26456. * If not and the texture is not ready, the engine will use a default black texture instead.
  26457. */
  26458. readonly isBlocking: boolean;
  26459. /**
  26460. * Instantiates a new BaseTexture.
  26461. * Base class of all the textures in babylon.
  26462. * It groups all the common properties the materials, post process, lights... might need
  26463. * in order to make a correct use of the texture.
  26464. * @param scene Define the scene the texture blongs to
  26465. */
  26466. constructor(scene: Nullable<Scene>);
  26467. /**
  26468. * Get the scene the texture belongs to.
  26469. * @returns the scene or null if undefined
  26470. */
  26471. getScene(): Nullable<Scene>;
  26472. /**
  26473. * Get the texture transform matrix used to offset tile the texture for istance.
  26474. * @returns the transformation matrix
  26475. */
  26476. getTextureMatrix(): Matrix;
  26477. /**
  26478. * Get the texture reflection matrix used to rotate/transform the reflection.
  26479. * @returns the reflection matrix
  26480. */
  26481. getReflectionTextureMatrix(): Matrix;
  26482. /**
  26483. * Get the underlying lower level texture from Babylon.
  26484. * @returns the insternal texture
  26485. */
  26486. getInternalTexture(): Nullable<InternalTexture>;
  26487. /**
  26488. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  26489. * @returns true if ready or not blocking
  26490. */
  26491. isReadyOrNotBlocking(): boolean;
  26492. /**
  26493. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  26494. * @returns true if fully ready
  26495. */
  26496. isReady(): boolean;
  26497. private _cachedSize;
  26498. /**
  26499. * Get the size of the texture.
  26500. * @returns the texture size.
  26501. */
  26502. getSize(): ISize;
  26503. /**
  26504. * Get the base size of the texture.
  26505. * It can be different from the size if the texture has been resized for POT for instance
  26506. * @returns the base size
  26507. */
  26508. getBaseSize(): ISize;
  26509. /**
  26510. * Update the sampling mode of the texture.
  26511. * Default is Trilinear mode.
  26512. *
  26513. * | Value | Type | Description |
  26514. * | ----- | ------------------ | ----------- |
  26515. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  26516. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  26517. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  26518. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  26519. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  26520. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  26521. * | 7 | NEAREST_LINEAR | |
  26522. * | 8 | NEAREST_NEAREST | |
  26523. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  26524. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  26525. * | 11 | LINEAR_LINEAR | |
  26526. * | 12 | LINEAR_NEAREST | |
  26527. *
  26528. * > _mag_: magnification filter (close to the viewer)
  26529. * > _min_: minification filter (far from the viewer)
  26530. * > _mip_: filter used between mip map levels
  26531. *@param samplingMode Define the new sampling mode of the texture
  26532. */
  26533. updateSamplingMode(samplingMode: number): void;
  26534. /**
  26535. * Scales the texture if is `canRescale()`
  26536. * @param ratio the resize factor we want to use to rescale
  26537. */
  26538. scale(ratio: number): void;
  26539. /**
  26540. * Get if the texture can rescale.
  26541. */
  26542. readonly canRescale: boolean;
  26543. /** @hidden */
  26544. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  26545. /** @hidden */
  26546. _rebuild(): void;
  26547. /**
  26548. * Triggers the load sequence in delayed load mode.
  26549. */
  26550. delayLoad(): void;
  26551. /**
  26552. * Clones the texture.
  26553. * @returns the cloned texture
  26554. */
  26555. clone(): Nullable<BaseTexture>;
  26556. /**
  26557. * Get the texture underlying type (INT, FLOAT...)
  26558. */
  26559. readonly textureType: number;
  26560. /**
  26561. * Get the texture underlying format (RGB, RGBA...)
  26562. */
  26563. readonly textureFormat: number;
  26564. /**
  26565. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  26566. * This will returns an RGBA array buffer containing either in values (0-255) or
  26567. * float values (0-1) depending of the underlying buffer type.
  26568. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  26569. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  26570. * @param buffer defines a user defined buffer to fill with data (can be null)
  26571. * @returns The Array buffer containing the pixels data.
  26572. */
  26573. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  26574. /**
  26575. * Release and destroy the underlying lower level texture aka internalTexture.
  26576. */
  26577. releaseInternalTexture(): void;
  26578. /**
  26579. * Get the polynomial representation of the texture data.
  26580. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  26581. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  26582. */
  26583. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26584. /** @hidden */
  26585. readonly _lodTextureHigh: Nullable<BaseTexture>;
  26586. /** @hidden */
  26587. readonly _lodTextureMid: Nullable<BaseTexture>;
  26588. /** @hidden */
  26589. readonly _lodTextureLow: Nullable<BaseTexture>;
  26590. /**
  26591. * Dispose the texture and release its associated resources.
  26592. */
  26593. dispose(): void;
  26594. /**
  26595. * Serialize the texture into a JSON representation that can be parsed later on.
  26596. * @returns the JSON representation of the texture
  26597. */
  26598. serialize(): any;
  26599. /**
  26600. * Helper function to be called back once a list of texture contains only ready textures.
  26601. * @param textures Define the list of textures to wait for
  26602. * @param callback Define the callback triggered once the entire list will be ready
  26603. */
  26604. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  26605. }
  26606. }
  26607. declare module BABYLON {
  26608. /**
  26609. * Uniform buffer objects.
  26610. *
  26611. * Handles blocks of uniform on the GPU.
  26612. *
  26613. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26614. *
  26615. * For more information, please refer to :
  26616. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26617. */
  26618. export class UniformBuffer {
  26619. private _engine;
  26620. private _buffer;
  26621. private _data;
  26622. private _bufferData;
  26623. private _dynamic?;
  26624. private _uniformLocations;
  26625. private _uniformSizes;
  26626. private _uniformLocationPointer;
  26627. private _needSync;
  26628. private _noUBO;
  26629. private _currentEffect;
  26630. private static _MAX_UNIFORM_SIZE;
  26631. private static _tempBuffer;
  26632. /**
  26633. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  26634. * This is dynamic to allow compat with webgl 1 and 2.
  26635. * You will need to pass the name of the uniform as well as the value.
  26636. */
  26637. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  26638. /**
  26639. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  26640. * This is dynamic to allow compat with webgl 1 and 2.
  26641. * You will need to pass the name of the uniform as well as the value.
  26642. */
  26643. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  26644. /**
  26645. * Lambda to Update a single float in a uniform buffer.
  26646. * This is dynamic to allow compat with webgl 1 and 2.
  26647. * You will need to pass the name of the uniform as well as the value.
  26648. */
  26649. updateFloat: (name: string, x: number) => void;
  26650. /**
  26651. * Lambda to Update a vec2 of float in a uniform buffer.
  26652. * This is dynamic to allow compat with webgl 1 and 2.
  26653. * You will need to pass the name of the uniform as well as the value.
  26654. */
  26655. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  26656. /**
  26657. * Lambda to Update a vec3 of float in a uniform buffer.
  26658. * This is dynamic to allow compat with webgl 1 and 2.
  26659. * You will need to pass the name of the uniform as well as the value.
  26660. */
  26661. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  26662. /**
  26663. * Lambda to Update a vec4 of float in a uniform buffer.
  26664. * This is dynamic to allow compat with webgl 1 and 2.
  26665. * You will need to pass the name of the uniform as well as the value.
  26666. */
  26667. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  26668. /**
  26669. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  26670. * This is dynamic to allow compat with webgl 1 and 2.
  26671. * You will need to pass the name of the uniform as well as the value.
  26672. */
  26673. updateMatrix: (name: string, mat: Matrix) => void;
  26674. /**
  26675. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  26676. * This is dynamic to allow compat with webgl 1 and 2.
  26677. * You will need to pass the name of the uniform as well as the value.
  26678. */
  26679. updateVector3: (name: string, vector: Vector3) => void;
  26680. /**
  26681. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  26682. * This is dynamic to allow compat with webgl 1 and 2.
  26683. * You will need to pass the name of the uniform as well as the value.
  26684. */
  26685. updateVector4: (name: string, vector: Vector4) => void;
  26686. /**
  26687. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  26688. * This is dynamic to allow compat with webgl 1 and 2.
  26689. * You will need to pass the name of the uniform as well as the value.
  26690. */
  26691. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  26692. /**
  26693. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  26694. * This is dynamic to allow compat with webgl 1 and 2.
  26695. * You will need to pass the name of the uniform as well as the value.
  26696. */
  26697. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  26698. /**
  26699. * Instantiates a new Uniform buffer objects.
  26700. *
  26701. * Handles blocks of uniform on the GPU.
  26702. *
  26703. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26704. *
  26705. * For more information, please refer to :
  26706. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26707. * @param engine Define the engine the buffer is associated with
  26708. * @param data Define the data contained in the buffer
  26709. * @param dynamic Define if the buffer is updatable
  26710. */
  26711. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  26712. /**
  26713. * Indicates if the buffer is using the WebGL2 UBO implementation,
  26714. * or just falling back on setUniformXXX calls.
  26715. */
  26716. readonly useUbo: boolean;
  26717. /**
  26718. * Indicates if the WebGL underlying uniform buffer is in sync
  26719. * with the javascript cache data.
  26720. */
  26721. readonly isSync: boolean;
  26722. /**
  26723. * Indicates if the WebGL underlying uniform buffer is dynamic.
  26724. * Also, a dynamic UniformBuffer will disable cache verification and always
  26725. * update the underlying WebGL uniform buffer to the GPU.
  26726. * @returns if Dynamic, otherwise false
  26727. */
  26728. isDynamic(): boolean;
  26729. /**
  26730. * The data cache on JS side.
  26731. * @returns the underlying data as a float array
  26732. */
  26733. getData(): Float32Array;
  26734. /**
  26735. * The underlying WebGL Uniform buffer.
  26736. * @returns the webgl buffer
  26737. */
  26738. getBuffer(): Nullable<DataBuffer>;
  26739. /**
  26740. * std140 layout specifies how to align data within an UBO structure.
  26741. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  26742. * for specs.
  26743. */
  26744. private _fillAlignment;
  26745. /**
  26746. * Adds an uniform in the buffer.
  26747. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  26748. * for the layout to be correct !
  26749. * @param name Name of the uniform, as used in the uniform block in the shader.
  26750. * @param size Data size, or data directly.
  26751. */
  26752. addUniform(name: string, size: number | number[]): void;
  26753. /**
  26754. * Adds a Matrix 4x4 to the uniform buffer.
  26755. * @param name Name of the uniform, as used in the uniform block in the shader.
  26756. * @param mat A 4x4 matrix.
  26757. */
  26758. addMatrix(name: string, mat: Matrix): void;
  26759. /**
  26760. * Adds a vec2 to the uniform buffer.
  26761. * @param name Name of the uniform, as used in the uniform block in the shader.
  26762. * @param x Define the x component value of the vec2
  26763. * @param y Define the y component value of the vec2
  26764. */
  26765. addFloat2(name: string, x: number, y: number): void;
  26766. /**
  26767. * Adds a vec3 to the uniform buffer.
  26768. * @param name Name of the uniform, as used in the uniform block in the shader.
  26769. * @param x Define the x component value of the vec3
  26770. * @param y Define the y component value of the vec3
  26771. * @param z Define the z component value of the vec3
  26772. */
  26773. addFloat3(name: string, x: number, y: number, z: number): void;
  26774. /**
  26775. * Adds a vec3 to the uniform buffer.
  26776. * @param name Name of the uniform, as used in the uniform block in the shader.
  26777. * @param color Define the vec3 from a Color
  26778. */
  26779. addColor3(name: string, color: Color3): void;
  26780. /**
  26781. * Adds a vec4 to the uniform buffer.
  26782. * @param name Name of the uniform, as used in the uniform block in the shader.
  26783. * @param color Define the rgb components from a Color
  26784. * @param alpha Define the a component of the vec4
  26785. */
  26786. addColor4(name: string, color: Color3, alpha: number): void;
  26787. /**
  26788. * Adds a vec3 to the uniform buffer.
  26789. * @param name Name of the uniform, as used in the uniform block in the shader.
  26790. * @param vector Define the vec3 components from a Vector
  26791. */
  26792. addVector3(name: string, vector: Vector3): void;
  26793. /**
  26794. * Adds a Matrix 3x3 to the uniform buffer.
  26795. * @param name Name of the uniform, as used in the uniform block in the shader.
  26796. */
  26797. addMatrix3x3(name: string): void;
  26798. /**
  26799. * Adds a Matrix 2x2 to the uniform buffer.
  26800. * @param name Name of the uniform, as used in the uniform block in the shader.
  26801. */
  26802. addMatrix2x2(name: string): void;
  26803. /**
  26804. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  26805. */
  26806. create(): void;
  26807. /** @hidden */
  26808. _rebuild(): void;
  26809. /**
  26810. * Updates the WebGL Uniform Buffer on the GPU.
  26811. * If the `dynamic` flag is set to true, no cache comparison is done.
  26812. * Otherwise, the buffer will be updated only if the cache differs.
  26813. */
  26814. update(): void;
  26815. /**
  26816. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  26817. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26818. * @param data Define the flattened data
  26819. * @param size Define the size of the data.
  26820. */
  26821. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26822. private _updateMatrix3x3ForUniform;
  26823. private _updateMatrix3x3ForEffect;
  26824. private _updateMatrix2x2ForEffect;
  26825. private _updateMatrix2x2ForUniform;
  26826. private _updateFloatForEffect;
  26827. private _updateFloatForUniform;
  26828. private _updateFloat2ForEffect;
  26829. private _updateFloat2ForUniform;
  26830. private _updateFloat3ForEffect;
  26831. private _updateFloat3ForUniform;
  26832. private _updateFloat4ForEffect;
  26833. private _updateFloat4ForUniform;
  26834. private _updateMatrixForEffect;
  26835. private _updateMatrixForUniform;
  26836. private _updateVector3ForEffect;
  26837. private _updateVector3ForUniform;
  26838. private _updateVector4ForEffect;
  26839. private _updateVector4ForUniform;
  26840. private _updateColor3ForEffect;
  26841. private _updateColor3ForUniform;
  26842. private _updateColor4ForEffect;
  26843. private _updateColor4ForUniform;
  26844. /**
  26845. * Sets a sampler uniform on the effect.
  26846. * @param name Define the name of the sampler.
  26847. * @param texture Define the texture to set in the sampler
  26848. */
  26849. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26850. /**
  26851. * Directly updates the value of the uniform in the cache AND on the GPU.
  26852. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26853. * @param data Define the flattened data
  26854. */
  26855. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26856. /**
  26857. * Binds this uniform buffer to an effect.
  26858. * @param effect Define the effect to bind the buffer to
  26859. * @param name Name of the uniform block in the shader.
  26860. */
  26861. bindToEffect(effect: Effect, name: string): void;
  26862. /**
  26863. * Disposes the uniform buffer.
  26864. */
  26865. dispose(): void;
  26866. }
  26867. }
  26868. declare module BABYLON {
  26869. /**
  26870. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26871. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26872. */
  26873. export class Analyser {
  26874. /**
  26875. * Gets or sets the smoothing
  26876. * @ignorenaming
  26877. */
  26878. SMOOTHING: number;
  26879. /**
  26880. * Gets or sets the FFT table size
  26881. * @ignorenaming
  26882. */
  26883. FFT_SIZE: number;
  26884. /**
  26885. * Gets or sets the bar graph amplitude
  26886. * @ignorenaming
  26887. */
  26888. BARGRAPHAMPLITUDE: number;
  26889. /**
  26890. * Gets or sets the position of the debug canvas
  26891. * @ignorenaming
  26892. */
  26893. DEBUGCANVASPOS: {
  26894. x: number;
  26895. y: number;
  26896. };
  26897. /**
  26898. * Gets or sets the debug canvas size
  26899. * @ignorenaming
  26900. */
  26901. DEBUGCANVASSIZE: {
  26902. width: number;
  26903. height: number;
  26904. };
  26905. private _byteFreqs;
  26906. private _byteTime;
  26907. private _floatFreqs;
  26908. private _webAudioAnalyser;
  26909. private _debugCanvas;
  26910. private _debugCanvasContext;
  26911. private _scene;
  26912. private _registerFunc;
  26913. private _audioEngine;
  26914. /**
  26915. * Creates a new analyser
  26916. * @param scene defines hosting scene
  26917. */
  26918. constructor(scene: Scene);
  26919. /**
  26920. * Get the number of data values you will have to play with for the visualization
  26921. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26922. * @returns a number
  26923. */
  26924. getFrequencyBinCount(): number;
  26925. /**
  26926. * Gets the current frequency data as a byte array
  26927. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26928. * @returns a Uint8Array
  26929. */
  26930. getByteFrequencyData(): Uint8Array;
  26931. /**
  26932. * Gets the current waveform as a byte array
  26933. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26934. * @returns a Uint8Array
  26935. */
  26936. getByteTimeDomainData(): Uint8Array;
  26937. /**
  26938. * Gets the current frequency data as a float array
  26939. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26940. * @returns a Float32Array
  26941. */
  26942. getFloatFrequencyData(): Float32Array;
  26943. /**
  26944. * Renders the debug canvas
  26945. */
  26946. drawDebugCanvas(): void;
  26947. /**
  26948. * Stops rendering the debug canvas and removes it
  26949. */
  26950. stopDebugCanvas(): void;
  26951. /**
  26952. * Connects two audio nodes
  26953. * @param inputAudioNode defines first node to connect
  26954. * @param outputAudioNode defines second node to connect
  26955. */
  26956. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26957. /**
  26958. * Releases all associated resources
  26959. */
  26960. dispose(): void;
  26961. }
  26962. }
  26963. declare module BABYLON {
  26964. /**
  26965. * This represents an audio engine and it is responsible
  26966. * to play, synchronize and analyse sounds throughout the application.
  26967. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26968. */
  26969. export interface IAudioEngine extends IDisposable {
  26970. /**
  26971. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26972. */
  26973. readonly canUseWebAudio: boolean;
  26974. /**
  26975. * Gets the current AudioContext if available.
  26976. */
  26977. readonly audioContext: Nullable<AudioContext>;
  26978. /**
  26979. * The master gain node defines the global audio volume of your audio engine.
  26980. */
  26981. readonly masterGain: GainNode;
  26982. /**
  26983. * Gets whether or not mp3 are supported by your browser.
  26984. */
  26985. readonly isMP3supported: boolean;
  26986. /**
  26987. * Gets whether or not ogg are supported by your browser.
  26988. */
  26989. readonly isOGGsupported: boolean;
  26990. /**
  26991. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26992. * @ignoreNaming
  26993. */
  26994. WarnedWebAudioUnsupported: boolean;
  26995. /**
  26996. * Defines if the audio engine relies on a custom unlocked button.
  26997. * In this case, the embedded button will not be displayed.
  26998. */
  26999. useCustomUnlockedButton: boolean;
  27000. /**
  27001. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  27002. */
  27003. readonly unlocked: boolean;
  27004. /**
  27005. * Event raised when audio has been unlocked on the browser.
  27006. */
  27007. onAudioUnlockedObservable: Observable<AudioEngine>;
  27008. /**
  27009. * Event raised when audio has been locked on the browser.
  27010. */
  27011. onAudioLockedObservable: Observable<AudioEngine>;
  27012. /**
  27013. * Flags the audio engine in Locked state.
  27014. * This happens due to new browser policies preventing audio to autoplay.
  27015. */
  27016. lock(): void;
  27017. /**
  27018. * Unlocks the audio engine once a user action has been done on the dom.
  27019. * This is helpful to resume play once browser policies have been satisfied.
  27020. */
  27021. unlock(): void;
  27022. }
  27023. /**
  27024. * This represents the default audio engine used in babylon.
  27025. * It is responsible to play, synchronize and analyse sounds throughout the application.
  27026. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27027. */
  27028. export class AudioEngine implements IAudioEngine {
  27029. private _audioContext;
  27030. private _audioContextInitialized;
  27031. private _muteButton;
  27032. private _hostElement;
  27033. /**
  27034. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27035. */
  27036. canUseWebAudio: boolean;
  27037. /**
  27038. * The master gain node defines the global audio volume of your audio engine.
  27039. */
  27040. masterGain: GainNode;
  27041. /**
  27042. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27043. * @ignoreNaming
  27044. */
  27045. WarnedWebAudioUnsupported: boolean;
  27046. /**
  27047. * Gets whether or not mp3 are supported by your browser.
  27048. */
  27049. isMP3supported: boolean;
  27050. /**
  27051. * Gets whether or not ogg are supported by your browser.
  27052. */
  27053. isOGGsupported: boolean;
  27054. /**
  27055. * Gets whether audio has been unlocked on the device.
  27056. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  27057. * a user interaction has happened.
  27058. */
  27059. unlocked: boolean;
  27060. /**
  27061. * Defines if the audio engine relies on a custom unlocked button.
  27062. * In this case, the embedded button will not be displayed.
  27063. */
  27064. useCustomUnlockedButton: boolean;
  27065. /**
  27066. * Event raised when audio has been unlocked on the browser.
  27067. */
  27068. onAudioUnlockedObservable: Observable<AudioEngine>;
  27069. /**
  27070. * Event raised when audio has been locked on the browser.
  27071. */
  27072. onAudioLockedObservable: Observable<AudioEngine>;
  27073. /**
  27074. * Gets the current AudioContext if available.
  27075. */
  27076. readonly audioContext: Nullable<AudioContext>;
  27077. private _connectedAnalyser;
  27078. /**
  27079. * Instantiates a new audio engine.
  27080. *
  27081. * There should be only one per page as some browsers restrict the number
  27082. * of audio contexts you can create.
  27083. * @param hostElement defines the host element where to display the mute icon if necessary
  27084. */
  27085. constructor(hostElement?: Nullable<HTMLElement>);
  27086. /**
  27087. * Flags the audio engine in Locked state.
  27088. * This happens due to new browser policies preventing audio to autoplay.
  27089. */
  27090. lock(): void;
  27091. /**
  27092. * Unlocks the audio engine once a user action has been done on the dom.
  27093. * This is helpful to resume play once browser policies have been satisfied.
  27094. */
  27095. unlock(): void;
  27096. private _resumeAudioContext;
  27097. private _initializeAudioContext;
  27098. private _tryToRun;
  27099. private _triggerRunningState;
  27100. private _triggerSuspendedState;
  27101. private _displayMuteButton;
  27102. private _moveButtonToTopLeft;
  27103. private _onResize;
  27104. private _hideMuteButton;
  27105. /**
  27106. * Destroy and release the resources associated with the audio ccontext.
  27107. */
  27108. dispose(): void;
  27109. /**
  27110. * Gets the global volume sets on the master gain.
  27111. * @returns the global volume if set or -1 otherwise
  27112. */
  27113. getGlobalVolume(): number;
  27114. /**
  27115. * Sets the global volume of your experience (sets on the master gain).
  27116. * @param newVolume Defines the new global volume of the application
  27117. */
  27118. setGlobalVolume(newVolume: number): void;
  27119. /**
  27120. * Connect the audio engine to an audio analyser allowing some amazing
  27121. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  27122. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  27123. * @param analyser The analyser to connect to the engine
  27124. */
  27125. connectToAnalyser(analyser: Analyser): void;
  27126. }
  27127. }
  27128. declare module BABYLON {
  27129. /**
  27130. * Interface used to present a loading screen while loading a scene
  27131. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27132. */
  27133. export interface ILoadingScreen {
  27134. /**
  27135. * Function called to display the loading screen
  27136. */
  27137. displayLoadingUI: () => void;
  27138. /**
  27139. * Function called to hide the loading screen
  27140. */
  27141. hideLoadingUI: () => void;
  27142. /**
  27143. * Gets or sets the color to use for the background
  27144. */
  27145. loadingUIBackgroundColor: string;
  27146. /**
  27147. * Gets or sets the text to display while loading
  27148. */
  27149. loadingUIText: string;
  27150. }
  27151. /**
  27152. * Class used for the default loading screen
  27153. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27154. */
  27155. export class DefaultLoadingScreen implements ILoadingScreen {
  27156. private _renderingCanvas;
  27157. private _loadingText;
  27158. private _loadingDivBackgroundColor;
  27159. private _loadingDiv;
  27160. private _loadingTextDiv;
  27161. /** Gets or sets the logo url to use for the default loading screen */
  27162. static DefaultLogoUrl: string;
  27163. /** Gets or sets the spinner url to use for the default loading screen */
  27164. static DefaultSpinnerUrl: string;
  27165. /**
  27166. * Creates a new default loading screen
  27167. * @param _renderingCanvas defines the canvas used to render the scene
  27168. * @param _loadingText defines the default text to display
  27169. * @param _loadingDivBackgroundColor defines the default background color
  27170. */
  27171. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  27172. /**
  27173. * Function called to display the loading screen
  27174. */
  27175. displayLoadingUI(): void;
  27176. /**
  27177. * Function called to hide the loading screen
  27178. */
  27179. hideLoadingUI(): void;
  27180. /**
  27181. * Gets or sets the text to display while loading
  27182. */
  27183. loadingUIText: string;
  27184. /**
  27185. * Gets or sets the color to use for the background
  27186. */
  27187. loadingUIBackgroundColor: string;
  27188. private _resizeLoadingUI;
  27189. }
  27190. }
  27191. declare module BABYLON {
  27192. /** @hidden */
  27193. export class WebGLPipelineContext implements IPipelineContext {
  27194. engine: Engine;
  27195. program: Nullable<WebGLProgram>;
  27196. context?: WebGLRenderingContext;
  27197. vertexShader?: WebGLShader;
  27198. fragmentShader?: WebGLShader;
  27199. isParallelCompiled: boolean;
  27200. onCompiled?: () => void;
  27201. transformFeedback?: WebGLTransformFeedback | null;
  27202. readonly isAsync: boolean;
  27203. readonly isReady: boolean;
  27204. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  27205. }
  27206. }
  27207. declare module BABYLON {
  27208. /** @hidden */
  27209. export class WebGLDataBuffer extends DataBuffer {
  27210. private _buffer;
  27211. constructor(resource: WebGLBuffer);
  27212. readonly underlyingResource: any;
  27213. }
  27214. }
  27215. declare module BABYLON {
  27216. /** @hidden */
  27217. export class WebGL2ShaderProcessor implements IShaderProcessor {
  27218. attributeProcessor(attribute: string): string;
  27219. varyingProcessor(varying: string, isFragment: boolean): string;
  27220. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  27221. }
  27222. }
  27223. declare module BABYLON {
  27224. /**
  27225. * Settings for finer control over video usage
  27226. */
  27227. export interface VideoTextureSettings {
  27228. /**
  27229. * Applies `autoplay` to video, if specified
  27230. */
  27231. autoPlay?: boolean;
  27232. /**
  27233. * Applies `loop` to video, if specified
  27234. */
  27235. loop?: boolean;
  27236. /**
  27237. * Automatically updates internal texture from video at every frame in the render loop
  27238. */
  27239. autoUpdateTexture: boolean;
  27240. /**
  27241. * Image src displayed during the video loading or until the user interacts with the video.
  27242. */
  27243. poster?: string;
  27244. }
  27245. /**
  27246. * If you want to display a video in your scene, this is the special texture for that.
  27247. * This special texture works similar to other textures, with the exception of a few parameters.
  27248. * @see https://doc.babylonjs.com/how_to/video_texture
  27249. */
  27250. export class VideoTexture extends Texture {
  27251. /**
  27252. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  27253. */
  27254. readonly autoUpdateTexture: boolean;
  27255. /**
  27256. * The video instance used by the texture internally
  27257. */
  27258. readonly video: HTMLVideoElement;
  27259. private _onUserActionRequestedObservable;
  27260. /**
  27261. * Event triggerd when a dom action is required by the user to play the video.
  27262. * This happens due to recent changes in browser policies preventing video to auto start.
  27263. */
  27264. readonly onUserActionRequestedObservable: Observable<Texture>;
  27265. private _generateMipMaps;
  27266. private _engine;
  27267. private _stillImageCaptured;
  27268. private _displayingPosterTexture;
  27269. private _settings;
  27270. private _createInternalTextureOnEvent;
  27271. /**
  27272. * Creates a video texture.
  27273. * If you want to display a video in your scene, this is the special texture for that.
  27274. * This special texture works similar to other textures, with the exception of a few parameters.
  27275. * @see https://doc.babylonjs.com/how_to/video_texture
  27276. * @param name optional name, will detect from video source, if not defined
  27277. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  27278. * @param scene is obviously the current scene.
  27279. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  27280. * @param invertY is false by default but can be used to invert video on Y axis
  27281. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  27282. * @param settings allows finer control over video usage
  27283. */
  27284. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  27285. private _getName;
  27286. private _getVideo;
  27287. private _createInternalTexture;
  27288. private reset;
  27289. /**
  27290. * @hidden Internal method to initiate `update`.
  27291. */
  27292. _rebuild(): void;
  27293. /**
  27294. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  27295. */
  27296. update(): void;
  27297. /**
  27298. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  27299. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  27300. */
  27301. updateTexture(isVisible: boolean): void;
  27302. protected _updateInternalTexture: () => void;
  27303. /**
  27304. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  27305. * @param url New url.
  27306. */
  27307. updateURL(url: string): void;
  27308. /**
  27309. * Dispose the texture and release its associated resources.
  27310. */
  27311. dispose(): void;
  27312. /**
  27313. * Creates a video texture straight from a stream.
  27314. * @param scene Define the scene the texture should be created in
  27315. * @param stream Define the stream the texture should be created from
  27316. * @returns The created video texture as a promise
  27317. */
  27318. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  27319. /**
  27320. * Creates a video texture straight from your WebCam video feed.
  27321. * @param scene Define the scene the texture should be created in
  27322. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27323. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27324. * @returns The created video texture as a promise
  27325. */
  27326. static CreateFromWebCamAsync(scene: Scene, constraints: {
  27327. minWidth: number;
  27328. maxWidth: number;
  27329. minHeight: number;
  27330. maxHeight: number;
  27331. deviceId: string;
  27332. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  27333. /**
  27334. * Creates a video texture straight from your WebCam video feed.
  27335. * @param scene Define the scene the texture should be created in
  27336. * @param onReady Define a callback to triggered once the texture will be ready
  27337. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27338. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27339. */
  27340. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  27341. minWidth: number;
  27342. maxWidth: number;
  27343. minHeight: number;
  27344. maxHeight: number;
  27345. deviceId: string;
  27346. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  27347. }
  27348. }
  27349. declare module BABYLON {
  27350. /**
  27351. * Interface for attribute information associated with buffer instanciation
  27352. */
  27353. export class InstancingAttributeInfo {
  27354. /**
  27355. * Index/offset of the attribute in the vertex shader
  27356. */
  27357. index: number;
  27358. /**
  27359. * size of the attribute, 1, 2, 3 or 4
  27360. */
  27361. attributeSize: number;
  27362. /**
  27363. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  27364. * default is FLOAT
  27365. */
  27366. attribyteType: number;
  27367. /**
  27368. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  27369. */
  27370. normalized: boolean;
  27371. /**
  27372. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  27373. */
  27374. offset: number;
  27375. /**
  27376. * Name of the GLSL attribute, for debugging purpose only
  27377. */
  27378. attributeName: string;
  27379. }
  27380. /**
  27381. * Define options used to create a depth texture
  27382. */
  27383. export class DepthTextureCreationOptions {
  27384. /** Specifies whether or not a stencil should be allocated in the texture */
  27385. generateStencil?: boolean;
  27386. /** Specifies whether or not bilinear filtering is enable on the texture */
  27387. bilinearFiltering?: boolean;
  27388. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  27389. comparisonFunction?: number;
  27390. /** Specifies if the created texture is a cube texture */
  27391. isCube?: boolean;
  27392. }
  27393. /**
  27394. * Class used to describe the capabilities of the engine relatively to the current browser
  27395. */
  27396. export class EngineCapabilities {
  27397. /** Maximum textures units per fragment shader */
  27398. maxTexturesImageUnits: number;
  27399. /** Maximum texture units per vertex shader */
  27400. maxVertexTextureImageUnits: number;
  27401. /** Maximum textures units in the entire pipeline */
  27402. maxCombinedTexturesImageUnits: number;
  27403. /** Maximum texture size */
  27404. maxTextureSize: number;
  27405. /** Maximum cube texture size */
  27406. maxCubemapTextureSize: number;
  27407. /** Maximum render texture size */
  27408. maxRenderTextureSize: number;
  27409. /** Maximum number of vertex attributes */
  27410. maxVertexAttribs: number;
  27411. /** Maximum number of varyings */
  27412. maxVaryingVectors: number;
  27413. /** Maximum number of uniforms per vertex shader */
  27414. maxVertexUniformVectors: number;
  27415. /** Maximum number of uniforms per fragment shader */
  27416. maxFragmentUniformVectors: number;
  27417. /** Defines if standard derivates (dx/dy) are supported */
  27418. standardDerivatives: boolean;
  27419. /** Defines if s3tc texture compression is supported */
  27420. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  27421. /** Defines if pvrtc texture compression is supported */
  27422. pvrtc: any;
  27423. /** Defines if etc1 texture compression is supported */
  27424. etc1: any;
  27425. /** Defines if etc2 texture compression is supported */
  27426. etc2: any;
  27427. /** Defines if astc texture compression is supported */
  27428. astc: any;
  27429. /** Defines if float textures are supported */
  27430. textureFloat: boolean;
  27431. /** Defines if vertex array objects are supported */
  27432. vertexArrayObject: boolean;
  27433. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  27434. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  27435. /** Gets the maximum level of anisotropy supported */
  27436. maxAnisotropy: number;
  27437. /** Defines if instancing is supported */
  27438. instancedArrays: boolean;
  27439. /** Defines if 32 bits indices are supported */
  27440. uintIndices: boolean;
  27441. /** Defines if high precision shaders are supported */
  27442. highPrecisionShaderSupported: boolean;
  27443. /** Defines if depth reading in the fragment shader is supported */
  27444. fragmentDepthSupported: boolean;
  27445. /** Defines if float texture linear filtering is supported*/
  27446. textureFloatLinearFiltering: boolean;
  27447. /** Defines if rendering to float textures is supported */
  27448. textureFloatRender: boolean;
  27449. /** Defines if half float textures are supported*/
  27450. textureHalfFloat: boolean;
  27451. /** Defines if half float texture linear filtering is supported*/
  27452. textureHalfFloatLinearFiltering: boolean;
  27453. /** Defines if rendering to half float textures is supported */
  27454. textureHalfFloatRender: boolean;
  27455. /** Defines if textureLOD shader command is supported */
  27456. textureLOD: boolean;
  27457. /** Defines if draw buffers extension is supported */
  27458. drawBuffersExtension: boolean;
  27459. /** Defines if depth textures are supported */
  27460. depthTextureExtension: boolean;
  27461. /** Defines if float color buffer are supported */
  27462. colorBufferFloat: boolean;
  27463. /** Gets disjoint timer query extension (null if not supported) */
  27464. timerQuery: EXT_disjoint_timer_query;
  27465. /** Defines if timestamp can be used with timer query */
  27466. canUseTimestampForTimerQuery: boolean;
  27467. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  27468. multiview: any;
  27469. /** Function used to let the system compiles shaders in background */
  27470. parallelShaderCompile: {
  27471. COMPLETION_STATUS_KHR: number;
  27472. };
  27473. }
  27474. /** Interface defining initialization parameters for Engine class */
  27475. export interface EngineOptions extends WebGLContextAttributes {
  27476. /**
  27477. * Defines if the engine should no exceed a specified device ratio
  27478. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  27479. */
  27480. limitDeviceRatio?: number;
  27481. /**
  27482. * Defines if webvr should be enabled automatically
  27483. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27484. */
  27485. autoEnableWebVR?: boolean;
  27486. /**
  27487. * Defines if webgl2 should be turned off even if supported
  27488. * @see http://doc.babylonjs.com/features/webgl2
  27489. */
  27490. disableWebGL2Support?: boolean;
  27491. /**
  27492. * Defines if webaudio should be initialized as well
  27493. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27494. */
  27495. audioEngine?: boolean;
  27496. /**
  27497. * Defines if animations should run using a deterministic lock step
  27498. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27499. */
  27500. deterministicLockstep?: boolean;
  27501. /** Defines the maximum steps to use with deterministic lock step mode */
  27502. lockstepMaxSteps?: number;
  27503. /**
  27504. * Defines that engine should ignore context lost events
  27505. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  27506. */
  27507. doNotHandleContextLost?: boolean;
  27508. /**
  27509. * Defines that engine should ignore modifying touch action attribute and style
  27510. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  27511. */
  27512. doNotHandleTouchAction?: boolean;
  27513. /**
  27514. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  27515. */
  27516. useHighPrecisionFloats?: boolean;
  27517. }
  27518. /**
  27519. * Defines the interface used by display changed events
  27520. */
  27521. export interface IDisplayChangedEventArgs {
  27522. /** Gets the vrDisplay object (if any) */
  27523. vrDisplay: Nullable<any>;
  27524. /** Gets a boolean indicating if webVR is supported */
  27525. vrSupported: boolean;
  27526. }
  27527. /**
  27528. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27529. */
  27530. export class Engine {
  27531. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  27532. static ExceptionList: ({
  27533. key: string;
  27534. capture: string;
  27535. captureConstraint: number;
  27536. targets: string[];
  27537. } | {
  27538. key: string;
  27539. capture: null;
  27540. captureConstraint: null;
  27541. targets: string[];
  27542. })[];
  27543. /** Gets the list of created engines */
  27544. static readonly Instances: Engine[];
  27545. /**
  27546. * Gets the latest created engine
  27547. */
  27548. static readonly LastCreatedEngine: Nullable<Engine>;
  27549. /**
  27550. * Gets the latest created scene
  27551. */
  27552. static readonly LastCreatedScene: Nullable<Scene>;
  27553. /**
  27554. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27555. * @param flag defines which part of the materials must be marked as dirty
  27556. * @param predicate defines a predicate used to filter which materials should be affected
  27557. */
  27558. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  27559. /** @hidden */
  27560. static _TextureLoaders: IInternalTextureLoader[];
  27561. /** Defines that alpha blending is disabled */
  27562. static readonly ALPHA_DISABLE: number;
  27563. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27564. static readonly ALPHA_ADD: number;
  27565. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27566. static readonly ALPHA_COMBINE: number;
  27567. /** Defines that alpha blending to DEST - SRC * DEST */
  27568. static readonly ALPHA_SUBTRACT: number;
  27569. /** Defines that alpha blending to SRC * DEST */
  27570. static readonly ALPHA_MULTIPLY: number;
  27571. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27572. static readonly ALPHA_MAXIMIZED: number;
  27573. /** Defines that alpha blending to SRC + DEST */
  27574. static readonly ALPHA_ONEONE: number;
  27575. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27576. static readonly ALPHA_PREMULTIPLIED: number;
  27577. /**
  27578. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27579. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27580. */
  27581. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  27582. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27583. static readonly ALPHA_INTERPOLATE: number;
  27584. /**
  27585. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27586. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27587. */
  27588. static readonly ALPHA_SCREENMODE: number;
  27589. /** Defines that the ressource is not delayed*/
  27590. static readonly DELAYLOADSTATE_NONE: number;
  27591. /** Defines that the ressource was successfully delay loaded */
  27592. static readonly DELAYLOADSTATE_LOADED: number;
  27593. /** Defines that the ressource is currently delay loading */
  27594. static readonly DELAYLOADSTATE_LOADING: number;
  27595. /** Defines that the ressource is delayed and has not started loading */
  27596. static readonly DELAYLOADSTATE_NOTLOADED: number;
  27597. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27598. static readonly NEVER: number;
  27599. /** 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 */
  27600. static readonly ALWAYS: number;
  27601. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27602. static readonly LESS: number;
  27603. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27604. static readonly EQUAL: number;
  27605. /** 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 */
  27606. static readonly LEQUAL: number;
  27607. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27608. static readonly GREATER: number;
  27609. /** 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 */
  27610. static readonly GEQUAL: number;
  27611. /** 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 */
  27612. static readonly NOTEQUAL: number;
  27613. /** Passed to stencilOperation to specify that stencil value must be kept */
  27614. static readonly KEEP: number;
  27615. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27616. static readonly REPLACE: number;
  27617. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27618. static readonly INCR: number;
  27619. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27620. static readonly DECR: number;
  27621. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27622. static readonly INVERT: number;
  27623. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27624. static readonly INCR_WRAP: number;
  27625. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27626. static readonly DECR_WRAP: number;
  27627. /** Texture is not repeating outside of 0..1 UVs */
  27628. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  27629. /** Texture is repeating outside of 0..1 UVs */
  27630. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  27631. /** Texture is repeating and mirrored */
  27632. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  27633. /** ALPHA */
  27634. static readonly TEXTUREFORMAT_ALPHA: number;
  27635. /** LUMINANCE */
  27636. static readonly TEXTUREFORMAT_LUMINANCE: number;
  27637. /** LUMINANCE_ALPHA */
  27638. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  27639. /** RGB */
  27640. static readonly TEXTUREFORMAT_RGB: number;
  27641. /** RGBA */
  27642. static readonly TEXTUREFORMAT_RGBA: number;
  27643. /** RED */
  27644. static readonly TEXTUREFORMAT_RED: number;
  27645. /** RED (2nd reference) */
  27646. static readonly TEXTUREFORMAT_R: number;
  27647. /** RG */
  27648. static readonly TEXTUREFORMAT_RG: number;
  27649. /** RED_INTEGER */
  27650. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  27651. /** RED_INTEGER (2nd reference) */
  27652. static readonly TEXTUREFORMAT_R_INTEGER: number;
  27653. /** RG_INTEGER */
  27654. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  27655. /** RGB_INTEGER */
  27656. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  27657. /** RGBA_INTEGER */
  27658. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  27659. /** UNSIGNED_BYTE */
  27660. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  27661. /** UNSIGNED_BYTE (2nd reference) */
  27662. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  27663. /** FLOAT */
  27664. static readonly TEXTURETYPE_FLOAT: number;
  27665. /** HALF_FLOAT */
  27666. static readonly TEXTURETYPE_HALF_FLOAT: number;
  27667. /** BYTE */
  27668. static readonly TEXTURETYPE_BYTE: number;
  27669. /** SHORT */
  27670. static readonly TEXTURETYPE_SHORT: number;
  27671. /** UNSIGNED_SHORT */
  27672. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  27673. /** INT */
  27674. static readonly TEXTURETYPE_INT: number;
  27675. /** UNSIGNED_INT */
  27676. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  27677. /** UNSIGNED_SHORT_4_4_4_4 */
  27678. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  27679. /** UNSIGNED_SHORT_5_5_5_1 */
  27680. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  27681. /** UNSIGNED_SHORT_5_6_5 */
  27682. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  27683. /** UNSIGNED_INT_2_10_10_10_REV */
  27684. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  27685. /** UNSIGNED_INT_24_8 */
  27686. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  27687. /** UNSIGNED_INT_10F_11F_11F_REV */
  27688. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27689. /** UNSIGNED_INT_5_9_9_9_REV */
  27690. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27691. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27692. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27693. /** nearest is mag = nearest and min = nearest and mip = linear */
  27694. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27695. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27696. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27697. /** Trilinear is mag = linear and min = linear and mip = linear */
  27698. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27699. /** nearest is mag = nearest and min = nearest and mip = linear */
  27700. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27701. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27702. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27703. /** Trilinear is mag = linear and min = linear and mip = linear */
  27704. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27705. /** mag = nearest and min = nearest and mip = nearest */
  27706. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27707. /** mag = nearest and min = linear and mip = nearest */
  27708. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27709. /** mag = nearest and min = linear and mip = linear */
  27710. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27711. /** mag = nearest and min = linear and mip = none */
  27712. static readonly TEXTURE_NEAREST_LINEAR: number;
  27713. /** mag = nearest and min = nearest and mip = none */
  27714. static readonly TEXTURE_NEAREST_NEAREST: number;
  27715. /** mag = linear and min = nearest and mip = nearest */
  27716. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27717. /** mag = linear and min = nearest and mip = linear */
  27718. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27719. /** mag = linear and min = linear and mip = none */
  27720. static readonly TEXTURE_LINEAR_LINEAR: number;
  27721. /** mag = linear and min = nearest and mip = none */
  27722. static readonly TEXTURE_LINEAR_NEAREST: number;
  27723. /** Explicit coordinates mode */
  27724. static readonly TEXTURE_EXPLICIT_MODE: number;
  27725. /** Spherical coordinates mode */
  27726. static readonly TEXTURE_SPHERICAL_MODE: number;
  27727. /** Planar coordinates mode */
  27728. static readonly TEXTURE_PLANAR_MODE: number;
  27729. /** Cubic coordinates mode */
  27730. static readonly TEXTURE_CUBIC_MODE: number;
  27731. /** Projection coordinates mode */
  27732. static readonly TEXTURE_PROJECTION_MODE: number;
  27733. /** Skybox coordinates mode */
  27734. static readonly TEXTURE_SKYBOX_MODE: number;
  27735. /** Inverse Cubic coordinates mode */
  27736. static readonly TEXTURE_INVCUBIC_MODE: number;
  27737. /** Equirectangular coordinates mode */
  27738. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27739. /** Equirectangular Fixed coordinates mode */
  27740. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27741. /** Equirectangular Fixed Mirrored coordinates mode */
  27742. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27743. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27744. static readonly SCALEMODE_FLOOR: number;
  27745. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27746. static readonly SCALEMODE_NEAREST: number;
  27747. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27748. static readonly SCALEMODE_CEILING: number;
  27749. /**
  27750. * Returns the current npm package of the sdk
  27751. */
  27752. static readonly NpmPackage: string;
  27753. /**
  27754. * Returns the current version of the framework
  27755. */
  27756. static readonly Version: string;
  27757. /**
  27758. * Returns a string describing the current engine
  27759. */
  27760. readonly description: string;
  27761. /**
  27762. * Gets or sets the epsilon value used by collision engine
  27763. */
  27764. static CollisionsEpsilon: number;
  27765. /**
  27766. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27767. */
  27768. static ShadersRepository: string;
  27769. /**
  27770. * Method called to create the default loading screen.
  27771. * This can be overriden in your own app.
  27772. * @param canvas The rendering canvas element
  27773. * @returns The loading screen
  27774. */
  27775. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27776. /**
  27777. * Method called to create the default rescale post process on each engine.
  27778. */
  27779. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27780. /** @hidden */
  27781. _shaderProcessor: IShaderProcessor;
  27782. /**
  27783. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27784. */
  27785. forcePOTTextures: boolean;
  27786. /**
  27787. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27788. */
  27789. isFullscreen: boolean;
  27790. /**
  27791. * Gets a boolean indicating if the pointer is currently locked
  27792. */
  27793. isPointerLock: boolean;
  27794. /**
  27795. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27796. */
  27797. cullBackFaces: boolean;
  27798. /**
  27799. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27800. */
  27801. renderEvenInBackground: boolean;
  27802. /**
  27803. * Gets or sets a boolean indicating that cache can be kept between frames
  27804. */
  27805. preventCacheWipeBetweenFrames: boolean;
  27806. /**
  27807. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27808. **/
  27809. enableOfflineSupport: boolean;
  27810. /**
  27811. * 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)
  27812. **/
  27813. disableManifestCheck: boolean;
  27814. /**
  27815. * Gets the list of created scenes
  27816. */
  27817. scenes: Scene[];
  27818. /**
  27819. * Event raised when a new scene is created
  27820. */
  27821. onNewSceneAddedObservable: Observable<Scene>;
  27822. /**
  27823. * Gets the list of created postprocesses
  27824. */
  27825. postProcesses: PostProcess[];
  27826. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27827. validateShaderPrograms: boolean;
  27828. /**
  27829. * Observable event triggered each time the rendering canvas is resized
  27830. */
  27831. onResizeObservable: Observable<Engine>;
  27832. /**
  27833. * Observable event triggered each time the canvas loses focus
  27834. */
  27835. onCanvasBlurObservable: Observable<Engine>;
  27836. /**
  27837. * Observable event triggered each time the canvas gains focus
  27838. */
  27839. onCanvasFocusObservable: Observable<Engine>;
  27840. /**
  27841. * Observable event triggered each time the canvas receives pointerout event
  27842. */
  27843. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27844. /**
  27845. * Observable event triggered before each texture is initialized
  27846. */
  27847. onBeforeTextureInitObservable: Observable<Texture>;
  27848. /**
  27849. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27850. */
  27851. disableUniformBuffers: boolean;
  27852. /** @hidden */
  27853. _uniformBuffers: UniformBuffer[];
  27854. /**
  27855. * Gets a boolean indicating that the engine supports uniform buffers
  27856. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27857. */
  27858. readonly supportsUniformBuffers: boolean;
  27859. /**
  27860. * Observable raised when the engine begins a new frame
  27861. */
  27862. onBeginFrameObservable: Observable<Engine>;
  27863. /**
  27864. * If set, will be used to request the next animation frame for the render loop
  27865. */
  27866. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27867. /**
  27868. * Observable raised when the engine ends the current frame
  27869. */
  27870. onEndFrameObservable: Observable<Engine>;
  27871. /**
  27872. * Observable raised when the engine is about to compile a shader
  27873. */
  27874. onBeforeShaderCompilationObservable: Observable<Engine>;
  27875. /**
  27876. * Observable raised when the engine has jsut compiled a shader
  27877. */
  27878. onAfterShaderCompilationObservable: Observable<Engine>;
  27879. /** @hidden */
  27880. _gl: WebGLRenderingContext;
  27881. private _renderingCanvas;
  27882. private _windowIsBackground;
  27883. private _webGLVersion;
  27884. protected _highPrecisionShadersAllowed: boolean;
  27885. /** @hidden */
  27886. readonly _shouldUseHighPrecisionShader: boolean;
  27887. /**
  27888. * Gets a boolean indicating that only power of 2 textures are supported
  27889. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27890. */
  27891. readonly needPOTTextures: boolean;
  27892. /** @hidden */
  27893. _badOS: boolean;
  27894. /** @hidden */
  27895. _badDesktopOS: boolean;
  27896. /**
  27897. * Gets the audio engine
  27898. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27899. * @ignorenaming
  27900. */
  27901. static audioEngine: IAudioEngine;
  27902. /**
  27903. * Default AudioEngine factory responsible of creating the Audio Engine.
  27904. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27905. */
  27906. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27907. /**
  27908. * Default offline support factory responsible of creating a tool used to store data locally.
  27909. * By default, this will create a Database object if the workload has been embedded.
  27910. */
  27911. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27912. private _onFocus;
  27913. private _onBlur;
  27914. private _onCanvasPointerOut;
  27915. private _onCanvasBlur;
  27916. private _onCanvasFocus;
  27917. private _onFullscreenChange;
  27918. private _onPointerLockChange;
  27919. private _hardwareScalingLevel;
  27920. /** @hidden */
  27921. _caps: EngineCapabilities;
  27922. private _pointerLockRequested;
  27923. private _isStencilEnable;
  27924. private _colorWrite;
  27925. private _loadingScreen;
  27926. /** @hidden */
  27927. _drawCalls: PerfCounter;
  27928. private _glVersion;
  27929. private _glRenderer;
  27930. private _glVendor;
  27931. private _videoTextureSupported;
  27932. private _renderingQueueLaunched;
  27933. private _activeRenderLoops;
  27934. private _deterministicLockstep;
  27935. private _lockstepMaxSteps;
  27936. /**
  27937. * Observable signaled when a context lost event is raised
  27938. */
  27939. onContextLostObservable: Observable<Engine>;
  27940. /**
  27941. * Observable signaled when a context restored event is raised
  27942. */
  27943. onContextRestoredObservable: Observable<Engine>;
  27944. private _onContextLost;
  27945. private _onContextRestored;
  27946. private _contextWasLost;
  27947. /** @hidden */
  27948. _doNotHandleContextLost: boolean;
  27949. /**
  27950. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27951. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27952. */
  27953. doNotHandleContextLost: boolean;
  27954. private _performanceMonitor;
  27955. private _fps;
  27956. private _deltaTime;
  27957. /**
  27958. * Turn this value on if you want to pause FPS computation when in background
  27959. */
  27960. disablePerformanceMonitorInBackground: boolean;
  27961. /**
  27962. * Gets the performance monitor attached to this engine
  27963. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27964. */
  27965. readonly performanceMonitor: PerformanceMonitor;
  27966. /**
  27967. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  27968. */
  27969. disableVertexArrayObjects: boolean;
  27970. /** @hidden */
  27971. protected _depthCullingState: _DepthCullingState;
  27972. /** @hidden */
  27973. protected _stencilState: _StencilState;
  27974. /** @hidden */
  27975. protected _alphaState: _AlphaState;
  27976. /** @hidden */
  27977. protected _alphaMode: number;
  27978. /** @hidden */
  27979. _internalTexturesCache: InternalTexture[];
  27980. /** @hidden */
  27981. protected _activeChannel: number;
  27982. private _currentTextureChannel;
  27983. /** @hidden */
  27984. protected _boundTexturesCache: {
  27985. [key: string]: Nullable<InternalTexture>;
  27986. };
  27987. /** @hidden */
  27988. protected _currentEffect: Nullable<Effect>;
  27989. /** @hidden */
  27990. protected _currentProgram: Nullable<WebGLProgram>;
  27991. private _compiledEffects;
  27992. private _vertexAttribArraysEnabled;
  27993. /** @hidden */
  27994. protected _cachedViewport: Nullable<Viewport>;
  27995. private _cachedVertexArrayObject;
  27996. /** @hidden */
  27997. protected _cachedVertexBuffers: any;
  27998. /** @hidden */
  27999. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  28000. /** @hidden */
  28001. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  28002. /** @hidden */
  28003. _currentRenderTarget: Nullable<InternalTexture>;
  28004. private _uintIndicesCurrentlySet;
  28005. private _currentBoundBuffer;
  28006. /** @hidden */
  28007. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  28008. private _currentBufferPointers;
  28009. private _currentInstanceLocations;
  28010. private _currentInstanceBuffers;
  28011. private _textureUnits;
  28012. /** @hidden */
  28013. _workingCanvas: Nullable<HTMLCanvasElement>;
  28014. /** @hidden */
  28015. _workingContext: Nullable<CanvasRenderingContext2D>;
  28016. private _rescalePostProcess;
  28017. private _dummyFramebuffer;
  28018. private _externalData;
  28019. /** @hidden */
  28020. _bindedRenderFunction: any;
  28021. private _vaoRecordInProgress;
  28022. private _mustWipeVertexAttributes;
  28023. private _emptyTexture;
  28024. private _emptyCubeTexture;
  28025. private _emptyTexture3D;
  28026. /** @hidden */
  28027. _frameHandler: number;
  28028. private _nextFreeTextureSlots;
  28029. private _maxSimultaneousTextures;
  28030. private _activeRequests;
  28031. private _texturesSupported;
  28032. /** @hidden */
  28033. _textureFormatInUse: Nullable<string>;
  28034. /**
  28035. * Gets the list of texture formats supported
  28036. */
  28037. readonly texturesSupported: Array<string>;
  28038. /**
  28039. * Gets the list of texture formats in use
  28040. */
  28041. readonly textureFormatInUse: Nullable<string>;
  28042. /**
  28043. * Gets the current viewport
  28044. */
  28045. readonly currentViewport: Nullable<Viewport>;
  28046. /**
  28047. * Gets the default empty texture
  28048. */
  28049. readonly emptyTexture: InternalTexture;
  28050. /**
  28051. * Gets the default empty 3D texture
  28052. */
  28053. readonly emptyTexture3D: InternalTexture;
  28054. /**
  28055. * Gets the default empty cube texture
  28056. */
  28057. readonly emptyCubeTexture: InternalTexture;
  28058. /**
  28059. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28060. */
  28061. readonly premultipliedAlpha: boolean;
  28062. /**
  28063. * Creates a new engine
  28064. * @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
  28065. * @param antialias defines enable antialiasing (default: false)
  28066. * @param options defines further options to be sent to the getContext() function
  28067. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  28068. */
  28069. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  28070. /**
  28071. * Initializes a webVR display and starts listening to display change events
  28072. * The onVRDisplayChangedObservable will be notified upon these changes
  28073. * @returns The onVRDisplayChangedObservable
  28074. */
  28075. initWebVR(): Observable<IDisplayChangedEventArgs>;
  28076. /** @hidden */
  28077. _prepareVRComponent(): void;
  28078. /** @hidden */
  28079. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  28080. /** @hidden */
  28081. _submitVRFrame(): void;
  28082. /**
  28083. * Call this function to leave webVR mode
  28084. * Will do nothing if webVR is not supported or if there is no webVR device
  28085. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28086. */
  28087. disableVR(): void;
  28088. /**
  28089. * Gets a boolean indicating that the system is in VR mode and is presenting
  28090. * @returns true if VR mode is engaged
  28091. */
  28092. isVRPresenting(): boolean;
  28093. /** @hidden */
  28094. _requestVRFrame(): void;
  28095. private _disableTouchAction;
  28096. private _rebuildInternalTextures;
  28097. private _rebuildEffects;
  28098. /**
  28099. * Gets a boolean indicating if all created effects are ready
  28100. * @returns true if all effects are ready
  28101. */
  28102. areAllEffectsReady(): boolean;
  28103. private _rebuildBuffers;
  28104. private _initGLContext;
  28105. /**
  28106. * Gets version of the current webGL context
  28107. */
  28108. readonly webGLVersion: number;
  28109. /**
  28110. * Gets a string idenfifying the name of the class
  28111. * @returns "Engine" string
  28112. */
  28113. getClassName(): string;
  28114. /**
  28115. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28116. */
  28117. readonly isStencilEnable: boolean;
  28118. /** @hidden */
  28119. _prepareWorkingCanvas(): void;
  28120. /**
  28121. * Reset the texture cache to empty state
  28122. */
  28123. resetTextureCache(): void;
  28124. /**
  28125. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  28126. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28127. * @returns true if engine is in deterministic lock step mode
  28128. */
  28129. isDeterministicLockStep(): boolean;
  28130. /**
  28131. * Gets the max steps when engine is running in deterministic lock step
  28132. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28133. * @returns the max steps
  28134. */
  28135. getLockstepMaxSteps(): number;
  28136. /**
  28137. * Gets an object containing information about the current webGL context
  28138. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28139. */
  28140. getGlInfo(): {
  28141. vendor: string;
  28142. renderer: string;
  28143. version: string;
  28144. };
  28145. /**
  28146. * Gets current aspect ratio
  28147. * @param camera defines the camera to use to get the aspect ratio
  28148. * @param useScreen defines if screen size must be used (or the current render target if any)
  28149. * @returns a number defining the aspect ratio
  28150. */
  28151. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  28152. /**
  28153. * Gets current screen aspect ratio
  28154. * @returns a number defining the aspect ratio
  28155. */
  28156. getScreenAspectRatio(): number;
  28157. /**
  28158. * Gets the current render width
  28159. * @param useScreen defines if screen size must be used (or the current render target if any)
  28160. * @returns a number defining the current render width
  28161. */
  28162. getRenderWidth(useScreen?: boolean): number;
  28163. /**
  28164. * Gets the current render height
  28165. * @param useScreen defines if screen size must be used (or the current render target if any)
  28166. * @returns a number defining the current render height
  28167. */
  28168. getRenderHeight(useScreen?: boolean): number;
  28169. /**
  28170. * Gets the HTML canvas attached with the current webGL context
  28171. * @returns a HTML canvas
  28172. */
  28173. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  28174. /**
  28175. * Gets the client rect of the HTML canvas attached with the current webGL context
  28176. * @returns a client rectanglee
  28177. */
  28178. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  28179. /**
  28180. * Defines the hardware scaling level.
  28181. * By default the hardware scaling level is computed from the window device ratio.
  28182. * 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.
  28183. * @param level defines the level to use
  28184. */
  28185. setHardwareScalingLevel(level: number): void;
  28186. /**
  28187. * Gets the current hardware scaling level.
  28188. * By default the hardware scaling level is computed from the window device ratio.
  28189. * 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.
  28190. * @returns a number indicating the current hardware scaling level
  28191. */
  28192. getHardwareScalingLevel(): number;
  28193. /**
  28194. * Gets the list of loaded textures
  28195. * @returns an array containing all loaded textures
  28196. */
  28197. getLoadedTexturesCache(): InternalTexture[];
  28198. /**
  28199. * Gets the object containing all engine capabilities
  28200. * @returns the EngineCapabilities object
  28201. */
  28202. getCaps(): EngineCapabilities;
  28203. /**
  28204. * Gets the current depth function
  28205. * @returns a number defining the depth function
  28206. */
  28207. getDepthFunction(): Nullable<number>;
  28208. /**
  28209. * Sets the current depth function
  28210. * @param depthFunc defines the function to use
  28211. */
  28212. setDepthFunction(depthFunc: number): void;
  28213. /**
  28214. * Sets the current depth function to GREATER
  28215. */
  28216. setDepthFunctionToGreater(): void;
  28217. /**
  28218. * Sets the current depth function to GEQUAL
  28219. */
  28220. setDepthFunctionToGreaterOrEqual(): void;
  28221. /**
  28222. * Sets the current depth function to LESS
  28223. */
  28224. setDepthFunctionToLess(): void;
  28225. private _cachedStencilBuffer;
  28226. private _cachedStencilFunction;
  28227. private _cachedStencilMask;
  28228. private _cachedStencilOperationPass;
  28229. private _cachedStencilOperationFail;
  28230. private _cachedStencilOperationDepthFail;
  28231. private _cachedStencilReference;
  28232. /**
  28233. * Caches the the state of the stencil buffer
  28234. */
  28235. cacheStencilState(): void;
  28236. /**
  28237. * Restores the state of the stencil buffer
  28238. */
  28239. restoreStencilState(): void;
  28240. /**
  28241. * Sets the current depth function to LEQUAL
  28242. */
  28243. setDepthFunctionToLessOrEqual(): void;
  28244. /**
  28245. * Gets a boolean indicating if stencil buffer is enabled
  28246. * @returns the current stencil buffer state
  28247. */
  28248. getStencilBuffer(): boolean;
  28249. /**
  28250. * Enable or disable the stencil buffer
  28251. * @param enable defines if the stencil buffer must be enabled or disabled
  28252. */
  28253. setStencilBuffer(enable: boolean): void;
  28254. /**
  28255. * Gets the current stencil mask
  28256. * @returns a number defining the new stencil mask to use
  28257. */
  28258. getStencilMask(): number;
  28259. /**
  28260. * Sets the current stencil mask
  28261. * @param mask defines the new stencil mask to use
  28262. */
  28263. setStencilMask(mask: number): void;
  28264. /**
  28265. * Gets the current stencil function
  28266. * @returns a number defining the stencil function to use
  28267. */
  28268. getStencilFunction(): number;
  28269. /**
  28270. * Gets the current stencil reference value
  28271. * @returns a number defining the stencil reference value to use
  28272. */
  28273. getStencilFunctionReference(): number;
  28274. /**
  28275. * Gets the current stencil mask
  28276. * @returns a number defining the stencil mask to use
  28277. */
  28278. getStencilFunctionMask(): number;
  28279. /**
  28280. * Sets the current stencil function
  28281. * @param stencilFunc defines the new stencil function to use
  28282. */
  28283. setStencilFunction(stencilFunc: number): void;
  28284. /**
  28285. * Sets the current stencil reference
  28286. * @param reference defines the new stencil reference to use
  28287. */
  28288. setStencilFunctionReference(reference: number): void;
  28289. /**
  28290. * Sets the current stencil mask
  28291. * @param mask defines the new stencil mask to use
  28292. */
  28293. setStencilFunctionMask(mask: number): void;
  28294. /**
  28295. * Gets the current stencil operation when stencil fails
  28296. * @returns a number defining stencil operation to use when stencil fails
  28297. */
  28298. getStencilOperationFail(): number;
  28299. /**
  28300. * Gets the current stencil operation when depth fails
  28301. * @returns a number defining stencil operation to use when depth fails
  28302. */
  28303. getStencilOperationDepthFail(): number;
  28304. /**
  28305. * Gets the current stencil operation when stencil passes
  28306. * @returns a number defining stencil operation to use when stencil passes
  28307. */
  28308. getStencilOperationPass(): number;
  28309. /**
  28310. * Sets the stencil operation to use when stencil fails
  28311. * @param operation defines the stencil operation to use when stencil fails
  28312. */
  28313. setStencilOperationFail(operation: number): void;
  28314. /**
  28315. * Sets the stencil operation to use when depth fails
  28316. * @param operation defines the stencil operation to use when depth fails
  28317. */
  28318. setStencilOperationDepthFail(operation: number): void;
  28319. /**
  28320. * Sets the stencil operation to use when stencil passes
  28321. * @param operation defines the stencil operation to use when stencil passes
  28322. */
  28323. setStencilOperationPass(operation: number): void;
  28324. /**
  28325. * Sets a boolean indicating if the dithering state is enabled or disabled
  28326. * @param value defines the dithering state
  28327. */
  28328. setDitheringState(value: boolean): void;
  28329. /**
  28330. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  28331. * @param value defines the rasterizer state
  28332. */
  28333. setRasterizerState(value: boolean): void;
  28334. /**
  28335. * stop executing a render loop function and remove it from the execution array
  28336. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28337. */
  28338. stopRenderLoop(renderFunction?: () => void): void;
  28339. /** @hidden */
  28340. _renderLoop(): void;
  28341. /**
  28342. * Register and execute a render loop. The engine can have more than one render function
  28343. * @param renderFunction defines the function to continuously execute
  28344. */
  28345. runRenderLoop(renderFunction: () => void): void;
  28346. /**
  28347. * Toggle full screen mode
  28348. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28349. */
  28350. switchFullscreen(requestPointerLock: boolean): void;
  28351. /**
  28352. * Enters full screen mode
  28353. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28354. */
  28355. enterFullscreen(requestPointerLock: boolean): void;
  28356. /**
  28357. * Exits full screen mode
  28358. */
  28359. exitFullscreen(): void;
  28360. /**
  28361. * Enters Pointerlock mode
  28362. */
  28363. enterPointerlock(): void;
  28364. /**
  28365. * Exits Pointerlock mode
  28366. */
  28367. exitPointerlock(): void;
  28368. /**
  28369. * Clear the current render buffer or the current render target (if any is set up)
  28370. * @param color defines the color to use
  28371. * @param backBuffer defines if the back buffer must be cleared
  28372. * @param depth defines if the depth buffer must be cleared
  28373. * @param stencil defines if the stencil buffer must be cleared
  28374. */
  28375. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  28376. /**
  28377. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  28378. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28379. * @param y defines the y-coordinate of the corner of the clear rectangle
  28380. * @param width defines the width of the clear rectangle
  28381. * @param height defines the height of the clear rectangle
  28382. * @param clearColor defines the clear color
  28383. */
  28384. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  28385. /**
  28386. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  28387. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28388. * @param y defines the y-coordinate of the corner of the clear rectangle
  28389. * @param width defines the width of the clear rectangle
  28390. * @param height defines the height of the clear rectangle
  28391. */
  28392. enableScissor(x: number, y: number, width: number, height: number): void;
  28393. /**
  28394. * Disable previously set scissor test rectangle
  28395. */
  28396. disableScissor(): void;
  28397. private _viewportCached;
  28398. /** @hidden */
  28399. _viewport(x: number, y: number, width: number, height: number): void;
  28400. /**
  28401. * Set the WebGL's viewport
  28402. * @param viewport defines the viewport element to be used
  28403. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28404. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28405. */
  28406. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  28407. /**
  28408. * Directly set the WebGL Viewport
  28409. * @param x defines the x coordinate of the viewport (in screen space)
  28410. * @param y defines the y coordinate of the viewport (in screen space)
  28411. * @param width defines the width of the viewport (in screen space)
  28412. * @param height defines the height of the viewport (in screen space)
  28413. * @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
  28414. */
  28415. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  28416. /**
  28417. * Begin a new frame
  28418. */
  28419. beginFrame(): void;
  28420. /**
  28421. * Enf the current frame
  28422. */
  28423. endFrame(): void;
  28424. /**
  28425. * Resize the view according to the canvas' size
  28426. */
  28427. resize(): void;
  28428. /**
  28429. * Force a specific size of the canvas
  28430. * @param width defines the new canvas' width
  28431. * @param height defines the new canvas' height
  28432. */
  28433. setSize(width: number, height: number): void;
  28434. /**
  28435. * Binds the frame buffer to the specified texture.
  28436. * @param texture The texture to render to or null for the default canvas
  28437. * @param faceIndex The face of the texture to render to in case of cube texture
  28438. * @param requiredWidth The width of the target to render to
  28439. * @param requiredHeight The height of the target to render to
  28440. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  28441. * @param depthStencilTexture The depth stencil texture to use to render
  28442. * @param lodLevel defines le lod level to bind to the frame buffer
  28443. */
  28444. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  28445. /** @hidden */
  28446. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  28447. /**
  28448. * Unbind the current render target texture from the webGL context
  28449. * @param texture defines the render target texture to unbind
  28450. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28451. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28452. */
  28453. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28454. /**
  28455. * Force the mipmap generation for the given render target texture
  28456. * @param texture defines the render target texture to use
  28457. */
  28458. generateMipMapsForCubemap(texture: InternalTexture): void;
  28459. /**
  28460. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  28461. */
  28462. flushFramebuffer(): void;
  28463. /**
  28464. * Unbind the current render target and bind the default framebuffer
  28465. */
  28466. restoreDefaultFramebuffer(): void;
  28467. /**
  28468. * Create an uniform buffer
  28469. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28470. * @param elements defines the content of the uniform buffer
  28471. * @returns the webGL uniform buffer
  28472. */
  28473. createUniformBuffer(elements: FloatArray): DataBuffer;
  28474. /**
  28475. * Create a dynamic uniform buffer
  28476. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28477. * @param elements defines the content of the uniform buffer
  28478. * @returns the webGL uniform buffer
  28479. */
  28480. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  28481. /**
  28482. * Update an existing uniform buffer
  28483. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28484. * @param uniformBuffer defines the target uniform buffer
  28485. * @param elements defines the content to update
  28486. * @param offset defines the offset in the uniform buffer where update should start
  28487. * @param count defines the size of the data to update
  28488. */
  28489. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  28490. private _resetVertexBufferBinding;
  28491. /**
  28492. * Creates a vertex buffer
  28493. * @param data the data for the vertex buffer
  28494. * @returns the new WebGL static buffer
  28495. */
  28496. createVertexBuffer(data: DataArray): DataBuffer;
  28497. /**
  28498. * Creates a dynamic vertex buffer
  28499. * @param data the data for the dynamic vertex buffer
  28500. * @returns the new WebGL dynamic buffer
  28501. */
  28502. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  28503. /**
  28504. * Update a dynamic index buffer
  28505. * @param indexBuffer defines the target index buffer
  28506. * @param indices defines the data to update
  28507. * @param offset defines the offset in the target index buffer where update should start
  28508. */
  28509. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  28510. /**
  28511. * Updates a dynamic vertex buffer.
  28512. * @param vertexBuffer the vertex buffer to update
  28513. * @param data the data used to update the vertex buffer
  28514. * @param byteOffset the byte offset of the data
  28515. * @param byteLength the byte length of the data
  28516. */
  28517. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  28518. private _resetIndexBufferBinding;
  28519. /**
  28520. * Creates a new index buffer
  28521. * @param indices defines the content of the index buffer
  28522. * @param updatable defines if the index buffer must be updatable
  28523. * @returns a new webGL buffer
  28524. */
  28525. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  28526. /**
  28527. * Bind a webGL buffer to the webGL context
  28528. * @param buffer defines the buffer to bind
  28529. */
  28530. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  28531. /**
  28532. * Bind an uniform buffer to the current webGL context
  28533. * @param buffer defines the buffer to bind
  28534. */
  28535. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  28536. /**
  28537. * Bind a buffer to the current webGL context at a given location
  28538. * @param buffer defines the buffer to bind
  28539. * @param location defines the index where to bind the buffer
  28540. */
  28541. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  28542. /**
  28543. * Bind a specific block at a given index in a specific shader program
  28544. * @param pipelineContext defines the pipeline context to use
  28545. * @param blockName defines the block name
  28546. * @param index defines the index where to bind the block
  28547. */
  28548. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  28549. private bindIndexBuffer;
  28550. private bindBuffer;
  28551. /**
  28552. * update the bound buffer with the given data
  28553. * @param data defines the data to update
  28554. */
  28555. updateArrayBuffer(data: Float32Array): void;
  28556. private _vertexAttribPointer;
  28557. private _bindIndexBufferWithCache;
  28558. private _bindVertexBuffersAttributes;
  28559. /**
  28560. * Records a vertex array object
  28561. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28562. * @param vertexBuffers defines the list of vertex buffers to store
  28563. * @param indexBuffer defines the index buffer to store
  28564. * @param effect defines the effect to store
  28565. * @returns the new vertex array object
  28566. */
  28567. recordVertexArrayObject(vertexBuffers: {
  28568. [key: string]: VertexBuffer;
  28569. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  28570. /**
  28571. * Bind a specific vertex array object
  28572. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28573. * @param vertexArrayObject defines the vertex array object to bind
  28574. * @param indexBuffer defines the index buffer to bind
  28575. */
  28576. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  28577. /**
  28578. * Bind webGl buffers directly to the webGL context
  28579. * @param vertexBuffer defines the vertex buffer to bind
  28580. * @param indexBuffer defines the index buffer to bind
  28581. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28582. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28583. * @param effect defines the effect associated with the vertex buffer
  28584. */
  28585. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28586. private _unbindVertexArrayObject;
  28587. /**
  28588. * Bind a list of vertex buffers to the webGL context
  28589. * @param vertexBuffers defines the list of vertex buffers to bind
  28590. * @param indexBuffer defines the index buffer to bind
  28591. * @param effect defines the effect associated with the vertex buffers
  28592. */
  28593. bindBuffers(vertexBuffers: {
  28594. [key: string]: Nullable<VertexBuffer>;
  28595. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  28596. /**
  28597. * Unbind all instance attributes
  28598. */
  28599. unbindInstanceAttributes(): void;
  28600. /**
  28601. * Release and free the memory of a vertex array object
  28602. * @param vao defines the vertex array object to delete
  28603. */
  28604. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28605. /** @hidden */
  28606. _releaseBuffer(buffer: DataBuffer): boolean;
  28607. /**
  28608. * Creates a webGL buffer to use with instanciation
  28609. * @param capacity defines the size of the buffer
  28610. * @returns the webGL buffer
  28611. */
  28612. createInstancesBuffer(capacity: number): DataBuffer;
  28613. /**
  28614. * Delete a webGL buffer used with instanciation
  28615. * @param buffer defines the webGL buffer to delete
  28616. */
  28617. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  28618. /**
  28619. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28620. * @param instancesBuffer defines the webGL buffer to update and bind
  28621. * @param data defines the data to store in the buffer
  28622. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28623. */
  28624. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  28625. /**
  28626. * Apply all cached states (depth, culling, stencil and alpha)
  28627. */
  28628. applyStates(): void;
  28629. /**
  28630. * Send a draw order
  28631. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28632. * @param indexStart defines the starting index
  28633. * @param indexCount defines the number of index to draw
  28634. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28635. */
  28636. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  28637. /**
  28638. * Draw a list of points
  28639. * @param verticesStart defines the index of first vertex to draw
  28640. * @param verticesCount defines the count of vertices to draw
  28641. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28642. */
  28643. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28644. /**
  28645. * Draw a list of unindexed primitives
  28646. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28647. * @param verticesStart defines the index of first vertex to draw
  28648. * @param verticesCount defines the count of vertices to draw
  28649. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28650. */
  28651. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28652. /**
  28653. * Draw a list of indexed primitives
  28654. * @param fillMode defines the primitive to use
  28655. * @param indexStart defines the starting index
  28656. * @param indexCount defines the number of index to draw
  28657. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28658. */
  28659. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  28660. /**
  28661. * Draw a list of unindexed primitives
  28662. * @param fillMode defines the primitive to use
  28663. * @param verticesStart defines the index of first vertex to draw
  28664. * @param verticesCount defines the count of vertices to draw
  28665. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28666. */
  28667. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28668. private _drawMode;
  28669. /** @hidden */
  28670. _releaseEffect(effect: Effect): void;
  28671. /** @hidden */
  28672. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  28673. /**
  28674. * Create a new effect (used to store vertex/fragment shaders)
  28675. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28676. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  28677. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  28678. * @param samplers defines an array of string used to represent textures
  28679. * @param defines defines the string containing the defines to use to compile the shaders
  28680. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28681. * @param onCompiled defines a function to call when the effect creation is successful
  28682. * @param onError defines a function to call when the effect creation has failed
  28683. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28684. * @returns the new Effect
  28685. */
  28686. 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;
  28687. private _compileShader;
  28688. private _compileRawShader;
  28689. /**
  28690. * Directly creates a webGL program
  28691. * @param pipelineContext defines the pipeline context to attach to
  28692. * @param vertexCode defines the vertex shader code to use
  28693. * @param fragmentCode defines the fragment shader code to use
  28694. * @param context defines the webGL context to use (if not set, the current one will be used)
  28695. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28696. * @returns the new webGL program
  28697. */
  28698. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28699. /**
  28700. * Creates a webGL program
  28701. * @param pipelineContext defines the pipeline context to attach to
  28702. * @param vertexCode defines the vertex shader code to use
  28703. * @param fragmentCode defines the fragment shader code to use
  28704. * @param defines defines the string containing the defines to use to compile the shaders
  28705. * @param context defines the webGL context to use (if not set, the current one will be used)
  28706. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28707. * @returns the new webGL program
  28708. */
  28709. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28710. /**
  28711. * Creates a new pipeline context
  28712. * @returns the new pipeline
  28713. */
  28714. createPipelineContext(): WebGLPipelineContext;
  28715. private _createShaderProgram;
  28716. private _finalizePipelineContext;
  28717. /** @hidden */
  28718. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  28719. /** @hidden */
  28720. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  28721. /** @hidden */
  28722. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  28723. /**
  28724. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28725. * @param pipelineContext defines the pipeline context to use
  28726. * @param uniformsNames defines the list of uniform names
  28727. * @returns an array of webGL uniform locations
  28728. */
  28729. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28730. /**
  28731. * Gets the lsit of active attributes for a given webGL program
  28732. * @param pipelineContext defines the pipeline context to use
  28733. * @param attributesNames defines the list of attribute names to get
  28734. * @returns an array of indices indicating the offset of each attribute
  28735. */
  28736. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  28737. /**
  28738. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28739. * @param effect defines the effect to activate
  28740. */
  28741. enableEffect(effect: Nullable<Effect>): void;
  28742. /**
  28743. * Set the value of an uniform to an array of int32
  28744. * @param uniform defines the webGL uniform location where to store the value
  28745. * @param array defines the array of int32 to store
  28746. */
  28747. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28748. /**
  28749. * Set the value of an uniform to an array of int32 (stored as vec2)
  28750. * @param uniform defines the webGL uniform location where to store the value
  28751. * @param array defines the array of int32 to store
  28752. */
  28753. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28754. /**
  28755. * Set the value of an uniform to an array of int32 (stored as vec3)
  28756. * @param uniform defines the webGL uniform location where to store the value
  28757. * @param array defines the array of int32 to store
  28758. */
  28759. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28760. /**
  28761. * Set the value of an uniform to an array of int32 (stored as vec4)
  28762. * @param uniform defines the webGL uniform location where to store the value
  28763. * @param array defines the array of int32 to store
  28764. */
  28765. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28766. /**
  28767. * Set the value of an uniform to an array of float32
  28768. * @param uniform defines the webGL uniform location where to store the value
  28769. * @param array defines the array of float32 to store
  28770. */
  28771. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28772. /**
  28773. * Set the value of an uniform to an array of float32 (stored as vec2)
  28774. * @param uniform defines the webGL uniform location where to store the value
  28775. * @param array defines the array of float32 to store
  28776. */
  28777. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28778. /**
  28779. * Set the value of an uniform to an array of float32 (stored as vec3)
  28780. * @param uniform defines the webGL uniform location where to store the value
  28781. * @param array defines the array of float32 to store
  28782. */
  28783. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28784. /**
  28785. * Set the value of an uniform to an array of float32 (stored as vec4)
  28786. * @param uniform defines the webGL uniform location where to store the value
  28787. * @param array defines the array of float32 to store
  28788. */
  28789. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28790. /**
  28791. * Set the value of an uniform to an array of number
  28792. * @param uniform defines the webGL uniform location where to store the value
  28793. * @param array defines the array of number to store
  28794. */
  28795. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28796. /**
  28797. * Set the value of an uniform to an array of number (stored as vec2)
  28798. * @param uniform defines the webGL uniform location where to store the value
  28799. * @param array defines the array of number to store
  28800. */
  28801. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28802. /**
  28803. * Set the value of an uniform to an array of number (stored as vec3)
  28804. * @param uniform defines the webGL uniform location where to store the value
  28805. * @param array defines the array of number to store
  28806. */
  28807. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28808. /**
  28809. * Set the value of an uniform to an array of number (stored as vec4)
  28810. * @param uniform defines the webGL uniform location where to store the value
  28811. * @param array defines the array of number to store
  28812. */
  28813. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28814. /**
  28815. * Set the value of an uniform to an array of float32 (stored as matrices)
  28816. * @param uniform defines the webGL uniform location where to store the value
  28817. * @param matrices defines the array of float32 to store
  28818. */
  28819. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28820. /**
  28821. * Set the value of an uniform to a matrix
  28822. * @param uniform defines the webGL uniform location where to store the value
  28823. * @param matrix defines the matrix to store
  28824. */
  28825. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28826. /**
  28827. * Set the value of an uniform to a matrix (3x3)
  28828. * @param uniform defines the webGL uniform location where to store the value
  28829. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28830. */
  28831. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28832. /**
  28833. * Set the value of an uniform to a matrix (2x2)
  28834. * @param uniform defines the webGL uniform location where to store the value
  28835. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28836. */
  28837. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28838. /**
  28839. * Set the value of an uniform to a number (int)
  28840. * @param uniform defines the webGL uniform location where to store the value
  28841. * @param value defines the int number to store
  28842. */
  28843. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28844. /**
  28845. * Set the value of an uniform to a number (float)
  28846. * @param uniform defines the webGL uniform location where to store the value
  28847. * @param value defines the float number to store
  28848. */
  28849. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28850. /**
  28851. * Set the value of an uniform to a vec2
  28852. * @param uniform defines the webGL uniform location where to store the value
  28853. * @param x defines the 1st component of the value
  28854. * @param y defines the 2nd component of the value
  28855. */
  28856. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28857. /**
  28858. * Set the value of an uniform to a vec3
  28859. * @param uniform defines the webGL uniform location where to store the value
  28860. * @param x defines the 1st component of the value
  28861. * @param y defines the 2nd component of the value
  28862. * @param z defines the 3rd component of the value
  28863. */
  28864. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28865. /**
  28866. * Set the value of an uniform to a boolean
  28867. * @param uniform defines the webGL uniform location where to store the value
  28868. * @param bool defines the boolean to store
  28869. */
  28870. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28871. /**
  28872. * Set the value of an uniform to a vec4
  28873. * @param uniform defines the webGL uniform location where to store the value
  28874. * @param x defines the 1st component of the value
  28875. * @param y defines the 2nd component of the value
  28876. * @param z defines the 3rd component of the value
  28877. * @param w defines the 4th component of the value
  28878. */
  28879. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28880. /**
  28881. * Set the value of an uniform to a Color3
  28882. * @param uniform defines the webGL uniform location where to store the value
  28883. * @param color3 defines the color to store
  28884. */
  28885. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28886. /**
  28887. * Set the value of an uniform to a Color3 and an alpha value
  28888. * @param uniform defines the webGL uniform location where to store the value
  28889. * @param color3 defines the color to store
  28890. * @param alpha defines the alpha component to store
  28891. */
  28892. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28893. /**
  28894. * Sets a Color4 on a uniform variable
  28895. * @param uniform defines the uniform location
  28896. * @param color4 defines the value to be set
  28897. */
  28898. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28899. /**
  28900. * Set various states to the webGL context
  28901. * @param culling defines backface culling state
  28902. * @param zOffset defines the value to apply to zOffset (0 by default)
  28903. * @param force defines if states must be applied even if cache is up to date
  28904. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28905. */
  28906. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28907. /**
  28908. * Set the z offset to apply to current rendering
  28909. * @param value defines the offset to apply
  28910. */
  28911. setZOffset(value: number): void;
  28912. /**
  28913. * Gets the current value of the zOffset
  28914. * @returns the current zOffset state
  28915. */
  28916. getZOffset(): number;
  28917. /**
  28918. * Enable or disable depth buffering
  28919. * @param enable defines the state to set
  28920. */
  28921. setDepthBuffer(enable: boolean): void;
  28922. /**
  28923. * Gets a boolean indicating if depth writing is enabled
  28924. * @returns the current depth writing state
  28925. */
  28926. getDepthWrite(): boolean;
  28927. /**
  28928. * Enable or disable depth writing
  28929. * @param enable defines the state to set
  28930. */
  28931. setDepthWrite(enable: boolean): void;
  28932. /**
  28933. * Enable or disable color writing
  28934. * @param enable defines the state to set
  28935. */
  28936. setColorWrite(enable: boolean): void;
  28937. /**
  28938. * Gets a boolean indicating if color writing is enabled
  28939. * @returns the current color writing state
  28940. */
  28941. getColorWrite(): boolean;
  28942. /**
  28943. * Sets alpha constants used by some alpha blending modes
  28944. * @param r defines the red component
  28945. * @param g defines the green component
  28946. * @param b defines the blue component
  28947. * @param a defines the alpha component
  28948. */
  28949. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28950. /**
  28951. * Sets the current alpha mode
  28952. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28953. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28954. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28955. */
  28956. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28957. /**
  28958. * Gets the current alpha mode
  28959. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28960. * @returns the current alpha mode
  28961. */
  28962. getAlphaMode(): number;
  28963. /**
  28964. * Clears the list of texture accessible through engine.
  28965. * This can help preventing texture load conflict due to name collision.
  28966. */
  28967. clearInternalTexturesCache(): void;
  28968. /**
  28969. * Force the entire cache to be cleared
  28970. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28971. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28972. */
  28973. wipeCaches(bruteForce?: boolean): void;
  28974. /**
  28975. * Set the compressed texture format to use, based on the formats you have, and the formats
  28976. * supported by the hardware / browser.
  28977. *
  28978. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28979. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28980. * to API arguments needed to compressed textures. This puts the burden on the container
  28981. * generator to house the arcane code for determining these for current & future formats.
  28982. *
  28983. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28984. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28985. *
  28986. * Note: The result of this call is not taken into account when a texture is base64.
  28987. *
  28988. * @param formatsAvailable defines the list of those format families you have created
  28989. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28990. *
  28991. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28992. * @returns The extension selected.
  28993. */
  28994. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28995. /** @hidden */
  28996. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  28997. min: number;
  28998. mag: number;
  28999. };
  29000. /** @hidden */
  29001. _createTexture(): WebGLTexture;
  29002. /**
  29003. * Usually called from Texture.ts.
  29004. * Passed information to create a WebGLTexture
  29005. * @param urlArg defines a value which contains one of the following:
  29006. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  29007. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  29008. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  29009. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  29010. * @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)
  29011. * @param scene needed for loading to the correct scene
  29012. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  29013. * @param onLoad optional callback to be called upon successful completion
  29014. * @param onError optional callback to be called upon failure
  29015. * @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
  29016. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  29017. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  29018. * @param forcedExtension defines the extension to use to pick the right loader
  29019. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29020. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29021. */
  29022. 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;
  29023. /**
  29024. * @hidden
  29025. * Rescales a texture
  29026. * @param source input texutre
  29027. * @param destination destination texture
  29028. * @param scene scene to use to render the resize
  29029. * @param internalFormat format to use when resizing
  29030. * @param onComplete callback to be called when resize has completed
  29031. */
  29032. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  29033. private _unpackFlipYCached;
  29034. /**
  29035. * In case you are sharing the context with other applications, it might
  29036. * be interested to not cache the unpack flip y state to ensure a consistent
  29037. * value would be set.
  29038. */
  29039. enableUnpackFlipYCached: boolean;
  29040. /** @hidden */
  29041. _unpackFlipY(value: boolean): void;
  29042. /** @hidden */
  29043. _getUnpackAlignement(): number;
  29044. /**
  29045. * Creates a dynamic texture
  29046. * @param width defines the width of the texture
  29047. * @param height defines the height of the texture
  29048. * @param generateMipMaps defines if the engine should generate the mip levels
  29049. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29050. * @returns the dynamic texture inside an InternalTexture
  29051. */
  29052. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  29053. /**
  29054. * Update the sampling mode of a given texture
  29055. * @param samplingMode defines the required sampling mode
  29056. * @param texture defines the texture to update
  29057. */
  29058. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29059. /**
  29060. * Update the content of a dynamic texture
  29061. * @param texture defines the texture to update
  29062. * @param canvas defines the canvas containing the source
  29063. * @param invertY defines if data must be stored with Y axis inverted
  29064. * @param premulAlpha defines if alpha is stored as premultiplied
  29065. * @param format defines the format of the data
  29066. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  29067. */
  29068. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  29069. /**
  29070. * Update a video texture
  29071. * @param texture defines the texture to update
  29072. * @param video defines the video element to use
  29073. * @param invertY defines if data must be stored with Y axis inverted
  29074. */
  29075. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29076. /**
  29077. * Updates a depth texture Comparison Mode and Function.
  29078. * If the comparison Function is equal to 0, the mode will be set to none.
  29079. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  29080. * @param texture The texture to set the comparison function for
  29081. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  29082. */
  29083. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  29084. /** @hidden */
  29085. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  29086. width: number;
  29087. height: number;
  29088. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  29089. /**
  29090. * Creates a depth stencil texture.
  29091. * This is only available in WebGL 2 or with the depth texture extension available.
  29092. * @param size The size of face edge in the texture.
  29093. * @param options The options defining the texture.
  29094. * @returns The texture
  29095. */
  29096. createDepthStencilTexture(size: number | {
  29097. width: number;
  29098. height: number;
  29099. }, options: DepthTextureCreationOptions): InternalTexture;
  29100. /**
  29101. * Creates a depth stencil texture.
  29102. * This is only available in WebGL 2 or with the depth texture extension available.
  29103. * @param size The size of face edge in the texture.
  29104. * @param options The options defining the texture.
  29105. * @returns The texture
  29106. */
  29107. private _createDepthStencilTexture;
  29108. /**
  29109. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  29110. * @param renderTarget The render target to set the frame buffer for
  29111. */
  29112. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  29113. /**
  29114. * Creates a new render target texture
  29115. * @param size defines the size of the texture
  29116. * @param options defines the options used to create the texture
  29117. * @returns a new render target texture stored in an InternalTexture
  29118. */
  29119. createRenderTargetTexture(size: number | {
  29120. width: number;
  29121. height: number;
  29122. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  29123. /** @hidden */
  29124. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  29125. /**
  29126. * Updates the sample count of a render target texture
  29127. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29128. * @param texture defines the texture to update
  29129. * @param samples defines the sample count to set
  29130. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29131. */
  29132. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  29133. /** @hidden */
  29134. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29135. /** @hidden */
  29136. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  29137. /** @hidden */
  29138. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29139. /** @hidden */
  29140. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  29141. /**
  29142. * @hidden
  29143. */
  29144. _setCubeMapTextureParams(loadMipmap: boolean): void;
  29145. private _prepareWebGLTextureContinuation;
  29146. private _prepareWebGLTexture;
  29147. /** @hidden */
  29148. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  29149. /** @hidden */
  29150. _releaseFramebufferObjects(texture: InternalTexture): void;
  29151. /** @hidden */
  29152. _releaseTexture(texture: InternalTexture): void;
  29153. private setProgram;
  29154. private _boundUniforms;
  29155. /**
  29156. * Binds an effect to the webGL context
  29157. * @param effect defines the effect to bind
  29158. */
  29159. bindSamplers(effect: Effect): void;
  29160. private _activateCurrentTexture;
  29161. /** @hidden */
  29162. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29163. /** @hidden */
  29164. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29165. /**
  29166. * Sets a texture to the webGL context from a postprocess
  29167. * @param channel defines the channel to use
  29168. * @param postProcess defines the source postprocess
  29169. */
  29170. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  29171. /**
  29172. * Binds the output of the passed in post process to the texture channel specified
  29173. * @param channel The channel the texture should be bound to
  29174. * @param postProcess The post process which's output should be bound
  29175. */
  29176. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  29177. /**
  29178. * Unbind all textures from the webGL context
  29179. */
  29180. unbindAllTextures(): void;
  29181. /**
  29182. * Sets a texture to the according uniform.
  29183. * @param channel The texture channel
  29184. * @param uniform The uniform to set
  29185. * @param texture The texture to apply
  29186. */
  29187. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29188. /**
  29189. * Sets a depth stencil texture from a render target to the according uniform.
  29190. * @param channel The texture channel
  29191. * @param uniform The uniform to set
  29192. * @param texture The render target texture containing the depth stencil texture to apply
  29193. */
  29194. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  29195. private _bindSamplerUniformToChannel;
  29196. private _getTextureWrapMode;
  29197. private _setTexture;
  29198. /**
  29199. * Sets an array of texture to the webGL context
  29200. * @param channel defines the channel where the texture array must be set
  29201. * @param uniform defines the associated uniform location
  29202. * @param textures defines the array of textures to bind
  29203. */
  29204. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29205. /** @hidden */
  29206. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29207. private _setTextureParameterFloat;
  29208. private _setTextureParameterInteger;
  29209. /**
  29210. * Reads pixels from the current frame buffer. Please note that this function can be slow
  29211. * @param x defines the x coordinate of the rectangle where pixels must be read
  29212. * @param y defines the y coordinate of the rectangle where pixels must be read
  29213. * @param width defines the width of the rectangle where pixels must be read
  29214. * @param height defines the height of the rectangle where pixels must be read
  29215. * @returns a Uint8Array containing RGBA colors
  29216. */
  29217. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  29218. /**
  29219. * Add an externaly attached data from its key.
  29220. * This method call will fail and return false, if such key already exists.
  29221. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  29222. * @param key the unique key that identifies the data
  29223. * @param data the data object to associate to the key for this Engine instance
  29224. * @return true if no such key were already present and the data was added successfully, false otherwise
  29225. */
  29226. addExternalData<T>(key: string, data: T): boolean;
  29227. /**
  29228. * Get an externaly attached data from its key
  29229. * @param key the unique key that identifies the data
  29230. * @return the associated data, if present (can be null), or undefined if not present
  29231. */
  29232. getExternalData<T>(key: string): T;
  29233. /**
  29234. * Get an externaly attached data from its key, create it using a factory if it's not already present
  29235. * @param key the unique key that identifies the data
  29236. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  29237. * @return the associated data, can be null if the factory returned null.
  29238. */
  29239. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  29240. /**
  29241. * Remove an externaly attached data from the Engine instance
  29242. * @param key the unique key that identifies the data
  29243. * @return true if the data was successfully removed, false if it doesn't exist
  29244. */
  29245. removeExternalData(key: string): boolean;
  29246. /**
  29247. * Unbind all vertex attributes from the webGL context
  29248. */
  29249. unbindAllAttributes(): void;
  29250. /**
  29251. * 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
  29252. */
  29253. releaseEffects(): void;
  29254. /**
  29255. * Dispose and release all associated resources
  29256. */
  29257. dispose(): void;
  29258. /**
  29259. * Display the loading screen
  29260. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29261. */
  29262. displayLoadingUI(): void;
  29263. /**
  29264. * Hide the loading screen
  29265. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29266. */
  29267. hideLoadingUI(): void;
  29268. /**
  29269. * Gets the current loading screen object
  29270. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29271. */
  29272. /**
  29273. * Sets the current loading screen object
  29274. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29275. */
  29276. loadingScreen: ILoadingScreen;
  29277. /**
  29278. * Sets the current loading screen text
  29279. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29280. */
  29281. loadingUIText: string;
  29282. /**
  29283. * Sets the current loading screen background color
  29284. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29285. */
  29286. loadingUIBackgroundColor: string;
  29287. /**
  29288. * Attach a new callback raised when context lost event is fired
  29289. * @param callback defines the callback to call
  29290. */
  29291. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29292. /**
  29293. * Attach a new callback raised when context restored event is fired
  29294. * @param callback defines the callback to call
  29295. */
  29296. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29297. /**
  29298. * Gets the source code of the vertex shader associated with a specific webGL program
  29299. * @param program defines the program to use
  29300. * @returns a string containing the source code of the vertex shader associated with the program
  29301. */
  29302. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  29303. /**
  29304. * Gets the source code of the fragment shader associated with a specific webGL program
  29305. * @param program defines the program to use
  29306. * @returns a string containing the source code of the fragment shader associated with the program
  29307. */
  29308. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  29309. /**
  29310. * Get the current error code of the webGL context
  29311. * @returns the error code
  29312. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  29313. */
  29314. getError(): number;
  29315. /**
  29316. * Gets the current framerate
  29317. * @returns a number representing the framerate
  29318. */
  29319. getFps(): number;
  29320. /**
  29321. * Gets the time spent between current and previous frame
  29322. * @returns a number representing the delta time in ms
  29323. */
  29324. getDeltaTime(): number;
  29325. private _measureFps;
  29326. /** @hidden */
  29327. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  29328. private _canRenderToFloatFramebuffer;
  29329. private _canRenderToHalfFloatFramebuffer;
  29330. private _canRenderToFramebuffer;
  29331. /** @hidden */
  29332. _getWebGLTextureType(type: number): number;
  29333. /** @hidden */
  29334. _getInternalFormat(format: number): number;
  29335. /** @hidden */
  29336. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  29337. /** @hidden */
  29338. _getRGBAMultiSampleBufferFormat(type: number): number;
  29339. /** @hidden */
  29340. _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;
  29341. /** @hidden */
  29342. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  29343. /**
  29344. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29345. * @returns true if the engine can be created
  29346. * @ignorenaming
  29347. */
  29348. static isSupported(): boolean;
  29349. }
  29350. }
  29351. declare module BABYLON {
  29352. /**
  29353. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  29354. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  29355. */
  29356. export class EffectFallbacks {
  29357. private _defines;
  29358. private _currentRank;
  29359. private _maxRank;
  29360. private _mesh;
  29361. /**
  29362. * Removes the fallback from the bound mesh.
  29363. */
  29364. unBindMesh(): void;
  29365. /**
  29366. * Adds a fallback on the specified property.
  29367. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29368. * @param define The name of the define in the shader
  29369. */
  29370. addFallback(rank: number, define: string): void;
  29371. /**
  29372. * Sets the mesh to use CPU skinning when needing to fallback.
  29373. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29374. * @param mesh The mesh to use the fallbacks.
  29375. */
  29376. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29377. /**
  29378. * Checks to see if more fallbacks are still availible.
  29379. */
  29380. readonly isMoreFallbacks: boolean;
  29381. /**
  29382. * Removes the defines that should be removed when falling back.
  29383. * @param currentDefines defines the current define statements for the shader.
  29384. * @param effect defines the current effect we try to compile
  29385. * @returns The resulting defines with defines of the current rank removed.
  29386. */
  29387. reduce(currentDefines: string, effect: Effect): string;
  29388. }
  29389. /**
  29390. * Options to be used when creating an effect.
  29391. */
  29392. export class EffectCreationOptions {
  29393. /**
  29394. * Atrributes that will be used in the shader.
  29395. */
  29396. attributes: string[];
  29397. /**
  29398. * Uniform varible names that will be set in the shader.
  29399. */
  29400. uniformsNames: string[];
  29401. /**
  29402. * Uniform buffer varible names that will be set in the shader.
  29403. */
  29404. uniformBuffersNames: string[];
  29405. /**
  29406. * Sampler texture variable names that will be set in the shader.
  29407. */
  29408. samplers: string[];
  29409. /**
  29410. * Define statements that will be set in the shader.
  29411. */
  29412. defines: any;
  29413. /**
  29414. * Possible fallbacks for this effect to improve performance when needed.
  29415. */
  29416. fallbacks: Nullable<EffectFallbacks>;
  29417. /**
  29418. * Callback that will be called when the shader is compiled.
  29419. */
  29420. onCompiled: Nullable<(effect: Effect) => void>;
  29421. /**
  29422. * Callback that will be called if an error occurs during shader compilation.
  29423. */
  29424. onError: Nullable<(effect: Effect, errors: string) => void>;
  29425. /**
  29426. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29427. */
  29428. indexParameters: any;
  29429. /**
  29430. * Max number of lights that can be used in the shader.
  29431. */
  29432. maxSimultaneousLights: number;
  29433. /**
  29434. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29435. */
  29436. transformFeedbackVaryings: Nullable<string[]>;
  29437. }
  29438. /**
  29439. * Effect containing vertex and fragment shader that can be executed on an object.
  29440. */
  29441. export class Effect implements IDisposable {
  29442. /**
  29443. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29444. */
  29445. static ShadersRepository: string;
  29446. /**
  29447. * Name of the effect.
  29448. */
  29449. name: any;
  29450. /**
  29451. * String container all the define statements that should be set on the shader.
  29452. */
  29453. defines: string;
  29454. /**
  29455. * Callback that will be called when the shader is compiled.
  29456. */
  29457. onCompiled: Nullable<(effect: Effect) => void>;
  29458. /**
  29459. * Callback that will be called if an error occurs during shader compilation.
  29460. */
  29461. onError: Nullable<(effect: Effect, errors: string) => void>;
  29462. /**
  29463. * Callback that will be called when effect is bound.
  29464. */
  29465. onBind: Nullable<(effect: Effect) => void>;
  29466. /**
  29467. * Unique ID of the effect.
  29468. */
  29469. uniqueId: number;
  29470. /**
  29471. * Observable that will be called when the shader is compiled.
  29472. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29473. */
  29474. onCompileObservable: Observable<Effect>;
  29475. /**
  29476. * Observable that will be called if an error occurs during shader compilation.
  29477. */
  29478. onErrorObservable: Observable<Effect>;
  29479. /** @hidden */
  29480. _onBindObservable: Nullable<Observable<Effect>>;
  29481. /**
  29482. * Observable that will be called when effect is bound.
  29483. */
  29484. readonly onBindObservable: Observable<Effect>;
  29485. /** @hidden */
  29486. _bonesComputationForcedToCPU: boolean;
  29487. private static _uniqueIdSeed;
  29488. private _engine;
  29489. private _uniformBuffersNames;
  29490. private _uniformsNames;
  29491. private _samplerList;
  29492. private _samplers;
  29493. private _isReady;
  29494. private _compilationError;
  29495. private _attributesNames;
  29496. private _attributes;
  29497. private _uniforms;
  29498. /**
  29499. * Key for the effect.
  29500. * @hidden
  29501. */
  29502. _key: string;
  29503. private _indexParameters;
  29504. private _fallbacks;
  29505. private _vertexSourceCode;
  29506. private _fragmentSourceCode;
  29507. private _vertexSourceCodeOverride;
  29508. private _fragmentSourceCodeOverride;
  29509. private _transformFeedbackVaryings;
  29510. /**
  29511. * Compiled shader to webGL program.
  29512. * @hidden
  29513. */
  29514. _pipelineContext: Nullable<IPipelineContext>;
  29515. private _valueCache;
  29516. private static _baseCache;
  29517. /**
  29518. * Instantiates an effect.
  29519. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29520. * @param baseName Name of the effect.
  29521. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29522. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29523. * @param samplers List of sampler variables that will be passed to the shader.
  29524. * @param engine Engine to be used to render the effect
  29525. * @param defines Define statements to be added to the shader.
  29526. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29527. * @param onCompiled Callback that will be called when the shader is compiled.
  29528. * @param onError Callback that will be called if an error occurs during shader compilation.
  29529. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29530. */
  29531. 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);
  29532. private _useFinalCode;
  29533. /**
  29534. * Unique key for this effect
  29535. */
  29536. readonly key: string;
  29537. /**
  29538. * If the effect has been compiled and prepared.
  29539. * @returns if the effect is compiled and prepared.
  29540. */
  29541. isReady(): boolean;
  29542. /**
  29543. * The engine the effect was initialized with.
  29544. * @returns the engine.
  29545. */
  29546. getEngine(): Engine;
  29547. /**
  29548. * The pipeline context for this effect
  29549. * @returns the associated pipeline context
  29550. */
  29551. getPipelineContext(): Nullable<IPipelineContext>;
  29552. /**
  29553. * The set of names of attribute variables for the shader.
  29554. * @returns An array of attribute names.
  29555. */
  29556. getAttributesNames(): string[];
  29557. /**
  29558. * Returns the attribute at the given index.
  29559. * @param index The index of the attribute.
  29560. * @returns The location of the attribute.
  29561. */
  29562. getAttributeLocation(index: number): number;
  29563. /**
  29564. * Returns the attribute based on the name of the variable.
  29565. * @param name of the attribute to look up.
  29566. * @returns the attribute location.
  29567. */
  29568. getAttributeLocationByName(name: string): number;
  29569. /**
  29570. * The number of attributes.
  29571. * @returns the numnber of attributes.
  29572. */
  29573. getAttributesCount(): number;
  29574. /**
  29575. * Gets the index of a uniform variable.
  29576. * @param uniformName of the uniform to look up.
  29577. * @returns the index.
  29578. */
  29579. getUniformIndex(uniformName: string): number;
  29580. /**
  29581. * Returns the attribute based on the name of the variable.
  29582. * @param uniformName of the uniform to look up.
  29583. * @returns the location of the uniform.
  29584. */
  29585. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29586. /**
  29587. * Returns an array of sampler variable names
  29588. * @returns The array of sampler variable neames.
  29589. */
  29590. getSamplers(): string[];
  29591. /**
  29592. * The error from the last compilation.
  29593. * @returns the error string.
  29594. */
  29595. getCompilationError(): string;
  29596. /**
  29597. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29598. * @param func The callback to be used.
  29599. */
  29600. executeWhenCompiled(func: (effect: Effect) => void): void;
  29601. private _checkIsReady;
  29602. /** @hidden */
  29603. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29604. /** @hidden */
  29605. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29606. /** @hidden */
  29607. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29608. /**
  29609. * Recompiles the webGL program
  29610. * @param vertexSourceCode The source code for the vertex shader.
  29611. * @param fragmentSourceCode The source code for the fragment shader.
  29612. * @param onCompiled Callback called when completed.
  29613. * @param onError Callback called on error.
  29614. * @hidden
  29615. */
  29616. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29617. /**
  29618. * Prepares the effect
  29619. * @hidden
  29620. */
  29621. _prepareEffect(): void;
  29622. /**
  29623. * Checks if the effect is supported. (Must be called after compilation)
  29624. */
  29625. readonly isSupported: boolean;
  29626. /**
  29627. * Binds a texture to the engine to be used as output of the shader.
  29628. * @param channel Name of the output variable.
  29629. * @param texture Texture to bind.
  29630. * @hidden
  29631. */
  29632. _bindTexture(channel: string, texture: InternalTexture): void;
  29633. /**
  29634. * Sets a texture on the engine to be used in the shader.
  29635. * @param channel Name of the sampler variable.
  29636. * @param texture Texture to set.
  29637. */
  29638. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29639. /**
  29640. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29641. * @param channel Name of the sampler variable.
  29642. * @param texture Texture to set.
  29643. */
  29644. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29645. /**
  29646. * Sets an array of textures on the engine to be used in the shader.
  29647. * @param channel Name of the variable.
  29648. * @param textures Textures to set.
  29649. */
  29650. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29651. /**
  29652. * 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)
  29653. * @param channel Name of the sampler variable.
  29654. * @param postProcess Post process to get the input texture from.
  29655. */
  29656. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29657. /**
  29658. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29659. * 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)
  29660. * @param channel Name of the sampler variable.
  29661. * @param postProcess Post process to get the output texture from.
  29662. */
  29663. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29664. /** @hidden */
  29665. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29666. /** @hidden */
  29667. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29668. /** @hidden */
  29669. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29670. /** @hidden */
  29671. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29672. /**
  29673. * Binds a buffer to a uniform.
  29674. * @param buffer Buffer to bind.
  29675. * @param name Name of the uniform variable to bind to.
  29676. */
  29677. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29678. /**
  29679. * Binds block to a uniform.
  29680. * @param blockName Name of the block to bind.
  29681. * @param index Index to bind.
  29682. */
  29683. bindUniformBlock(blockName: string, index: number): void;
  29684. /**
  29685. * Sets an interger value on a uniform variable.
  29686. * @param uniformName Name of the variable.
  29687. * @param value Value to be set.
  29688. * @returns this effect.
  29689. */
  29690. setInt(uniformName: string, value: number): Effect;
  29691. /**
  29692. * Sets an int array on a uniform variable.
  29693. * @param uniformName Name of the variable.
  29694. * @param array array to be set.
  29695. * @returns this effect.
  29696. */
  29697. setIntArray(uniformName: string, array: Int32Array): Effect;
  29698. /**
  29699. * 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)
  29700. * @param uniformName Name of the variable.
  29701. * @param array array to be set.
  29702. * @returns this effect.
  29703. */
  29704. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29705. /**
  29706. * 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)
  29707. * @param uniformName Name of the variable.
  29708. * @param array array to be set.
  29709. * @returns this effect.
  29710. */
  29711. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29712. /**
  29713. * 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)
  29714. * @param uniformName Name of the variable.
  29715. * @param array array to be set.
  29716. * @returns this effect.
  29717. */
  29718. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29719. /**
  29720. * Sets an float array on a uniform variable.
  29721. * @param uniformName Name of the variable.
  29722. * @param array array to be set.
  29723. * @returns this effect.
  29724. */
  29725. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29726. /**
  29727. * 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)
  29728. * @param uniformName Name of the variable.
  29729. * @param array array to be set.
  29730. * @returns this effect.
  29731. */
  29732. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29733. /**
  29734. * 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)
  29735. * @param uniformName Name of the variable.
  29736. * @param array array to be set.
  29737. * @returns this effect.
  29738. */
  29739. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29740. /**
  29741. * 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)
  29742. * @param uniformName Name of the variable.
  29743. * @param array array to be set.
  29744. * @returns this effect.
  29745. */
  29746. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29747. /**
  29748. * Sets an array on a uniform variable.
  29749. * @param uniformName Name of the variable.
  29750. * @param array array to be set.
  29751. * @returns this effect.
  29752. */
  29753. setArray(uniformName: string, array: number[]): Effect;
  29754. /**
  29755. * 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)
  29756. * @param uniformName Name of the variable.
  29757. * @param array array to be set.
  29758. * @returns this effect.
  29759. */
  29760. setArray2(uniformName: string, array: number[]): Effect;
  29761. /**
  29762. * 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)
  29763. * @param uniformName Name of the variable.
  29764. * @param array array to be set.
  29765. * @returns this effect.
  29766. */
  29767. setArray3(uniformName: string, array: number[]): Effect;
  29768. /**
  29769. * 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)
  29770. * @param uniformName Name of the variable.
  29771. * @param array array to be set.
  29772. * @returns this effect.
  29773. */
  29774. setArray4(uniformName: string, array: number[]): Effect;
  29775. /**
  29776. * Sets matrices on a uniform variable.
  29777. * @param uniformName Name of the variable.
  29778. * @param matrices matrices to be set.
  29779. * @returns this effect.
  29780. */
  29781. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29782. /**
  29783. * Sets matrix on a uniform variable.
  29784. * @param uniformName Name of the variable.
  29785. * @param matrix matrix to be set.
  29786. * @returns this effect.
  29787. */
  29788. setMatrix(uniformName: string, matrix: Matrix): Effect;
  29789. /**
  29790. * 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)
  29791. * @param uniformName Name of the variable.
  29792. * @param matrix matrix to be set.
  29793. * @returns this effect.
  29794. */
  29795. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29796. /**
  29797. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29798. * @param uniformName Name of the variable.
  29799. * @param matrix matrix to be set.
  29800. * @returns this effect.
  29801. */
  29802. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29803. /**
  29804. * Sets a float on a uniform variable.
  29805. * @param uniformName Name of the variable.
  29806. * @param value value to be set.
  29807. * @returns this effect.
  29808. */
  29809. setFloat(uniformName: string, value: number): Effect;
  29810. /**
  29811. * Sets a boolean on a uniform variable.
  29812. * @param uniformName Name of the variable.
  29813. * @param bool value to be set.
  29814. * @returns this effect.
  29815. */
  29816. setBool(uniformName: string, bool: boolean): Effect;
  29817. /**
  29818. * Sets a Vector2 on a uniform variable.
  29819. * @param uniformName Name of the variable.
  29820. * @param vector2 vector2 to be set.
  29821. * @returns this effect.
  29822. */
  29823. setVector2(uniformName: string, vector2: Vector2): Effect;
  29824. /**
  29825. * Sets a float2 on a uniform variable.
  29826. * @param uniformName Name of the variable.
  29827. * @param x First float in float2.
  29828. * @param y Second float in float2.
  29829. * @returns this effect.
  29830. */
  29831. setFloat2(uniformName: string, x: number, y: number): Effect;
  29832. /**
  29833. * Sets a Vector3 on a uniform variable.
  29834. * @param uniformName Name of the variable.
  29835. * @param vector3 Value to be set.
  29836. * @returns this effect.
  29837. */
  29838. setVector3(uniformName: string, vector3: Vector3): Effect;
  29839. /**
  29840. * Sets a float3 on a uniform variable.
  29841. * @param uniformName Name of the variable.
  29842. * @param x First float in float3.
  29843. * @param y Second float in float3.
  29844. * @param z Third float in float3.
  29845. * @returns this effect.
  29846. */
  29847. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29848. /**
  29849. * Sets a Vector4 on a uniform variable.
  29850. * @param uniformName Name of the variable.
  29851. * @param vector4 Value to be set.
  29852. * @returns this effect.
  29853. */
  29854. setVector4(uniformName: string, vector4: Vector4): Effect;
  29855. /**
  29856. * Sets a float4 on a uniform variable.
  29857. * @param uniformName Name of the variable.
  29858. * @param x First float in float4.
  29859. * @param y Second float in float4.
  29860. * @param z Third float in float4.
  29861. * @param w Fourth float in float4.
  29862. * @returns this effect.
  29863. */
  29864. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29865. /**
  29866. * Sets a Color3 on a uniform variable.
  29867. * @param uniformName Name of the variable.
  29868. * @param color3 Value to be set.
  29869. * @returns this effect.
  29870. */
  29871. setColor3(uniformName: string, color3: Color3): Effect;
  29872. /**
  29873. * Sets a Color4 on a uniform variable.
  29874. * @param uniformName Name of the variable.
  29875. * @param color3 Value to be set.
  29876. * @param alpha Alpha value to be set.
  29877. * @returns this effect.
  29878. */
  29879. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  29880. /**
  29881. * Sets a Color4 on a uniform variable
  29882. * @param uniformName defines the name of the variable
  29883. * @param color4 defines the value to be set
  29884. * @returns this effect.
  29885. */
  29886. setDirectColor4(uniformName: string, color4: Color4): Effect;
  29887. /** Release all associated resources */
  29888. dispose(): void;
  29889. /**
  29890. * This function will add a new shader to the shader store
  29891. * @param name the name of the shader
  29892. * @param pixelShader optional pixel shader content
  29893. * @param vertexShader optional vertex shader content
  29894. */
  29895. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29896. /**
  29897. * Store of each shader (The can be looked up using effect.key)
  29898. */
  29899. static ShadersStore: {
  29900. [key: string]: string;
  29901. };
  29902. /**
  29903. * Store of each included file for a shader (The can be looked up using effect.key)
  29904. */
  29905. static IncludesShadersStore: {
  29906. [key: string]: string;
  29907. };
  29908. /**
  29909. * Resets the cache of effects.
  29910. */
  29911. static ResetCache(): void;
  29912. }
  29913. }
  29914. declare module BABYLON {
  29915. /**
  29916. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29917. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29918. * 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;
  29919. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29920. */
  29921. export class ColorCurves {
  29922. private _dirty;
  29923. private _tempColor;
  29924. private _globalCurve;
  29925. private _highlightsCurve;
  29926. private _midtonesCurve;
  29927. private _shadowsCurve;
  29928. private _positiveCurve;
  29929. private _negativeCurve;
  29930. private _globalHue;
  29931. private _globalDensity;
  29932. private _globalSaturation;
  29933. private _globalExposure;
  29934. /**
  29935. * Gets the global Hue value.
  29936. * 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).
  29937. */
  29938. /**
  29939. * Sets the global Hue value.
  29940. * 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).
  29941. */
  29942. globalHue: number;
  29943. /**
  29944. * Gets the global Density value.
  29945. * 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.
  29946. * Values less than zero provide a filter of opposite hue.
  29947. */
  29948. /**
  29949. * Sets the global Density value.
  29950. * 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.
  29951. * Values less than zero provide a filter of opposite hue.
  29952. */
  29953. globalDensity: number;
  29954. /**
  29955. * Gets the global Saturation value.
  29956. * 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.
  29957. */
  29958. /**
  29959. * Sets the global Saturation value.
  29960. * 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.
  29961. */
  29962. globalSaturation: number;
  29963. /**
  29964. * Gets the global Exposure value.
  29965. * 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.
  29966. */
  29967. /**
  29968. * Sets the global Exposure value.
  29969. * 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.
  29970. */
  29971. globalExposure: number;
  29972. private _highlightsHue;
  29973. private _highlightsDensity;
  29974. private _highlightsSaturation;
  29975. private _highlightsExposure;
  29976. /**
  29977. * Gets the highlights Hue value.
  29978. * 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).
  29979. */
  29980. /**
  29981. * Sets the highlights Hue value.
  29982. * 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).
  29983. */
  29984. highlightsHue: number;
  29985. /**
  29986. * Gets the highlights Density value.
  29987. * 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.
  29988. * Values less than zero provide a filter of opposite hue.
  29989. */
  29990. /**
  29991. * Sets the highlights Density value.
  29992. * 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.
  29993. * Values less than zero provide a filter of opposite hue.
  29994. */
  29995. highlightsDensity: number;
  29996. /**
  29997. * Gets the highlights Saturation value.
  29998. * 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.
  29999. */
  30000. /**
  30001. * Sets the highlights Saturation value.
  30002. * 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.
  30003. */
  30004. highlightsSaturation: number;
  30005. /**
  30006. * Gets the highlights Exposure value.
  30007. * 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.
  30008. */
  30009. /**
  30010. * Sets the highlights Exposure value.
  30011. * 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.
  30012. */
  30013. highlightsExposure: number;
  30014. private _midtonesHue;
  30015. private _midtonesDensity;
  30016. private _midtonesSaturation;
  30017. private _midtonesExposure;
  30018. /**
  30019. * Gets the midtones Hue value.
  30020. * 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).
  30021. */
  30022. /**
  30023. * Sets the midtones Hue value.
  30024. * 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).
  30025. */
  30026. midtonesHue: number;
  30027. /**
  30028. * Gets the midtones Density value.
  30029. * 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.
  30030. * Values less than zero provide a filter of opposite hue.
  30031. */
  30032. /**
  30033. * Sets the midtones Density value.
  30034. * 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.
  30035. * Values less than zero provide a filter of opposite hue.
  30036. */
  30037. midtonesDensity: number;
  30038. /**
  30039. * Gets the midtones Saturation value.
  30040. * 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.
  30041. */
  30042. /**
  30043. * Sets the midtones Saturation value.
  30044. * 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.
  30045. */
  30046. midtonesSaturation: number;
  30047. /**
  30048. * Gets the midtones Exposure value.
  30049. * 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.
  30050. */
  30051. /**
  30052. * Sets the midtones Exposure value.
  30053. * 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.
  30054. */
  30055. midtonesExposure: number;
  30056. private _shadowsHue;
  30057. private _shadowsDensity;
  30058. private _shadowsSaturation;
  30059. private _shadowsExposure;
  30060. /**
  30061. * Gets the shadows Hue value.
  30062. * 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).
  30063. */
  30064. /**
  30065. * Sets the shadows Hue value.
  30066. * 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).
  30067. */
  30068. shadowsHue: number;
  30069. /**
  30070. * Gets the shadows Density value.
  30071. * 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.
  30072. * Values less than zero provide a filter of opposite hue.
  30073. */
  30074. /**
  30075. * Sets the shadows Density value.
  30076. * 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.
  30077. * Values less than zero provide a filter of opposite hue.
  30078. */
  30079. shadowsDensity: number;
  30080. /**
  30081. * Gets the shadows Saturation value.
  30082. * 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.
  30083. */
  30084. /**
  30085. * Sets the shadows Saturation value.
  30086. * 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.
  30087. */
  30088. shadowsSaturation: number;
  30089. /**
  30090. * Gets the shadows Exposure value.
  30091. * 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.
  30092. */
  30093. /**
  30094. * Sets the shadows Exposure value.
  30095. * 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.
  30096. */
  30097. shadowsExposure: number;
  30098. /**
  30099. * Returns the class name
  30100. * @returns The class name
  30101. */
  30102. getClassName(): string;
  30103. /**
  30104. * Binds the color curves to the shader.
  30105. * @param colorCurves The color curve to bind
  30106. * @param effect The effect to bind to
  30107. * @param positiveUniform The positive uniform shader parameter
  30108. * @param neutralUniform The neutral uniform shader parameter
  30109. * @param negativeUniform The negative uniform shader parameter
  30110. */
  30111. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  30112. /**
  30113. * Prepare the list of uniforms associated with the ColorCurves effects.
  30114. * @param uniformsList The list of uniforms used in the effect
  30115. */
  30116. static PrepareUniforms(uniformsList: string[]): void;
  30117. /**
  30118. * Returns color grading data based on a hue, density, saturation and exposure value.
  30119. * @param filterHue The hue of the color filter.
  30120. * @param filterDensity The density of the color filter.
  30121. * @param saturation The saturation.
  30122. * @param exposure The exposure.
  30123. * @param result The result data container.
  30124. */
  30125. private getColorGradingDataToRef;
  30126. /**
  30127. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  30128. * @param value The input slider value in range [-100,100].
  30129. * @returns Adjusted value.
  30130. */
  30131. private static applyColorGradingSliderNonlinear;
  30132. /**
  30133. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  30134. * @param hue The hue (H) input.
  30135. * @param saturation The saturation (S) input.
  30136. * @param brightness The brightness (B) input.
  30137. * @result An RGBA color represented as Vector4.
  30138. */
  30139. private static fromHSBToRef;
  30140. /**
  30141. * Returns a value clamped between min and max
  30142. * @param value The value to clamp
  30143. * @param min The minimum of value
  30144. * @param max The maximum of value
  30145. * @returns The clamped value.
  30146. */
  30147. private static clamp;
  30148. /**
  30149. * Clones the current color curve instance.
  30150. * @return The cloned curves
  30151. */
  30152. clone(): ColorCurves;
  30153. /**
  30154. * Serializes the current color curve instance to a json representation.
  30155. * @return a JSON representation
  30156. */
  30157. serialize(): any;
  30158. /**
  30159. * Parses the color curve from a json representation.
  30160. * @param source the JSON source to parse
  30161. * @return The parsed curves
  30162. */
  30163. static Parse(source: any): ColorCurves;
  30164. }
  30165. }
  30166. declare module BABYLON {
  30167. /**
  30168. * Interface to follow in your material defines to integrate easily the
  30169. * Image proccessing functions.
  30170. * @hidden
  30171. */
  30172. export interface IImageProcessingConfigurationDefines {
  30173. IMAGEPROCESSING: boolean;
  30174. VIGNETTE: boolean;
  30175. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30176. VIGNETTEBLENDMODEOPAQUE: boolean;
  30177. TONEMAPPING: boolean;
  30178. TONEMAPPING_ACES: boolean;
  30179. CONTRAST: boolean;
  30180. EXPOSURE: boolean;
  30181. COLORCURVES: boolean;
  30182. COLORGRADING: boolean;
  30183. COLORGRADING3D: boolean;
  30184. SAMPLER3DGREENDEPTH: boolean;
  30185. SAMPLER3DBGRMAP: boolean;
  30186. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30187. }
  30188. /**
  30189. * @hidden
  30190. */
  30191. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30192. IMAGEPROCESSING: boolean;
  30193. VIGNETTE: boolean;
  30194. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30195. VIGNETTEBLENDMODEOPAQUE: boolean;
  30196. TONEMAPPING: boolean;
  30197. TONEMAPPING_ACES: boolean;
  30198. CONTRAST: boolean;
  30199. COLORCURVES: boolean;
  30200. COLORGRADING: boolean;
  30201. COLORGRADING3D: boolean;
  30202. SAMPLER3DGREENDEPTH: boolean;
  30203. SAMPLER3DBGRMAP: boolean;
  30204. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30205. EXPOSURE: boolean;
  30206. constructor();
  30207. }
  30208. /**
  30209. * This groups together the common properties used for image processing either in direct forward pass
  30210. * or through post processing effect depending on the use of the image processing pipeline in your scene
  30211. * or not.
  30212. */
  30213. export class ImageProcessingConfiguration {
  30214. /**
  30215. * Default tone mapping applied in BabylonJS.
  30216. */
  30217. static readonly TONEMAPPING_STANDARD: number;
  30218. /**
  30219. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  30220. * to other engines rendering to increase portability.
  30221. */
  30222. static readonly TONEMAPPING_ACES: number;
  30223. /**
  30224. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  30225. */
  30226. colorCurves: Nullable<ColorCurves>;
  30227. private _colorCurvesEnabled;
  30228. /**
  30229. * Gets wether the color curves effect is enabled.
  30230. */
  30231. /**
  30232. * Sets wether the color curves effect is enabled.
  30233. */
  30234. colorCurvesEnabled: boolean;
  30235. private _colorGradingTexture;
  30236. /**
  30237. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30238. */
  30239. /**
  30240. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30241. */
  30242. colorGradingTexture: Nullable<BaseTexture>;
  30243. private _colorGradingEnabled;
  30244. /**
  30245. * Gets wether the color grading effect is enabled.
  30246. */
  30247. /**
  30248. * Sets wether the color grading effect is enabled.
  30249. */
  30250. colorGradingEnabled: boolean;
  30251. private _colorGradingWithGreenDepth;
  30252. /**
  30253. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  30254. */
  30255. /**
  30256. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  30257. */
  30258. colorGradingWithGreenDepth: boolean;
  30259. private _colorGradingBGR;
  30260. /**
  30261. * Gets wether the color grading texture contains BGR values.
  30262. */
  30263. /**
  30264. * Sets wether the color grading texture contains BGR values.
  30265. */
  30266. colorGradingBGR: boolean;
  30267. /** @hidden */
  30268. _exposure: number;
  30269. /**
  30270. * Gets the Exposure used in the effect.
  30271. */
  30272. /**
  30273. * Sets the Exposure used in the effect.
  30274. */
  30275. exposure: number;
  30276. private _toneMappingEnabled;
  30277. /**
  30278. * Gets wether the tone mapping effect is enabled.
  30279. */
  30280. /**
  30281. * Sets wether the tone mapping effect is enabled.
  30282. */
  30283. toneMappingEnabled: boolean;
  30284. private _toneMappingType;
  30285. /**
  30286. * Gets the type of tone mapping effect.
  30287. */
  30288. /**
  30289. * Sets the type of tone mapping effect used in BabylonJS.
  30290. */
  30291. toneMappingType: number;
  30292. protected _contrast: number;
  30293. /**
  30294. * Gets the contrast used in the effect.
  30295. */
  30296. /**
  30297. * Sets the contrast used in the effect.
  30298. */
  30299. contrast: number;
  30300. /**
  30301. * Vignette stretch size.
  30302. */
  30303. vignetteStretch: number;
  30304. /**
  30305. * Vignette centre X Offset.
  30306. */
  30307. vignetteCentreX: number;
  30308. /**
  30309. * Vignette centre Y Offset.
  30310. */
  30311. vignetteCentreY: number;
  30312. /**
  30313. * Vignette weight or intensity of the vignette effect.
  30314. */
  30315. vignetteWeight: number;
  30316. /**
  30317. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  30318. * if vignetteEnabled is set to true.
  30319. */
  30320. vignetteColor: Color4;
  30321. /**
  30322. * Camera field of view used by the Vignette effect.
  30323. */
  30324. vignetteCameraFov: number;
  30325. private _vignetteBlendMode;
  30326. /**
  30327. * Gets the vignette blend mode allowing different kind of effect.
  30328. */
  30329. /**
  30330. * Sets the vignette blend mode allowing different kind of effect.
  30331. */
  30332. vignetteBlendMode: number;
  30333. private _vignetteEnabled;
  30334. /**
  30335. * Gets wether the vignette effect is enabled.
  30336. */
  30337. /**
  30338. * Sets wether the vignette effect is enabled.
  30339. */
  30340. vignetteEnabled: boolean;
  30341. private _applyByPostProcess;
  30342. /**
  30343. * Gets wether the image processing is applied through a post process or not.
  30344. */
  30345. /**
  30346. * Sets wether the image processing is applied through a post process or not.
  30347. */
  30348. applyByPostProcess: boolean;
  30349. private _isEnabled;
  30350. /**
  30351. * Gets wether the image processing is enabled or not.
  30352. */
  30353. /**
  30354. * Sets wether the image processing is enabled or not.
  30355. */
  30356. isEnabled: boolean;
  30357. /**
  30358. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  30359. */
  30360. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  30361. /**
  30362. * Method called each time the image processing information changes requires to recompile the effect.
  30363. */
  30364. protected _updateParameters(): void;
  30365. /**
  30366. * Gets the current class name.
  30367. * @return "ImageProcessingConfiguration"
  30368. */
  30369. getClassName(): string;
  30370. /**
  30371. * Prepare the list of uniforms associated with the Image Processing effects.
  30372. * @param uniforms The list of uniforms used in the effect
  30373. * @param defines the list of defines currently in use
  30374. */
  30375. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  30376. /**
  30377. * Prepare the list of samplers associated with the Image Processing effects.
  30378. * @param samplersList The list of uniforms used in the effect
  30379. * @param defines the list of defines currently in use
  30380. */
  30381. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  30382. /**
  30383. * Prepare the list of defines associated to the shader.
  30384. * @param defines the list of defines to complete
  30385. * @param forPostProcess Define if we are currently in post process mode or not
  30386. */
  30387. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  30388. /**
  30389. * Returns true if all the image processing information are ready.
  30390. * @returns True if ready, otherwise, false
  30391. */
  30392. isReady(): boolean;
  30393. /**
  30394. * Binds the image processing to the shader.
  30395. * @param effect The effect to bind to
  30396. * @param aspectRatio Define the current aspect ratio of the effect
  30397. */
  30398. bind(effect: Effect, aspectRatio?: number): void;
  30399. /**
  30400. * Clones the current image processing instance.
  30401. * @return The cloned image processing
  30402. */
  30403. clone(): ImageProcessingConfiguration;
  30404. /**
  30405. * Serializes the current image processing instance to a json representation.
  30406. * @return a JSON representation
  30407. */
  30408. serialize(): any;
  30409. /**
  30410. * Parses the image processing from a json representation.
  30411. * @param source the JSON source to parse
  30412. * @return The parsed image processing
  30413. */
  30414. static Parse(source: any): ImageProcessingConfiguration;
  30415. private static _VIGNETTEMODE_MULTIPLY;
  30416. private static _VIGNETTEMODE_OPAQUE;
  30417. /**
  30418. * Used to apply the vignette as a mix with the pixel color.
  30419. */
  30420. static readonly VIGNETTEMODE_MULTIPLY: number;
  30421. /**
  30422. * Used to apply the vignette as a replacement of the pixel color.
  30423. */
  30424. static readonly VIGNETTEMODE_OPAQUE: number;
  30425. }
  30426. }
  30427. declare module BABYLON {
  30428. /**
  30429. * This represents all the required information to add a fresnel effect on a material:
  30430. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30431. */
  30432. export class FresnelParameters {
  30433. private _isEnabled;
  30434. /**
  30435. * Define if the fresnel effect is enable or not.
  30436. */
  30437. isEnabled: boolean;
  30438. /**
  30439. * Define the color used on edges (grazing angle)
  30440. */
  30441. leftColor: Color3;
  30442. /**
  30443. * Define the color used on center
  30444. */
  30445. rightColor: Color3;
  30446. /**
  30447. * Define bias applied to computed fresnel term
  30448. */
  30449. bias: number;
  30450. /**
  30451. * Defined the power exponent applied to fresnel term
  30452. */
  30453. power: number;
  30454. /**
  30455. * Clones the current fresnel and its valuues
  30456. * @returns a clone fresnel configuration
  30457. */
  30458. clone(): FresnelParameters;
  30459. /**
  30460. * Serializes the current fresnel parameters to a JSON representation.
  30461. * @return the JSON serialization
  30462. */
  30463. serialize(): any;
  30464. /**
  30465. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30466. * @param parsedFresnelParameters Define the JSON representation
  30467. * @returns the parsed parameters
  30468. */
  30469. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30470. }
  30471. }
  30472. declare module BABYLON {
  30473. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30474. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30475. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30476. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30477. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30478. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30479. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30480. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30481. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30482. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30483. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30484. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30485. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30486. /**
  30487. * Decorator used to define property that can be serialized as reference to a camera
  30488. * @param sourceName defines the name of the property to decorate
  30489. */
  30490. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30491. /**
  30492. * Class used to help serialization objects
  30493. */
  30494. export class SerializationHelper {
  30495. /** @hidden */
  30496. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  30497. /** @hidden */
  30498. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  30499. /** @hidden */
  30500. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  30501. /** @hidden */
  30502. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  30503. /**
  30504. * Appends the serialized animations from the source animations
  30505. * @param source Source containing the animations
  30506. * @param destination Target to store the animations
  30507. */
  30508. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30509. /**
  30510. * Static function used to serialized a specific entity
  30511. * @param entity defines the entity to serialize
  30512. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30513. * @returns a JSON compatible object representing the serialization of the entity
  30514. */
  30515. static Serialize<T>(entity: T, serializationObject?: any): any;
  30516. /**
  30517. * Creates a new entity from a serialization data object
  30518. * @param creationFunction defines a function used to instanciated the new entity
  30519. * @param source defines the source serialization data
  30520. * @param scene defines the hosting scene
  30521. * @param rootUrl defines the root url for resources
  30522. * @returns a new entity
  30523. */
  30524. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30525. /**
  30526. * Clones an object
  30527. * @param creationFunction defines the function used to instanciate the new object
  30528. * @param source defines the source object
  30529. * @returns the cloned object
  30530. */
  30531. static Clone<T>(creationFunction: () => T, source: T): T;
  30532. /**
  30533. * Instanciates a new object based on a source one (some data will be shared between both object)
  30534. * @param creationFunction defines the function used to instanciate the new object
  30535. * @param source defines the source object
  30536. * @returns the new object
  30537. */
  30538. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30539. }
  30540. }
  30541. declare module BABYLON {
  30542. /**
  30543. * This is the base class of all the camera used in the application.
  30544. * @see http://doc.babylonjs.com/features/cameras
  30545. */
  30546. export class Camera extends Node {
  30547. /** @hidden */
  30548. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30549. /**
  30550. * This is the default projection mode used by the cameras.
  30551. * It helps recreating a feeling of perspective and better appreciate depth.
  30552. * This is the best way to simulate real life cameras.
  30553. */
  30554. static readonly PERSPECTIVE_CAMERA: number;
  30555. /**
  30556. * This helps creating camera with an orthographic mode.
  30557. * 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.
  30558. */
  30559. static readonly ORTHOGRAPHIC_CAMERA: number;
  30560. /**
  30561. * This is the default FOV mode for perspective cameras.
  30562. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30563. */
  30564. static readonly FOVMODE_VERTICAL_FIXED: number;
  30565. /**
  30566. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30567. */
  30568. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30569. /**
  30570. * This specifies ther is no need for a camera rig.
  30571. * Basically only one eye is rendered corresponding to the camera.
  30572. */
  30573. static readonly RIG_MODE_NONE: number;
  30574. /**
  30575. * Simulates a camera Rig with one blue eye and one red eye.
  30576. * This can be use with 3d blue and red glasses.
  30577. */
  30578. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30579. /**
  30580. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30581. */
  30582. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30583. /**
  30584. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30585. */
  30586. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30587. /**
  30588. * Defines that both eyes of the camera will be rendered over under each other.
  30589. */
  30590. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30591. /**
  30592. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30593. */
  30594. static readonly RIG_MODE_VR: number;
  30595. /**
  30596. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30597. */
  30598. static readonly RIG_MODE_WEBVR: number;
  30599. /**
  30600. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30601. */
  30602. static readonly RIG_MODE_CUSTOM: number;
  30603. /**
  30604. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30605. */
  30606. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30607. /**
  30608. * Define the input manager associated with the camera.
  30609. */
  30610. inputs: CameraInputsManager<Camera>;
  30611. /** @hidden */
  30612. _position: Vector3;
  30613. /**
  30614. * Define the current local position of the camera in the scene
  30615. */
  30616. position: Vector3;
  30617. /**
  30618. * The vector the camera should consider as up.
  30619. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30620. */
  30621. upVector: Vector3;
  30622. /**
  30623. * Define the current limit on the left side for an orthographic camera
  30624. * In scene unit
  30625. */
  30626. orthoLeft: Nullable<number>;
  30627. /**
  30628. * Define the current limit on the right side for an orthographic camera
  30629. * In scene unit
  30630. */
  30631. orthoRight: Nullable<number>;
  30632. /**
  30633. * Define the current limit on the bottom side for an orthographic camera
  30634. * In scene unit
  30635. */
  30636. orthoBottom: Nullable<number>;
  30637. /**
  30638. * Define the current limit on the top side for an orthographic camera
  30639. * In scene unit
  30640. */
  30641. orthoTop: Nullable<number>;
  30642. /**
  30643. * Field Of View is set in Radians. (default is 0.8)
  30644. */
  30645. fov: number;
  30646. /**
  30647. * Define the minimum distance the camera can see from.
  30648. * This is important to note that the depth buffer are not infinite and the closer it starts
  30649. * the more your scene might encounter depth fighting issue.
  30650. */
  30651. minZ: number;
  30652. /**
  30653. * Define the maximum distance the camera can see to.
  30654. * This is important to note that the depth buffer are not infinite and the further it end
  30655. * the more your scene might encounter depth fighting issue.
  30656. */
  30657. maxZ: number;
  30658. /**
  30659. * Define the default inertia of the camera.
  30660. * This helps giving a smooth feeling to the camera movement.
  30661. */
  30662. inertia: number;
  30663. /**
  30664. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  30665. */
  30666. mode: number;
  30667. /**
  30668. * Define wether the camera is intermediate.
  30669. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30670. */
  30671. isIntermediate: boolean;
  30672. /**
  30673. * Define the viewport of the camera.
  30674. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30675. */
  30676. viewport: Viewport;
  30677. /**
  30678. * Restricts the camera to viewing objects with the same layerMask.
  30679. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30680. */
  30681. layerMask: number;
  30682. /**
  30683. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30684. */
  30685. fovMode: number;
  30686. /**
  30687. * Rig mode of the camera.
  30688. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30689. * This is normally controlled byt the camera themselves as internal use.
  30690. */
  30691. cameraRigMode: number;
  30692. /**
  30693. * Defines the distance between both "eyes" in case of a RIG
  30694. */
  30695. interaxialDistance: number;
  30696. /**
  30697. * Defines if stereoscopic rendering is done side by side or over under.
  30698. */
  30699. isStereoscopicSideBySide: boolean;
  30700. /**
  30701. * 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
  30702. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30703. * else in the scene.
  30704. */
  30705. customRenderTargets: RenderTargetTexture[];
  30706. /**
  30707. * When set, the camera will render to this render target instead of the default canvas
  30708. */
  30709. outputRenderTarget: Nullable<RenderTargetTexture>;
  30710. /**
  30711. * Observable triggered when the camera view matrix has changed.
  30712. */
  30713. onViewMatrixChangedObservable: Observable<Camera>;
  30714. /**
  30715. * Observable triggered when the camera Projection matrix has changed.
  30716. */
  30717. onProjectionMatrixChangedObservable: Observable<Camera>;
  30718. /**
  30719. * Observable triggered when the inputs have been processed.
  30720. */
  30721. onAfterCheckInputsObservable: Observable<Camera>;
  30722. /**
  30723. * Observable triggered when reset has been called and applied to the camera.
  30724. */
  30725. onRestoreStateObservable: Observable<Camera>;
  30726. /** @hidden */
  30727. _cameraRigParams: any;
  30728. /** @hidden */
  30729. _rigCameras: Camera[];
  30730. /** @hidden */
  30731. _rigPostProcess: Nullable<PostProcess>;
  30732. protected _webvrViewMatrix: Matrix;
  30733. /** @hidden */
  30734. _skipRendering: boolean;
  30735. /** @hidden */
  30736. _projectionMatrix: Matrix;
  30737. /** @hidden */
  30738. _postProcesses: Nullable<PostProcess>[];
  30739. /** @hidden */
  30740. _activeMeshes: SmartArray<AbstractMesh>;
  30741. protected _globalPosition: Vector3;
  30742. /** @hidden */
  30743. _computedViewMatrix: Matrix;
  30744. private _doNotComputeProjectionMatrix;
  30745. private _transformMatrix;
  30746. private _frustumPlanes;
  30747. private _refreshFrustumPlanes;
  30748. private _storedFov;
  30749. private _stateStored;
  30750. /**
  30751. * Instantiates a new camera object.
  30752. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30753. * @see http://doc.babylonjs.com/features/cameras
  30754. * @param name Defines the name of the camera in the scene
  30755. * @param position Defines the position of the camera
  30756. * @param scene Defines the scene the camera belongs too
  30757. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30758. */
  30759. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30760. /**
  30761. * Store current camera state (fov, position, etc..)
  30762. * @returns the camera
  30763. */
  30764. storeState(): Camera;
  30765. /**
  30766. * Restores the camera state values if it has been stored. You must call storeState() first
  30767. */
  30768. protected _restoreStateValues(): boolean;
  30769. /**
  30770. * Restored camera state. You must call storeState() first.
  30771. * @returns true if restored and false otherwise
  30772. */
  30773. restoreState(): boolean;
  30774. /**
  30775. * Gets the class name of the camera.
  30776. * @returns the class name
  30777. */
  30778. getClassName(): string;
  30779. /** @hidden */
  30780. readonly _isCamera: boolean;
  30781. /**
  30782. * Gets a string representation of the camera useful for debug purpose.
  30783. * @param fullDetails Defines that a more verboe level of logging is required
  30784. * @returns the string representation
  30785. */
  30786. toString(fullDetails?: boolean): string;
  30787. /**
  30788. * Gets the current world space position of the camera.
  30789. */
  30790. readonly globalPosition: Vector3;
  30791. /**
  30792. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30793. * @returns the active meshe list
  30794. */
  30795. getActiveMeshes(): SmartArray<AbstractMesh>;
  30796. /**
  30797. * Check wether a mesh is part of the current active mesh list of the camera
  30798. * @param mesh Defines the mesh to check
  30799. * @returns true if active, false otherwise
  30800. */
  30801. isActiveMesh(mesh: Mesh): boolean;
  30802. /**
  30803. * Is this camera ready to be used/rendered
  30804. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30805. * @return true if the camera is ready
  30806. */
  30807. isReady(completeCheck?: boolean): boolean;
  30808. /** @hidden */
  30809. _initCache(): void;
  30810. /** @hidden */
  30811. _updateCache(ignoreParentClass?: boolean): void;
  30812. /** @hidden */
  30813. _isSynchronized(): boolean;
  30814. /** @hidden */
  30815. _isSynchronizedViewMatrix(): boolean;
  30816. /** @hidden */
  30817. _isSynchronizedProjectionMatrix(): boolean;
  30818. /**
  30819. * Attach the input controls to a specific dom element to get the input from.
  30820. * @param element Defines the element the controls should be listened from
  30821. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30822. */
  30823. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30824. /**
  30825. * Detach the current controls from the specified dom element.
  30826. * @param element Defines the element to stop listening the inputs from
  30827. */
  30828. detachControl(element: HTMLElement): void;
  30829. /**
  30830. * Update the camera state according to the different inputs gathered during the frame.
  30831. */
  30832. update(): void;
  30833. /** @hidden */
  30834. _checkInputs(): void;
  30835. /** @hidden */
  30836. readonly rigCameras: Camera[];
  30837. /**
  30838. * Gets the post process used by the rig cameras
  30839. */
  30840. readonly rigPostProcess: Nullable<PostProcess>;
  30841. /**
  30842. * Internal, gets the first post proces.
  30843. * @returns the first post process to be run on this camera.
  30844. */
  30845. _getFirstPostProcess(): Nullable<PostProcess>;
  30846. private _cascadePostProcessesToRigCams;
  30847. /**
  30848. * Attach a post process to the camera.
  30849. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30850. * @param postProcess The post process to attach to the camera
  30851. * @param insertAt The position of the post process in case several of them are in use in the scene
  30852. * @returns the position the post process has been inserted at
  30853. */
  30854. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30855. /**
  30856. * Detach a post process to the camera.
  30857. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30858. * @param postProcess The post process to detach from the camera
  30859. */
  30860. detachPostProcess(postProcess: PostProcess): void;
  30861. /**
  30862. * Gets the current world matrix of the camera
  30863. */
  30864. getWorldMatrix(): Matrix;
  30865. /** @hidden */
  30866. _getViewMatrix(): Matrix;
  30867. /**
  30868. * Gets the current view matrix of the camera.
  30869. * @param force forces the camera to recompute the matrix without looking at the cached state
  30870. * @returns the view matrix
  30871. */
  30872. getViewMatrix(force?: boolean): Matrix;
  30873. /**
  30874. * Freeze the projection matrix.
  30875. * It will prevent the cache check of the camera projection compute and can speed up perf
  30876. * if no parameter of the camera are meant to change
  30877. * @param projection Defines manually a projection if necessary
  30878. */
  30879. freezeProjectionMatrix(projection?: Matrix): void;
  30880. /**
  30881. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30882. */
  30883. unfreezeProjectionMatrix(): void;
  30884. /**
  30885. * Gets the current projection matrix of the camera.
  30886. * @param force forces the camera to recompute the matrix without looking at the cached state
  30887. * @returns the projection matrix
  30888. */
  30889. getProjectionMatrix(force?: boolean): Matrix;
  30890. /**
  30891. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30892. * @returns a Matrix
  30893. */
  30894. getTransformationMatrix(): Matrix;
  30895. private _updateFrustumPlanes;
  30896. /**
  30897. * Checks if a cullable object (mesh...) is in the camera frustum
  30898. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30899. * @param target The object to check
  30900. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  30901. * @returns true if the object is in frustum otherwise false
  30902. */
  30903. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  30904. /**
  30905. * Checks if a cullable object (mesh...) is in the camera frustum
  30906. * Unlike isInFrustum this cheks the full bounding box
  30907. * @param target The object to check
  30908. * @returns true if the object is in frustum otherwise false
  30909. */
  30910. isCompletelyInFrustum(target: ICullable): boolean;
  30911. /**
  30912. * Gets a ray in the forward direction from the camera.
  30913. * @param length Defines the length of the ray to create
  30914. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30915. * @param origin Defines the start point of the ray which defaults to the camera position
  30916. * @returns the forward ray
  30917. */
  30918. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30919. /**
  30920. * Releases resources associated with this node.
  30921. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30922. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30923. */
  30924. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30925. /** @hidden */
  30926. _isLeftCamera: boolean;
  30927. /**
  30928. * Gets the left camera of a rig setup in case of Rigged Camera
  30929. */
  30930. readonly isLeftCamera: boolean;
  30931. /** @hidden */
  30932. _isRightCamera: boolean;
  30933. /**
  30934. * Gets the right camera of a rig setup in case of Rigged Camera
  30935. */
  30936. readonly isRightCamera: boolean;
  30937. /**
  30938. * Gets the left camera of a rig setup in case of Rigged Camera
  30939. */
  30940. readonly leftCamera: Nullable<FreeCamera>;
  30941. /**
  30942. * Gets the right camera of a rig setup in case of Rigged Camera
  30943. */
  30944. readonly rightCamera: Nullable<FreeCamera>;
  30945. /**
  30946. * Gets the left camera target of a rig setup in case of Rigged Camera
  30947. * @returns the target position
  30948. */
  30949. getLeftTarget(): Nullable<Vector3>;
  30950. /**
  30951. * Gets the right camera target of a rig setup in case of Rigged Camera
  30952. * @returns the target position
  30953. */
  30954. getRightTarget(): Nullable<Vector3>;
  30955. /**
  30956. * @hidden
  30957. */
  30958. setCameraRigMode(mode: number, rigParams: any): void;
  30959. /** @hidden */
  30960. static _setStereoscopicRigMode(camera: Camera): void;
  30961. /** @hidden */
  30962. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30963. /** @hidden */
  30964. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30965. /** @hidden */
  30966. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30967. /** @hidden */
  30968. _getVRProjectionMatrix(): Matrix;
  30969. protected _updateCameraRotationMatrix(): void;
  30970. protected _updateWebVRCameraRotationMatrix(): void;
  30971. /**
  30972. * This function MUST be overwritten by the different WebVR cameras available.
  30973. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30974. * @hidden
  30975. */
  30976. _getWebVRProjectionMatrix(): Matrix;
  30977. /**
  30978. * This function MUST be overwritten by the different WebVR cameras available.
  30979. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30980. * @hidden
  30981. */
  30982. _getWebVRViewMatrix(): Matrix;
  30983. /** @hidden */
  30984. setCameraRigParameter(name: string, value: any): void;
  30985. /**
  30986. * needs to be overridden by children so sub has required properties to be copied
  30987. * @hidden
  30988. */
  30989. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30990. /**
  30991. * May need to be overridden by children
  30992. * @hidden
  30993. */
  30994. _updateRigCameras(): void;
  30995. /** @hidden */
  30996. _setupInputs(): void;
  30997. /**
  30998. * Serialiaze the camera setup to a json represention
  30999. * @returns the JSON representation
  31000. */
  31001. serialize(): any;
  31002. /**
  31003. * Clones the current camera.
  31004. * @param name The cloned camera name
  31005. * @returns the cloned camera
  31006. */
  31007. clone(name: string): Camera;
  31008. /**
  31009. * Gets the direction of the camera relative to a given local axis.
  31010. * @param localAxis Defines the reference axis to provide a relative direction.
  31011. * @return the direction
  31012. */
  31013. getDirection(localAxis: Vector3): Vector3;
  31014. /**
  31015. * Gets the direction of the camera relative to a given local axis into a passed vector.
  31016. * @param localAxis Defines the reference axis to provide a relative direction.
  31017. * @param result Defines the vector to store the result in
  31018. */
  31019. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  31020. /**
  31021. * Gets a camera constructor for a given camera type
  31022. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  31023. * @param name The name of the camera the result will be able to instantiate
  31024. * @param scene The scene the result will construct the camera in
  31025. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  31026. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  31027. * @returns a factory method to construc the camera
  31028. */
  31029. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  31030. /**
  31031. * Compute the world matrix of the camera.
  31032. * @returns the camera workd matrix
  31033. */
  31034. computeWorldMatrix(): Matrix;
  31035. /**
  31036. * Parse a JSON and creates the camera from the parsed information
  31037. * @param parsedCamera The JSON to parse
  31038. * @param scene The scene to instantiate the camera in
  31039. * @returns the newly constructed camera
  31040. */
  31041. static Parse(parsedCamera: any, scene: Scene): Camera;
  31042. }
  31043. }
  31044. declare module BABYLON {
  31045. /**
  31046. * Interface for any object that can request an animation frame
  31047. */
  31048. export interface ICustomAnimationFrameRequester {
  31049. /**
  31050. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31051. */
  31052. renderFunction?: Function;
  31053. /**
  31054. * Called to request the next frame to render to
  31055. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31056. */
  31057. requestAnimationFrame: Function;
  31058. /**
  31059. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31060. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31061. */
  31062. requestID?: number;
  31063. }
  31064. /**
  31065. * Interface containing an array of animations
  31066. */
  31067. export interface IAnimatable {
  31068. /**
  31069. * Array of animations
  31070. */
  31071. animations: Nullable<Array<Animation>>;
  31072. }
  31073. /** Interface used by value gradients (color, factor, ...) */
  31074. export interface IValueGradient {
  31075. /**
  31076. * Gets or sets the gradient value (between 0 and 1)
  31077. */
  31078. gradient: number;
  31079. }
  31080. /** Class used to store color4 gradient */
  31081. export class ColorGradient implements IValueGradient {
  31082. /**
  31083. * Gets or sets the gradient value (between 0 and 1)
  31084. */
  31085. gradient: number;
  31086. /**
  31087. * Gets or sets first associated color
  31088. */
  31089. color1: Color4;
  31090. /**
  31091. * Gets or sets second associated color
  31092. */
  31093. color2?: Color4;
  31094. /**
  31095. * Will get a color picked randomly between color1 and color2.
  31096. * If color2 is undefined then color1 will be used
  31097. * @param result defines the target Color4 to store the result in
  31098. */
  31099. getColorToRef(result: Color4): void;
  31100. }
  31101. /** Class used to store color 3 gradient */
  31102. export class Color3Gradient implements IValueGradient {
  31103. /**
  31104. * Gets or sets the gradient value (between 0 and 1)
  31105. */
  31106. gradient: number;
  31107. /**
  31108. * Gets or sets the associated color
  31109. */
  31110. color: Color3;
  31111. }
  31112. /** Class used to store factor gradient */
  31113. export class FactorGradient implements IValueGradient {
  31114. /**
  31115. * Gets or sets the gradient value (between 0 and 1)
  31116. */
  31117. gradient: number;
  31118. /**
  31119. * Gets or sets first associated factor
  31120. */
  31121. factor1: number;
  31122. /**
  31123. * Gets or sets second associated factor
  31124. */
  31125. factor2?: number;
  31126. /**
  31127. * Will get a number picked randomly between factor1 and factor2.
  31128. * If factor2 is undefined then factor1 will be used
  31129. * @returns the picked number
  31130. */
  31131. getFactor(): number;
  31132. }
  31133. /**
  31134. * @ignore
  31135. * Application error to support additional information when loading a file
  31136. */
  31137. export class LoadFileError extends Error {
  31138. /** defines the optional web request */
  31139. request?: WebRequest | undefined;
  31140. private static _setPrototypeOf;
  31141. /**
  31142. * Creates a new LoadFileError
  31143. * @param message defines the message of the error
  31144. * @param request defines the optional web request
  31145. */
  31146. constructor(message: string,
  31147. /** defines the optional web request */
  31148. request?: WebRequest | undefined);
  31149. }
  31150. /**
  31151. * Class used to define a retry strategy when error happens while loading assets
  31152. */
  31153. export class RetryStrategy {
  31154. /**
  31155. * Function used to defines an exponential back off strategy
  31156. * @param maxRetries defines the maximum number of retries (3 by default)
  31157. * @param baseInterval defines the interval between retries
  31158. * @returns the strategy function to use
  31159. */
  31160. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  31161. }
  31162. /**
  31163. * File request interface
  31164. */
  31165. export interface IFileRequest {
  31166. /**
  31167. * Raised when the request is complete (success or error).
  31168. */
  31169. onCompleteObservable: Observable<IFileRequest>;
  31170. /**
  31171. * Aborts the request for a file.
  31172. */
  31173. abort: () => void;
  31174. }
  31175. /**
  31176. * Class containing a set of static utilities functions
  31177. */
  31178. export class Tools {
  31179. /**
  31180. * Gets or sets the base URL to use to load assets
  31181. */
  31182. static BaseUrl: string;
  31183. /**
  31184. * Enable/Disable Custom HTTP Request Headers globally.
  31185. * default = false
  31186. * @see CustomRequestHeaders
  31187. */
  31188. static UseCustomRequestHeaders: boolean;
  31189. /**
  31190. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31191. * i.e. when loading files, where the server/service expects an Authorization header
  31192. */
  31193. static CustomRequestHeaders: {
  31194. [key: string]: string;
  31195. };
  31196. /**
  31197. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31198. */
  31199. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31200. /**
  31201. * Default behaviour for cors in the application.
  31202. * It can be a string if the expected behavior is identical in the entire app.
  31203. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31204. */
  31205. static CorsBehavior: string | ((url: string | string[]) => string);
  31206. /**
  31207. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31208. * @ignorenaming
  31209. */
  31210. static UseFallbackTexture: boolean;
  31211. /**
  31212. * Use this object to register external classes like custom textures or material
  31213. * to allow the laoders to instantiate them
  31214. */
  31215. static RegisteredExternalClasses: {
  31216. [key: string]: Object;
  31217. };
  31218. /**
  31219. * Texture content used if a texture cannot loaded
  31220. * @ignorenaming
  31221. */
  31222. static fallbackTexture: string;
  31223. /**
  31224. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31225. * @param u defines the coordinate on X axis
  31226. * @param v defines the coordinate on Y axis
  31227. * @param width defines the width of the source data
  31228. * @param height defines the height of the source data
  31229. * @param pixels defines the source byte array
  31230. * @param color defines the output color
  31231. */
  31232. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  31233. /**
  31234. * Interpolates between a and b via alpha
  31235. * @param a The lower value (returned when alpha = 0)
  31236. * @param b The upper value (returned when alpha = 1)
  31237. * @param alpha The interpolation-factor
  31238. * @return The mixed value
  31239. */
  31240. static Mix(a: number, b: number, alpha: number): number;
  31241. /**
  31242. * Tries to instantiate a new object from a given class name
  31243. * @param className defines the class name to instantiate
  31244. * @returns the new object or null if the system was not able to do the instantiation
  31245. */
  31246. static Instantiate(className: string): any;
  31247. /**
  31248. * Provides a slice function that will work even on IE
  31249. * @param data defines the array to slice
  31250. * @param start defines the start of the data (optional)
  31251. * @param end defines the end of the data (optional)
  31252. * @returns the new sliced array
  31253. */
  31254. static Slice<T>(data: T, start?: number, end?: number): T;
  31255. /**
  31256. * Polyfill for setImmediate
  31257. * @param action defines the action to execute after the current execution block
  31258. */
  31259. static SetImmediate(action: () => void): void;
  31260. /**
  31261. * Function indicating if a number is an exponent of 2
  31262. * @param value defines the value to test
  31263. * @returns true if the value is an exponent of 2
  31264. */
  31265. static IsExponentOfTwo(value: number): boolean;
  31266. private static _tmpFloatArray;
  31267. /**
  31268. * Returns the nearest 32-bit single precision float representation of a Number
  31269. * @param value A Number. If the parameter is of a different type, it will get converted
  31270. * to a number or to NaN if it cannot be converted
  31271. * @returns number
  31272. */
  31273. static FloatRound(value: number): number;
  31274. /**
  31275. * Find the next highest power of two.
  31276. * @param x Number to start search from.
  31277. * @return Next highest power of two.
  31278. */
  31279. static CeilingPOT(x: number): number;
  31280. /**
  31281. * Find the next lowest power of two.
  31282. * @param x Number to start search from.
  31283. * @return Next lowest power of two.
  31284. */
  31285. static FloorPOT(x: number): number;
  31286. /**
  31287. * Find the nearest power of two.
  31288. * @param x Number to start search from.
  31289. * @return Next nearest power of two.
  31290. */
  31291. static NearestPOT(x: number): number;
  31292. /**
  31293. * Get the closest exponent of two
  31294. * @param value defines the value to approximate
  31295. * @param max defines the maximum value to return
  31296. * @param mode defines how to define the closest value
  31297. * @returns closest exponent of two of the given value
  31298. */
  31299. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31300. /**
  31301. * Extracts the filename from a path
  31302. * @param path defines the path to use
  31303. * @returns the filename
  31304. */
  31305. static GetFilename(path: string): string;
  31306. /**
  31307. * Extracts the "folder" part of a path (everything before the filename).
  31308. * @param uri The URI to extract the info from
  31309. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31310. * @returns The "folder" part of the path
  31311. */
  31312. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31313. /**
  31314. * Extracts text content from a DOM element hierarchy
  31315. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31316. */
  31317. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31318. /**
  31319. * Convert an angle in radians to degrees
  31320. * @param angle defines the angle to convert
  31321. * @returns the angle in degrees
  31322. */
  31323. static ToDegrees(angle: number): number;
  31324. /**
  31325. * Convert an angle in degrees to radians
  31326. * @param angle defines the angle to convert
  31327. * @returns the angle in radians
  31328. */
  31329. static ToRadians(angle: number): number;
  31330. /**
  31331. * Encode a buffer to a base64 string
  31332. * @param buffer defines the buffer to encode
  31333. * @returns the encoded string
  31334. */
  31335. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31336. /**
  31337. * Extracts minimum and maximum values from a list of indexed positions
  31338. * @param positions defines the positions to use
  31339. * @param indices defines the indices to the positions
  31340. * @param indexStart defines the start index
  31341. * @param indexCount defines the end index
  31342. * @param bias defines bias value to add to the result
  31343. * @return minimum and maximum values
  31344. */
  31345. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  31346. minimum: Vector3;
  31347. maximum: Vector3;
  31348. };
  31349. /**
  31350. * Extracts minimum and maximum values from a list of positions
  31351. * @param positions defines the positions to use
  31352. * @param start defines the start index in the positions array
  31353. * @param count defines the number of positions to handle
  31354. * @param bias defines bias value to add to the result
  31355. * @param stride defines the stride size to use (distance between two positions in the positions array)
  31356. * @return minimum and maximum values
  31357. */
  31358. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  31359. minimum: Vector3;
  31360. maximum: Vector3;
  31361. };
  31362. /**
  31363. * Returns an array if obj is not an array
  31364. * @param obj defines the object to evaluate as an array
  31365. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31366. * @returns either obj directly if obj is an array or a new array containing obj
  31367. */
  31368. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31369. /**
  31370. * Gets the pointer prefix to use
  31371. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31372. */
  31373. static GetPointerPrefix(): string;
  31374. /**
  31375. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31376. * @param func - the function to be called
  31377. * @param requester - the object that will request the next frame. Falls back to window.
  31378. * @returns frame number
  31379. */
  31380. static QueueNewFrame(func: () => void, requester?: any): number;
  31381. /**
  31382. * Ask the browser to promote the current element to fullscreen rendering mode
  31383. * @param element defines the DOM element to promote
  31384. */
  31385. static RequestFullscreen(element: HTMLElement): void;
  31386. /**
  31387. * Asks the browser to exit fullscreen mode
  31388. */
  31389. static ExitFullscreen(): void;
  31390. /**
  31391. * Ask the browser to promote the current element to pointerlock mode
  31392. * @param element defines the DOM element to promote
  31393. */
  31394. static RequestPointerlock(element: HTMLElement): void;
  31395. /**
  31396. * Asks the browser to exit pointerlock mode
  31397. */
  31398. static ExitPointerlock(): void;
  31399. /**
  31400. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31401. * @param url define the url we are trying
  31402. * @param element define the dom element where to configure the cors policy
  31403. */
  31404. static SetCorsBehavior(url: string | string[], element: {
  31405. crossOrigin: string | null;
  31406. }): void;
  31407. /**
  31408. * Removes unwanted characters from an url
  31409. * @param url defines the url to clean
  31410. * @returns the cleaned url
  31411. */
  31412. static CleanUrl(url: string): string;
  31413. /**
  31414. * Gets or sets a function used to pre-process url before using them to load assets
  31415. */
  31416. static PreprocessUrl: (url: string) => string;
  31417. /**
  31418. * Loads an image as an HTMLImageElement.
  31419. * @param input url string, ArrayBuffer, or Blob to load
  31420. * @param onLoad callback called when the image successfully loads
  31421. * @param onError callback called when the image fails to load
  31422. * @param offlineProvider offline provider for caching
  31423. * @returns the HTMLImageElement of the loaded image
  31424. */
  31425. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31426. /**
  31427. * Loads a file
  31428. * @param url url string, ArrayBuffer, or Blob to load
  31429. * @param onSuccess callback called when the file successfully loads
  31430. * @param onProgress callback called while file is loading (if the server supports this mode)
  31431. * @param offlineProvider defines the offline provider for caching
  31432. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31433. * @param onError callback called when the file fails to load
  31434. * @returns a file request object
  31435. */
  31436. 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;
  31437. /**
  31438. * Loads a file from a url
  31439. * @param url the file url to load
  31440. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  31441. */
  31442. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  31443. /**
  31444. * Load a script (identified by an url). When the url returns, the
  31445. * content of this file is added into a new script element, attached to the DOM (body element)
  31446. * @param scriptUrl defines the url of the script to laod
  31447. * @param onSuccess defines the callback called when the script is loaded
  31448. * @param onError defines the callback to call if an error occurs
  31449. * @param scriptId defines the id of the script element
  31450. */
  31451. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31452. /**
  31453. * Load an asynchronous script (identified by an url). When the url returns, the
  31454. * content of this file is added into a new script element, attached to the DOM (body element)
  31455. * @param scriptUrl defines the url of the script to laod
  31456. * @param scriptId defines the id of the script element
  31457. * @returns a promise request object
  31458. */
  31459. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  31460. /**
  31461. * Loads a file from a blob
  31462. * @param fileToLoad defines the blob to use
  31463. * @param callback defines the callback to call when data is loaded
  31464. * @param progressCallback defines the callback to call during loading process
  31465. * @returns a file request object
  31466. */
  31467. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31468. /**
  31469. * Loads a file
  31470. * @param fileToLoad defines the file to load
  31471. * @param callback defines the callback to call when data is loaded
  31472. * @param progressCallBack defines the callback to call during loading process
  31473. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31474. * @returns a file request object
  31475. */
  31476. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31477. /**
  31478. * Creates a data url from a given string content
  31479. * @param content defines the content to convert
  31480. * @returns the new data url link
  31481. */
  31482. static FileAsURL(content: string): string;
  31483. /**
  31484. * Format the given number to a specific decimal format
  31485. * @param value defines the number to format
  31486. * @param decimals defines the number of decimals to use
  31487. * @returns the formatted string
  31488. */
  31489. static Format(value: number, decimals?: number): string;
  31490. /**
  31491. * Checks if a given vector is inside a specific range
  31492. * @param v defines the vector to test
  31493. * @param min defines the minimum range
  31494. * @param max defines the maximum range
  31495. */
  31496. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31497. /**
  31498. * Tries to copy an object by duplicating every property
  31499. * @param source defines the source object
  31500. * @param destination defines the target object
  31501. * @param doNotCopyList defines a list of properties to avoid
  31502. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31503. */
  31504. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31505. /**
  31506. * Gets a boolean indicating if the given object has no own property
  31507. * @param obj defines the object to test
  31508. * @returns true if object has no own property
  31509. */
  31510. static IsEmpty(obj: any): boolean;
  31511. /**
  31512. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  31513. * @param str Source string
  31514. * @param suffix Suffix to search for in the source string
  31515. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  31516. */
  31517. static EndsWith(str: string, suffix: string): boolean;
  31518. /**
  31519. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  31520. * @param str Source string
  31521. * @param suffix Suffix to search for in the source string
  31522. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  31523. */
  31524. static StartsWith(str: string, suffix: string): boolean;
  31525. /**
  31526. * Function used to register events at window level
  31527. * @param events defines the events to register
  31528. */
  31529. static RegisterTopRootEvents(events: {
  31530. name: string;
  31531. handler: Nullable<(e: FocusEvent) => any>;
  31532. }[]): void;
  31533. /**
  31534. * Function used to unregister events from window level
  31535. * @param events defines the events to unregister
  31536. */
  31537. static UnregisterTopRootEvents(events: {
  31538. name: string;
  31539. handler: Nullable<(e: FocusEvent) => any>;
  31540. }[]): void;
  31541. /**
  31542. * @ignore
  31543. */
  31544. static _ScreenshotCanvas: HTMLCanvasElement;
  31545. /**
  31546. * Dumps the current bound framebuffer
  31547. * @param width defines the rendering width
  31548. * @param height defines the rendering height
  31549. * @param engine defines the hosting engine
  31550. * @param successCallback defines the callback triggered once the data are available
  31551. * @param mimeType defines the mime type of the result
  31552. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31553. */
  31554. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31555. /**
  31556. * Converts the canvas data to blob.
  31557. * This acts as a polyfill for browsers not supporting the to blob function.
  31558. * @param canvas Defines the canvas to extract the data from
  31559. * @param successCallback Defines the callback triggered once the data are available
  31560. * @param mimeType Defines the mime type of the result
  31561. */
  31562. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31563. /**
  31564. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31565. * @param successCallback defines the callback triggered once the data are available
  31566. * @param mimeType defines the mime type of the result
  31567. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31568. */
  31569. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31570. /**
  31571. * Downloads a blob in the browser
  31572. * @param blob defines the blob to download
  31573. * @param fileName defines the name of the downloaded file
  31574. */
  31575. static Download(blob: Blob, fileName: string): void;
  31576. /**
  31577. * Captures a screenshot of the current rendering
  31578. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31579. * @param engine defines the rendering engine
  31580. * @param camera defines the source camera
  31581. * @param size This parameter can be set to a single number or to an object with the
  31582. * following (optional) properties: precision, width, height. If a single number is passed,
  31583. * it will be used for both width and height. If an object is passed, the screenshot size
  31584. * will be derived from the parameters. The precision property is a multiplier allowing
  31585. * rendering at a higher or lower resolution
  31586. * @param successCallback defines the callback receives a single parameter which contains the
  31587. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31588. * src parameter of an <img> to display it
  31589. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31590. * Check your browser for supported MIME types
  31591. */
  31592. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31593. /**
  31594. * Generates an image screenshot from the specified camera.
  31595. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31596. * @param engine The engine to use for rendering
  31597. * @param camera The camera to use for rendering
  31598. * @param size This parameter can be set to a single number or to an object with the
  31599. * following (optional) properties: precision, width, height. If a single number is passed,
  31600. * it will be used for both width and height. If an object is passed, the screenshot size
  31601. * will be derived from the parameters. The precision property is a multiplier allowing
  31602. * rendering at a higher or lower resolution
  31603. * @param successCallback The callback receives a single parameter which contains the
  31604. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31605. * src parameter of an <img> to display it
  31606. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31607. * Check your browser for supported MIME types
  31608. * @param samples Texture samples (default: 1)
  31609. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31610. * @param fileName A name for for the downloaded file.
  31611. */
  31612. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31613. /**
  31614. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31615. * Be aware Math.random() could cause collisions, but:
  31616. * "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"
  31617. * @returns a pseudo random id
  31618. */
  31619. static RandomId(): string;
  31620. /**
  31621. * Test if the given uri is a base64 string
  31622. * @param uri The uri to test
  31623. * @return True if the uri is a base64 string or false otherwise
  31624. */
  31625. static IsBase64(uri: string): boolean;
  31626. /**
  31627. * Decode the given base64 uri.
  31628. * @param uri The uri to decode
  31629. * @return The decoded base64 data.
  31630. */
  31631. static DecodeBase64(uri: string): ArrayBuffer;
  31632. /**
  31633. * Gets the absolute url.
  31634. * @param url the input url
  31635. * @return the absolute url
  31636. */
  31637. static GetAbsoluteUrl(url: string): string;
  31638. /**
  31639. * No log
  31640. */
  31641. static readonly NoneLogLevel: number;
  31642. /**
  31643. * Only message logs
  31644. */
  31645. static readonly MessageLogLevel: number;
  31646. /**
  31647. * Only warning logs
  31648. */
  31649. static readonly WarningLogLevel: number;
  31650. /**
  31651. * Only error logs
  31652. */
  31653. static readonly ErrorLogLevel: number;
  31654. /**
  31655. * All logs
  31656. */
  31657. static readonly AllLogLevel: number;
  31658. /**
  31659. * Gets a value indicating the number of loading errors
  31660. * @ignorenaming
  31661. */
  31662. static readonly errorsCount: number;
  31663. /**
  31664. * Callback called when a new log is added
  31665. */
  31666. static OnNewCacheEntry: (entry: string) => void;
  31667. /**
  31668. * Log a message to the console
  31669. * @param message defines the message to log
  31670. */
  31671. static Log(message: string): void;
  31672. /**
  31673. * Write a warning message to the console
  31674. * @param message defines the message to log
  31675. */
  31676. static Warn(message: string): void;
  31677. /**
  31678. * Write an error message to the console
  31679. * @param message defines the message to log
  31680. */
  31681. static Error(message: string): void;
  31682. /**
  31683. * Gets current log cache (list of logs)
  31684. */
  31685. static readonly LogCache: string;
  31686. /**
  31687. * Clears the log cache
  31688. */
  31689. static ClearLogCache(): void;
  31690. /**
  31691. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31692. */
  31693. static LogLevels: number;
  31694. /**
  31695. * Checks if the loaded document was accessed via `file:`-Protocol.
  31696. * @returns boolean
  31697. */
  31698. static IsFileURL(): boolean;
  31699. /**
  31700. * Checks if the window object exists
  31701. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31702. */
  31703. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31704. /**
  31705. * No performance log
  31706. */
  31707. static readonly PerformanceNoneLogLevel: number;
  31708. /**
  31709. * Use user marks to log performance
  31710. */
  31711. static readonly PerformanceUserMarkLogLevel: number;
  31712. /**
  31713. * Log performance to the console
  31714. */
  31715. static readonly PerformanceConsoleLogLevel: number;
  31716. private static _performance;
  31717. /**
  31718. * Sets the current performance log level
  31719. */
  31720. static PerformanceLogLevel: number;
  31721. private static _StartPerformanceCounterDisabled;
  31722. private static _EndPerformanceCounterDisabled;
  31723. private static _StartUserMark;
  31724. private static _EndUserMark;
  31725. private static _StartPerformanceConsole;
  31726. private static _EndPerformanceConsole;
  31727. /**
  31728. * Starts a performance counter
  31729. */
  31730. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31731. /**
  31732. * Ends a specific performance coutner
  31733. */
  31734. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31735. /**
  31736. * Gets either window.performance.now() if supported or Date.now() else
  31737. */
  31738. static readonly Now: number;
  31739. /**
  31740. * This method will return the name of the class used to create the instance of the given object.
  31741. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31742. * @param object the object to get the class name from
  31743. * @param isType defines if the object is actually a type
  31744. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31745. */
  31746. static GetClassName(object: any, isType?: boolean): string;
  31747. /**
  31748. * Gets the first element of an array satisfying a given predicate
  31749. * @param array defines the array to browse
  31750. * @param predicate defines the predicate to use
  31751. * @returns null if not found or the element
  31752. */
  31753. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31754. /**
  31755. * This method will return the name of the full name of the class, including its owning module (if any).
  31756. * 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).
  31757. * @param object the object to get the class name from
  31758. * @param isType defines if the object is actually a type
  31759. * @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.
  31760. * @ignorenaming
  31761. */
  31762. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31763. /**
  31764. * Returns a promise that resolves after the given amount of time.
  31765. * @param delay Number of milliseconds to delay
  31766. * @returns Promise that resolves after the given amount of time
  31767. */
  31768. static DelayAsync(delay: number): Promise<void>;
  31769. /**
  31770. * Gets the current gradient from an array of IValueGradient
  31771. * @param ratio defines the current ratio to get
  31772. * @param gradients defines the array of IValueGradient
  31773. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31774. */
  31775. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31776. }
  31777. /**
  31778. * This class is used to track a performance counter which is number based.
  31779. * The user has access to many properties which give statistics of different nature.
  31780. *
  31781. * The implementer can track two kinds of Performance Counter: time and count.
  31782. * 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.
  31783. * 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.
  31784. */
  31785. export class PerfCounter {
  31786. /**
  31787. * Gets or sets a global boolean to turn on and off all the counters
  31788. */
  31789. static Enabled: boolean;
  31790. /**
  31791. * Returns the smallest value ever
  31792. */
  31793. readonly min: number;
  31794. /**
  31795. * Returns the biggest value ever
  31796. */
  31797. readonly max: number;
  31798. /**
  31799. * Returns the average value since the performance counter is running
  31800. */
  31801. readonly average: number;
  31802. /**
  31803. * Returns the average value of the last second the counter was monitored
  31804. */
  31805. readonly lastSecAverage: number;
  31806. /**
  31807. * Returns the current value
  31808. */
  31809. readonly current: number;
  31810. /**
  31811. * Gets the accumulated total
  31812. */
  31813. readonly total: number;
  31814. /**
  31815. * Gets the total value count
  31816. */
  31817. readonly count: number;
  31818. /**
  31819. * Creates a new counter
  31820. */
  31821. constructor();
  31822. /**
  31823. * Call this method to start monitoring a new frame.
  31824. * 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.
  31825. */
  31826. fetchNewFrame(): void;
  31827. /**
  31828. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31829. * @param newCount the count value to add to the monitored count
  31830. * @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.
  31831. */
  31832. addCount(newCount: number, fetchResult: boolean): void;
  31833. /**
  31834. * Start monitoring this performance counter
  31835. */
  31836. beginMonitoring(): void;
  31837. /**
  31838. * Compute the time lapsed since the previous beginMonitoring() call.
  31839. * @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
  31840. */
  31841. endMonitoring(newFrame?: boolean): void;
  31842. private _fetchResult;
  31843. private _startMonitoringTime;
  31844. private _min;
  31845. private _max;
  31846. private _average;
  31847. private _current;
  31848. private _totalValueCount;
  31849. private _totalAccumulated;
  31850. private _lastSecAverage;
  31851. private _lastSecAccumulated;
  31852. private _lastSecTime;
  31853. private _lastSecValueCount;
  31854. }
  31855. /**
  31856. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31857. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31858. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31859. * @param name The name of the class, case should be preserved
  31860. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31861. */
  31862. export function className(name: string, module?: string): (target: Object) => void;
  31863. /**
  31864. * An implementation of a loop for asynchronous functions.
  31865. */
  31866. export class AsyncLoop {
  31867. /**
  31868. * Defines the number of iterations for the loop
  31869. */
  31870. iterations: number;
  31871. /**
  31872. * Defines the current index of the loop.
  31873. */
  31874. index: number;
  31875. private _done;
  31876. private _fn;
  31877. private _successCallback;
  31878. /**
  31879. * Constructor.
  31880. * @param iterations the number of iterations.
  31881. * @param func the function to run each iteration
  31882. * @param successCallback the callback that will be called upon succesful execution
  31883. * @param offset starting offset.
  31884. */
  31885. constructor(
  31886. /**
  31887. * Defines the number of iterations for the loop
  31888. */
  31889. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31890. /**
  31891. * Execute the next iteration. Must be called after the last iteration was finished.
  31892. */
  31893. executeNext(): void;
  31894. /**
  31895. * Break the loop and run the success callback.
  31896. */
  31897. breakLoop(): void;
  31898. /**
  31899. * Create and run an async loop.
  31900. * @param iterations the number of iterations.
  31901. * @param fn the function to run each iteration
  31902. * @param successCallback the callback that will be called upon succesful execution
  31903. * @param offset starting offset.
  31904. * @returns the created async loop object
  31905. */
  31906. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31907. /**
  31908. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31909. * @param iterations total number of iterations
  31910. * @param syncedIterations number of synchronous iterations in each async iteration.
  31911. * @param fn the function to call each iteration.
  31912. * @param callback a success call back that will be called when iterating stops.
  31913. * @param breakFunction a break condition (optional)
  31914. * @param timeout timeout settings for the setTimeout function. default - 0.
  31915. * @returns the created async loop object
  31916. */
  31917. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31918. }
  31919. }
  31920. declare module BABYLON {
  31921. /** @hidden */
  31922. export interface ICollisionCoordinator {
  31923. createCollider(): Collider;
  31924. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31925. init(scene: Scene): void;
  31926. }
  31927. /** @hidden */
  31928. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31929. private _scene;
  31930. private _scaledPosition;
  31931. private _scaledVelocity;
  31932. private _finalPosition;
  31933. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31934. createCollider(): Collider;
  31935. init(scene: Scene): void;
  31936. private _collideWithWorld;
  31937. }
  31938. }
  31939. declare module BABYLON {
  31940. /**
  31941. * Class used to manage all inputs for the scene.
  31942. */
  31943. export class InputManager {
  31944. /** The distance in pixel that you have to move to prevent some events */
  31945. static DragMovementThreshold: number;
  31946. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  31947. static LongPressDelay: number;
  31948. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  31949. static DoubleClickDelay: number;
  31950. /** If you need to check double click without raising a single click at first click, enable this flag */
  31951. static ExclusiveDoubleClickMode: boolean;
  31952. private _wheelEventName;
  31953. private _onPointerMove;
  31954. private _onPointerDown;
  31955. private _onPointerUp;
  31956. private _initClickEvent;
  31957. private _initActionManager;
  31958. private _delayedSimpleClick;
  31959. private _delayedSimpleClickTimeout;
  31960. private _previousDelayedSimpleClickTimeout;
  31961. private _meshPickProceed;
  31962. private _previousButtonPressed;
  31963. private _currentPickResult;
  31964. private _previousPickResult;
  31965. private _totalPointersPressed;
  31966. private _doubleClickOccured;
  31967. private _pointerOverMesh;
  31968. private _pickedDownMesh;
  31969. private _pickedUpMesh;
  31970. private _pointerX;
  31971. private _pointerY;
  31972. private _unTranslatedPointerX;
  31973. private _unTranslatedPointerY;
  31974. private _startingPointerPosition;
  31975. private _previousStartingPointerPosition;
  31976. private _startingPointerTime;
  31977. private _previousStartingPointerTime;
  31978. private _pointerCaptures;
  31979. private _onKeyDown;
  31980. private _onKeyUp;
  31981. private _onCanvasFocusObserver;
  31982. private _onCanvasBlurObserver;
  31983. private _scene;
  31984. /**
  31985. * Creates a new InputManager
  31986. * @param scene defines the hosting scene
  31987. */
  31988. constructor(scene: Scene);
  31989. /**
  31990. * Gets the mesh that is currently under the pointer
  31991. */
  31992. readonly meshUnderPointer: Nullable<AbstractMesh>;
  31993. /**
  31994. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  31995. */
  31996. readonly unTranslatedPointer: Vector2;
  31997. /**
  31998. * Gets or sets the current on-screen X position of the pointer
  31999. */
  32000. pointerX: number;
  32001. /**
  32002. * Gets or sets the current on-screen Y position of the pointer
  32003. */
  32004. pointerY: number;
  32005. private _updatePointerPosition;
  32006. private _processPointerMove;
  32007. private _setRayOnPointerInfo;
  32008. private _checkPrePointerObservable;
  32009. /**
  32010. * Use this method to simulate a pointer move on a mesh
  32011. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32012. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32013. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32014. */
  32015. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32016. /**
  32017. * Use this method to simulate a pointer down on a mesh
  32018. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32019. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32020. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32021. */
  32022. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32023. private _processPointerDown;
  32024. /** @hidden */
  32025. _isPointerSwiping(): boolean;
  32026. /**
  32027. * Use this method to simulate a pointer up on a mesh
  32028. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32029. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32030. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32031. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32032. */
  32033. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32034. private _processPointerUp;
  32035. /**
  32036. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32037. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32038. * @returns true if the pointer was captured
  32039. */
  32040. isPointerCaptured(pointerId?: number): boolean;
  32041. /**
  32042. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32043. * @param attachUp defines if you want to attach events to pointerup
  32044. * @param attachDown defines if you want to attach events to pointerdown
  32045. * @param attachMove defines if you want to attach events to pointermove
  32046. */
  32047. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32048. /**
  32049. * Detaches all event handlers
  32050. */
  32051. detachControl(): void;
  32052. /**
  32053. * Force the value of meshUnderPointer
  32054. * @param mesh defines the mesh to use
  32055. */
  32056. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32057. /**
  32058. * Gets the mesh under the pointer
  32059. * @returns a Mesh or null if no mesh is under the pointer
  32060. */
  32061. getPointerOverMesh(): Nullable<AbstractMesh>;
  32062. }
  32063. }
  32064. declare module BABYLON {
  32065. /**
  32066. * This class defines the direct association between an animation and a target
  32067. */
  32068. export class TargetedAnimation {
  32069. /**
  32070. * Animation to perform
  32071. */
  32072. animation: Animation;
  32073. /**
  32074. * Target to animate
  32075. */
  32076. target: any;
  32077. /**
  32078. * Serialize the object
  32079. * @returns the JSON object representing the current entity
  32080. */
  32081. serialize(): any;
  32082. }
  32083. /**
  32084. * Use this class to create coordinated animations on multiple targets
  32085. */
  32086. export class AnimationGroup implements IDisposable {
  32087. /** The name of the animation group */
  32088. name: string;
  32089. private _scene;
  32090. private _targetedAnimations;
  32091. private _animatables;
  32092. private _from;
  32093. private _to;
  32094. private _isStarted;
  32095. private _isPaused;
  32096. private _speedRatio;
  32097. private _loopAnimation;
  32098. /**
  32099. * Gets or sets the unique id of the node
  32100. */
  32101. uniqueId: number;
  32102. /**
  32103. * This observable will notify when one animation have ended
  32104. */
  32105. onAnimationEndObservable: Observable<TargetedAnimation>;
  32106. /**
  32107. * Observer raised when one animation loops
  32108. */
  32109. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32110. /**
  32111. * This observable will notify when all animations have ended.
  32112. */
  32113. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32114. /**
  32115. * This observable will notify when all animations have paused.
  32116. */
  32117. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32118. /**
  32119. * This observable will notify when all animations are playing.
  32120. */
  32121. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32122. /**
  32123. * Gets the first frame
  32124. */
  32125. readonly from: number;
  32126. /**
  32127. * Gets the last frame
  32128. */
  32129. readonly to: number;
  32130. /**
  32131. * Define if the animations are started
  32132. */
  32133. readonly isStarted: boolean;
  32134. /**
  32135. * Gets a value indicating that the current group is playing
  32136. */
  32137. readonly isPlaying: boolean;
  32138. /**
  32139. * Gets or sets the speed ratio to use for all animations
  32140. */
  32141. /**
  32142. * Gets or sets the speed ratio to use for all animations
  32143. */
  32144. speedRatio: number;
  32145. /**
  32146. * Gets or sets if all animations should loop or not
  32147. */
  32148. loopAnimation: boolean;
  32149. /**
  32150. * Gets the targeted animations for this animation group
  32151. */
  32152. readonly targetedAnimations: Array<TargetedAnimation>;
  32153. /**
  32154. * returning the list of animatables controlled by this animation group.
  32155. */
  32156. readonly animatables: Array<Animatable>;
  32157. /**
  32158. * Instantiates a new Animation Group.
  32159. * This helps managing several animations at once.
  32160. * @see http://doc.babylonjs.com/how_to/group
  32161. * @param name Defines the name of the group
  32162. * @param scene Defines the scene the group belongs to
  32163. */
  32164. constructor(
  32165. /** The name of the animation group */
  32166. name: string, scene?: Nullable<Scene>);
  32167. /**
  32168. * Add an animation (with its target) in the group
  32169. * @param animation defines the animation we want to add
  32170. * @param target defines the target of the animation
  32171. * @returns the TargetedAnimation object
  32172. */
  32173. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32174. /**
  32175. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32176. * It can add constant keys at begin or end
  32177. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32178. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32179. * @returns the animation group
  32180. */
  32181. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32182. /**
  32183. * Start all animations on given targets
  32184. * @param loop defines if animations must loop
  32185. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32186. * @param from defines the from key (optional)
  32187. * @param to defines the to key (optional)
  32188. * @returns the current animation group
  32189. */
  32190. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32191. /**
  32192. * Pause all animations
  32193. * @returns the animation group
  32194. */
  32195. pause(): AnimationGroup;
  32196. /**
  32197. * Play all animations to initial state
  32198. * This function will start() the animations if they were not started or will restart() them if they were paused
  32199. * @param loop defines if animations must loop
  32200. * @returns the animation group
  32201. */
  32202. play(loop?: boolean): AnimationGroup;
  32203. /**
  32204. * Reset all animations to initial state
  32205. * @returns the animation group
  32206. */
  32207. reset(): AnimationGroup;
  32208. /**
  32209. * Restart animations from key 0
  32210. * @returns the animation group
  32211. */
  32212. restart(): AnimationGroup;
  32213. /**
  32214. * Stop all animations
  32215. * @returns the animation group
  32216. */
  32217. stop(): AnimationGroup;
  32218. /**
  32219. * Set animation weight for all animatables
  32220. * @param weight defines the weight to use
  32221. * @return the animationGroup
  32222. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32223. */
  32224. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32225. /**
  32226. * Synchronize and normalize all animatables with a source animatable
  32227. * @param root defines the root animatable to synchronize with
  32228. * @return the animationGroup
  32229. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32230. */
  32231. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32232. /**
  32233. * Goes to a specific frame in this animation group
  32234. * @param frame the frame number to go to
  32235. * @return the animationGroup
  32236. */
  32237. goToFrame(frame: number): AnimationGroup;
  32238. /**
  32239. * Dispose all associated resources
  32240. */
  32241. dispose(): void;
  32242. private _checkAnimationGroupEnded;
  32243. /**
  32244. * Clone the current animation group and returns a copy
  32245. * @param newName defines the name of the new group
  32246. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32247. * @returns the new aniamtion group
  32248. */
  32249. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32250. /**
  32251. * Serializes the animationGroup to an object
  32252. * @returns Serialized object
  32253. */
  32254. serialize(): any;
  32255. /**
  32256. * Returns a new AnimationGroup object parsed from the source provided.
  32257. * @param parsedAnimationGroup defines the source
  32258. * @param scene defines the scene that will receive the animationGroup
  32259. * @returns a new AnimationGroup
  32260. */
  32261. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32262. /**
  32263. * Returns the string "AnimationGroup"
  32264. * @returns "AnimationGroup"
  32265. */
  32266. getClassName(): string;
  32267. /**
  32268. * Creates a detailled string about the object
  32269. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32270. * @returns a string representing the object
  32271. */
  32272. toString(fullDetails?: boolean): string;
  32273. }
  32274. }
  32275. declare module BABYLON {
  32276. /**
  32277. * Define an interface for all classes that will hold resources
  32278. */
  32279. export interface IDisposable {
  32280. /**
  32281. * Releases all held resources
  32282. */
  32283. dispose(): void;
  32284. }
  32285. /** Interface defining initialization parameters for Scene class */
  32286. export interface SceneOptions {
  32287. /**
  32288. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32289. * It will improve performance when the number of geometries becomes important.
  32290. */
  32291. useGeometryUniqueIdsMap?: boolean;
  32292. /**
  32293. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32294. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32295. */
  32296. useMaterialMeshMap?: boolean;
  32297. /**
  32298. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32299. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32300. */
  32301. useClonedMeshhMap?: boolean;
  32302. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  32303. virtual?: boolean;
  32304. }
  32305. /**
  32306. * Represents a scene to be rendered by the engine.
  32307. * @see http://doc.babylonjs.com/features/scene
  32308. */
  32309. export class Scene extends AbstractScene implements IAnimatable {
  32310. private static _uniqueIdCounter;
  32311. /** The fog is deactivated */
  32312. static readonly FOGMODE_NONE: number;
  32313. /** The fog density is following an exponential function */
  32314. static readonly FOGMODE_EXP: number;
  32315. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32316. static readonly FOGMODE_EXP2: number;
  32317. /** The fog density is following a linear function. */
  32318. static readonly FOGMODE_LINEAR: number;
  32319. /**
  32320. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32321. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32322. */
  32323. static MinDeltaTime: number;
  32324. /**
  32325. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32326. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32327. */
  32328. static MaxDeltaTime: number;
  32329. /**
  32330. * Factory used to create the default material.
  32331. * @param name The name of the material to create
  32332. * @param scene The scene to create the material for
  32333. * @returns The default material
  32334. */
  32335. static DefaultMaterialFactory(scene: Scene): Material;
  32336. /**
  32337. * Factory used to create the a collision coordinator.
  32338. * @returns The collision coordinator
  32339. */
  32340. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32341. /** @hidden */
  32342. _inputManager: InputManager;
  32343. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32344. cameraToUseForPointers: Nullable<Camera>;
  32345. /** @hidden */
  32346. readonly _isScene: boolean;
  32347. /**
  32348. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32349. */
  32350. autoClear: boolean;
  32351. /**
  32352. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32353. */
  32354. autoClearDepthAndStencil: boolean;
  32355. /**
  32356. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32357. */
  32358. clearColor: Color4;
  32359. /**
  32360. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32361. */
  32362. ambientColor: Color3;
  32363. /**
  32364. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32365. * It should only be one of the following (if not the default embedded one):
  32366. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32367. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32368. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32369. * The material properties need to be setup according to the type of texture in use.
  32370. */
  32371. environmentBRDFTexture: BaseTexture;
  32372. /** @hidden */
  32373. protected _environmentTexture: Nullable<BaseTexture>;
  32374. /**
  32375. * Texture used in all pbr material as the reflection texture.
  32376. * As in the majority of the scene they are the same (exception for multi room and so on),
  32377. * this is easier to reference from here than from all the materials.
  32378. */
  32379. /**
  32380. * Texture used in all pbr material as the reflection texture.
  32381. * As in the majority of the scene they are the same (exception for multi room and so on),
  32382. * this is easier to set here than in all the materials.
  32383. */
  32384. environmentTexture: Nullable<BaseTexture>;
  32385. /** @hidden */
  32386. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32387. /**
  32388. * Default image processing configuration used either in the rendering
  32389. * Forward main pass or through the imageProcessingPostProcess if present.
  32390. * As in the majority of the scene they are the same (exception for multi camera),
  32391. * this is easier to reference from here than from all the materials and post process.
  32392. *
  32393. * No setter as we it is a shared configuration, you can set the values instead.
  32394. */
  32395. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32396. private _forceWireframe;
  32397. /**
  32398. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32399. */
  32400. forceWireframe: boolean;
  32401. private _forcePointsCloud;
  32402. /**
  32403. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32404. */
  32405. forcePointsCloud: boolean;
  32406. /**
  32407. * Gets or sets the active clipplane 1
  32408. */
  32409. clipPlane: Nullable<Plane>;
  32410. /**
  32411. * Gets or sets the active clipplane 2
  32412. */
  32413. clipPlane2: Nullable<Plane>;
  32414. /**
  32415. * Gets or sets the active clipplane 3
  32416. */
  32417. clipPlane3: Nullable<Plane>;
  32418. /**
  32419. * Gets or sets the active clipplane 4
  32420. */
  32421. clipPlane4: Nullable<Plane>;
  32422. /**
  32423. * Gets or sets a boolean indicating if animations are enabled
  32424. */
  32425. animationsEnabled: boolean;
  32426. private _animationPropertiesOverride;
  32427. /**
  32428. * Gets or sets the animation properties override
  32429. */
  32430. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32431. /**
  32432. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32433. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32434. */
  32435. useConstantAnimationDeltaTime: boolean;
  32436. /**
  32437. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32438. * Please note that it requires to run a ray cast through the scene on every frame
  32439. */
  32440. constantlyUpdateMeshUnderPointer: boolean;
  32441. /**
  32442. * Defines the HTML cursor to use when hovering over interactive elements
  32443. */
  32444. hoverCursor: string;
  32445. /**
  32446. * Defines the HTML default cursor to use (empty by default)
  32447. */
  32448. defaultCursor: string;
  32449. /**
  32450. * This is used to call preventDefault() on pointer down
  32451. * in order to block unwanted artifacts like system double clicks
  32452. */
  32453. preventDefaultOnPointerDown: boolean;
  32454. /**
  32455. * This is used to call preventDefault() on pointer up
  32456. * in order to block unwanted artifacts like system double clicks
  32457. */
  32458. preventDefaultOnPointerUp: boolean;
  32459. /**
  32460. * Gets or sets user defined metadata
  32461. */
  32462. metadata: any;
  32463. /**
  32464. * For internal use only. Please do not use.
  32465. */
  32466. reservedDataStore: any;
  32467. /**
  32468. * Gets the name of the plugin used to load this scene (null by default)
  32469. */
  32470. loadingPluginName: string;
  32471. /**
  32472. * Use this array to add regular expressions used to disable offline support for specific urls
  32473. */
  32474. disableOfflineSupportExceptionRules: RegExp[];
  32475. /**
  32476. * An event triggered when the scene is disposed.
  32477. */
  32478. onDisposeObservable: Observable<Scene>;
  32479. private _onDisposeObserver;
  32480. /** Sets a function to be executed when this scene is disposed. */
  32481. onDispose: () => void;
  32482. /**
  32483. * An event triggered before rendering the scene (right after animations and physics)
  32484. */
  32485. onBeforeRenderObservable: Observable<Scene>;
  32486. private _onBeforeRenderObserver;
  32487. /** Sets a function to be executed before rendering this scene */
  32488. beforeRender: Nullable<() => void>;
  32489. /**
  32490. * An event triggered after rendering the scene
  32491. */
  32492. onAfterRenderObservable: Observable<Scene>;
  32493. /**
  32494. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  32495. */
  32496. onAfterRenderCameraObservable: Observable<Camera>;
  32497. private _onAfterRenderObserver;
  32498. /** Sets a function to be executed after rendering this scene */
  32499. afterRender: Nullable<() => void>;
  32500. /**
  32501. * An event triggered before animating the scene
  32502. */
  32503. onBeforeAnimationsObservable: Observable<Scene>;
  32504. /**
  32505. * An event triggered after animations processing
  32506. */
  32507. onAfterAnimationsObservable: Observable<Scene>;
  32508. /**
  32509. * An event triggered before draw calls are ready to be sent
  32510. */
  32511. onBeforeDrawPhaseObservable: Observable<Scene>;
  32512. /**
  32513. * An event triggered after draw calls have been sent
  32514. */
  32515. onAfterDrawPhaseObservable: Observable<Scene>;
  32516. /**
  32517. * An event triggered when the scene is ready
  32518. */
  32519. onReadyObservable: Observable<Scene>;
  32520. /**
  32521. * An event triggered before rendering a camera
  32522. */
  32523. onBeforeCameraRenderObservable: Observable<Camera>;
  32524. private _onBeforeCameraRenderObserver;
  32525. /** Sets a function to be executed before rendering a camera*/
  32526. beforeCameraRender: () => void;
  32527. /**
  32528. * An event triggered after rendering a camera
  32529. */
  32530. onAfterCameraRenderObservable: Observable<Camera>;
  32531. private _onAfterCameraRenderObserver;
  32532. /** Sets a function to be executed after rendering a camera*/
  32533. afterCameraRender: () => void;
  32534. /**
  32535. * An event triggered when active meshes evaluation is about to start
  32536. */
  32537. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32538. /**
  32539. * An event triggered when active meshes evaluation is done
  32540. */
  32541. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32542. /**
  32543. * An event triggered when particles rendering is about to start
  32544. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32545. */
  32546. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32547. /**
  32548. * An event triggered when particles rendering is done
  32549. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32550. */
  32551. onAfterParticlesRenderingObservable: Observable<Scene>;
  32552. /**
  32553. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32554. */
  32555. onDataLoadedObservable: Observable<Scene>;
  32556. /**
  32557. * An event triggered when a camera is created
  32558. */
  32559. onNewCameraAddedObservable: Observable<Camera>;
  32560. /**
  32561. * An event triggered when a camera is removed
  32562. */
  32563. onCameraRemovedObservable: Observable<Camera>;
  32564. /**
  32565. * An event triggered when a light is created
  32566. */
  32567. onNewLightAddedObservable: Observable<Light>;
  32568. /**
  32569. * An event triggered when a light is removed
  32570. */
  32571. onLightRemovedObservable: Observable<Light>;
  32572. /**
  32573. * An event triggered when a geometry is created
  32574. */
  32575. onNewGeometryAddedObservable: Observable<Geometry>;
  32576. /**
  32577. * An event triggered when a geometry is removed
  32578. */
  32579. onGeometryRemovedObservable: Observable<Geometry>;
  32580. /**
  32581. * An event triggered when a transform node is created
  32582. */
  32583. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32584. /**
  32585. * An event triggered when a transform node is removed
  32586. */
  32587. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32588. /**
  32589. * An event triggered when a mesh is created
  32590. */
  32591. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32592. /**
  32593. * An event triggered when a mesh is removed
  32594. */
  32595. onMeshRemovedObservable: Observable<AbstractMesh>;
  32596. /**
  32597. * An event triggered when a skeleton is created
  32598. */
  32599. onNewSkeletonAddedObservable: Observable<Skeleton>;
  32600. /**
  32601. * An event triggered when a skeleton is removed
  32602. */
  32603. onSkeletonRemovedObservable: Observable<Skeleton>;
  32604. /**
  32605. * An event triggered when a material is created
  32606. */
  32607. onNewMaterialAddedObservable: Observable<Material>;
  32608. /**
  32609. * An event triggered when a material is removed
  32610. */
  32611. onMaterialRemovedObservable: Observable<Material>;
  32612. /**
  32613. * An event triggered when a texture is created
  32614. */
  32615. onNewTextureAddedObservable: Observable<BaseTexture>;
  32616. /**
  32617. * An event triggered when a texture is removed
  32618. */
  32619. onTextureRemovedObservable: Observable<BaseTexture>;
  32620. /**
  32621. * An event triggered when render targets are about to be rendered
  32622. * Can happen multiple times per frame.
  32623. */
  32624. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32625. /**
  32626. * An event triggered when render targets were rendered.
  32627. * Can happen multiple times per frame.
  32628. */
  32629. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32630. /**
  32631. * An event triggered before calculating deterministic simulation step
  32632. */
  32633. onBeforeStepObservable: Observable<Scene>;
  32634. /**
  32635. * An event triggered after calculating deterministic simulation step
  32636. */
  32637. onAfterStepObservable: Observable<Scene>;
  32638. /**
  32639. * An event triggered when the activeCamera property is updated
  32640. */
  32641. onActiveCameraChanged: Observable<Scene>;
  32642. /**
  32643. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32644. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32645. * 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)
  32646. */
  32647. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32648. /**
  32649. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32650. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32651. * 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)
  32652. */
  32653. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32654. /**
  32655. * This Observable will when a mesh has been imported into the scene.
  32656. */
  32657. onMeshImportedObservable: Observable<AbstractMesh>;
  32658. /**
  32659. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32660. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32661. */
  32662. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32663. /** @hidden */
  32664. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32665. /**
  32666. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32667. */
  32668. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32669. /**
  32670. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32671. */
  32672. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32673. /**
  32674. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32675. */
  32676. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32677. /** Callback called when a pointer move is detected */
  32678. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32679. /** Callback called when a pointer down is detected */
  32680. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32681. /** Callback called when a pointer up is detected */
  32682. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32683. /** Callback called when a pointer pick is detected */
  32684. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32685. /**
  32686. * 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).
  32687. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32688. */
  32689. onPrePointerObservable: Observable<PointerInfoPre>;
  32690. /**
  32691. * Observable event triggered each time an input event is received from the rendering canvas
  32692. */
  32693. onPointerObservable: Observable<PointerInfo>;
  32694. /**
  32695. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32696. */
  32697. readonly unTranslatedPointer: Vector2;
  32698. /**
  32699. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  32700. */
  32701. static DragMovementThreshold: number;
  32702. /**
  32703. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  32704. */
  32705. static LongPressDelay: number;
  32706. /**
  32707. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  32708. */
  32709. static DoubleClickDelay: number;
  32710. /** If you need to check double click without raising a single click at first click, enable this flag */
  32711. static ExclusiveDoubleClickMode: boolean;
  32712. /** @hidden */
  32713. _mirroredCameraPosition: Nullable<Vector3>;
  32714. /**
  32715. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32716. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32717. */
  32718. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32719. /**
  32720. * Observable event triggered each time an keyboard event is received from the hosting window
  32721. */
  32722. onKeyboardObservable: Observable<KeyboardInfo>;
  32723. private _useRightHandedSystem;
  32724. /**
  32725. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32726. */
  32727. useRightHandedSystem: boolean;
  32728. private _timeAccumulator;
  32729. private _currentStepId;
  32730. private _currentInternalStep;
  32731. /**
  32732. * Sets the step Id used by deterministic lock step
  32733. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32734. * @param newStepId defines the step Id
  32735. */
  32736. setStepId(newStepId: number): void;
  32737. /**
  32738. * Gets the step Id used by deterministic lock step
  32739. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32740. * @returns the step Id
  32741. */
  32742. getStepId(): number;
  32743. /**
  32744. * Gets the internal step used by deterministic lock step
  32745. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32746. * @returns the internal step
  32747. */
  32748. getInternalStep(): number;
  32749. private _fogEnabled;
  32750. /**
  32751. * Gets or sets a boolean indicating if fog is enabled on this scene
  32752. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32753. * (Default is true)
  32754. */
  32755. fogEnabled: boolean;
  32756. private _fogMode;
  32757. /**
  32758. * Gets or sets the fog mode to use
  32759. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32760. * | mode | value |
  32761. * | --- | --- |
  32762. * | FOGMODE_NONE | 0 |
  32763. * | FOGMODE_EXP | 1 |
  32764. * | FOGMODE_EXP2 | 2 |
  32765. * | FOGMODE_LINEAR | 3 |
  32766. */
  32767. fogMode: number;
  32768. /**
  32769. * Gets or sets the fog color to use
  32770. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32771. * (Default is Color3(0.2, 0.2, 0.3))
  32772. */
  32773. fogColor: Color3;
  32774. /**
  32775. * Gets or sets the fog density to use
  32776. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32777. * (Default is 0.1)
  32778. */
  32779. fogDensity: number;
  32780. /**
  32781. * Gets or sets the fog start distance to use
  32782. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32783. * (Default is 0)
  32784. */
  32785. fogStart: number;
  32786. /**
  32787. * Gets or sets the fog end distance to use
  32788. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32789. * (Default is 1000)
  32790. */
  32791. fogEnd: number;
  32792. private _shadowsEnabled;
  32793. /**
  32794. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32795. */
  32796. shadowsEnabled: boolean;
  32797. private _lightsEnabled;
  32798. /**
  32799. * Gets or sets a boolean indicating if lights are enabled on this scene
  32800. */
  32801. lightsEnabled: boolean;
  32802. /** All of the active cameras added to this scene. */
  32803. activeCameras: Camera[];
  32804. /** @hidden */
  32805. _activeCamera: Nullable<Camera>;
  32806. /** Gets or sets the current active camera */
  32807. activeCamera: Nullable<Camera>;
  32808. private _defaultMaterial;
  32809. /** The default material used on meshes when no material is affected */
  32810. /** The default material used on meshes when no material is affected */
  32811. defaultMaterial: Material;
  32812. private _texturesEnabled;
  32813. /**
  32814. * Gets or sets a boolean indicating if textures are enabled on this scene
  32815. */
  32816. texturesEnabled: boolean;
  32817. /**
  32818. * Gets or sets a boolean indicating if particles are enabled on this scene
  32819. */
  32820. particlesEnabled: boolean;
  32821. /**
  32822. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32823. */
  32824. spritesEnabled: boolean;
  32825. private _skeletonsEnabled;
  32826. /**
  32827. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32828. */
  32829. skeletonsEnabled: boolean;
  32830. /**
  32831. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32832. */
  32833. lensFlaresEnabled: boolean;
  32834. /**
  32835. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32836. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32837. */
  32838. collisionsEnabled: boolean;
  32839. private _collisionCoordinator;
  32840. /** @hidden */
  32841. readonly collisionCoordinator: ICollisionCoordinator;
  32842. /**
  32843. * Defines the gravity applied to this scene (used only for collisions)
  32844. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32845. */
  32846. gravity: Vector3;
  32847. /**
  32848. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32849. */
  32850. postProcessesEnabled: boolean;
  32851. /**
  32852. * The list of postprocesses added to the scene
  32853. */
  32854. postProcesses: PostProcess[];
  32855. /**
  32856. * Gets the current postprocess manager
  32857. */
  32858. postProcessManager: PostProcessManager;
  32859. /**
  32860. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32861. */
  32862. renderTargetsEnabled: boolean;
  32863. /**
  32864. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32865. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32866. */
  32867. dumpNextRenderTargets: boolean;
  32868. /**
  32869. * The list of user defined render targets added to the scene
  32870. */
  32871. customRenderTargets: RenderTargetTexture[];
  32872. /**
  32873. * Defines if texture loading must be delayed
  32874. * If true, textures will only be loaded when they need to be rendered
  32875. */
  32876. useDelayedTextureLoading: boolean;
  32877. /**
  32878. * Gets the list of meshes imported to the scene through SceneLoader
  32879. */
  32880. importedMeshesFiles: String[];
  32881. /**
  32882. * Gets or sets a boolean indicating if probes are enabled on this scene
  32883. */
  32884. probesEnabled: boolean;
  32885. /**
  32886. * Gets or sets the current offline provider to use to store scene data
  32887. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32888. */
  32889. offlineProvider: IOfflineProvider;
  32890. /**
  32891. * Gets or sets the action manager associated with the scene
  32892. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32893. */
  32894. actionManager: AbstractActionManager;
  32895. private _meshesForIntersections;
  32896. /**
  32897. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32898. */
  32899. proceduralTexturesEnabled: boolean;
  32900. private _engine;
  32901. private _totalVertices;
  32902. /** @hidden */
  32903. _activeIndices: PerfCounter;
  32904. /** @hidden */
  32905. _activeParticles: PerfCounter;
  32906. /** @hidden */
  32907. _activeBones: PerfCounter;
  32908. private _animationRatio;
  32909. /** @hidden */
  32910. _animationTimeLast: number;
  32911. /** @hidden */
  32912. _animationTime: number;
  32913. /**
  32914. * Gets or sets a general scale for animation speed
  32915. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32916. */
  32917. animationTimeScale: number;
  32918. /** @hidden */
  32919. _cachedMaterial: Nullable<Material>;
  32920. /** @hidden */
  32921. _cachedEffect: Nullable<Effect>;
  32922. /** @hidden */
  32923. _cachedVisibility: Nullable<number>;
  32924. private _renderId;
  32925. private _frameId;
  32926. private _executeWhenReadyTimeoutId;
  32927. private _intermediateRendering;
  32928. private _viewUpdateFlag;
  32929. private _projectionUpdateFlag;
  32930. /** @hidden */
  32931. _toBeDisposed: Nullable<IDisposable>[];
  32932. private _activeRequests;
  32933. /** @hidden */
  32934. _pendingData: any[];
  32935. private _isDisposed;
  32936. /**
  32937. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32938. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32939. */
  32940. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32941. private _activeMeshes;
  32942. private _processedMaterials;
  32943. private _renderTargets;
  32944. /** @hidden */
  32945. _activeParticleSystems: SmartArray<IParticleSystem>;
  32946. private _activeSkeletons;
  32947. private _softwareSkinnedMeshes;
  32948. private _renderingManager;
  32949. /** @hidden */
  32950. _activeAnimatables: Animatable[];
  32951. private _transformMatrix;
  32952. private _sceneUbo;
  32953. /** @hidden */
  32954. _viewMatrix: Matrix;
  32955. private _projectionMatrix;
  32956. /** @hidden */
  32957. _forcedViewPosition: Nullable<Vector3>;
  32958. /** @hidden */
  32959. _frustumPlanes: Plane[];
  32960. /**
  32961. * Gets the list of frustum planes (built from the active camera)
  32962. */
  32963. readonly frustumPlanes: Plane[];
  32964. /**
  32965. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32966. * This is useful if there are more lights that the maximum simulteanous authorized
  32967. */
  32968. requireLightSorting: boolean;
  32969. /** @hidden */
  32970. readonly useMaterialMeshMap: boolean;
  32971. /** @hidden */
  32972. readonly useClonedMeshhMap: boolean;
  32973. private _externalData;
  32974. private _uid;
  32975. /**
  32976. * @hidden
  32977. * Backing store of defined scene components.
  32978. */
  32979. _components: ISceneComponent[];
  32980. /**
  32981. * @hidden
  32982. * Backing store of defined scene components.
  32983. */
  32984. _serializableComponents: ISceneSerializableComponent[];
  32985. /**
  32986. * List of components to register on the next registration step.
  32987. */
  32988. private _transientComponents;
  32989. /**
  32990. * Registers the transient components if needed.
  32991. */
  32992. private _registerTransientComponents;
  32993. /**
  32994. * @hidden
  32995. * Add a component to the scene.
  32996. * Note that the ccomponent could be registered on th next frame if this is called after
  32997. * the register component stage.
  32998. * @param component Defines the component to add to the scene
  32999. */
  33000. _addComponent(component: ISceneComponent): void;
  33001. /**
  33002. * @hidden
  33003. * Gets a component from the scene.
  33004. * @param name defines the name of the component to retrieve
  33005. * @returns the component or null if not present
  33006. */
  33007. _getComponent(name: string): Nullable<ISceneComponent>;
  33008. /**
  33009. * @hidden
  33010. * Defines the actions happening before camera updates.
  33011. */
  33012. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33013. /**
  33014. * @hidden
  33015. * Defines the actions happening before clear the canvas.
  33016. */
  33017. _beforeClearStage: Stage<SimpleStageAction>;
  33018. /**
  33019. * @hidden
  33020. * Defines the actions when collecting render targets for the frame.
  33021. */
  33022. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33023. /**
  33024. * @hidden
  33025. * Defines the actions happening for one camera in the frame.
  33026. */
  33027. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33028. /**
  33029. * @hidden
  33030. * Defines the actions happening during the per mesh ready checks.
  33031. */
  33032. _isReadyForMeshStage: Stage<MeshStageAction>;
  33033. /**
  33034. * @hidden
  33035. * Defines the actions happening before evaluate active mesh checks.
  33036. */
  33037. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33038. /**
  33039. * @hidden
  33040. * Defines the actions happening during the evaluate sub mesh checks.
  33041. */
  33042. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33043. /**
  33044. * @hidden
  33045. * Defines the actions happening during the active mesh stage.
  33046. */
  33047. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33048. /**
  33049. * @hidden
  33050. * Defines the actions happening during the per camera render target step.
  33051. */
  33052. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33053. /**
  33054. * @hidden
  33055. * Defines the actions happening just before the active camera is drawing.
  33056. */
  33057. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33058. /**
  33059. * @hidden
  33060. * Defines the actions happening just before a render target is drawing.
  33061. */
  33062. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33063. /**
  33064. * @hidden
  33065. * Defines the actions happening just before a rendering group is drawing.
  33066. */
  33067. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33068. /**
  33069. * @hidden
  33070. * Defines the actions happening just before a mesh is drawing.
  33071. */
  33072. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33073. /**
  33074. * @hidden
  33075. * Defines the actions happening just after a mesh has been drawn.
  33076. */
  33077. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33078. /**
  33079. * @hidden
  33080. * Defines the actions happening just after a rendering group has been drawn.
  33081. */
  33082. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33083. /**
  33084. * @hidden
  33085. * Defines the actions happening just after the active camera has been drawn.
  33086. */
  33087. _afterCameraDrawStage: Stage<CameraStageAction>;
  33088. /**
  33089. * @hidden
  33090. * Defines the actions happening just after a render target has been drawn.
  33091. */
  33092. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33093. /**
  33094. * @hidden
  33095. * Defines the actions happening just after rendering all cameras and computing intersections.
  33096. */
  33097. _afterRenderStage: Stage<SimpleStageAction>;
  33098. /**
  33099. * @hidden
  33100. * Defines the actions happening when a pointer move event happens.
  33101. */
  33102. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33103. /**
  33104. * @hidden
  33105. * Defines the actions happening when a pointer down event happens.
  33106. */
  33107. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33108. /**
  33109. * @hidden
  33110. * Defines the actions happening when a pointer up event happens.
  33111. */
  33112. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33113. /**
  33114. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33115. */
  33116. private geometriesByUniqueId;
  33117. /**
  33118. * Creates a new Scene
  33119. * @param engine defines the engine to use to render this scene
  33120. * @param options defines the scene options
  33121. */
  33122. constructor(engine: Engine, options?: SceneOptions);
  33123. /**
  33124. * Gets a string idenfifying the name of the class
  33125. * @returns "Scene" string
  33126. */
  33127. getClassName(): string;
  33128. private _defaultMeshCandidates;
  33129. /**
  33130. * @hidden
  33131. */
  33132. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33133. private _defaultSubMeshCandidates;
  33134. /**
  33135. * @hidden
  33136. */
  33137. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33138. /**
  33139. * Sets the default candidate providers for the scene.
  33140. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33141. * and getCollidingSubMeshCandidates to their default function
  33142. */
  33143. setDefaultCandidateProviders(): void;
  33144. /**
  33145. * Gets the mesh that is currently under the pointer
  33146. */
  33147. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33148. /**
  33149. * Gets or sets the current on-screen X position of the pointer
  33150. */
  33151. pointerX: number;
  33152. /**
  33153. * Gets or sets the current on-screen Y position of the pointer
  33154. */
  33155. pointerY: number;
  33156. /**
  33157. * Gets the cached material (ie. the latest rendered one)
  33158. * @returns the cached material
  33159. */
  33160. getCachedMaterial(): Nullable<Material>;
  33161. /**
  33162. * Gets the cached effect (ie. the latest rendered one)
  33163. * @returns the cached effect
  33164. */
  33165. getCachedEffect(): Nullable<Effect>;
  33166. /**
  33167. * Gets the cached visibility state (ie. the latest rendered one)
  33168. * @returns the cached visibility state
  33169. */
  33170. getCachedVisibility(): Nullable<number>;
  33171. /**
  33172. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33173. * @param material defines the current material
  33174. * @param effect defines the current effect
  33175. * @param visibility defines the current visibility state
  33176. * @returns true if one parameter is not cached
  33177. */
  33178. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33179. /**
  33180. * Gets the engine associated with the scene
  33181. * @returns an Engine
  33182. */
  33183. getEngine(): Engine;
  33184. /**
  33185. * Gets the total number of vertices rendered per frame
  33186. * @returns the total number of vertices rendered per frame
  33187. */
  33188. getTotalVertices(): number;
  33189. /**
  33190. * Gets the performance counter for total vertices
  33191. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33192. */
  33193. readonly totalVerticesPerfCounter: PerfCounter;
  33194. /**
  33195. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33196. * @returns the total number of active indices rendered per frame
  33197. */
  33198. getActiveIndices(): number;
  33199. /**
  33200. * Gets the performance counter for active indices
  33201. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33202. */
  33203. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33204. /**
  33205. * Gets the total number of active particles rendered per frame
  33206. * @returns the total number of active particles rendered per frame
  33207. */
  33208. getActiveParticles(): number;
  33209. /**
  33210. * Gets the performance counter for active particles
  33211. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33212. */
  33213. readonly activeParticlesPerfCounter: PerfCounter;
  33214. /**
  33215. * Gets the total number of active bones rendered per frame
  33216. * @returns the total number of active bones rendered per frame
  33217. */
  33218. getActiveBones(): number;
  33219. /**
  33220. * Gets the performance counter for active bones
  33221. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33222. */
  33223. readonly activeBonesPerfCounter: PerfCounter;
  33224. /**
  33225. * Gets the array of active meshes
  33226. * @returns an array of AbstractMesh
  33227. */
  33228. getActiveMeshes(): SmartArray<AbstractMesh>;
  33229. /**
  33230. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33231. * @returns a number
  33232. */
  33233. getAnimationRatio(): number;
  33234. /**
  33235. * Gets an unique Id for the current render phase
  33236. * @returns a number
  33237. */
  33238. getRenderId(): number;
  33239. /**
  33240. * Gets an unique Id for the current frame
  33241. * @returns a number
  33242. */
  33243. getFrameId(): number;
  33244. /** Call this function if you want to manually increment the render Id*/
  33245. incrementRenderId(): void;
  33246. private _createUbo;
  33247. /**
  33248. * Use this method to simulate a pointer move on a mesh
  33249. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33250. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33251. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33252. * @returns the current scene
  33253. */
  33254. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33255. /**
  33256. * Use this method to simulate a pointer down on a mesh
  33257. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33258. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33259. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33260. * @returns the current scene
  33261. */
  33262. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33263. /**
  33264. * Use this method to simulate a pointer up on a mesh
  33265. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33266. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33267. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33268. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33269. * @returns the current scene
  33270. */
  33271. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33272. /**
  33273. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33274. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33275. * @returns true if the pointer was captured
  33276. */
  33277. isPointerCaptured(pointerId?: number): boolean;
  33278. /**
  33279. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33280. * @param attachUp defines if you want to attach events to pointerup
  33281. * @param attachDown defines if you want to attach events to pointerdown
  33282. * @param attachMove defines if you want to attach events to pointermove
  33283. */
  33284. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33285. /** Detaches all event handlers*/
  33286. detachControl(): void;
  33287. /**
  33288. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33289. * Delay loaded resources are not taking in account
  33290. * @return true if all required resources are ready
  33291. */
  33292. isReady(): boolean;
  33293. /** Resets all cached information relative to material (including effect and visibility) */
  33294. resetCachedMaterial(): void;
  33295. /**
  33296. * Registers a function to be called before every frame render
  33297. * @param func defines the function to register
  33298. */
  33299. registerBeforeRender(func: () => void): void;
  33300. /**
  33301. * Unregisters a function called before every frame render
  33302. * @param func defines the function to unregister
  33303. */
  33304. unregisterBeforeRender(func: () => void): void;
  33305. /**
  33306. * Registers a function to be called after every frame render
  33307. * @param func defines the function to register
  33308. */
  33309. registerAfterRender(func: () => void): void;
  33310. /**
  33311. * Unregisters a function called after every frame render
  33312. * @param func defines the function to unregister
  33313. */
  33314. unregisterAfterRender(func: () => void): void;
  33315. private _executeOnceBeforeRender;
  33316. /**
  33317. * The provided function will run before render once and will be disposed afterwards.
  33318. * A timeout delay can be provided so that the function will be executed in N ms.
  33319. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33320. * @param func The function to be executed.
  33321. * @param timeout optional delay in ms
  33322. */
  33323. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33324. /** @hidden */
  33325. _addPendingData(data: any): void;
  33326. /** @hidden */
  33327. _removePendingData(data: any): void;
  33328. /**
  33329. * Returns the number of items waiting to be loaded
  33330. * @returns the number of items waiting to be loaded
  33331. */
  33332. getWaitingItemsCount(): number;
  33333. /**
  33334. * Returns a boolean indicating if the scene is still loading data
  33335. */
  33336. readonly isLoading: boolean;
  33337. /**
  33338. * Registers a function to be executed when the scene is ready
  33339. * @param {Function} func - the function to be executed
  33340. */
  33341. executeWhenReady(func: () => void): void;
  33342. /**
  33343. * Returns a promise that resolves when the scene is ready
  33344. * @returns A promise that resolves when the scene is ready
  33345. */
  33346. whenReadyAsync(): Promise<void>;
  33347. /** @hidden */
  33348. _checkIsReady(): void;
  33349. /**
  33350. * Gets all animatable attached to the scene
  33351. */
  33352. readonly animatables: Animatable[];
  33353. /**
  33354. * Resets the last animation time frame.
  33355. * Useful to override when animations start running when loading a scene for the first time.
  33356. */
  33357. resetLastAnimationTimeFrame(): void;
  33358. /**
  33359. * Gets the current view matrix
  33360. * @returns a Matrix
  33361. */
  33362. getViewMatrix(): Matrix;
  33363. /**
  33364. * Gets the current projection matrix
  33365. * @returns a Matrix
  33366. */
  33367. getProjectionMatrix(): Matrix;
  33368. /**
  33369. * Gets the current transform matrix
  33370. * @returns a Matrix made of View * Projection
  33371. */
  33372. getTransformMatrix(): Matrix;
  33373. /**
  33374. * Sets the current transform matrix
  33375. * @param viewL defines the View matrix to use
  33376. * @param projectionL defines the Projection matrix to use
  33377. * @param viewR defines the right View matrix to use (if provided)
  33378. * @param projectionR defines the right Projection matrix to use (if provided)
  33379. */
  33380. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33381. /**
  33382. * Gets the uniform buffer used to store scene data
  33383. * @returns a UniformBuffer
  33384. */
  33385. getSceneUniformBuffer(): UniformBuffer;
  33386. /**
  33387. * Gets an unique (relatively to the current scene) Id
  33388. * @returns an unique number for the scene
  33389. */
  33390. getUniqueId(): number;
  33391. /**
  33392. * Add a mesh to the list of scene's meshes
  33393. * @param newMesh defines the mesh to add
  33394. * @param recursive if all child meshes should also be added to the scene
  33395. */
  33396. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33397. /**
  33398. * Remove a mesh for the list of scene's meshes
  33399. * @param toRemove defines the mesh to remove
  33400. * @param recursive if all child meshes should also be removed from the scene
  33401. * @returns the index where the mesh was in the mesh list
  33402. */
  33403. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33404. /**
  33405. * Add a transform node to the list of scene's transform nodes
  33406. * @param newTransformNode defines the transform node to add
  33407. */
  33408. addTransformNode(newTransformNode: TransformNode): void;
  33409. /**
  33410. * Remove a transform node for the list of scene's transform nodes
  33411. * @param toRemove defines the transform node to remove
  33412. * @returns the index where the transform node was in the transform node list
  33413. */
  33414. removeTransformNode(toRemove: TransformNode): number;
  33415. /**
  33416. * Remove a skeleton for the list of scene's skeletons
  33417. * @param toRemove defines the skeleton to remove
  33418. * @returns the index where the skeleton was in the skeleton list
  33419. */
  33420. removeSkeleton(toRemove: Skeleton): number;
  33421. /**
  33422. * Remove a morph target for the list of scene's morph targets
  33423. * @param toRemove defines the morph target to remove
  33424. * @returns the index where the morph target was in the morph target list
  33425. */
  33426. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33427. /**
  33428. * Remove a light for the list of scene's lights
  33429. * @param toRemove defines the light to remove
  33430. * @returns the index where the light was in the light list
  33431. */
  33432. removeLight(toRemove: Light): number;
  33433. /**
  33434. * Remove a camera for the list of scene's cameras
  33435. * @param toRemove defines the camera to remove
  33436. * @returns the index where the camera was in the camera list
  33437. */
  33438. removeCamera(toRemove: Camera): number;
  33439. /**
  33440. * Remove a particle system for the list of scene's particle systems
  33441. * @param toRemove defines the particle system to remove
  33442. * @returns the index where the particle system was in the particle system list
  33443. */
  33444. removeParticleSystem(toRemove: IParticleSystem): number;
  33445. /**
  33446. * Remove a animation for the list of scene's animations
  33447. * @param toRemove defines the animation to remove
  33448. * @returns the index where the animation was in the animation list
  33449. */
  33450. removeAnimation(toRemove: Animation): number;
  33451. /**
  33452. * Will stop the animation of the given target
  33453. * @param target - the target
  33454. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  33455. * @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)
  33456. */
  33457. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  33458. /**
  33459. * Removes the given animation group from this scene.
  33460. * @param toRemove The animation group to remove
  33461. * @returns The index of the removed animation group
  33462. */
  33463. removeAnimationGroup(toRemove: AnimationGroup): number;
  33464. /**
  33465. * Removes the given multi-material from this scene.
  33466. * @param toRemove The multi-material to remove
  33467. * @returns The index of the removed multi-material
  33468. */
  33469. removeMultiMaterial(toRemove: MultiMaterial): number;
  33470. /**
  33471. * Removes the given material from this scene.
  33472. * @param toRemove The material to remove
  33473. * @returns The index of the removed material
  33474. */
  33475. removeMaterial(toRemove: Material): number;
  33476. /**
  33477. * Removes the given action manager from this scene.
  33478. * @param toRemove The action manager to remove
  33479. * @returns The index of the removed action manager
  33480. */
  33481. removeActionManager(toRemove: AbstractActionManager): number;
  33482. /**
  33483. * Removes the given texture from this scene.
  33484. * @param toRemove The texture to remove
  33485. * @returns The index of the removed texture
  33486. */
  33487. removeTexture(toRemove: BaseTexture): number;
  33488. /**
  33489. * Adds the given light to this scene
  33490. * @param newLight The light to add
  33491. */
  33492. addLight(newLight: Light): void;
  33493. /**
  33494. * Sorts the list list based on light priorities
  33495. */
  33496. sortLightsByPriority(): void;
  33497. /**
  33498. * Adds the given camera to this scene
  33499. * @param newCamera The camera to add
  33500. */
  33501. addCamera(newCamera: Camera): void;
  33502. /**
  33503. * Adds the given skeleton to this scene
  33504. * @param newSkeleton The skeleton to add
  33505. */
  33506. addSkeleton(newSkeleton: Skeleton): void;
  33507. /**
  33508. * Adds the given particle system to this scene
  33509. * @param newParticleSystem The particle system to add
  33510. */
  33511. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33512. /**
  33513. * Adds the given animation to this scene
  33514. * @param newAnimation The animation to add
  33515. */
  33516. addAnimation(newAnimation: Animation): void;
  33517. /**
  33518. * Adds the given animation group to this scene.
  33519. * @param newAnimationGroup The animation group to add
  33520. */
  33521. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33522. /**
  33523. * Adds the given multi-material to this scene
  33524. * @param newMultiMaterial The multi-material to add
  33525. */
  33526. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33527. /**
  33528. * Adds the given material to this scene
  33529. * @param newMaterial The material to add
  33530. */
  33531. addMaterial(newMaterial: Material): void;
  33532. /**
  33533. * Adds the given morph target to this scene
  33534. * @param newMorphTargetManager The morph target to add
  33535. */
  33536. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33537. /**
  33538. * Adds the given geometry to this scene
  33539. * @param newGeometry The geometry to add
  33540. */
  33541. addGeometry(newGeometry: Geometry): void;
  33542. /**
  33543. * Adds the given action manager to this scene
  33544. * @param newActionManager The action manager to add
  33545. */
  33546. addActionManager(newActionManager: AbstractActionManager): void;
  33547. /**
  33548. * Adds the given texture to this scene.
  33549. * @param newTexture The texture to add
  33550. */
  33551. addTexture(newTexture: BaseTexture): void;
  33552. /**
  33553. * Switch active camera
  33554. * @param newCamera defines the new active camera
  33555. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33556. */
  33557. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33558. /**
  33559. * sets the active camera of the scene using its ID
  33560. * @param id defines the camera's ID
  33561. * @return the new active camera or null if none found.
  33562. */
  33563. setActiveCameraByID(id: string): Nullable<Camera>;
  33564. /**
  33565. * sets the active camera of the scene using its name
  33566. * @param name defines the camera's name
  33567. * @returns the new active camera or null if none found.
  33568. */
  33569. setActiveCameraByName(name: string): Nullable<Camera>;
  33570. /**
  33571. * get an animation group using its name
  33572. * @param name defines the material's name
  33573. * @return the animation group or null if none found.
  33574. */
  33575. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33576. /**
  33577. * Get a material using its unique id
  33578. * @param uniqueId defines the material's unique id
  33579. * @return the material or null if none found.
  33580. */
  33581. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  33582. /**
  33583. * get a material using its id
  33584. * @param id defines the material's ID
  33585. * @return the material or null if none found.
  33586. */
  33587. getMaterialByID(id: string): Nullable<Material>;
  33588. /**
  33589. * Gets a the last added material using a given id
  33590. * @param id defines the material's ID
  33591. * @return the last material with the given id or null if none found.
  33592. */
  33593. getLastMaterialByID(id: string): Nullable<Material>;
  33594. /**
  33595. * Gets a material using its name
  33596. * @param name defines the material's name
  33597. * @return the material or null if none found.
  33598. */
  33599. getMaterialByName(name: string): Nullable<Material>;
  33600. /**
  33601. * Gets a camera using its id
  33602. * @param id defines the id to look for
  33603. * @returns the camera or null if not found
  33604. */
  33605. getCameraByID(id: string): Nullable<Camera>;
  33606. /**
  33607. * Gets a camera using its unique id
  33608. * @param uniqueId defines the unique id to look for
  33609. * @returns the camera or null if not found
  33610. */
  33611. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33612. /**
  33613. * Gets a camera using its name
  33614. * @param name defines the camera's name
  33615. * @return the camera or null if none found.
  33616. */
  33617. getCameraByName(name: string): Nullable<Camera>;
  33618. /**
  33619. * Gets a bone using its id
  33620. * @param id defines the bone's id
  33621. * @return the bone or null if not found
  33622. */
  33623. getBoneByID(id: string): Nullable<Bone>;
  33624. /**
  33625. * Gets a bone using its id
  33626. * @param name defines the bone's name
  33627. * @return the bone or null if not found
  33628. */
  33629. getBoneByName(name: string): Nullable<Bone>;
  33630. /**
  33631. * Gets a light node using its name
  33632. * @param name defines the the light's name
  33633. * @return the light or null if none found.
  33634. */
  33635. getLightByName(name: string): Nullable<Light>;
  33636. /**
  33637. * Gets a light node using its id
  33638. * @param id defines the light's id
  33639. * @return the light or null if none found.
  33640. */
  33641. getLightByID(id: string): Nullable<Light>;
  33642. /**
  33643. * Gets a light node using its scene-generated unique ID
  33644. * @param uniqueId defines the light's unique id
  33645. * @return the light or null if none found.
  33646. */
  33647. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33648. /**
  33649. * Gets a particle system by id
  33650. * @param id defines the particle system id
  33651. * @return the corresponding system or null if none found
  33652. */
  33653. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33654. /**
  33655. * Gets a geometry using its ID
  33656. * @param id defines the geometry's id
  33657. * @return the geometry or null if none found.
  33658. */
  33659. getGeometryByID(id: string): Nullable<Geometry>;
  33660. private _getGeometryByUniqueID;
  33661. /**
  33662. * Add a new geometry to this scene
  33663. * @param geometry defines the geometry to be added to the scene.
  33664. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33665. * @return a boolean defining if the geometry was added or not
  33666. */
  33667. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33668. /**
  33669. * Removes an existing geometry
  33670. * @param geometry defines the geometry to be removed from the scene
  33671. * @return a boolean defining if the geometry was removed or not
  33672. */
  33673. removeGeometry(geometry: Geometry): boolean;
  33674. /**
  33675. * Gets the list of geometries attached to the scene
  33676. * @returns an array of Geometry
  33677. */
  33678. getGeometries(): Geometry[];
  33679. /**
  33680. * Gets the first added mesh found of a given ID
  33681. * @param id defines the id to search for
  33682. * @return the mesh found or null if not found at all
  33683. */
  33684. getMeshByID(id: string): Nullable<AbstractMesh>;
  33685. /**
  33686. * Gets a list of meshes using their id
  33687. * @param id defines the id to search for
  33688. * @returns a list of meshes
  33689. */
  33690. getMeshesByID(id: string): Array<AbstractMesh>;
  33691. /**
  33692. * Gets the first added transform node found of a given ID
  33693. * @param id defines the id to search for
  33694. * @return the found transform node or null if not found at all.
  33695. */
  33696. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33697. /**
  33698. * Gets a transform node with its auto-generated unique id
  33699. * @param uniqueId efines the unique id to search for
  33700. * @return the found transform node or null if not found at all.
  33701. */
  33702. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  33703. /**
  33704. * Gets a list of transform nodes using their id
  33705. * @param id defines the id to search for
  33706. * @returns a list of transform nodes
  33707. */
  33708. getTransformNodesByID(id: string): Array<TransformNode>;
  33709. /**
  33710. * Gets a mesh with its auto-generated unique id
  33711. * @param uniqueId defines the unique id to search for
  33712. * @return the found mesh or null if not found at all.
  33713. */
  33714. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33715. /**
  33716. * Gets a the last added mesh using a given id
  33717. * @param id defines the id to search for
  33718. * @return the found mesh or null if not found at all.
  33719. */
  33720. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33721. /**
  33722. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33723. * @param id defines the id to search for
  33724. * @return the found node or null if not found at all
  33725. */
  33726. getLastEntryByID(id: string): Nullable<Node>;
  33727. /**
  33728. * Gets a node (Mesh, Camera, Light) using a given id
  33729. * @param id defines the id to search for
  33730. * @return the found node or null if not found at all
  33731. */
  33732. getNodeByID(id: string): Nullable<Node>;
  33733. /**
  33734. * Gets a node (Mesh, Camera, Light) using a given name
  33735. * @param name defines the name to search for
  33736. * @return the found node or null if not found at all.
  33737. */
  33738. getNodeByName(name: string): Nullable<Node>;
  33739. /**
  33740. * Gets a mesh using a given name
  33741. * @param name defines the name to search for
  33742. * @return the found mesh or null if not found at all.
  33743. */
  33744. getMeshByName(name: string): Nullable<AbstractMesh>;
  33745. /**
  33746. * Gets a transform node using a given name
  33747. * @param name defines the name to search for
  33748. * @return the found transform node or null if not found at all.
  33749. */
  33750. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33751. /**
  33752. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33753. * @param id defines the id to search for
  33754. * @return the found skeleton or null if not found at all.
  33755. */
  33756. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33757. /**
  33758. * Gets a skeleton using a given auto generated unique id
  33759. * @param uniqueId defines the unique id to search for
  33760. * @return the found skeleton or null if not found at all.
  33761. */
  33762. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  33763. /**
  33764. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33765. * @param id defines the id to search for
  33766. * @return the found skeleton or null if not found at all.
  33767. */
  33768. getSkeletonById(id: string): Nullable<Skeleton>;
  33769. /**
  33770. * Gets a skeleton using a given name
  33771. * @param name defines the name to search for
  33772. * @return the found skeleton or null if not found at all.
  33773. */
  33774. getSkeletonByName(name: string): Nullable<Skeleton>;
  33775. /**
  33776. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33777. * @param id defines the id to search for
  33778. * @return the found morph target manager or null if not found at all.
  33779. */
  33780. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33781. /**
  33782. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33783. * @param id defines the id to search for
  33784. * @return the found morph target or null if not found at all.
  33785. */
  33786. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33787. /**
  33788. * Gets a boolean indicating if the given mesh is active
  33789. * @param mesh defines the mesh to look for
  33790. * @returns true if the mesh is in the active list
  33791. */
  33792. isActiveMesh(mesh: AbstractMesh): boolean;
  33793. /**
  33794. * Return a unique id as a string which can serve as an identifier for the scene
  33795. */
  33796. readonly uid: string;
  33797. /**
  33798. * Add an externaly attached data from its key.
  33799. * This method call will fail and return false, if such key already exists.
  33800. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33801. * @param key the unique key that identifies the data
  33802. * @param data the data object to associate to the key for this Engine instance
  33803. * @return true if no such key were already present and the data was added successfully, false otherwise
  33804. */
  33805. addExternalData<T>(key: string, data: T): boolean;
  33806. /**
  33807. * Get an externaly attached data from its key
  33808. * @param key the unique key that identifies the data
  33809. * @return the associated data, if present (can be null), or undefined if not present
  33810. */
  33811. getExternalData<T>(key: string): Nullable<T>;
  33812. /**
  33813. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33814. * @param key the unique key that identifies the data
  33815. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33816. * @return the associated data, can be null if the factory returned null.
  33817. */
  33818. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33819. /**
  33820. * Remove an externaly attached data from the Engine instance
  33821. * @param key the unique key that identifies the data
  33822. * @return true if the data was successfully removed, false if it doesn't exist
  33823. */
  33824. removeExternalData(key: string): boolean;
  33825. private _evaluateSubMesh;
  33826. /**
  33827. * Clear the processed materials smart array preventing retention point in material dispose.
  33828. */
  33829. freeProcessedMaterials(): void;
  33830. private _preventFreeActiveMeshesAndRenderingGroups;
  33831. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33832. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33833. * when disposing several meshes in a row or a hierarchy of meshes.
  33834. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33835. */
  33836. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33837. /**
  33838. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33839. */
  33840. freeActiveMeshes(): void;
  33841. /**
  33842. * Clear the info related to rendering groups preventing retention points during dispose.
  33843. */
  33844. freeRenderingGroups(): void;
  33845. /** @hidden */
  33846. _isInIntermediateRendering(): boolean;
  33847. /**
  33848. * Lambda returning the list of potentially active meshes.
  33849. */
  33850. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33851. /**
  33852. * Lambda returning the list of potentially active sub meshes.
  33853. */
  33854. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33855. /**
  33856. * Lambda returning the list of potentially intersecting sub meshes.
  33857. */
  33858. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33859. /**
  33860. * Lambda returning the list of potentially colliding sub meshes.
  33861. */
  33862. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33863. private _activeMeshesFrozen;
  33864. /**
  33865. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33866. * @returns the current scene
  33867. */
  33868. freezeActiveMeshes(): Scene;
  33869. /**
  33870. * Use this function to restart evaluating active meshes on every frame
  33871. * @returns the current scene
  33872. */
  33873. unfreezeActiveMeshes(): Scene;
  33874. private _evaluateActiveMeshes;
  33875. private _activeMesh;
  33876. /**
  33877. * Update the transform matrix to update from the current active camera
  33878. * @param force defines a boolean used to force the update even if cache is up to date
  33879. */
  33880. updateTransformMatrix(force?: boolean): void;
  33881. private _bindFrameBuffer;
  33882. /** @hidden */
  33883. _allowPostProcessClearColor: boolean;
  33884. /** @hidden */
  33885. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  33886. private _processSubCameras;
  33887. private _checkIntersections;
  33888. /** @hidden */
  33889. _advancePhysicsEngineStep(step: number): void;
  33890. /**
  33891. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33892. */
  33893. getDeterministicFrameTime: () => number;
  33894. /** @hidden */
  33895. _animate(): void;
  33896. /** Execute all animations (for a frame) */
  33897. animate(): void;
  33898. /**
  33899. * Render the scene
  33900. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33901. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  33902. */
  33903. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  33904. /**
  33905. * Freeze all materials
  33906. * A frozen material will not be updatable but should be faster to render
  33907. */
  33908. freezeMaterials(): void;
  33909. /**
  33910. * Unfreeze all materials
  33911. * A frozen material will not be updatable but should be faster to render
  33912. */
  33913. unfreezeMaterials(): void;
  33914. /**
  33915. * Releases all held ressources
  33916. */
  33917. dispose(): void;
  33918. /**
  33919. * Gets if the scene is already disposed
  33920. */
  33921. readonly isDisposed: boolean;
  33922. /**
  33923. * Call this function to reduce memory footprint of the scene.
  33924. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33925. */
  33926. clearCachedVertexData(): void;
  33927. /**
  33928. * This function will remove the local cached buffer data from texture.
  33929. * It will save memory but will prevent the texture from being rebuilt
  33930. */
  33931. cleanCachedTextureBuffer(): void;
  33932. /**
  33933. * Get the world extend vectors with an optional filter
  33934. *
  33935. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33936. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33937. */
  33938. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33939. min: Vector3;
  33940. max: Vector3;
  33941. };
  33942. /**
  33943. * Creates a ray that can be used to pick in the scene
  33944. * @param x defines the x coordinate of the origin (on-screen)
  33945. * @param y defines the y coordinate of the origin (on-screen)
  33946. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33947. * @param camera defines the camera to use for the picking
  33948. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33949. * @returns a Ray
  33950. */
  33951. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33952. /**
  33953. * Creates a ray that can be used to pick in the scene
  33954. * @param x defines the x coordinate of the origin (on-screen)
  33955. * @param y defines the y coordinate of the origin (on-screen)
  33956. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33957. * @param result defines the ray where to store the picking ray
  33958. * @param camera defines the camera to use for the picking
  33959. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33960. * @returns the current scene
  33961. */
  33962. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33963. /**
  33964. * Creates a ray that can be used to pick in the scene
  33965. * @param x defines the x coordinate of the origin (on-screen)
  33966. * @param y defines the y coordinate of the origin (on-screen)
  33967. * @param camera defines the camera to use for the picking
  33968. * @returns a Ray
  33969. */
  33970. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33971. /**
  33972. * Creates a ray that can be used to pick in the scene
  33973. * @param x defines the x coordinate of the origin (on-screen)
  33974. * @param y defines the y coordinate of the origin (on-screen)
  33975. * @param result defines the ray where to store the picking ray
  33976. * @param camera defines the camera to use for the picking
  33977. * @returns the current scene
  33978. */
  33979. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33980. /** Launch a ray to try to pick a mesh in the scene
  33981. * @param x position on screen
  33982. * @param y position on screen
  33983. * @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
  33984. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33985. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33986. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33987. * @returns a PickingInfo
  33988. */
  33989. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33990. /** Use the given ray to pick a mesh in the scene
  33991. * @param ray The ray to use to pick meshes
  33992. * @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
  33993. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33994. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33995. * @returns a PickingInfo
  33996. */
  33997. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33998. /**
  33999. * Launch a ray to try to pick a mesh in the scene
  34000. * @param x X position on screen
  34001. * @param y Y position on screen
  34002. * @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
  34003. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34004. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34005. * @returns an array of PickingInfo
  34006. */
  34007. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34008. /**
  34009. * Launch a ray to try to pick a mesh in the scene
  34010. * @param ray Ray to use
  34011. * @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
  34012. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34013. * @returns an array of PickingInfo
  34014. */
  34015. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34016. /**
  34017. * Force the value of meshUnderPointer
  34018. * @param mesh defines the mesh to use
  34019. */
  34020. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34021. /**
  34022. * Gets the mesh under the pointer
  34023. * @returns a Mesh or null if no mesh is under the pointer
  34024. */
  34025. getPointerOverMesh(): Nullable<AbstractMesh>;
  34026. /** @hidden */
  34027. _rebuildGeometries(): void;
  34028. /** @hidden */
  34029. _rebuildTextures(): void;
  34030. private _getByTags;
  34031. /**
  34032. * Get a list of meshes by tags
  34033. * @param tagsQuery defines the tags query to use
  34034. * @param forEach defines a predicate used to filter results
  34035. * @returns an array of Mesh
  34036. */
  34037. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34038. /**
  34039. * Get a list of cameras by tags
  34040. * @param tagsQuery defines the tags query to use
  34041. * @param forEach defines a predicate used to filter results
  34042. * @returns an array of Camera
  34043. */
  34044. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34045. /**
  34046. * Get a list of lights by tags
  34047. * @param tagsQuery defines the tags query to use
  34048. * @param forEach defines a predicate used to filter results
  34049. * @returns an array of Light
  34050. */
  34051. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34052. /**
  34053. * Get a list of materials by tags
  34054. * @param tagsQuery defines the tags query to use
  34055. * @param forEach defines a predicate used to filter results
  34056. * @returns an array of Material
  34057. */
  34058. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34059. /**
  34060. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34061. * This allowed control for front to back rendering or reversly depending of the special needs.
  34062. *
  34063. * @param renderingGroupId The rendering group id corresponding to its index
  34064. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34065. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34066. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34067. */
  34068. 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;
  34069. /**
  34070. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34071. *
  34072. * @param renderingGroupId The rendering group id corresponding to its index
  34073. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34074. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34075. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34076. */
  34077. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34078. /**
  34079. * Gets the current auto clear configuration for one rendering group of the rendering
  34080. * manager.
  34081. * @param index the rendering group index to get the information for
  34082. * @returns The auto clear setup for the requested rendering group
  34083. */
  34084. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34085. private _blockMaterialDirtyMechanism;
  34086. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34087. blockMaterialDirtyMechanism: boolean;
  34088. /**
  34089. * Will flag all materials as dirty to trigger new shader compilation
  34090. * @param flag defines the flag used to specify which material part must be marked as dirty
  34091. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34092. */
  34093. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34094. /** @hidden */
  34095. _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;
  34096. /** @hidden */
  34097. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34098. }
  34099. }
  34100. declare module BABYLON {
  34101. /**
  34102. * Set of assets to keep when moving a scene into an asset container.
  34103. */
  34104. export class KeepAssets extends AbstractScene {
  34105. }
  34106. /**
  34107. * Container with a set of assets that can be added or removed from a scene.
  34108. */
  34109. export class AssetContainer extends AbstractScene {
  34110. /**
  34111. * The scene the AssetContainer belongs to.
  34112. */
  34113. scene: Scene;
  34114. /**
  34115. * Instantiates an AssetContainer.
  34116. * @param scene The scene the AssetContainer belongs to.
  34117. */
  34118. constructor(scene: Scene);
  34119. /**
  34120. * Adds all the assets from the container to the scene.
  34121. */
  34122. addAllToScene(): void;
  34123. /**
  34124. * Removes all the assets in the container from the scene
  34125. */
  34126. removeAllFromScene(): void;
  34127. /**
  34128. * Disposes all the assets in the container
  34129. */
  34130. dispose(): void;
  34131. private _moveAssets;
  34132. /**
  34133. * Removes all the assets contained in the scene and adds them to the container.
  34134. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34135. */
  34136. moveAllFromScene(keepAssets?: KeepAssets): void;
  34137. /**
  34138. * 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.
  34139. * @returns the root mesh
  34140. */
  34141. createRootMesh(): Mesh;
  34142. }
  34143. }
  34144. declare module BABYLON {
  34145. /**
  34146. * Defines how the parser contract is defined.
  34147. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34148. */
  34149. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34150. /**
  34151. * Defines how the individual parser contract is defined.
  34152. * These parser can parse an individual asset
  34153. */
  34154. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34155. /**
  34156. * Base class of the scene acting as a container for the different elements composing a scene.
  34157. * This class is dynamically extended by the different components of the scene increasing
  34158. * flexibility and reducing coupling
  34159. */
  34160. export abstract class AbstractScene {
  34161. /**
  34162. * Stores the list of available parsers in the application.
  34163. */
  34164. private static _BabylonFileParsers;
  34165. /**
  34166. * Stores the list of available individual parsers in the application.
  34167. */
  34168. private static _IndividualBabylonFileParsers;
  34169. /**
  34170. * Adds a parser in the list of available ones
  34171. * @param name Defines the name of the parser
  34172. * @param parser Defines the parser to add
  34173. */
  34174. static AddParser(name: string, parser: BabylonFileParser): void;
  34175. /**
  34176. * Gets a general parser from the list of avaialble ones
  34177. * @param name Defines the name of the parser
  34178. * @returns the requested parser or null
  34179. */
  34180. static GetParser(name: string): Nullable<BabylonFileParser>;
  34181. /**
  34182. * Adds n individual parser in the list of available ones
  34183. * @param name Defines the name of the parser
  34184. * @param parser Defines the parser to add
  34185. */
  34186. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34187. /**
  34188. * Gets an individual parser from the list of avaialble ones
  34189. * @param name Defines the name of the parser
  34190. * @returns the requested parser or null
  34191. */
  34192. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34193. /**
  34194. * Parser json data and populate both a scene and its associated container object
  34195. * @param jsonData Defines the data to parse
  34196. * @param scene Defines the scene to parse the data for
  34197. * @param container Defines the container attached to the parsing sequence
  34198. * @param rootUrl Defines the root url of the data
  34199. */
  34200. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34201. /**
  34202. * Gets the list of root nodes (ie. nodes with no parent)
  34203. */
  34204. rootNodes: Node[];
  34205. /** All of the cameras added to this scene
  34206. * @see http://doc.babylonjs.com/babylon101/cameras
  34207. */
  34208. cameras: Camera[];
  34209. /**
  34210. * All of the lights added to this scene
  34211. * @see http://doc.babylonjs.com/babylon101/lights
  34212. */
  34213. lights: Light[];
  34214. /**
  34215. * All of the (abstract) meshes added to this scene
  34216. */
  34217. meshes: AbstractMesh[];
  34218. /**
  34219. * The list of skeletons added to the scene
  34220. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34221. */
  34222. skeletons: Skeleton[];
  34223. /**
  34224. * All of the particle systems added to this scene
  34225. * @see http://doc.babylonjs.com/babylon101/particles
  34226. */
  34227. particleSystems: IParticleSystem[];
  34228. /**
  34229. * Gets a list of Animations associated with the scene
  34230. */
  34231. animations: Animation[];
  34232. /**
  34233. * All of the animation groups added to this scene
  34234. * @see http://doc.babylonjs.com/how_to/group
  34235. */
  34236. animationGroups: AnimationGroup[];
  34237. /**
  34238. * All of the multi-materials added to this scene
  34239. * @see http://doc.babylonjs.com/how_to/multi_materials
  34240. */
  34241. multiMaterials: MultiMaterial[];
  34242. /**
  34243. * All of the materials added to this scene
  34244. * In the context of a Scene, it is not supposed to be modified manually.
  34245. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34246. * Note also that the order of the Material wihin the array is not significant and might change.
  34247. * @see http://doc.babylonjs.com/babylon101/materials
  34248. */
  34249. materials: Material[];
  34250. /**
  34251. * The list of morph target managers added to the scene
  34252. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34253. */
  34254. morphTargetManagers: MorphTargetManager[];
  34255. /**
  34256. * The list of geometries used in the scene.
  34257. */
  34258. geometries: Geometry[];
  34259. /**
  34260. * All of the tranform nodes added to this scene
  34261. * In the context of a Scene, it is not supposed to be modified manually.
  34262. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34263. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34264. * @see http://doc.babylonjs.com/how_to/transformnode
  34265. */
  34266. transformNodes: TransformNode[];
  34267. /**
  34268. * ActionManagers available on the scene.
  34269. */
  34270. actionManagers: AbstractActionManager[];
  34271. /**
  34272. * Textures to keep.
  34273. */
  34274. textures: BaseTexture[];
  34275. /**
  34276. * Environment texture for the scene
  34277. */
  34278. environmentTexture: Nullable<BaseTexture>;
  34279. }
  34280. }
  34281. declare module BABYLON {
  34282. /**
  34283. * Interface used to define options for Sound class
  34284. */
  34285. export interface ISoundOptions {
  34286. /**
  34287. * Does the sound autoplay once loaded.
  34288. */
  34289. autoplay?: boolean;
  34290. /**
  34291. * Does the sound loop after it finishes playing once.
  34292. */
  34293. loop?: boolean;
  34294. /**
  34295. * Sound's volume
  34296. */
  34297. volume?: number;
  34298. /**
  34299. * Is it a spatial sound?
  34300. */
  34301. spatialSound?: boolean;
  34302. /**
  34303. * Maximum distance to hear that sound
  34304. */
  34305. maxDistance?: number;
  34306. /**
  34307. * Uses user defined attenuation function
  34308. */
  34309. useCustomAttenuation?: boolean;
  34310. /**
  34311. * Define the roll off factor of spatial sounds.
  34312. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34313. */
  34314. rolloffFactor?: number;
  34315. /**
  34316. * Define the reference distance the sound should be heard perfectly.
  34317. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34318. */
  34319. refDistance?: number;
  34320. /**
  34321. * Define the distance attenuation model the sound will follow.
  34322. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34323. */
  34324. distanceModel?: string;
  34325. /**
  34326. * Defines the playback speed (1 by default)
  34327. */
  34328. playbackRate?: number;
  34329. /**
  34330. * Defines if the sound is from a streaming source
  34331. */
  34332. streaming?: boolean;
  34333. /**
  34334. * Defines an optional length (in seconds) inside the sound file
  34335. */
  34336. length?: number;
  34337. /**
  34338. * Defines an optional offset (in seconds) inside the sound file
  34339. */
  34340. offset?: number;
  34341. /**
  34342. * If true, URLs will not be required to state the audio file codec to use.
  34343. */
  34344. skipCodecCheck?: boolean;
  34345. }
  34346. /**
  34347. * Defines a sound that can be played in the application.
  34348. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34349. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34350. */
  34351. export class Sound {
  34352. /**
  34353. * The name of the sound in the scene.
  34354. */
  34355. name: string;
  34356. /**
  34357. * Does the sound autoplay once loaded.
  34358. */
  34359. autoplay: boolean;
  34360. /**
  34361. * Does the sound loop after it finishes playing once.
  34362. */
  34363. loop: boolean;
  34364. /**
  34365. * Does the sound use a custom attenuation curve to simulate the falloff
  34366. * happening when the source gets further away from the camera.
  34367. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34368. */
  34369. useCustomAttenuation: boolean;
  34370. /**
  34371. * The sound track id this sound belongs to.
  34372. */
  34373. soundTrackId: number;
  34374. /**
  34375. * Is this sound currently played.
  34376. */
  34377. isPlaying: boolean;
  34378. /**
  34379. * Is this sound currently paused.
  34380. */
  34381. isPaused: boolean;
  34382. /**
  34383. * Does this sound enables spatial sound.
  34384. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34385. */
  34386. spatialSound: boolean;
  34387. /**
  34388. * Define the reference distance the sound should be heard perfectly.
  34389. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34390. */
  34391. refDistance: number;
  34392. /**
  34393. * Define the roll off factor of spatial sounds.
  34394. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34395. */
  34396. rolloffFactor: number;
  34397. /**
  34398. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34399. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34400. */
  34401. maxDistance: number;
  34402. /**
  34403. * Define the distance attenuation model the sound will follow.
  34404. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34405. */
  34406. distanceModel: string;
  34407. /**
  34408. * @hidden
  34409. * Back Compat
  34410. **/
  34411. onended: () => any;
  34412. /**
  34413. * Observable event when the current playing sound finishes.
  34414. */
  34415. onEndedObservable: Observable<Sound>;
  34416. private _panningModel;
  34417. private _playbackRate;
  34418. private _streaming;
  34419. private _startTime;
  34420. private _startOffset;
  34421. private _position;
  34422. /** @hidden */
  34423. _positionInEmitterSpace: boolean;
  34424. private _localDirection;
  34425. private _volume;
  34426. private _isReadyToPlay;
  34427. private _isDirectional;
  34428. private _readyToPlayCallback;
  34429. private _audioBuffer;
  34430. private _soundSource;
  34431. private _streamingSource;
  34432. private _soundPanner;
  34433. private _soundGain;
  34434. private _inputAudioNode;
  34435. private _outputAudioNode;
  34436. private _coneInnerAngle;
  34437. private _coneOuterAngle;
  34438. private _coneOuterGain;
  34439. private _scene;
  34440. private _connectedTransformNode;
  34441. private _customAttenuationFunction;
  34442. private _registerFunc;
  34443. private _isOutputConnected;
  34444. private _htmlAudioElement;
  34445. private _urlType;
  34446. private _length?;
  34447. private _offset?;
  34448. /** @hidden */
  34449. static _SceneComponentInitialization: (scene: Scene) => void;
  34450. /**
  34451. * Create a sound and attach it to a scene
  34452. * @param name Name of your sound
  34453. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34454. * @param scene defines the scene the sound belongs to
  34455. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34456. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34457. */
  34458. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  34459. /**
  34460. * Release the sound and its associated resources
  34461. */
  34462. dispose(): void;
  34463. /**
  34464. * Gets if the sounds is ready to be played or not.
  34465. * @returns true if ready, otherwise false
  34466. */
  34467. isReady(): boolean;
  34468. private _soundLoaded;
  34469. /**
  34470. * Sets the data of the sound from an audiobuffer
  34471. * @param audioBuffer The audioBuffer containing the data
  34472. */
  34473. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34474. /**
  34475. * Updates the current sounds options such as maxdistance, loop...
  34476. * @param options A JSON object containing values named as the object properties
  34477. */
  34478. updateOptions(options: ISoundOptions): void;
  34479. private _createSpatialParameters;
  34480. private _updateSpatialParameters;
  34481. /**
  34482. * Switch the panning model to HRTF:
  34483. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34484. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34485. */
  34486. switchPanningModelToHRTF(): void;
  34487. /**
  34488. * Switch the panning model to Equal Power:
  34489. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34490. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34491. */
  34492. switchPanningModelToEqualPower(): void;
  34493. private _switchPanningModel;
  34494. /**
  34495. * Connect this sound to a sound track audio node like gain...
  34496. * @param soundTrackAudioNode the sound track audio node to connect to
  34497. */
  34498. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34499. /**
  34500. * Transform this sound into a directional source
  34501. * @param coneInnerAngle Size of the inner cone in degree
  34502. * @param coneOuterAngle Size of the outer cone in degree
  34503. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34504. */
  34505. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34506. /**
  34507. * Gets or sets the inner angle for the directional cone.
  34508. */
  34509. /**
  34510. * Gets or sets the inner angle for the directional cone.
  34511. */
  34512. directionalConeInnerAngle: number;
  34513. /**
  34514. * Gets or sets the outer angle for the directional cone.
  34515. */
  34516. /**
  34517. * Gets or sets the outer angle for the directional cone.
  34518. */
  34519. directionalConeOuterAngle: number;
  34520. /**
  34521. * Sets the position of the emitter if spatial sound is enabled
  34522. * @param newPosition Defines the new posisiton
  34523. */
  34524. setPosition(newPosition: Vector3): void;
  34525. /**
  34526. * Sets the local direction of the emitter if spatial sound is enabled
  34527. * @param newLocalDirection Defines the new local direction
  34528. */
  34529. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34530. private _updateDirection;
  34531. /** @hidden */
  34532. updateDistanceFromListener(): void;
  34533. /**
  34534. * Sets a new custom attenuation function for the sound.
  34535. * @param callback Defines the function used for the attenuation
  34536. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34537. */
  34538. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34539. /**
  34540. * Play the sound
  34541. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34542. * @param offset (optional) Start the sound at a specific time in seconds
  34543. * @param length (optional) Sound duration (in seconds)
  34544. */
  34545. play(time?: number, offset?: number, length?: number): void;
  34546. private _onended;
  34547. /**
  34548. * Stop the sound
  34549. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34550. */
  34551. stop(time?: number): void;
  34552. /**
  34553. * Put the sound in pause
  34554. */
  34555. pause(): void;
  34556. /**
  34557. * Sets a dedicated volume for this sounds
  34558. * @param newVolume Define the new volume of the sound
  34559. * @param time Define time for gradual change to new volume
  34560. */
  34561. setVolume(newVolume: number, time?: number): void;
  34562. /**
  34563. * Set the sound play back rate
  34564. * @param newPlaybackRate Define the playback rate the sound should be played at
  34565. */
  34566. setPlaybackRate(newPlaybackRate: number): void;
  34567. /**
  34568. * Gets the volume of the sound.
  34569. * @returns the volume of the sound
  34570. */
  34571. getVolume(): number;
  34572. /**
  34573. * Attach the sound to a dedicated mesh
  34574. * @param transformNode The transform node to connect the sound with
  34575. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34576. */
  34577. attachToMesh(transformNode: TransformNode): void;
  34578. /**
  34579. * Detach the sound from the previously attached mesh
  34580. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34581. */
  34582. detachFromMesh(): void;
  34583. private _onRegisterAfterWorldMatrixUpdate;
  34584. /**
  34585. * Clone the current sound in the scene.
  34586. * @returns the new sound clone
  34587. */
  34588. clone(): Nullable<Sound>;
  34589. /**
  34590. * Gets the current underlying audio buffer containing the data
  34591. * @returns the audio buffer
  34592. */
  34593. getAudioBuffer(): Nullable<AudioBuffer>;
  34594. /**
  34595. * Serializes the Sound in a JSON representation
  34596. * @returns the JSON representation of the sound
  34597. */
  34598. serialize(): any;
  34599. /**
  34600. * Parse a JSON representation of a sound to innstantiate in a given scene
  34601. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34602. * @param scene Define the scene the new parsed sound should be created in
  34603. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34604. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34605. * @returns the newly parsed sound
  34606. */
  34607. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34608. }
  34609. }
  34610. declare module BABYLON {
  34611. /**
  34612. * This defines an action helpful to play a defined sound on a triggered action.
  34613. */
  34614. export class PlaySoundAction extends Action {
  34615. private _sound;
  34616. /**
  34617. * Instantiate the action
  34618. * @param triggerOptions defines the trigger options
  34619. * @param sound defines the sound to play
  34620. * @param condition defines the trigger related conditions
  34621. */
  34622. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34623. /** @hidden */
  34624. _prepare(): void;
  34625. /**
  34626. * Execute the action and play the sound.
  34627. */
  34628. execute(): void;
  34629. /**
  34630. * Serializes the actions and its related information.
  34631. * @param parent defines the object to serialize in
  34632. * @returns the serialized object
  34633. */
  34634. serialize(parent: any): any;
  34635. }
  34636. /**
  34637. * This defines an action helpful to stop a defined sound on a triggered action.
  34638. */
  34639. export class StopSoundAction extends Action {
  34640. private _sound;
  34641. /**
  34642. * Instantiate the action
  34643. * @param triggerOptions defines the trigger options
  34644. * @param sound defines the sound to stop
  34645. * @param condition defines the trigger related conditions
  34646. */
  34647. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34648. /** @hidden */
  34649. _prepare(): void;
  34650. /**
  34651. * Execute the action and stop the sound.
  34652. */
  34653. execute(): void;
  34654. /**
  34655. * Serializes the actions and its related information.
  34656. * @param parent defines the object to serialize in
  34657. * @returns the serialized object
  34658. */
  34659. serialize(parent: any): any;
  34660. }
  34661. }
  34662. declare module BABYLON {
  34663. /**
  34664. * This defines an action responsible to change the value of a property
  34665. * by interpolating between its current value and the newly set one once triggered.
  34666. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34667. */
  34668. export class InterpolateValueAction extends Action {
  34669. /**
  34670. * Defines the path of the property where the value should be interpolated
  34671. */
  34672. propertyPath: string;
  34673. /**
  34674. * Defines the target value at the end of the interpolation.
  34675. */
  34676. value: any;
  34677. /**
  34678. * Defines the time it will take for the property to interpolate to the value.
  34679. */
  34680. duration: number;
  34681. /**
  34682. * Defines if the other scene animations should be stopped when the action has been triggered
  34683. */
  34684. stopOtherAnimations?: boolean;
  34685. /**
  34686. * Defines a callback raised once the interpolation animation has been done.
  34687. */
  34688. onInterpolationDone?: () => void;
  34689. /**
  34690. * Observable triggered once the interpolation animation has been done.
  34691. */
  34692. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34693. private _target;
  34694. private _effectiveTarget;
  34695. private _property;
  34696. /**
  34697. * Instantiate the action
  34698. * @param triggerOptions defines the trigger options
  34699. * @param target defines the object containing the value to interpolate
  34700. * @param propertyPath defines the path to the property in the target object
  34701. * @param value defines the target value at the end of the interpolation
  34702. * @param duration deines the time it will take for the property to interpolate to the value.
  34703. * @param condition defines the trigger related conditions
  34704. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34705. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34706. */
  34707. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34708. /** @hidden */
  34709. _prepare(): void;
  34710. /**
  34711. * Execute the action starts the value interpolation.
  34712. */
  34713. execute(): void;
  34714. /**
  34715. * Serializes the actions and its related information.
  34716. * @param parent defines the object to serialize in
  34717. * @returns the serialized object
  34718. */
  34719. serialize(parent: any): any;
  34720. }
  34721. }
  34722. declare module BABYLON {
  34723. /**
  34724. * Options allowed during the creation of a sound track.
  34725. */
  34726. export interface ISoundTrackOptions {
  34727. /**
  34728. * The volume the sound track should take during creation
  34729. */
  34730. volume?: number;
  34731. /**
  34732. * Define if the sound track is the main sound track of the scene
  34733. */
  34734. mainTrack?: boolean;
  34735. }
  34736. /**
  34737. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34738. * It will be also used in a future release to apply effects on a specific track.
  34739. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34740. */
  34741. export class SoundTrack {
  34742. /**
  34743. * The unique identifier of the sound track in the scene.
  34744. */
  34745. id: number;
  34746. /**
  34747. * The list of sounds included in the sound track.
  34748. */
  34749. soundCollection: Array<Sound>;
  34750. private _outputAudioNode;
  34751. private _scene;
  34752. private _isMainTrack;
  34753. private _connectedAnalyser;
  34754. private _options;
  34755. private _isInitialized;
  34756. /**
  34757. * Creates a new sound track.
  34758. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34759. * @param scene Define the scene the sound track belongs to
  34760. * @param options
  34761. */
  34762. constructor(scene: Scene, options?: ISoundTrackOptions);
  34763. private _initializeSoundTrackAudioGraph;
  34764. /**
  34765. * Release the sound track and its associated resources
  34766. */
  34767. dispose(): void;
  34768. /**
  34769. * Adds a sound to this sound track
  34770. * @param sound define the cound to add
  34771. * @ignoreNaming
  34772. */
  34773. AddSound(sound: Sound): void;
  34774. /**
  34775. * Removes a sound to this sound track
  34776. * @param sound define the cound to remove
  34777. * @ignoreNaming
  34778. */
  34779. RemoveSound(sound: Sound): void;
  34780. /**
  34781. * Set a global volume for the full sound track.
  34782. * @param newVolume Define the new volume of the sound track
  34783. */
  34784. setVolume(newVolume: number): void;
  34785. /**
  34786. * Switch the panning model to HRTF:
  34787. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34788. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34789. */
  34790. switchPanningModelToHRTF(): void;
  34791. /**
  34792. * Switch the panning model to Equal Power:
  34793. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34794. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34795. */
  34796. switchPanningModelToEqualPower(): void;
  34797. /**
  34798. * Connect the sound track to an audio analyser allowing some amazing
  34799. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34800. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34801. * @param analyser The analyser to connect to the engine
  34802. */
  34803. connectToAnalyser(analyser: Analyser): void;
  34804. }
  34805. }
  34806. declare module BABYLON {
  34807. interface AbstractScene {
  34808. /**
  34809. * The list of sounds used in the scene.
  34810. */
  34811. sounds: Nullable<Array<Sound>>;
  34812. }
  34813. interface Scene {
  34814. /**
  34815. * @hidden
  34816. * Backing field
  34817. */
  34818. _mainSoundTrack: SoundTrack;
  34819. /**
  34820. * The main sound track played by the scene.
  34821. * It cotains your primary collection of sounds.
  34822. */
  34823. mainSoundTrack: SoundTrack;
  34824. /**
  34825. * The list of sound tracks added to the scene
  34826. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34827. */
  34828. soundTracks: Nullable<Array<SoundTrack>>;
  34829. /**
  34830. * Gets a sound using a given name
  34831. * @param name defines the name to search for
  34832. * @return the found sound or null if not found at all.
  34833. */
  34834. getSoundByName(name: string): Nullable<Sound>;
  34835. /**
  34836. * Gets or sets if audio support is enabled
  34837. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34838. */
  34839. audioEnabled: boolean;
  34840. /**
  34841. * Gets or sets if audio will be output to headphones
  34842. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34843. */
  34844. headphone: boolean;
  34845. }
  34846. /**
  34847. * Defines the sound scene component responsible to manage any sounds
  34848. * in a given scene.
  34849. */
  34850. export class AudioSceneComponent implements ISceneSerializableComponent {
  34851. /**
  34852. * The component name helpfull to identify the component in the list of scene components.
  34853. */
  34854. readonly name: string;
  34855. /**
  34856. * The scene the component belongs to.
  34857. */
  34858. scene: Scene;
  34859. private _audioEnabled;
  34860. /**
  34861. * Gets whether audio is enabled or not.
  34862. * Please use related enable/disable method to switch state.
  34863. */
  34864. readonly audioEnabled: boolean;
  34865. private _headphone;
  34866. /**
  34867. * Gets whether audio is outputing to headphone or not.
  34868. * Please use the according Switch methods to change output.
  34869. */
  34870. readonly headphone: boolean;
  34871. /**
  34872. * Creates a new instance of the component for the given scene
  34873. * @param scene Defines the scene to register the component in
  34874. */
  34875. constructor(scene: Scene);
  34876. /**
  34877. * Registers the component in a given scene
  34878. */
  34879. register(): void;
  34880. /**
  34881. * Rebuilds the elements related to this component in case of
  34882. * context lost for instance.
  34883. */
  34884. rebuild(): void;
  34885. /**
  34886. * Serializes the component data to the specified json object
  34887. * @param serializationObject The object to serialize to
  34888. */
  34889. serialize(serializationObject: any): void;
  34890. /**
  34891. * Adds all the elements from the container to the scene
  34892. * @param container the container holding the elements
  34893. */
  34894. addFromContainer(container: AbstractScene): void;
  34895. /**
  34896. * Removes all the elements in the container from the scene
  34897. * @param container contains the elements to remove
  34898. * @param dispose if the removed element should be disposed (default: false)
  34899. */
  34900. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  34901. /**
  34902. * Disposes the component and the associated ressources.
  34903. */
  34904. dispose(): void;
  34905. /**
  34906. * Disables audio in the associated scene.
  34907. */
  34908. disableAudio(): void;
  34909. /**
  34910. * Enables audio in the associated scene.
  34911. */
  34912. enableAudio(): void;
  34913. /**
  34914. * Switch audio to headphone output.
  34915. */
  34916. switchAudioModeForHeadphones(): void;
  34917. /**
  34918. * Switch audio to normal speakers.
  34919. */
  34920. switchAudioModeForNormalSpeakers(): void;
  34921. private _afterRender;
  34922. }
  34923. }
  34924. declare module BABYLON {
  34925. /**
  34926. * Wraps one or more Sound objects and selects one with random weight for playback.
  34927. */
  34928. export class WeightedSound {
  34929. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34930. loop: boolean;
  34931. private _coneInnerAngle;
  34932. private _coneOuterAngle;
  34933. private _volume;
  34934. /** A Sound is currently playing. */
  34935. isPlaying: boolean;
  34936. /** A Sound is currently paused. */
  34937. isPaused: boolean;
  34938. private _sounds;
  34939. private _weights;
  34940. private _currentIndex?;
  34941. /**
  34942. * Creates a new WeightedSound from the list of sounds given.
  34943. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34944. * @param sounds Array of Sounds that will be selected from.
  34945. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34946. */
  34947. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34948. /**
  34949. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34950. */
  34951. /**
  34952. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34953. */
  34954. directionalConeInnerAngle: number;
  34955. /**
  34956. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34957. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34958. */
  34959. /**
  34960. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34961. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34962. */
  34963. directionalConeOuterAngle: number;
  34964. /**
  34965. * Playback volume.
  34966. */
  34967. /**
  34968. * Playback volume.
  34969. */
  34970. volume: number;
  34971. private _onended;
  34972. /**
  34973. * Suspend playback
  34974. */
  34975. pause(): void;
  34976. /**
  34977. * Stop playback
  34978. */
  34979. stop(): void;
  34980. /**
  34981. * Start playback.
  34982. * @param startOffset Position the clip head at a specific time in seconds.
  34983. */
  34984. play(startOffset?: number): void;
  34985. }
  34986. }
  34987. declare module BABYLON {
  34988. /**
  34989. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34990. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34991. */
  34992. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34993. /**
  34994. * Gets the name of the behavior.
  34995. */
  34996. readonly name: string;
  34997. /**
  34998. * The easing function used by animations
  34999. */
  35000. static EasingFunction: BackEase;
  35001. /**
  35002. * The easing mode used by animations
  35003. */
  35004. static EasingMode: number;
  35005. /**
  35006. * The duration of the animation, in milliseconds
  35007. */
  35008. transitionDuration: number;
  35009. /**
  35010. * Length of the distance animated by the transition when lower radius is reached
  35011. */
  35012. lowerRadiusTransitionRange: number;
  35013. /**
  35014. * Length of the distance animated by the transition when upper radius is reached
  35015. */
  35016. upperRadiusTransitionRange: number;
  35017. private _autoTransitionRange;
  35018. /**
  35019. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35020. */
  35021. /**
  35022. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35023. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35024. */
  35025. autoTransitionRange: boolean;
  35026. private _attachedCamera;
  35027. private _onAfterCheckInputsObserver;
  35028. private _onMeshTargetChangedObserver;
  35029. /**
  35030. * Initializes the behavior.
  35031. */
  35032. init(): void;
  35033. /**
  35034. * Attaches the behavior to its arc rotate camera.
  35035. * @param camera Defines the camera to attach the behavior to
  35036. */
  35037. attach(camera: ArcRotateCamera): void;
  35038. /**
  35039. * Detaches the behavior from its current arc rotate camera.
  35040. */
  35041. detach(): void;
  35042. private _radiusIsAnimating;
  35043. private _radiusBounceTransition;
  35044. private _animatables;
  35045. private _cachedWheelPrecision;
  35046. /**
  35047. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35048. * @param radiusLimit The limit to check against.
  35049. * @return Bool to indicate if at limit.
  35050. */
  35051. private _isRadiusAtLimit;
  35052. /**
  35053. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35054. * @param radiusDelta The delta by which to animate to. Can be negative.
  35055. */
  35056. private _applyBoundRadiusAnimation;
  35057. /**
  35058. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35059. */
  35060. protected _clearAnimationLocks(): void;
  35061. /**
  35062. * Stops and removes all animations that have been applied to the camera
  35063. */
  35064. stopAllAnimations(): void;
  35065. }
  35066. }
  35067. declare module BABYLON {
  35068. /**
  35069. * 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.
  35070. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35071. */
  35072. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35073. /**
  35074. * Gets the name of the behavior.
  35075. */
  35076. readonly name: string;
  35077. private _mode;
  35078. private _radiusScale;
  35079. private _positionScale;
  35080. private _defaultElevation;
  35081. private _elevationReturnTime;
  35082. private _elevationReturnWaitTime;
  35083. private _zoomStopsAnimation;
  35084. private _framingTime;
  35085. /**
  35086. * The easing function used by animations
  35087. */
  35088. static EasingFunction: ExponentialEase;
  35089. /**
  35090. * The easing mode used by animations
  35091. */
  35092. static EasingMode: number;
  35093. /**
  35094. * Sets the current mode used by the behavior
  35095. */
  35096. /**
  35097. * Gets current mode used by the behavior.
  35098. */
  35099. mode: number;
  35100. /**
  35101. * Sets the scale applied to the radius (1 by default)
  35102. */
  35103. /**
  35104. * Gets the scale applied to the radius
  35105. */
  35106. radiusScale: number;
  35107. /**
  35108. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35109. */
  35110. /**
  35111. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35112. */
  35113. positionScale: number;
  35114. /**
  35115. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35116. * behaviour is triggered, in radians.
  35117. */
  35118. /**
  35119. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35120. * behaviour is triggered, in radians.
  35121. */
  35122. defaultElevation: number;
  35123. /**
  35124. * Sets the time (in milliseconds) taken to return to the default beta position.
  35125. * Negative value indicates camera should not return to default.
  35126. */
  35127. /**
  35128. * Gets the time (in milliseconds) taken to return to the default beta position.
  35129. * Negative value indicates camera should not return to default.
  35130. */
  35131. elevationReturnTime: number;
  35132. /**
  35133. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35134. */
  35135. /**
  35136. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35137. */
  35138. elevationReturnWaitTime: number;
  35139. /**
  35140. * Sets the flag that indicates if user zooming should stop animation.
  35141. */
  35142. /**
  35143. * Gets the flag that indicates if user zooming should stop animation.
  35144. */
  35145. zoomStopsAnimation: boolean;
  35146. /**
  35147. * Sets the transition time when framing the mesh, in milliseconds
  35148. */
  35149. /**
  35150. * Gets the transition time when framing the mesh, in milliseconds
  35151. */
  35152. framingTime: number;
  35153. /**
  35154. * Define if the behavior should automatically change the configured
  35155. * camera limits and sensibilities.
  35156. */
  35157. autoCorrectCameraLimitsAndSensibility: boolean;
  35158. private _onPrePointerObservableObserver;
  35159. private _onAfterCheckInputsObserver;
  35160. private _onMeshTargetChangedObserver;
  35161. private _attachedCamera;
  35162. private _isPointerDown;
  35163. private _lastInteractionTime;
  35164. /**
  35165. * Initializes the behavior.
  35166. */
  35167. init(): void;
  35168. /**
  35169. * Attaches the behavior to its arc rotate camera.
  35170. * @param camera Defines the camera to attach the behavior to
  35171. */
  35172. attach(camera: ArcRotateCamera): void;
  35173. /**
  35174. * Detaches the behavior from its current arc rotate camera.
  35175. */
  35176. detach(): void;
  35177. private _animatables;
  35178. private _betaIsAnimating;
  35179. private _betaTransition;
  35180. private _radiusTransition;
  35181. private _vectorTransition;
  35182. /**
  35183. * Targets the given mesh and updates zoom level accordingly.
  35184. * @param mesh The mesh to target.
  35185. * @param radius Optional. If a cached radius position already exists, overrides default.
  35186. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35187. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35188. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35189. */
  35190. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35191. /**
  35192. * Targets the given mesh with its children and updates zoom level accordingly.
  35193. * @param mesh The mesh to target.
  35194. * @param radius Optional. If a cached radius position already exists, overrides default.
  35195. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35196. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35197. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35198. */
  35199. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35200. /**
  35201. * Targets the given meshes with their children and updates zoom level accordingly.
  35202. * @param meshes The mesh to target.
  35203. * @param radius Optional. If a cached radius position already exists, overrides default.
  35204. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35205. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35206. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35207. */
  35208. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35209. /**
  35210. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35211. * @param minimumWorld Determines the smaller position of the bounding box extend
  35212. * @param maximumWorld Determines the bigger position of the bounding box extend
  35213. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35214. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35215. */
  35216. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35217. /**
  35218. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35219. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35220. * frustum width.
  35221. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35222. * to fully enclose the mesh in the viewing frustum.
  35223. */
  35224. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35225. /**
  35226. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35227. * is automatically returned to its default position (expected to be above ground plane).
  35228. */
  35229. private _maintainCameraAboveGround;
  35230. /**
  35231. * Returns the frustum slope based on the canvas ratio and camera FOV
  35232. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35233. */
  35234. private _getFrustumSlope;
  35235. /**
  35236. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35237. */
  35238. private _clearAnimationLocks;
  35239. /**
  35240. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35241. */
  35242. private _applyUserInteraction;
  35243. /**
  35244. * Stops and removes all animations that have been applied to the camera
  35245. */
  35246. stopAllAnimations(): void;
  35247. /**
  35248. * Gets a value indicating if the user is moving the camera
  35249. */
  35250. readonly isUserIsMoving: boolean;
  35251. /**
  35252. * The camera can move all the way towards the mesh.
  35253. */
  35254. static IgnoreBoundsSizeMode: number;
  35255. /**
  35256. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35257. */
  35258. static FitFrustumSidesMode: number;
  35259. }
  35260. }
  35261. declare module BABYLON {
  35262. /**
  35263. * Base class for Camera Pointer Inputs.
  35264. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35265. * for example usage.
  35266. */
  35267. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35268. /**
  35269. * Defines the camera the input is attached to.
  35270. */
  35271. abstract camera: Camera;
  35272. /**
  35273. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35274. */
  35275. protected _altKey: boolean;
  35276. protected _ctrlKey: boolean;
  35277. protected _metaKey: boolean;
  35278. protected _shiftKey: boolean;
  35279. /**
  35280. * Which mouse buttons were pressed at time of last mouse event.
  35281. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35282. */
  35283. protected _buttonsPressed: number;
  35284. /**
  35285. * Defines the buttons associated with the input to handle camera move.
  35286. */
  35287. buttons: number[];
  35288. /**
  35289. * Attach the input controls to a specific dom element to get the input from.
  35290. * @param element Defines the element the controls should be listened from
  35291. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35292. */
  35293. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35294. /**
  35295. * Detach the current controls from the specified dom element.
  35296. * @param element Defines the element to stop listening the inputs from
  35297. */
  35298. detachControl(element: Nullable<HTMLElement>): void;
  35299. /**
  35300. * Gets the class name of the current input.
  35301. * @returns the class name
  35302. */
  35303. getClassName(): string;
  35304. /**
  35305. * Get the friendly name associated with the input class.
  35306. * @returns the input friendly name
  35307. */
  35308. getSimpleName(): string;
  35309. /**
  35310. * Called on pointer POINTERDOUBLETAP event.
  35311. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35312. */
  35313. protected onDoubleTap(type: string): void;
  35314. /**
  35315. * Called on pointer POINTERMOVE event if only a single touch is active.
  35316. * Override this method to provide functionality.
  35317. */
  35318. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35319. /**
  35320. * Called on pointer POINTERMOVE event if multiple touches are active.
  35321. * Override this method to provide functionality.
  35322. */
  35323. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35324. /**
  35325. * Called on JS contextmenu event.
  35326. * Override this method to provide functionality.
  35327. */
  35328. protected onContextMenu(evt: PointerEvent): void;
  35329. /**
  35330. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35331. * press.
  35332. * Override this method to provide functionality.
  35333. */
  35334. protected onButtonDown(evt: PointerEvent): void;
  35335. /**
  35336. * Called each time a new POINTERUP event occurs. Ie, for each button
  35337. * release.
  35338. * Override this method to provide functionality.
  35339. */
  35340. protected onButtonUp(evt: PointerEvent): void;
  35341. /**
  35342. * Called when window becomes inactive.
  35343. * Override this method to provide functionality.
  35344. */
  35345. protected onLostFocus(): void;
  35346. private _pointerInput;
  35347. private _observer;
  35348. private _onLostFocus;
  35349. private pointA;
  35350. private pointB;
  35351. }
  35352. }
  35353. declare module BABYLON {
  35354. /**
  35355. * Manage the pointers inputs to control an arc rotate camera.
  35356. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35357. */
  35358. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35359. /**
  35360. * Defines the camera the input is attached to.
  35361. */
  35362. camera: ArcRotateCamera;
  35363. /**
  35364. * Gets the class name of the current input.
  35365. * @returns the class name
  35366. */
  35367. getClassName(): string;
  35368. /**
  35369. * Defines the buttons associated with the input to handle camera move.
  35370. */
  35371. buttons: number[];
  35372. /**
  35373. * Defines the pointer angular sensibility along the X axis or how fast is
  35374. * the camera rotating.
  35375. */
  35376. angularSensibilityX: number;
  35377. /**
  35378. * Defines the pointer angular sensibility along the Y axis or how fast is
  35379. * the camera rotating.
  35380. */
  35381. angularSensibilityY: number;
  35382. /**
  35383. * Defines the pointer pinch precision or how fast is the camera zooming.
  35384. */
  35385. pinchPrecision: number;
  35386. /**
  35387. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35388. * from 0.
  35389. * It defines the percentage of current camera.radius to use as delta when
  35390. * pinch zoom is used.
  35391. */
  35392. pinchDeltaPercentage: number;
  35393. /**
  35394. * Defines the pointer panning sensibility or how fast is the camera moving.
  35395. */
  35396. panningSensibility: number;
  35397. /**
  35398. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35399. */
  35400. multiTouchPanning: boolean;
  35401. /**
  35402. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35403. * zoom (pinch) through multitouch.
  35404. */
  35405. multiTouchPanAndZoom: boolean;
  35406. /**
  35407. * Revers pinch action direction.
  35408. */
  35409. pinchInwards: boolean;
  35410. private _isPanClick;
  35411. private _twoFingerActivityCount;
  35412. private _isPinching;
  35413. /**
  35414. * Called on pointer POINTERMOVE event if only a single touch is active.
  35415. */
  35416. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35417. /**
  35418. * Called on pointer POINTERDOUBLETAP event.
  35419. */
  35420. protected onDoubleTap(type: string): void;
  35421. /**
  35422. * Called on pointer POINTERMOVE event if multiple touches are active.
  35423. */
  35424. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35425. /**
  35426. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35427. * press.
  35428. */
  35429. protected onButtonDown(evt: PointerEvent): void;
  35430. /**
  35431. * Called each time a new POINTERUP event occurs. Ie, for each button
  35432. * release.
  35433. */
  35434. protected onButtonUp(evt: PointerEvent): void;
  35435. /**
  35436. * Called when window becomes inactive.
  35437. */
  35438. protected onLostFocus(): void;
  35439. }
  35440. }
  35441. declare module BABYLON {
  35442. /**
  35443. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35444. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35445. */
  35446. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35447. /**
  35448. * Defines the camera the input is attached to.
  35449. */
  35450. camera: ArcRotateCamera;
  35451. /**
  35452. * Defines the list of key codes associated with the up action (increase alpha)
  35453. */
  35454. keysUp: number[];
  35455. /**
  35456. * Defines the list of key codes associated with the down action (decrease alpha)
  35457. */
  35458. keysDown: number[];
  35459. /**
  35460. * Defines the list of key codes associated with the left action (increase beta)
  35461. */
  35462. keysLeft: number[];
  35463. /**
  35464. * Defines the list of key codes associated with the right action (decrease beta)
  35465. */
  35466. keysRight: number[];
  35467. /**
  35468. * Defines the list of key codes associated with the reset action.
  35469. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35470. */
  35471. keysReset: number[];
  35472. /**
  35473. * Defines the panning sensibility of the inputs.
  35474. * (How fast is the camera paning)
  35475. */
  35476. panningSensibility: number;
  35477. /**
  35478. * Defines the zooming sensibility of the inputs.
  35479. * (How fast is the camera zooming)
  35480. */
  35481. zoomingSensibility: number;
  35482. /**
  35483. * Defines wether maintaining the alt key down switch the movement mode from
  35484. * orientation to zoom.
  35485. */
  35486. useAltToZoom: boolean;
  35487. /**
  35488. * Rotation speed of the camera
  35489. */
  35490. angularSpeed: number;
  35491. private _keys;
  35492. private _ctrlPressed;
  35493. private _altPressed;
  35494. private _onCanvasBlurObserver;
  35495. private _onKeyboardObserver;
  35496. private _engine;
  35497. private _scene;
  35498. /**
  35499. * Attach the input controls to a specific dom element to get the input from.
  35500. * @param element Defines the element the controls should be listened from
  35501. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35502. */
  35503. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35504. /**
  35505. * Detach the current controls from the specified dom element.
  35506. * @param element Defines the element to stop listening the inputs from
  35507. */
  35508. detachControl(element: Nullable<HTMLElement>): void;
  35509. /**
  35510. * Update the current camera state depending on the inputs that have been used this frame.
  35511. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35512. */
  35513. checkInputs(): void;
  35514. /**
  35515. * Gets the class name of the current intput.
  35516. * @returns the class name
  35517. */
  35518. getClassName(): string;
  35519. /**
  35520. * Get the friendly name associated with the input class.
  35521. * @returns the input friendly name
  35522. */
  35523. getSimpleName(): string;
  35524. }
  35525. }
  35526. declare module BABYLON {
  35527. /**
  35528. * Manage the mouse wheel inputs to control an arc rotate camera.
  35529. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35530. */
  35531. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35532. /**
  35533. * Defines the camera the input is attached to.
  35534. */
  35535. camera: ArcRotateCamera;
  35536. /**
  35537. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35538. */
  35539. wheelPrecision: number;
  35540. /**
  35541. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35542. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35543. */
  35544. wheelDeltaPercentage: number;
  35545. private _wheel;
  35546. private _observer;
  35547. private computeDeltaFromMouseWheelLegacyEvent;
  35548. /**
  35549. * Attach the input controls to a specific dom element to get the input from.
  35550. * @param element Defines the element the controls should be listened from
  35551. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35552. */
  35553. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35554. /**
  35555. * Detach the current controls from the specified dom element.
  35556. * @param element Defines the element to stop listening the inputs from
  35557. */
  35558. detachControl(element: Nullable<HTMLElement>): void;
  35559. /**
  35560. * Gets the class name of the current intput.
  35561. * @returns the class name
  35562. */
  35563. getClassName(): string;
  35564. /**
  35565. * Get the friendly name associated with the input class.
  35566. * @returns the input friendly name
  35567. */
  35568. getSimpleName(): string;
  35569. }
  35570. }
  35571. declare module BABYLON {
  35572. /**
  35573. * Default Inputs manager for the ArcRotateCamera.
  35574. * It groups all the default supported inputs for ease of use.
  35575. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35576. */
  35577. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35578. /**
  35579. * Instantiates a new ArcRotateCameraInputsManager.
  35580. * @param camera Defines the camera the inputs belong to
  35581. */
  35582. constructor(camera: ArcRotateCamera);
  35583. /**
  35584. * Add mouse wheel input support to the input manager.
  35585. * @returns the current input manager
  35586. */
  35587. addMouseWheel(): ArcRotateCameraInputsManager;
  35588. /**
  35589. * Add pointers input support to the input manager.
  35590. * @returns the current input manager
  35591. */
  35592. addPointers(): ArcRotateCameraInputsManager;
  35593. /**
  35594. * Add keyboard input support to the input manager.
  35595. * @returns the current input manager
  35596. */
  35597. addKeyboard(): ArcRotateCameraInputsManager;
  35598. }
  35599. }
  35600. declare module BABYLON {
  35601. /**
  35602. * This represents an orbital type of camera.
  35603. *
  35604. * 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.
  35605. * 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.
  35606. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35607. */
  35608. export class ArcRotateCamera extends TargetCamera {
  35609. /**
  35610. * Defines the rotation angle of the camera along the longitudinal axis.
  35611. */
  35612. alpha: number;
  35613. /**
  35614. * Defines the rotation angle of the camera along the latitudinal axis.
  35615. */
  35616. beta: number;
  35617. /**
  35618. * Defines the radius of the camera from it s target point.
  35619. */
  35620. radius: number;
  35621. protected _target: Vector3;
  35622. protected _targetHost: Nullable<AbstractMesh>;
  35623. /**
  35624. * Defines the target point of the camera.
  35625. * The camera looks towards it form the radius distance.
  35626. */
  35627. target: Vector3;
  35628. /**
  35629. * Define the current local position of the camera in the scene
  35630. */
  35631. position: Vector3;
  35632. protected _upVector: Vector3;
  35633. protected _upToYMatrix: Matrix;
  35634. protected _YToUpMatrix: Matrix;
  35635. /**
  35636. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  35637. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  35638. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  35639. */
  35640. upVector: Vector3;
  35641. /**
  35642. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  35643. */
  35644. setMatUp(): void;
  35645. /**
  35646. * Current inertia value on the longitudinal axis.
  35647. * The bigger this number the longer it will take for the camera to stop.
  35648. */
  35649. inertialAlphaOffset: number;
  35650. /**
  35651. * Current inertia value on the latitudinal axis.
  35652. * The bigger this number the longer it will take for the camera to stop.
  35653. */
  35654. inertialBetaOffset: number;
  35655. /**
  35656. * Current inertia value on the radius axis.
  35657. * The bigger this number the longer it will take for the camera to stop.
  35658. */
  35659. inertialRadiusOffset: number;
  35660. /**
  35661. * Minimum allowed angle on the longitudinal axis.
  35662. * This can help limiting how the Camera is able to move in the scene.
  35663. */
  35664. lowerAlphaLimit: Nullable<number>;
  35665. /**
  35666. * Maximum allowed angle on the longitudinal axis.
  35667. * This can help limiting how the Camera is able to move in the scene.
  35668. */
  35669. upperAlphaLimit: Nullable<number>;
  35670. /**
  35671. * Minimum allowed angle on the latitudinal axis.
  35672. * This can help limiting how the Camera is able to move in the scene.
  35673. */
  35674. lowerBetaLimit: number;
  35675. /**
  35676. * Maximum allowed angle on the latitudinal axis.
  35677. * This can help limiting how the Camera is able to move in the scene.
  35678. */
  35679. upperBetaLimit: number;
  35680. /**
  35681. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35682. * This can help limiting how the Camera is able to move in the scene.
  35683. */
  35684. lowerRadiusLimit: Nullable<number>;
  35685. /**
  35686. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35687. * This can help limiting how the Camera is able to move in the scene.
  35688. */
  35689. upperRadiusLimit: Nullable<number>;
  35690. /**
  35691. * Defines the current inertia value used during panning of the camera along the X axis.
  35692. */
  35693. inertialPanningX: number;
  35694. /**
  35695. * Defines the current inertia value used during panning of the camera along the Y axis.
  35696. */
  35697. inertialPanningY: number;
  35698. /**
  35699. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35700. * Basically if your fingers moves away from more than this distance you will be considered
  35701. * in pinch mode.
  35702. */
  35703. pinchToPanMaxDistance: number;
  35704. /**
  35705. * Defines the maximum distance the camera can pan.
  35706. * This could help keeping the cammera always in your scene.
  35707. */
  35708. panningDistanceLimit: Nullable<number>;
  35709. /**
  35710. * Defines the target of the camera before paning.
  35711. */
  35712. panningOriginTarget: Vector3;
  35713. /**
  35714. * Defines the value of the inertia used during panning.
  35715. * 0 would mean stop inertia and one would mean no decelleration at all.
  35716. */
  35717. panningInertia: number;
  35718. /**
  35719. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35720. */
  35721. angularSensibilityX: number;
  35722. /**
  35723. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35724. */
  35725. angularSensibilityY: number;
  35726. /**
  35727. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35728. */
  35729. pinchPrecision: number;
  35730. /**
  35731. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35732. * It will be used instead of pinchDeltaPrecision if different from 0.
  35733. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35734. */
  35735. pinchDeltaPercentage: number;
  35736. /**
  35737. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35738. */
  35739. panningSensibility: number;
  35740. /**
  35741. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35742. */
  35743. keysUp: number[];
  35744. /**
  35745. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35746. */
  35747. keysDown: number[];
  35748. /**
  35749. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35750. */
  35751. keysLeft: number[];
  35752. /**
  35753. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35754. */
  35755. keysRight: number[];
  35756. /**
  35757. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35758. */
  35759. wheelPrecision: number;
  35760. /**
  35761. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35762. * It will be used instead of pinchDeltaPrecision if different from 0.
  35763. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35764. */
  35765. wheelDeltaPercentage: number;
  35766. /**
  35767. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35768. */
  35769. zoomOnFactor: number;
  35770. /**
  35771. * Defines a screen offset for the camera position.
  35772. */
  35773. targetScreenOffset: Vector2;
  35774. /**
  35775. * Allows the camera to be completely reversed.
  35776. * If false the camera can not arrive upside down.
  35777. */
  35778. allowUpsideDown: boolean;
  35779. /**
  35780. * Define if double tap/click is used to restore the previously saved state of the camera.
  35781. */
  35782. useInputToRestoreState: boolean;
  35783. /** @hidden */
  35784. _viewMatrix: Matrix;
  35785. /** @hidden */
  35786. _useCtrlForPanning: boolean;
  35787. /** @hidden */
  35788. _panningMouseButton: number;
  35789. /**
  35790. * Defines the input associated to the camera.
  35791. */
  35792. inputs: ArcRotateCameraInputsManager;
  35793. /** @hidden */
  35794. _reset: () => void;
  35795. /**
  35796. * Defines the allowed panning axis.
  35797. */
  35798. panningAxis: Vector3;
  35799. protected _localDirection: Vector3;
  35800. protected _transformedDirection: Vector3;
  35801. private _bouncingBehavior;
  35802. /**
  35803. * Gets the bouncing behavior of the camera if it has been enabled.
  35804. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35805. */
  35806. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35807. /**
  35808. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35809. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35810. */
  35811. useBouncingBehavior: boolean;
  35812. private _framingBehavior;
  35813. /**
  35814. * Gets the framing behavior of the camera if it has been enabled.
  35815. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35816. */
  35817. readonly framingBehavior: Nullable<FramingBehavior>;
  35818. /**
  35819. * Defines if the framing behavior of the camera is enabled on the camera.
  35820. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35821. */
  35822. useFramingBehavior: boolean;
  35823. private _autoRotationBehavior;
  35824. /**
  35825. * Gets the auto rotation behavior of the camera if it has been enabled.
  35826. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35827. */
  35828. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35829. /**
  35830. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35831. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35832. */
  35833. useAutoRotationBehavior: boolean;
  35834. /**
  35835. * Observable triggered when the mesh target has been changed on the camera.
  35836. */
  35837. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35838. /**
  35839. * Event raised when the camera is colliding with a mesh.
  35840. */
  35841. onCollide: (collidedMesh: AbstractMesh) => void;
  35842. /**
  35843. * Defines whether the camera should check collision with the objects oh the scene.
  35844. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35845. */
  35846. checkCollisions: boolean;
  35847. /**
  35848. * Defines the collision radius of the camera.
  35849. * This simulates a sphere around the camera.
  35850. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35851. */
  35852. collisionRadius: Vector3;
  35853. protected _collider: Collider;
  35854. protected _previousPosition: Vector3;
  35855. protected _collisionVelocity: Vector3;
  35856. protected _newPosition: Vector3;
  35857. protected _previousAlpha: number;
  35858. protected _previousBeta: number;
  35859. protected _previousRadius: number;
  35860. protected _collisionTriggered: boolean;
  35861. protected _targetBoundingCenter: Nullable<Vector3>;
  35862. private _computationVector;
  35863. /**
  35864. * Instantiates a new ArcRotateCamera in a given scene
  35865. * @param name Defines the name of the camera
  35866. * @param alpha Defines the camera rotation along the logitudinal axis
  35867. * @param beta Defines the camera rotation along the latitudinal axis
  35868. * @param radius Defines the camera distance from its target
  35869. * @param target Defines the camera target
  35870. * @param scene Defines the scene the camera belongs to
  35871. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35872. */
  35873. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35874. /** @hidden */
  35875. _initCache(): void;
  35876. /** @hidden */
  35877. _updateCache(ignoreParentClass?: boolean): void;
  35878. protected _getTargetPosition(): Vector3;
  35879. private _storedAlpha;
  35880. private _storedBeta;
  35881. private _storedRadius;
  35882. private _storedTarget;
  35883. /**
  35884. * Stores the current state of the camera (alpha, beta, radius and target)
  35885. * @returns the camera itself
  35886. */
  35887. storeState(): Camera;
  35888. /**
  35889. * @hidden
  35890. * Restored camera state. You must call storeState() first
  35891. */
  35892. _restoreStateValues(): boolean;
  35893. /** @hidden */
  35894. _isSynchronizedViewMatrix(): boolean;
  35895. /**
  35896. * Attached controls to the current camera.
  35897. * @param element Defines the element the controls should be listened from
  35898. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35899. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35900. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35901. */
  35902. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35903. /**
  35904. * Detach the current controls from the camera.
  35905. * The camera will stop reacting to inputs.
  35906. * @param element Defines the element to stop listening the inputs from
  35907. */
  35908. detachControl(element: HTMLElement): void;
  35909. /** @hidden */
  35910. _checkInputs(): void;
  35911. protected _checkLimits(): void;
  35912. /**
  35913. * Rebuilds angles (alpha, beta) and radius from the give position and target
  35914. */
  35915. rebuildAnglesAndRadius(): void;
  35916. /**
  35917. * Use a position to define the current camera related information like aplha, beta and radius
  35918. * @param position Defines the position to set the camera at
  35919. */
  35920. setPosition(position: Vector3): void;
  35921. /**
  35922. * Defines the target the camera should look at.
  35923. * This will automatically adapt alpha beta and radius to fit within the new target.
  35924. * @param target Defines the new target as a Vector or a mesh
  35925. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35926. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35927. */
  35928. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35929. /** @hidden */
  35930. _getViewMatrix(): Matrix;
  35931. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35932. /**
  35933. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35934. * @param meshes Defines the mesh to zoom on
  35935. * @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)
  35936. */
  35937. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35938. /**
  35939. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35940. * The target will be changed but the radius
  35941. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35942. * @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)
  35943. */
  35944. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35945. min: Vector3;
  35946. max: Vector3;
  35947. distance: number;
  35948. }, doNotUpdateMaxZ?: boolean): void;
  35949. /**
  35950. * @override
  35951. * Override Camera.createRigCamera
  35952. */
  35953. createRigCamera(name: string, cameraIndex: number): Camera;
  35954. /**
  35955. * @hidden
  35956. * @override
  35957. * Override Camera._updateRigCameras
  35958. */
  35959. _updateRigCameras(): void;
  35960. /**
  35961. * Destroy the camera and release the current resources hold by it.
  35962. */
  35963. dispose(): void;
  35964. /**
  35965. * Gets the current object class name.
  35966. * @return the class name
  35967. */
  35968. getClassName(): string;
  35969. }
  35970. }
  35971. declare module BABYLON {
  35972. /**
  35973. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35974. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35975. */
  35976. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35977. /**
  35978. * Gets the name of the behavior.
  35979. */
  35980. readonly name: string;
  35981. private _zoomStopsAnimation;
  35982. private _idleRotationSpeed;
  35983. private _idleRotationWaitTime;
  35984. private _idleRotationSpinupTime;
  35985. /**
  35986. * Sets the flag that indicates if user zooming should stop animation.
  35987. */
  35988. /**
  35989. * Gets the flag that indicates if user zooming should stop animation.
  35990. */
  35991. zoomStopsAnimation: boolean;
  35992. /**
  35993. * Sets the default speed at which the camera rotates around the model.
  35994. */
  35995. /**
  35996. * Gets the default speed at which the camera rotates around the model.
  35997. */
  35998. idleRotationSpeed: number;
  35999. /**
  36000. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36001. */
  36002. /**
  36003. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36004. */
  36005. idleRotationWaitTime: number;
  36006. /**
  36007. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36008. */
  36009. /**
  36010. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36011. */
  36012. idleRotationSpinupTime: number;
  36013. /**
  36014. * Gets a value indicating if the camera is currently rotating because of this behavior
  36015. */
  36016. readonly rotationInProgress: boolean;
  36017. private _onPrePointerObservableObserver;
  36018. private _onAfterCheckInputsObserver;
  36019. private _attachedCamera;
  36020. private _isPointerDown;
  36021. private _lastFrameTime;
  36022. private _lastInteractionTime;
  36023. private _cameraRotationSpeed;
  36024. /**
  36025. * Initializes the behavior.
  36026. */
  36027. init(): void;
  36028. /**
  36029. * Attaches the behavior to its arc rotate camera.
  36030. * @param camera Defines the camera to attach the behavior to
  36031. */
  36032. attach(camera: ArcRotateCamera): void;
  36033. /**
  36034. * Detaches the behavior from its current arc rotate camera.
  36035. */
  36036. detach(): void;
  36037. /**
  36038. * Returns true if user is scrolling.
  36039. * @return true if user is scrolling.
  36040. */
  36041. private _userIsZooming;
  36042. private _lastFrameRadius;
  36043. private _shouldAnimationStopForInteraction;
  36044. /**
  36045. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36046. */
  36047. private _applyUserInteraction;
  36048. private _userIsMoving;
  36049. }
  36050. }
  36051. declare module BABYLON {
  36052. /**
  36053. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36054. */
  36055. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36056. private ui;
  36057. /**
  36058. * The name of the behavior
  36059. */
  36060. name: string;
  36061. /**
  36062. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36063. */
  36064. distanceAwayFromFace: number;
  36065. /**
  36066. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36067. */
  36068. distanceAwayFromBottomOfFace: number;
  36069. private _faceVectors;
  36070. private _target;
  36071. private _scene;
  36072. private _onRenderObserver;
  36073. private _tmpMatrix;
  36074. private _tmpVector;
  36075. /**
  36076. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36077. * @param ui The transform node that should be attched to the mesh
  36078. */
  36079. constructor(ui: TransformNode);
  36080. /**
  36081. * Initializes the behavior
  36082. */
  36083. init(): void;
  36084. private _closestFace;
  36085. private _zeroVector;
  36086. private _lookAtTmpMatrix;
  36087. private _lookAtToRef;
  36088. /**
  36089. * Attaches the AttachToBoxBehavior to the passed in mesh
  36090. * @param target The mesh that the specified node will be attached to
  36091. */
  36092. attach(target: Mesh): void;
  36093. /**
  36094. * Detaches the behavior from the mesh
  36095. */
  36096. detach(): void;
  36097. }
  36098. }
  36099. declare module BABYLON {
  36100. /**
  36101. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36102. */
  36103. export class FadeInOutBehavior implements Behavior<Mesh> {
  36104. /**
  36105. * Time in milliseconds to delay before fading in (Default: 0)
  36106. */
  36107. delay: number;
  36108. /**
  36109. * Time in milliseconds for the mesh to fade in (Default: 300)
  36110. */
  36111. fadeInTime: number;
  36112. private _millisecondsPerFrame;
  36113. private _hovered;
  36114. private _hoverValue;
  36115. private _ownerNode;
  36116. /**
  36117. * Instatiates the FadeInOutBehavior
  36118. */
  36119. constructor();
  36120. /**
  36121. * The name of the behavior
  36122. */
  36123. readonly name: string;
  36124. /**
  36125. * Initializes the behavior
  36126. */
  36127. init(): void;
  36128. /**
  36129. * Attaches the fade behavior on the passed in mesh
  36130. * @param ownerNode The mesh that will be faded in/out once attached
  36131. */
  36132. attach(ownerNode: Mesh): void;
  36133. /**
  36134. * Detaches the behavior from the mesh
  36135. */
  36136. detach(): void;
  36137. /**
  36138. * Triggers the mesh to begin fading in or out
  36139. * @param value if the object should fade in or out (true to fade in)
  36140. */
  36141. fadeIn(value: boolean): void;
  36142. private _update;
  36143. private _setAllVisibility;
  36144. }
  36145. }
  36146. declare module BABYLON {
  36147. /**
  36148. * Class containing a set of static utilities functions for managing Pivots
  36149. * @hidden
  36150. */
  36151. export class PivotTools {
  36152. private static _PivotCached;
  36153. private static _OldPivotPoint;
  36154. private static _PivotTranslation;
  36155. private static _PivotTmpVector;
  36156. /** @hidden */
  36157. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36158. /** @hidden */
  36159. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36160. }
  36161. }
  36162. declare module BABYLON {
  36163. /**
  36164. * Class containing static functions to help procedurally build meshes
  36165. */
  36166. export class PlaneBuilder {
  36167. /**
  36168. * Creates a plane mesh
  36169. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36170. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36171. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36172. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36173. * * 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
  36174. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36175. * @param name defines the name of the mesh
  36176. * @param options defines the options used to create the mesh
  36177. * @param scene defines the hosting scene
  36178. * @returns the plane mesh
  36179. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36180. */
  36181. static CreatePlane(name: string, options: {
  36182. size?: number;
  36183. width?: number;
  36184. height?: number;
  36185. sideOrientation?: number;
  36186. frontUVs?: Vector4;
  36187. backUVs?: Vector4;
  36188. updatable?: boolean;
  36189. sourcePlane?: Plane;
  36190. }, scene?: Nullable<Scene>): Mesh;
  36191. }
  36192. }
  36193. declare module BABYLON {
  36194. /**
  36195. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36196. */
  36197. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36198. private static _AnyMouseID;
  36199. /**
  36200. * Abstract mesh the behavior is set on
  36201. */
  36202. attachedNode: AbstractMesh;
  36203. private _dragPlane;
  36204. private _scene;
  36205. private _pointerObserver;
  36206. private _beforeRenderObserver;
  36207. private static _planeScene;
  36208. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36209. /**
  36210. * 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)
  36211. */
  36212. maxDragAngle: number;
  36213. /**
  36214. * @hidden
  36215. */
  36216. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36217. /**
  36218. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36219. */
  36220. currentDraggingPointerID: number;
  36221. /**
  36222. * The last position where the pointer hit the drag plane in world space
  36223. */
  36224. lastDragPosition: Vector3;
  36225. /**
  36226. * If the behavior is currently in a dragging state
  36227. */
  36228. dragging: boolean;
  36229. /**
  36230. * 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)
  36231. */
  36232. dragDeltaRatio: number;
  36233. /**
  36234. * If the drag plane orientation should be updated during the dragging (Default: true)
  36235. */
  36236. updateDragPlane: boolean;
  36237. private _debugMode;
  36238. private _moving;
  36239. /**
  36240. * Fires each time the attached mesh is dragged with the pointer
  36241. * * delta between last drag position and current drag position in world space
  36242. * * dragDistance along the drag axis
  36243. * * dragPlaneNormal normal of the current drag plane used during the drag
  36244. * * dragPlanePoint in world space where the drag intersects the drag plane
  36245. */
  36246. onDragObservable: Observable<{
  36247. delta: Vector3;
  36248. dragPlanePoint: Vector3;
  36249. dragPlaneNormal: Vector3;
  36250. dragDistance: number;
  36251. pointerId: number;
  36252. }>;
  36253. /**
  36254. * Fires each time a drag begins (eg. mouse down on mesh)
  36255. */
  36256. onDragStartObservable: Observable<{
  36257. dragPlanePoint: Vector3;
  36258. pointerId: number;
  36259. }>;
  36260. /**
  36261. * Fires each time a drag ends (eg. mouse release after drag)
  36262. */
  36263. onDragEndObservable: Observable<{
  36264. dragPlanePoint: Vector3;
  36265. pointerId: number;
  36266. }>;
  36267. /**
  36268. * If the attached mesh should be moved when dragged
  36269. */
  36270. moveAttached: boolean;
  36271. /**
  36272. * If the drag behavior will react to drag events (Default: true)
  36273. */
  36274. enabled: boolean;
  36275. /**
  36276. * If pointer events should start and release the drag (Default: true)
  36277. */
  36278. startAndReleaseDragOnPointerEvents: boolean;
  36279. /**
  36280. * If camera controls should be detached during the drag
  36281. */
  36282. detachCameraControls: boolean;
  36283. /**
  36284. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36285. */
  36286. useObjectOrienationForDragging: boolean;
  36287. private _options;
  36288. /**
  36289. * Creates a pointer drag behavior that can be attached to a mesh
  36290. * @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)
  36291. */
  36292. constructor(options?: {
  36293. dragAxis?: Vector3;
  36294. dragPlaneNormal?: Vector3;
  36295. });
  36296. /**
  36297. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36298. */
  36299. validateDrag: (targetPosition: Vector3) => boolean;
  36300. /**
  36301. * The name of the behavior
  36302. */
  36303. readonly name: string;
  36304. /**
  36305. * Initializes the behavior
  36306. */
  36307. init(): void;
  36308. private _tmpVector;
  36309. private _alternatePickedPoint;
  36310. private _worldDragAxis;
  36311. private _targetPosition;
  36312. private _attachedElement;
  36313. /**
  36314. * Attaches the drag behavior the passed in mesh
  36315. * @param ownerNode The mesh that will be dragged around once attached
  36316. */
  36317. attach(ownerNode: AbstractMesh): void;
  36318. /**
  36319. * Force relase the drag action by code.
  36320. */
  36321. releaseDrag(): void;
  36322. private _startDragRay;
  36323. private _lastPointerRay;
  36324. /**
  36325. * Simulates the start of a pointer drag event on the behavior
  36326. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36327. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36328. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36329. */
  36330. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36331. private _startDrag;
  36332. private _dragDelta;
  36333. private _moveDrag;
  36334. private _pickWithRayOnDragPlane;
  36335. private _pointA;
  36336. private _pointB;
  36337. private _pointC;
  36338. private _lineA;
  36339. private _lineB;
  36340. private _localAxis;
  36341. private _lookAt;
  36342. private _updateDragPlanePosition;
  36343. /**
  36344. * Detaches the behavior from the mesh
  36345. */
  36346. detach(): void;
  36347. }
  36348. }
  36349. declare module BABYLON {
  36350. /**
  36351. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36352. */
  36353. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36354. private _dragBehaviorA;
  36355. private _dragBehaviorB;
  36356. private _startDistance;
  36357. private _initialScale;
  36358. private _targetScale;
  36359. private _ownerNode;
  36360. private _sceneRenderObserver;
  36361. /**
  36362. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36363. */
  36364. constructor();
  36365. /**
  36366. * The name of the behavior
  36367. */
  36368. readonly name: string;
  36369. /**
  36370. * Initializes the behavior
  36371. */
  36372. init(): void;
  36373. private _getCurrentDistance;
  36374. /**
  36375. * Attaches the scale behavior the passed in mesh
  36376. * @param ownerNode The mesh that will be scaled around once attached
  36377. */
  36378. attach(ownerNode: Mesh): void;
  36379. /**
  36380. * Detaches the behavior from the mesh
  36381. */
  36382. detach(): void;
  36383. }
  36384. }
  36385. declare module BABYLON {
  36386. /**
  36387. * 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
  36388. */
  36389. export class SixDofDragBehavior implements Behavior<Mesh> {
  36390. private static _virtualScene;
  36391. private _ownerNode;
  36392. private _sceneRenderObserver;
  36393. private _scene;
  36394. private _targetPosition;
  36395. private _virtualOriginMesh;
  36396. private _virtualDragMesh;
  36397. private _pointerObserver;
  36398. private _moving;
  36399. private _startingOrientation;
  36400. /**
  36401. * 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)
  36402. */
  36403. private zDragFactor;
  36404. /**
  36405. * If the object should rotate to face the drag origin
  36406. */
  36407. rotateDraggedObject: boolean;
  36408. /**
  36409. * If the behavior is currently in a dragging state
  36410. */
  36411. dragging: boolean;
  36412. /**
  36413. * 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)
  36414. */
  36415. dragDeltaRatio: number;
  36416. /**
  36417. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36418. */
  36419. currentDraggingPointerID: number;
  36420. /**
  36421. * If camera controls should be detached during the drag
  36422. */
  36423. detachCameraControls: boolean;
  36424. /**
  36425. * Fires each time a drag starts
  36426. */
  36427. onDragStartObservable: Observable<{}>;
  36428. /**
  36429. * Fires each time a drag ends (eg. mouse release after drag)
  36430. */
  36431. onDragEndObservable: Observable<{}>;
  36432. /**
  36433. * 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
  36434. */
  36435. constructor();
  36436. /**
  36437. * The name of the behavior
  36438. */
  36439. readonly name: string;
  36440. /**
  36441. * Initializes the behavior
  36442. */
  36443. init(): void;
  36444. /**
  36445. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  36446. */
  36447. private readonly _pointerCamera;
  36448. /**
  36449. * Attaches the scale behavior the passed in mesh
  36450. * @param ownerNode The mesh that will be scaled around once attached
  36451. */
  36452. attach(ownerNode: Mesh): void;
  36453. /**
  36454. * Detaches the behavior from the mesh
  36455. */
  36456. detach(): void;
  36457. }
  36458. }
  36459. declare module BABYLON {
  36460. /**
  36461. * Class used to apply inverse kinematics to bones
  36462. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36463. */
  36464. export class BoneIKController {
  36465. private static _tmpVecs;
  36466. private static _tmpQuat;
  36467. private static _tmpMats;
  36468. /**
  36469. * Gets or sets the target mesh
  36470. */
  36471. targetMesh: AbstractMesh;
  36472. /** Gets or sets the mesh used as pole */
  36473. poleTargetMesh: AbstractMesh;
  36474. /**
  36475. * Gets or sets the bone used as pole
  36476. */
  36477. poleTargetBone: Nullable<Bone>;
  36478. /**
  36479. * Gets or sets the target position
  36480. */
  36481. targetPosition: Vector3;
  36482. /**
  36483. * Gets or sets the pole target position
  36484. */
  36485. poleTargetPosition: Vector3;
  36486. /**
  36487. * Gets or sets the pole target local offset
  36488. */
  36489. poleTargetLocalOffset: Vector3;
  36490. /**
  36491. * Gets or sets the pole angle
  36492. */
  36493. poleAngle: number;
  36494. /**
  36495. * Gets or sets the mesh associated with the controller
  36496. */
  36497. mesh: AbstractMesh;
  36498. /**
  36499. * 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)
  36500. */
  36501. slerpAmount: number;
  36502. private _bone1Quat;
  36503. private _bone1Mat;
  36504. private _bone2Ang;
  36505. private _bone1;
  36506. private _bone2;
  36507. private _bone1Length;
  36508. private _bone2Length;
  36509. private _maxAngle;
  36510. private _maxReach;
  36511. private _rightHandedSystem;
  36512. private _bendAxis;
  36513. private _slerping;
  36514. private _adjustRoll;
  36515. /**
  36516. * Gets or sets maximum allowed angle
  36517. */
  36518. maxAngle: number;
  36519. /**
  36520. * Creates a new BoneIKController
  36521. * @param mesh defines the mesh to control
  36522. * @param bone defines the bone to control
  36523. * @param options defines options to set up the controller
  36524. */
  36525. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36526. targetMesh?: AbstractMesh;
  36527. poleTargetMesh?: AbstractMesh;
  36528. poleTargetBone?: Bone;
  36529. poleTargetLocalOffset?: Vector3;
  36530. poleAngle?: number;
  36531. bendAxis?: Vector3;
  36532. maxAngle?: number;
  36533. slerpAmount?: number;
  36534. });
  36535. private _setMaxAngle;
  36536. /**
  36537. * Force the controller to update the bones
  36538. */
  36539. update(): void;
  36540. }
  36541. }
  36542. declare module BABYLON {
  36543. /**
  36544. * Class used to make a bone look toward a point in space
  36545. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36546. */
  36547. export class BoneLookController {
  36548. private static _tmpVecs;
  36549. private static _tmpQuat;
  36550. private static _tmpMats;
  36551. /**
  36552. * The target Vector3 that the bone will look at
  36553. */
  36554. target: Vector3;
  36555. /**
  36556. * The mesh that the bone is attached to
  36557. */
  36558. mesh: AbstractMesh;
  36559. /**
  36560. * The bone that will be looking to the target
  36561. */
  36562. bone: Bone;
  36563. /**
  36564. * The up axis of the coordinate system that is used when the bone is rotated
  36565. */
  36566. upAxis: Vector3;
  36567. /**
  36568. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36569. */
  36570. upAxisSpace: Space;
  36571. /**
  36572. * Used to make an adjustment to the yaw of the bone
  36573. */
  36574. adjustYaw: number;
  36575. /**
  36576. * Used to make an adjustment to the pitch of the bone
  36577. */
  36578. adjustPitch: number;
  36579. /**
  36580. * Used to make an adjustment to the roll of the bone
  36581. */
  36582. adjustRoll: number;
  36583. /**
  36584. * 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)
  36585. */
  36586. slerpAmount: number;
  36587. private _minYaw;
  36588. private _maxYaw;
  36589. private _minPitch;
  36590. private _maxPitch;
  36591. private _minYawSin;
  36592. private _minYawCos;
  36593. private _maxYawSin;
  36594. private _maxYawCos;
  36595. private _midYawConstraint;
  36596. private _minPitchTan;
  36597. private _maxPitchTan;
  36598. private _boneQuat;
  36599. private _slerping;
  36600. private _transformYawPitch;
  36601. private _transformYawPitchInv;
  36602. private _firstFrameSkipped;
  36603. private _yawRange;
  36604. private _fowardAxis;
  36605. /**
  36606. * Gets or sets the minimum yaw angle that the bone can look to
  36607. */
  36608. minYaw: number;
  36609. /**
  36610. * Gets or sets the maximum yaw angle that the bone can look to
  36611. */
  36612. maxYaw: number;
  36613. /**
  36614. * Gets or sets the minimum pitch angle that the bone can look to
  36615. */
  36616. minPitch: number;
  36617. /**
  36618. * Gets or sets the maximum pitch angle that the bone can look to
  36619. */
  36620. maxPitch: number;
  36621. /**
  36622. * Create a BoneLookController
  36623. * @param mesh the mesh that the bone belongs to
  36624. * @param bone the bone that will be looking to the target
  36625. * @param target the target Vector3 to look at
  36626. * @param options optional settings:
  36627. * * maxYaw: the maximum angle the bone will yaw to
  36628. * * minYaw: the minimum angle the bone will yaw to
  36629. * * maxPitch: the maximum angle the bone will pitch to
  36630. * * minPitch: the minimum angle the bone will yaw to
  36631. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36632. * * upAxis: the up axis of the coordinate system
  36633. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36634. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36635. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36636. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36637. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36638. * * adjustRoll: used to make an adjustment to the roll of the bone
  36639. **/
  36640. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36641. maxYaw?: number;
  36642. minYaw?: number;
  36643. maxPitch?: number;
  36644. minPitch?: number;
  36645. slerpAmount?: number;
  36646. upAxis?: Vector3;
  36647. upAxisSpace?: Space;
  36648. yawAxis?: Vector3;
  36649. pitchAxis?: Vector3;
  36650. adjustYaw?: number;
  36651. adjustPitch?: number;
  36652. adjustRoll?: number;
  36653. });
  36654. /**
  36655. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36656. */
  36657. update(): void;
  36658. private _getAngleDiff;
  36659. private _getAngleBetween;
  36660. private _isAngleBetween;
  36661. }
  36662. }
  36663. declare module BABYLON {
  36664. /**
  36665. * Manage the gamepad inputs to control an arc rotate camera.
  36666. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36667. */
  36668. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36669. /**
  36670. * Defines the camera the input is attached to.
  36671. */
  36672. camera: ArcRotateCamera;
  36673. /**
  36674. * Defines the gamepad the input is gathering event from.
  36675. */
  36676. gamepad: Nullable<Gamepad>;
  36677. /**
  36678. * Defines the gamepad rotation sensiblity.
  36679. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36680. */
  36681. gamepadRotationSensibility: number;
  36682. /**
  36683. * Defines the gamepad move sensiblity.
  36684. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36685. */
  36686. gamepadMoveSensibility: number;
  36687. private _onGamepadConnectedObserver;
  36688. private _onGamepadDisconnectedObserver;
  36689. /**
  36690. * Attach the input controls to a specific dom element to get the input from.
  36691. * @param element Defines the element the controls should be listened from
  36692. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36693. */
  36694. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36695. /**
  36696. * Detach the current controls from the specified dom element.
  36697. * @param element Defines the element to stop listening the inputs from
  36698. */
  36699. detachControl(element: Nullable<HTMLElement>): void;
  36700. /**
  36701. * Update the current camera state depending on the inputs that have been used this frame.
  36702. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36703. */
  36704. checkInputs(): void;
  36705. /**
  36706. * Gets the class name of the current intput.
  36707. * @returns the class name
  36708. */
  36709. getClassName(): string;
  36710. /**
  36711. * Get the friendly name associated with the input class.
  36712. * @returns the input friendly name
  36713. */
  36714. getSimpleName(): string;
  36715. }
  36716. }
  36717. declare module BABYLON {
  36718. interface ArcRotateCameraInputsManager {
  36719. /**
  36720. * Add orientation input support to the input manager.
  36721. * @returns the current input manager
  36722. */
  36723. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36724. }
  36725. /**
  36726. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36727. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36728. */
  36729. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36730. /**
  36731. * Defines the camera the input is attached to.
  36732. */
  36733. camera: ArcRotateCamera;
  36734. /**
  36735. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36736. */
  36737. alphaCorrection: number;
  36738. /**
  36739. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36740. */
  36741. gammaCorrection: number;
  36742. private _alpha;
  36743. private _gamma;
  36744. private _dirty;
  36745. private _deviceOrientationHandler;
  36746. /**
  36747. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36748. */
  36749. constructor();
  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. /** @hidden */
  36757. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36758. /**
  36759. * Update the current camera state depending on the inputs that have been used this frame.
  36760. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36761. */
  36762. checkInputs(): void;
  36763. /**
  36764. * Detach the current controls from the specified dom element.
  36765. * @param element Defines the element to stop listening the inputs from
  36766. */
  36767. detachControl(element: Nullable<HTMLElement>): void;
  36768. /**
  36769. * Gets the class name of the current intput.
  36770. * @returns the class name
  36771. */
  36772. getClassName(): string;
  36773. /**
  36774. * Get the friendly name associated with the input class.
  36775. * @returns the input friendly name
  36776. */
  36777. getSimpleName(): string;
  36778. }
  36779. }
  36780. declare module BABYLON {
  36781. /**
  36782. * Listen to mouse events to control the camera.
  36783. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36784. */
  36785. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36786. /**
  36787. * Defines the camera the input is attached to.
  36788. */
  36789. camera: FlyCamera;
  36790. /**
  36791. * Defines if touch is enabled. (Default is true.)
  36792. */
  36793. touchEnabled: boolean;
  36794. /**
  36795. * Defines the buttons associated with the input to handle camera rotation.
  36796. */
  36797. buttons: number[];
  36798. /**
  36799. * Assign buttons for Yaw control.
  36800. */
  36801. buttonsYaw: number[];
  36802. /**
  36803. * Assign buttons for Pitch control.
  36804. */
  36805. buttonsPitch: number[];
  36806. /**
  36807. * Assign buttons for Roll control.
  36808. */
  36809. buttonsRoll: number[];
  36810. /**
  36811. * Detect if any button is being pressed while mouse is moved.
  36812. * -1 = Mouse locked.
  36813. * 0 = Left button.
  36814. * 1 = Middle Button.
  36815. * 2 = Right Button.
  36816. */
  36817. activeButton: number;
  36818. /**
  36819. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36820. * Higher values reduce its sensitivity.
  36821. */
  36822. angularSensibility: number;
  36823. private _mousemoveCallback;
  36824. private _observer;
  36825. private _rollObserver;
  36826. private previousPosition;
  36827. private noPreventDefault;
  36828. private element;
  36829. /**
  36830. * Listen to mouse events to control the camera.
  36831. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36832. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36833. */
  36834. constructor(touchEnabled?: boolean);
  36835. /**
  36836. * Attach the mouse control to the HTML DOM element.
  36837. * @param element Defines the element that listens to the input events.
  36838. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36839. */
  36840. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36841. /**
  36842. * Detach the current controls from the specified dom element.
  36843. * @param element Defines the element to stop listening the inputs from
  36844. */
  36845. detachControl(element: Nullable<HTMLElement>): void;
  36846. /**
  36847. * Gets the class name of the current input.
  36848. * @returns the class name.
  36849. */
  36850. getClassName(): string;
  36851. /**
  36852. * Get the friendly name associated with the input class.
  36853. * @returns the input's friendly name.
  36854. */
  36855. getSimpleName(): string;
  36856. private _pointerInput;
  36857. private _onMouseMove;
  36858. /**
  36859. * Rotate camera by mouse offset.
  36860. */
  36861. private rotateCamera;
  36862. }
  36863. }
  36864. declare module BABYLON {
  36865. /**
  36866. * Default Inputs manager for the FlyCamera.
  36867. * It groups all the default supported inputs for ease of use.
  36868. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36869. */
  36870. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36871. /**
  36872. * Instantiates a new FlyCameraInputsManager.
  36873. * @param camera Defines the camera the inputs belong to.
  36874. */
  36875. constructor(camera: FlyCamera);
  36876. /**
  36877. * Add keyboard input support to the input manager.
  36878. * @returns the new FlyCameraKeyboardMoveInput().
  36879. */
  36880. addKeyboard(): FlyCameraInputsManager;
  36881. /**
  36882. * Add mouse input support to the input manager.
  36883. * @param touchEnabled Enable touch screen support.
  36884. * @returns the new FlyCameraMouseInput().
  36885. */
  36886. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36887. }
  36888. }
  36889. declare module BABYLON {
  36890. /**
  36891. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36892. * such as in a 3D Space Shooter or a Flight Simulator.
  36893. */
  36894. export class FlyCamera extends TargetCamera {
  36895. /**
  36896. * Define the collision ellipsoid of the camera.
  36897. * This is helpful for simulating a camera body, like a player's body.
  36898. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36899. */
  36900. ellipsoid: Vector3;
  36901. /**
  36902. * Define an offset for the position of the ellipsoid around the camera.
  36903. * This can be helpful if the camera is attached away from the player's body center,
  36904. * such as at its head.
  36905. */
  36906. ellipsoidOffset: Vector3;
  36907. /**
  36908. * Enable or disable collisions of the camera with the rest of the scene objects.
  36909. */
  36910. checkCollisions: boolean;
  36911. /**
  36912. * Enable or disable gravity on the camera.
  36913. */
  36914. applyGravity: boolean;
  36915. /**
  36916. * Define the current direction the camera is moving to.
  36917. */
  36918. cameraDirection: Vector3;
  36919. /**
  36920. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36921. * This overrides and empties cameraRotation.
  36922. */
  36923. rotationQuaternion: Quaternion;
  36924. /**
  36925. * Track Roll to maintain the wanted Rolling when looking around.
  36926. */
  36927. _trackRoll: number;
  36928. /**
  36929. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36930. */
  36931. rollCorrect: number;
  36932. /**
  36933. * Mimic a banked turn, Rolling the camera when Yawing.
  36934. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36935. */
  36936. bankedTurn: boolean;
  36937. /**
  36938. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36939. */
  36940. bankedTurnLimit: number;
  36941. /**
  36942. * Value of 0 disables the banked Roll.
  36943. * Value of 1 is equal to the Yaw angle in radians.
  36944. */
  36945. bankedTurnMultiplier: number;
  36946. /**
  36947. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36948. */
  36949. inputs: FlyCameraInputsManager;
  36950. /**
  36951. * Gets the input sensibility for mouse input.
  36952. * Higher values reduce sensitivity.
  36953. */
  36954. /**
  36955. * Sets the input sensibility for a mouse input.
  36956. * Higher values reduce sensitivity.
  36957. */
  36958. angularSensibility: number;
  36959. /**
  36960. * Get the keys for camera movement forward.
  36961. */
  36962. /**
  36963. * Set the keys for camera movement forward.
  36964. */
  36965. keysForward: number[];
  36966. /**
  36967. * Get the keys for camera movement backward.
  36968. */
  36969. keysBackward: number[];
  36970. /**
  36971. * Get the keys for camera movement up.
  36972. */
  36973. /**
  36974. * Set the keys for camera movement up.
  36975. */
  36976. keysUp: number[];
  36977. /**
  36978. * Get the keys for camera movement down.
  36979. */
  36980. /**
  36981. * Set the keys for camera movement down.
  36982. */
  36983. keysDown: number[];
  36984. /**
  36985. * Get the keys for camera movement left.
  36986. */
  36987. /**
  36988. * Set the keys for camera movement left.
  36989. */
  36990. keysLeft: number[];
  36991. /**
  36992. * Set the keys for camera movement right.
  36993. */
  36994. /**
  36995. * Set the keys for camera movement right.
  36996. */
  36997. keysRight: number[];
  36998. /**
  36999. * Event raised when the camera collides with a mesh in the scene.
  37000. */
  37001. onCollide: (collidedMesh: AbstractMesh) => void;
  37002. private _collider;
  37003. private _needMoveForGravity;
  37004. private _oldPosition;
  37005. private _diffPosition;
  37006. private _newPosition;
  37007. /** @hidden */
  37008. _localDirection: Vector3;
  37009. /** @hidden */
  37010. _transformedDirection: Vector3;
  37011. /**
  37012. * Instantiates a FlyCamera.
  37013. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37014. * such as in a 3D Space Shooter or a Flight Simulator.
  37015. * @param name Define the name of the camera in the scene.
  37016. * @param position Define the starting position of the camera in the scene.
  37017. * @param scene Define the scene the camera belongs to.
  37018. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37019. */
  37020. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37021. /**
  37022. * Attach a control to the HTML DOM element.
  37023. * @param element Defines the element that listens to the input events.
  37024. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37025. */
  37026. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37027. /**
  37028. * Detach a control from the HTML DOM element.
  37029. * The camera will stop reacting to that input.
  37030. * @param element Defines the element that listens to the input events.
  37031. */
  37032. detachControl(element: HTMLElement): void;
  37033. private _collisionMask;
  37034. /**
  37035. * Get the mask that the camera ignores in collision events.
  37036. */
  37037. /**
  37038. * Set the mask that the camera ignores in collision events.
  37039. */
  37040. collisionMask: number;
  37041. /** @hidden */
  37042. _collideWithWorld(displacement: Vector3): void;
  37043. /** @hidden */
  37044. private _onCollisionPositionChange;
  37045. /** @hidden */
  37046. _checkInputs(): void;
  37047. /** @hidden */
  37048. _decideIfNeedsToMove(): boolean;
  37049. /** @hidden */
  37050. _updatePosition(): void;
  37051. /**
  37052. * Restore the Roll to its target value at the rate specified.
  37053. * @param rate - Higher means slower restoring.
  37054. * @hidden
  37055. */
  37056. restoreRoll(rate: number): void;
  37057. /**
  37058. * Destroy the camera and release the current resources held by it.
  37059. */
  37060. dispose(): void;
  37061. /**
  37062. * Get the current object class name.
  37063. * @returns the class name.
  37064. */
  37065. getClassName(): string;
  37066. }
  37067. }
  37068. declare module BABYLON {
  37069. /**
  37070. * Listen to keyboard events to control the camera.
  37071. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37072. */
  37073. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37074. /**
  37075. * Defines the camera the input is attached to.
  37076. */
  37077. camera: FlyCamera;
  37078. /**
  37079. * The list of keyboard keys used to control the forward move of the camera.
  37080. */
  37081. keysForward: number[];
  37082. /**
  37083. * The list of keyboard keys used to control the backward move of the camera.
  37084. */
  37085. keysBackward: number[];
  37086. /**
  37087. * The list of keyboard keys used to control the forward move of the camera.
  37088. */
  37089. keysUp: number[];
  37090. /**
  37091. * The list of keyboard keys used to control the backward move of the camera.
  37092. */
  37093. keysDown: number[];
  37094. /**
  37095. * The list of keyboard keys used to control the right strafe move of the camera.
  37096. */
  37097. keysRight: number[];
  37098. /**
  37099. * The list of keyboard keys used to control the left strafe move of the camera.
  37100. */
  37101. keysLeft: number[];
  37102. private _keys;
  37103. private _onCanvasBlurObserver;
  37104. private _onKeyboardObserver;
  37105. private _engine;
  37106. private _scene;
  37107. /**
  37108. * Attach the input controls to a specific dom element to get the input from.
  37109. * @param element Defines the element the controls should be listened from
  37110. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37111. */
  37112. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37113. /**
  37114. * Detach the current controls from the specified dom element.
  37115. * @param element Defines the element to stop listening the inputs from
  37116. */
  37117. detachControl(element: Nullable<HTMLElement>): void;
  37118. /**
  37119. * Gets the class name of the current intput.
  37120. * @returns the class name
  37121. */
  37122. getClassName(): string;
  37123. /** @hidden */
  37124. _onLostFocus(e: FocusEvent): void;
  37125. /**
  37126. * Get the friendly name associated with the input class.
  37127. * @returns the input friendly name
  37128. */
  37129. getSimpleName(): string;
  37130. /**
  37131. * Update the current camera state depending on the inputs that have been used this frame.
  37132. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37133. */
  37134. checkInputs(): void;
  37135. }
  37136. }
  37137. declare module BABYLON {
  37138. /**
  37139. * Manage the mouse wheel inputs to control a follow camera.
  37140. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37141. */
  37142. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37143. /**
  37144. * Defines the camera the input is attached to.
  37145. */
  37146. camera: FollowCamera;
  37147. /**
  37148. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37149. */
  37150. axisControlRadius: boolean;
  37151. /**
  37152. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37153. */
  37154. axisControlHeight: boolean;
  37155. /**
  37156. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37157. */
  37158. axisControlRotation: boolean;
  37159. /**
  37160. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37161. * relation to mouseWheel events.
  37162. */
  37163. wheelPrecision: number;
  37164. /**
  37165. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37166. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37167. */
  37168. wheelDeltaPercentage: number;
  37169. private _wheel;
  37170. private _observer;
  37171. /**
  37172. * Attach the input controls to a specific dom element to get the input from.
  37173. * @param element Defines the element the controls should be listened from
  37174. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37175. */
  37176. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37177. /**
  37178. * Detach the current controls from the specified dom element.
  37179. * @param element Defines the element to stop listening the inputs from
  37180. */
  37181. detachControl(element: Nullable<HTMLElement>): void;
  37182. /**
  37183. * Gets the class name of the current intput.
  37184. * @returns the class name
  37185. */
  37186. getClassName(): string;
  37187. /**
  37188. * Get the friendly name associated with the input class.
  37189. * @returns the input friendly name
  37190. */
  37191. getSimpleName(): string;
  37192. }
  37193. }
  37194. declare module BABYLON {
  37195. /**
  37196. * Manage the pointers inputs to control an follow camera.
  37197. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37198. */
  37199. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37200. /**
  37201. * Defines the camera the input is attached to.
  37202. */
  37203. camera: FollowCamera;
  37204. /**
  37205. * Gets the class name of the current input.
  37206. * @returns the class name
  37207. */
  37208. getClassName(): string;
  37209. /**
  37210. * Defines the pointer angular sensibility along the X axis or how fast is
  37211. * the camera rotating.
  37212. * A negative number will reverse the axis direction.
  37213. */
  37214. angularSensibilityX: number;
  37215. /**
  37216. * Defines the pointer angular sensibility along the Y axis or how fast is
  37217. * the camera rotating.
  37218. * A negative number will reverse the axis direction.
  37219. */
  37220. angularSensibilityY: number;
  37221. /**
  37222. * Defines the pointer pinch precision or how fast is the camera zooming.
  37223. * A negative number will reverse the axis direction.
  37224. */
  37225. pinchPrecision: number;
  37226. /**
  37227. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37228. * from 0.
  37229. * It defines the percentage of current camera.radius to use as delta when
  37230. * pinch zoom is used.
  37231. */
  37232. pinchDeltaPercentage: number;
  37233. /**
  37234. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37235. */
  37236. axisXControlRadius: boolean;
  37237. /**
  37238. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37239. */
  37240. axisXControlHeight: boolean;
  37241. /**
  37242. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37243. */
  37244. axisXControlRotation: boolean;
  37245. /**
  37246. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37247. */
  37248. axisYControlRadius: boolean;
  37249. /**
  37250. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37251. */
  37252. axisYControlHeight: boolean;
  37253. /**
  37254. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37255. */
  37256. axisYControlRotation: boolean;
  37257. /**
  37258. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37259. */
  37260. axisPinchControlRadius: boolean;
  37261. /**
  37262. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37263. */
  37264. axisPinchControlHeight: boolean;
  37265. /**
  37266. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37267. */
  37268. axisPinchControlRotation: boolean;
  37269. /**
  37270. * Log error messages if basic misconfiguration has occurred.
  37271. */
  37272. warningEnable: boolean;
  37273. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37274. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37275. private _warningCounter;
  37276. private _warning;
  37277. }
  37278. }
  37279. declare module BABYLON {
  37280. /**
  37281. * Default Inputs manager for the FollowCamera.
  37282. * It groups all the default supported inputs for ease of use.
  37283. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37284. */
  37285. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37286. /**
  37287. * Instantiates a new FollowCameraInputsManager.
  37288. * @param camera Defines the camera the inputs belong to
  37289. */
  37290. constructor(camera: FollowCamera);
  37291. /**
  37292. * Add keyboard input support to the input manager.
  37293. * @returns the current input manager
  37294. */
  37295. addKeyboard(): FollowCameraInputsManager;
  37296. /**
  37297. * Add mouse wheel input support to the input manager.
  37298. * @returns the current input manager
  37299. */
  37300. addMouseWheel(): FollowCameraInputsManager;
  37301. /**
  37302. * Add pointers input support to the input manager.
  37303. * @returns the current input manager
  37304. */
  37305. addPointers(): FollowCameraInputsManager;
  37306. /**
  37307. * Add orientation input support to the input manager.
  37308. * @returns the current input manager
  37309. */
  37310. addVRDeviceOrientation(): FollowCameraInputsManager;
  37311. }
  37312. }
  37313. declare module BABYLON {
  37314. /**
  37315. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37316. * an arc rotate version arcFollowCamera are available.
  37317. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37318. */
  37319. export class FollowCamera extends TargetCamera {
  37320. /**
  37321. * Distance the follow camera should follow an object at
  37322. */
  37323. radius: number;
  37324. /**
  37325. * Minimum allowed distance of the camera to the axis of rotation
  37326. * (The camera can not get closer).
  37327. * This can help limiting how the Camera is able to move in the scene.
  37328. */
  37329. lowerRadiusLimit: Nullable<number>;
  37330. /**
  37331. * Maximum allowed distance of the camera to the axis of rotation
  37332. * (The camera can not get further).
  37333. * This can help limiting how the Camera is able to move in the scene.
  37334. */
  37335. upperRadiusLimit: Nullable<number>;
  37336. /**
  37337. * Define a rotation offset between the camera and the object it follows
  37338. */
  37339. rotationOffset: number;
  37340. /**
  37341. * Minimum allowed angle to camera position relative to target object.
  37342. * This can help limiting how the Camera is able to move in the scene.
  37343. */
  37344. lowerRotationOffsetLimit: Nullable<number>;
  37345. /**
  37346. * Maximum allowed angle to camera position relative to target object.
  37347. * This can help limiting how the Camera is able to move in the scene.
  37348. */
  37349. upperRotationOffsetLimit: Nullable<number>;
  37350. /**
  37351. * Define a height offset between the camera and the object it follows.
  37352. * It can help following an object from the top (like a car chaing a plane)
  37353. */
  37354. heightOffset: number;
  37355. /**
  37356. * Minimum allowed height of camera position relative to target object.
  37357. * This can help limiting how the Camera is able to move in the scene.
  37358. */
  37359. lowerHeightOffsetLimit: Nullable<number>;
  37360. /**
  37361. * Maximum allowed height of camera position relative to target object.
  37362. * This can help limiting how the Camera is able to move in the scene.
  37363. */
  37364. upperHeightOffsetLimit: Nullable<number>;
  37365. /**
  37366. * Define how fast the camera can accelerate to follow it s target.
  37367. */
  37368. cameraAcceleration: number;
  37369. /**
  37370. * Define the speed limit of the camera following an object.
  37371. */
  37372. maxCameraSpeed: number;
  37373. /**
  37374. * Define the target of the camera.
  37375. */
  37376. lockedTarget: Nullable<AbstractMesh>;
  37377. /**
  37378. * Defines the input associated with the camera.
  37379. */
  37380. inputs: FollowCameraInputsManager;
  37381. /**
  37382. * Instantiates the follow camera.
  37383. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37384. * @param name Define the name of the camera in the scene
  37385. * @param position Define the position of the camera
  37386. * @param scene Define the scene the camera belong to
  37387. * @param lockedTarget Define the target of the camera
  37388. */
  37389. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37390. private _follow;
  37391. /**
  37392. * Attached controls to the current camera.
  37393. * @param element Defines the element the controls should be listened from
  37394. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37395. */
  37396. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37397. /**
  37398. * Detach the current controls from the camera.
  37399. * The camera will stop reacting to inputs.
  37400. * @param element Defines the element to stop listening the inputs from
  37401. */
  37402. detachControl(element: HTMLElement): void;
  37403. /** @hidden */
  37404. _checkInputs(): void;
  37405. private _checkLimits;
  37406. /**
  37407. * Gets the camera class name.
  37408. * @returns the class name
  37409. */
  37410. getClassName(): string;
  37411. }
  37412. /**
  37413. * Arc Rotate version of the follow camera.
  37414. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37415. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37416. */
  37417. export class ArcFollowCamera extends TargetCamera {
  37418. /** The longitudinal angle of the camera */
  37419. alpha: number;
  37420. /** The latitudinal angle of the camera */
  37421. beta: number;
  37422. /** The radius of the camera from its target */
  37423. radius: number;
  37424. /** Define the camera target (the messh it should follow) */
  37425. target: Nullable<AbstractMesh>;
  37426. private _cartesianCoordinates;
  37427. /**
  37428. * Instantiates a new ArcFollowCamera
  37429. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37430. * @param name Define the name of the camera
  37431. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37432. * @param beta Define the rotation angle of the camera around the elevation axis
  37433. * @param radius Define the radius of the camera from its target point
  37434. * @param target Define the target of the camera
  37435. * @param scene Define the scene the camera belongs to
  37436. */
  37437. constructor(name: string,
  37438. /** The longitudinal angle of the camera */
  37439. alpha: number,
  37440. /** The latitudinal angle of the camera */
  37441. beta: number,
  37442. /** The radius of the camera from its target */
  37443. radius: number,
  37444. /** Define the camera target (the messh it should follow) */
  37445. target: Nullable<AbstractMesh>, scene: Scene);
  37446. private _follow;
  37447. /** @hidden */
  37448. _checkInputs(): void;
  37449. /**
  37450. * Returns the class name of the object.
  37451. * It is mostly used internally for serialization purposes.
  37452. */
  37453. getClassName(): string;
  37454. }
  37455. }
  37456. declare module BABYLON {
  37457. /**
  37458. * Manage the keyboard inputs to control the movement of a follow camera.
  37459. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37460. */
  37461. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37462. /**
  37463. * Defines the camera the input is attached to.
  37464. */
  37465. camera: FollowCamera;
  37466. /**
  37467. * Defines the list of key codes associated with the up action (increase heightOffset)
  37468. */
  37469. keysHeightOffsetIncr: number[];
  37470. /**
  37471. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37472. */
  37473. keysHeightOffsetDecr: number[];
  37474. /**
  37475. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37476. */
  37477. keysHeightOffsetModifierAlt: boolean;
  37478. /**
  37479. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37480. */
  37481. keysHeightOffsetModifierCtrl: boolean;
  37482. /**
  37483. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37484. */
  37485. keysHeightOffsetModifierShift: boolean;
  37486. /**
  37487. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37488. */
  37489. keysRotationOffsetIncr: number[];
  37490. /**
  37491. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37492. */
  37493. keysRotationOffsetDecr: number[];
  37494. /**
  37495. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37496. */
  37497. keysRotationOffsetModifierAlt: boolean;
  37498. /**
  37499. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37500. */
  37501. keysRotationOffsetModifierCtrl: boolean;
  37502. /**
  37503. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37504. */
  37505. keysRotationOffsetModifierShift: boolean;
  37506. /**
  37507. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37508. */
  37509. keysRadiusIncr: number[];
  37510. /**
  37511. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37512. */
  37513. keysRadiusDecr: number[];
  37514. /**
  37515. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37516. */
  37517. keysRadiusModifierAlt: boolean;
  37518. /**
  37519. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37520. */
  37521. keysRadiusModifierCtrl: boolean;
  37522. /**
  37523. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37524. */
  37525. keysRadiusModifierShift: boolean;
  37526. /**
  37527. * Defines the rate of change of heightOffset.
  37528. */
  37529. heightSensibility: number;
  37530. /**
  37531. * Defines the rate of change of rotationOffset.
  37532. */
  37533. rotationSensibility: number;
  37534. /**
  37535. * Defines the rate of change of radius.
  37536. */
  37537. radiusSensibility: number;
  37538. private _keys;
  37539. private _ctrlPressed;
  37540. private _altPressed;
  37541. private _shiftPressed;
  37542. private _onCanvasBlurObserver;
  37543. private _onKeyboardObserver;
  37544. private _engine;
  37545. private _scene;
  37546. /**
  37547. * Attach the input controls to a specific dom element to get the input from.
  37548. * @param element Defines the element the controls should be listened from
  37549. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37550. */
  37551. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37552. /**
  37553. * Detach the current controls from the specified dom element.
  37554. * @param element Defines the element to stop listening the inputs from
  37555. */
  37556. detachControl(element: Nullable<HTMLElement>): void;
  37557. /**
  37558. * Update the current camera state depending on the inputs that have been used this frame.
  37559. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37560. */
  37561. checkInputs(): void;
  37562. /**
  37563. * Gets the class name of the current input.
  37564. * @returns the class name
  37565. */
  37566. getClassName(): string;
  37567. /**
  37568. * Get the friendly name associated with the input class.
  37569. * @returns the input friendly name
  37570. */
  37571. getSimpleName(): string;
  37572. /**
  37573. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37574. * allow modification of the heightOffset value.
  37575. */
  37576. private _modifierHeightOffset;
  37577. /**
  37578. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37579. * allow modification of the rotationOffset value.
  37580. */
  37581. private _modifierRotationOffset;
  37582. /**
  37583. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37584. * allow modification of the radius value.
  37585. */
  37586. private _modifierRadius;
  37587. }
  37588. }
  37589. declare module BABYLON {
  37590. interface FreeCameraInputsManager {
  37591. /**
  37592. * @hidden
  37593. */
  37594. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  37595. /**
  37596. * Add orientation input support to the input manager.
  37597. * @returns the current input manager
  37598. */
  37599. addDeviceOrientation(): FreeCameraInputsManager;
  37600. }
  37601. /**
  37602. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37603. * Screen rotation is taken into account.
  37604. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37605. */
  37606. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37607. private _camera;
  37608. private _screenOrientationAngle;
  37609. private _constantTranform;
  37610. private _screenQuaternion;
  37611. private _alpha;
  37612. private _beta;
  37613. private _gamma;
  37614. /**
  37615. * Can be used to detect if a device orientation sensor is availible on a device
  37616. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  37617. * @returns a promise that will resolve on orientation change
  37618. */
  37619. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  37620. /**
  37621. * @hidden
  37622. */
  37623. _onDeviceOrientationChangedObservable: Observable<void>;
  37624. /**
  37625. * Instantiates a new input
  37626. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37627. */
  37628. constructor();
  37629. /**
  37630. * Define the camera controlled by the input.
  37631. */
  37632. camera: FreeCamera;
  37633. /**
  37634. * Attach the input controls to a specific dom element to get the input from.
  37635. * @param element Defines the element the controls should be listened from
  37636. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37637. */
  37638. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37639. private _orientationChanged;
  37640. private _deviceOrientation;
  37641. /**
  37642. * Detach the current controls from the specified dom element.
  37643. * @param element Defines the element to stop listening the inputs from
  37644. */
  37645. detachControl(element: Nullable<HTMLElement>): void;
  37646. /**
  37647. * Update the current camera state depending on the inputs that have been used this frame.
  37648. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37649. */
  37650. checkInputs(): void;
  37651. /**
  37652. * Gets the class name of the current intput.
  37653. * @returns the class name
  37654. */
  37655. getClassName(): string;
  37656. /**
  37657. * Get the friendly name associated with the input class.
  37658. * @returns the input friendly name
  37659. */
  37660. getSimpleName(): string;
  37661. }
  37662. }
  37663. declare module BABYLON {
  37664. /**
  37665. * Manage the gamepad inputs to control a free camera.
  37666. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37667. */
  37668. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37669. /**
  37670. * Define the camera the input is attached to.
  37671. */
  37672. camera: FreeCamera;
  37673. /**
  37674. * Define the Gamepad controlling the input
  37675. */
  37676. gamepad: Nullable<Gamepad>;
  37677. /**
  37678. * Defines the gamepad rotation sensiblity.
  37679. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37680. */
  37681. gamepadAngularSensibility: number;
  37682. /**
  37683. * Defines the gamepad move sensiblity.
  37684. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37685. */
  37686. gamepadMoveSensibility: number;
  37687. private _onGamepadConnectedObserver;
  37688. private _onGamepadDisconnectedObserver;
  37689. private _cameraTransform;
  37690. private _deltaTransform;
  37691. private _vector3;
  37692. private _vector2;
  37693. /**
  37694. * Attach the input controls to a specific dom element to get the input from.
  37695. * @param element Defines the element the controls should be listened from
  37696. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37697. */
  37698. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37699. /**
  37700. * Detach the current controls from the specified dom element.
  37701. * @param element Defines the element to stop listening the inputs from
  37702. */
  37703. detachControl(element: Nullable<HTMLElement>): void;
  37704. /**
  37705. * Update the current camera state depending on the inputs that have been used this frame.
  37706. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37707. */
  37708. checkInputs(): void;
  37709. /**
  37710. * Gets the class name of the current intput.
  37711. * @returns the class name
  37712. */
  37713. getClassName(): string;
  37714. /**
  37715. * Get the friendly name associated with the input class.
  37716. * @returns the input friendly name
  37717. */
  37718. getSimpleName(): string;
  37719. }
  37720. }
  37721. declare module BABYLON {
  37722. /**
  37723. * Defines the potential axis of a Joystick
  37724. */
  37725. export enum JoystickAxis {
  37726. /** X axis */
  37727. X = 0,
  37728. /** Y axis */
  37729. Y = 1,
  37730. /** Z axis */
  37731. Z = 2
  37732. }
  37733. /**
  37734. * Class used to define virtual joystick (used in touch mode)
  37735. */
  37736. export class VirtualJoystick {
  37737. /**
  37738. * Gets or sets a boolean indicating that left and right values must be inverted
  37739. */
  37740. reverseLeftRight: boolean;
  37741. /**
  37742. * Gets or sets a boolean indicating that up and down values must be inverted
  37743. */
  37744. reverseUpDown: boolean;
  37745. /**
  37746. * Gets the offset value for the position (ie. the change of the position value)
  37747. */
  37748. deltaPosition: Vector3;
  37749. /**
  37750. * Gets a boolean indicating if the virtual joystick was pressed
  37751. */
  37752. pressed: boolean;
  37753. /**
  37754. * Canvas the virtual joystick will render onto, default z-index of this is 5
  37755. */
  37756. static Canvas: Nullable<HTMLCanvasElement>;
  37757. private static _globalJoystickIndex;
  37758. private static vjCanvasContext;
  37759. private static vjCanvasWidth;
  37760. private static vjCanvasHeight;
  37761. private static halfWidth;
  37762. private _action;
  37763. private _axisTargetedByLeftAndRight;
  37764. private _axisTargetedByUpAndDown;
  37765. private _joystickSensibility;
  37766. private _inversedSensibility;
  37767. private _joystickPointerID;
  37768. private _joystickColor;
  37769. private _joystickPointerPos;
  37770. private _joystickPreviousPointerPos;
  37771. private _joystickPointerStartPos;
  37772. private _deltaJoystickVector;
  37773. private _leftJoystick;
  37774. private _touches;
  37775. private _onPointerDownHandlerRef;
  37776. private _onPointerMoveHandlerRef;
  37777. private _onPointerUpHandlerRef;
  37778. private _onResize;
  37779. /**
  37780. * Creates a new virtual joystick
  37781. * @param leftJoystick defines that the joystick is for left hand (false by default)
  37782. */
  37783. constructor(leftJoystick?: boolean);
  37784. /**
  37785. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  37786. * @param newJoystickSensibility defines the new sensibility
  37787. */
  37788. setJoystickSensibility(newJoystickSensibility: number): void;
  37789. private _onPointerDown;
  37790. private _onPointerMove;
  37791. private _onPointerUp;
  37792. /**
  37793. * Change the color of the virtual joystick
  37794. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  37795. */
  37796. setJoystickColor(newColor: string): void;
  37797. /**
  37798. * Defines a callback to call when the joystick is touched
  37799. * @param action defines the callback
  37800. */
  37801. setActionOnTouch(action: () => any): void;
  37802. /**
  37803. * Defines which axis you'd like to control for left & right
  37804. * @param axis defines the axis to use
  37805. */
  37806. setAxisForLeftRight(axis: JoystickAxis): void;
  37807. /**
  37808. * Defines which axis you'd like to control for up & down
  37809. * @param axis defines the axis to use
  37810. */
  37811. setAxisForUpDown(axis: JoystickAxis): void;
  37812. private _drawVirtualJoystick;
  37813. /**
  37814. * Release internal HTML canvas
  37815. */
  37816. releaseCanvas(): void;
  37817. }
  37818. }
  37819. declare module BABYLON {
  37820. interface FreeCameraInputsManager {
  37821. /**
  37822. * Add virtual joystick input support to the input manager.
  37823. * @returns the current input manager
  37824. */
  37825. addVirtualJoystick(): FreeCameraInputsManager;
  37826. }
  37827. /**
  37828. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  37829. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37830. */
  37831. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  37832. /**
  37833. * Defines the camera the input is attached to.
  37834. */
  37835. camera: FreeCamera;
  37836. private _leftjoystick;
  37837. private _rightjoystick;
  37838. /**
  37839. * Gets the left stick of the virtual joystick.
  37840. * @returns The virtual Joystick
  37841. */
  37842. getLeftJoystick(): VirtualJoystick;
  37843. /**
  37844. * Gets the right stick of the virtual joystick.
  37845. * @returns The virtual Joystick
  37846. */
  37847. getRightJoystick(): VirtualJoystick;
  37848. /**
  37849. * Update the current camera state depending on the inputs that have been used this frame.
  37850. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37851. */
  37852. checkInputs(): void;
  37853. /**
  37854. * Attach the input controls to a specific dom element to get the input from.
  37855. * @param element Defines the element the controls should be listened from
  37856. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37857. */
  37858. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37859. /**
  37860. * Detach the current controls from the specified dom element.
  37861. * @param element Defines the element to stop listening the inputs from
  37862. */
  37863. detachControl(element: Nullable<HTMLElement>): void;
  37864. /**
  37865. * Gets the class name of the current intput.
  37866. * @returns the class name
  37867. */
  37868. getClassName(): string;
  37869. /**
  37870. * Get the friendly name associated with the input class.
  37871. * @returns the input friendly name
  37872. */
  37873. getSimpleName(): string;
  37874. }
  37875. }
  37876. declare module BABYLON {
  37877. /**
  37878. * This represents a FPS type of camera controlled by touch.
  37879. * This is like a universal camera minus the Gamepad controls.
  37880. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37881. */
  37882. export class TouchCamera extends FreeCamera {
  37883. /**
  37884. * Defines the touch sensibility for rotation.
  37885. * The higher the faster.
  37886. */
  37887. touchAngularSensibility: number;
  37888. /**
  37889. * Defines the touch sensibility for move.
  37890. * The higher the faster.
  37891. */
  37892. touchMoveSensibility: number;
  37893. /**
  37894. * Instantiates a new touch camera.
  37895. * This represents a FPS type of camera controlled by touch.
  37896. * This is like a universal camera minus the Gamepad controls.
  37897. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37898. * @param name Define the name of the camera in the scene
  37899. * @param position Define the start position of the camera in the scene
  37900. * @param scene Define the scene the camera belongs to
  37901. */
  37902. constructor(name: string, position: Vector3, scene: Scene);
  37903. /**
  37904. * Gets the current object class name.
  37905. * @return the class name
  37906. */
  37907. getClassName(): string;
  37908. /** @hidden */
  37909. _setupInputs(): void;
  37910. }
  37911. }
  37912. declare module BABYLON {
  37913. /**
  37914. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  37915. * being tilted forward or back and left or right.
  37916. */
  37917. export class DeviceOrientationCamera extends FreeCamera {
  37918. private _initialQuaternion;
  37919. private _quaternionCache;
  37920. private _tmpDragQuaternion;
  37921. /**
  37922. * Creates a new device orientation camera
  37923. * @param name The name of the camera
  37924. * @param position The start position camera
  37925. * @param scene The scene the camera belongs to
  37926. */
  37927. constructor(name: string, position: Vector3, scene: Scene);
  37928. /**
  37929. * @hidden
  37930. * Disabled pointer input on first orientation sensor update (Default: true)
  37931. */
  37932. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  37933. private _dragFactor;
  37934. /**
  37935. * Enabled turning on the y axis when the orientation sensor is active
  37936. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  37937. */
  37938. enableHorizontalDragging(dragFactor?: number): void;
  37939. /**
  37940. * Gets the current instance class name ("DeviceOrientationCamera").
  37941. * This helps avoiding instanceof at run time.
  37942. * @returns the class name
  37943. */
  37944. getClassName(): string;
  37945. /**
  37946. * @hidden
  37947. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  37948. */
  37949. _checkInputs(): void;
  37950. /**
  37951. * Reset the camera to its default orientation on the specified axis only.
  37952. * @param axis The axis to reset
  37953. */
  37954. resetToCurrentRotation(axis?: Axis): void;
  37955. }
  37956. }
  37957. declare module BABYLON {
  37958. /**
  37959. * Defines supported buttons for XBox360 compatible gamepads
  37960. */
  37961. export enum Xbox360Button {
  37962. /** A */
  37963. A = 0,
  37964. /** B */
  37965. B = 1,
  37966. /** X */
  37967. X = 2,
  37968. /** Y */
  37969. Y = 3,
  37970. /** Start */
  37971. Start = 4,
  37972. /** Back */
  37973. Back = 5,
  37974. /** Left button */
  37975. LB = 6,
  37976. /** Right button */
  37977. RB = 7,
  37978. /** Left stick */
  37979. LeftStick = 8,
  37980. /** Right stick */
  37981. RightStick = 9
  37982. }
  37983. /** Defines values for XBox360 DPad */
  37984. export enum Xbox360Dpad {
  37985. /** Up */
  37986. Up = 0,
  37987. /** Down */
  37988. Down = 1,
  37989. /** Left */
  37990. Left = 2,
  37991. /** Right */
  37992. Right = 3
  37993. }
  37994. /**
  37995. * Defines a XBox360 gamepad
  37996. */
  37997. export class Xbox360Pad extends Gamepad {
  37998. private _leftTrigger;
  37999. private _rightTrigger;
  38000. private _onlefttriggerchanged;
  38001. private _onrighttriggerchanged;
  38002. private _onbuttondown;
  38003. private _onbuttonup;
  38004. private _ondpaddown;
  38005. private _ondpadup;
  38006. /** Observable raised when a button is pressed */
  38007. onButtonDownObservable: Observable<Xbox360Button>;
  38008. /** Observable raised when a button is released */
  38009. onButtonUpObservable: Observable<Xbox360Button>;
  38010. /** Observable raised when a pad is pressed */
  38011. onPadDownObservable: Observable<Xbox360Dpad>;
  38012. /** Observable raised when a pad is released */
  38013. onPadUpObservable: Observable<Xbox360Dpad>;
  38014. private _buttonA;
  38015. private _buttonB;
  38016. private _buttonX;
  38017. private _buttonY;
  38018. private _buttonBack;
  38019. private _buttonStart;
  38020. private _buttonLB;
  38021. private _buttonRB;
  38022. private _buttonLeftStick;
  38023. private _buttonRightStick;
  38024. private _dPadUp;
  38025. private _dPadDown;
  38026. private _dPadLeft;
  38027. private _dPadRight;
  38028. private _isXboxOnePad;
  38029. /**
  38030. * Creates a new XBox360 gamepad object
  38031. * @param id defines the id of this gamepad
  38032. * @param index defines its index
  38033. * @param gamepad defines the internal HTML gamepad object
  38034. * @param xboxOne defines if it is a XBox One gamepad
  38035. */
  38036. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38037. /**
  38038. * Defines the callback to call when left trigger is pressed
  38039. * @param callback defines the callback to use
  38040. */
  38041. onlefttriggerchanged(callback: (value: number) => void): void;
  38042. /**
  38043. * Defines the callback to call when right trigger is pressed
  38044. * @param callback defines the callback to use
  38045. */
  38046. onrighttriggerchanged(callback: (value: number) => void): void;
  38047. /**
  38048. * Gets the left trigger value
  38049. */
  38050. /**
  38051. * Sets the left trigger value
  38052. */
  38053. leftTrigger: number;
  38054. /**
  38055. * Gets the right trigger value
  38056. */
  38057. /**
  38058. * Sets the right trigger value
  38059. */
  38060. rightTrigger: number;
  38061. /**
  38062. * Defines the callback to call when a button is pressed
  38063. * @param callback defines the callback to use
  38064. */
  38065. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38066. /**
  38067. * Defines the callback to call when a button is released
  38068. * @param callback defines the callback to use
  38069. */
  38070. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38071. /**
  38072. * Defines the callback to call when a pad is pressed
  38073. * @param callback defines the callback to use
  38074. */
  38075. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38076. /**
  38077. * Defines the callback to call when a pad is released
  38078. * @param callback defines the callback to use
  38079. */
  38080. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38081. private _setButtonValue;
  38082. private _setDPadValue;
  38083. /**
  38084. * Gets the value of the `A` button
  38085. */
  38086. /**
  38087. * Sets the value of the `A` button
  38088. */
  38089. buttonA: number;
  38090. /**
  38091. * Gets the value of the `B` button
  38092. */
  38093. /**
  38094. * Sets the value of the `B` button
  38095. */
  38096. buttonB: number;
  38097. /**
  38098. * Gets the value of the `X` button
  38099. */
  38100. /**
  38101. * Sets the value of the `X` button
  38102. */
  38103. buttonX: number;
  38104. /**
  38105. * Gets the value of the `Y` button
  38106. */
  38107. /**
  38108. * Sets the value of the `Y` button
  38109. */
  38110. buttonY: number;
  38111. /**
  38112. * Gets the value of the `Start` button
  38113. */
  38114. /**
  38115. * Sets the value of the `Start` button
  38116. */
  38117. buttonStart: number;
  38118. /**
  38119. * Gets the value of the `Back` button
  38120. */
  38121. /**
  38122. * Sets the value of the `Back` button
  38123. */
  38124. buttonBack: number;
  38125. /**
  38126. * Gets the value of the `Left` button
  38127. */
  38128. /**
  38129. * Sets the value of the `Left` button
  38130. */
  38131. buttonLB: number;
  38132. /**
  38133. * Gets the value of the `Right` button
  38134. */
  38135. /**
  38136. * Sets the value of the `Right` button
  38137. */
  38138. buttonRB: number;
  38139. /**
  38140. * Gets the value of the Left joystick
  38141. */
  38142. /**
  38143. * Sets the value of the Left joystick
  38144. */
  38145. buttonLeftStick: number;
  38146. /**
  38147. * Gets the value of the Right joystick
  38148. */
  38149. /**
  38150. * Sets the value of the Right joystick
  38151. */
  38152. buttonRightStick: number;
  38153. /**
  38154. * Gets the value of D-pad up
  38155. */
  38156. /**
  38157. * Sets the value of D-pad up
  38158. */
  38159. dPadUp: number;
  38160. /**
  38161. * Gets the value of D-pad down
  38162. */
  38163. /**
  38164. * Sets the value of D-pad down
  38165. */
  38166. dPadDown: number;
  38167. /**
  38168. * Gets the value of D-pad left
  38169. */
  38170. /**
  38171. * Sets the value of D-pad left
  38172. */
  38173. dPadLeft: number;
  38174. /**
  38175. * Gets the value of D-pad right
  38176. */
  38177. /**
  38178. * Sets the value of D-pad right
  38179. */
  38180. dPadRight: number;
  38181. /**
  38182. * Force the gamepad to synchronize with device values
  38183. */
  38184. update(): void;
  38185. /**
  38186. * Disposes the gamepad
  38187. */
  38188. dispose(): void;
  38189. }
  38190. }
  38191. declare module BABYLON {
  38192. /**
  38193. * Manager for handling gamepads
  38194. */
  38195. export class GamepadManager {
  38196. private _scene?;
  38197. private _babylonGamepads;
  38198. private _oneGamepadConnected;
  38199. /** @hidden */
  38200. _isMonitoring: boolean;
  38201. private _gamepadEventSupported;
  38202. private _gamepadSupport;
  38203. /**
  38204. * observable to be triggered when the gamepad controller has been connected
  38205. */
  38206. onGamepadConnectedObservable: Observable<Gamepad>;
  38207. /**
  38208. * observable to be triggered when the gamepad controller has been disconnected
  38209. */
  38210. onGamepadDisconnectedObservable: Observable<Gamepad>;
  38211. private _onGamepadConnectedEvent;
  38212. private _onGamepadDisconnectedEvent;
  38213. /**
  38214. * Initializes the gamepad manager
  38215. * @param _scene BabylonJS scene
  38216. */
  38217. constructor(_scene?: Scene | undefined);
  38218. /**
  38219. * The gamepads in the game pad manager
  38220. */
  38221. readonly gamepads: Gamepad[];
  38222. /**
  38223. * Get the gamepad controllers based on type
  38224. * @param type The type of gamepad controller
  38225. * @returns Nullable gamepad
  38226. */
  38227. getGamepadByType(type?: number): Nullable<Gamepad>;
  38228. /**
  38229. * Disposes the gamepad manager
  38230. */
  38231. dispose(): void;
  38232. private _addNewGamepad;
  38233. private _startMonitoringGamepads;
  38234. private _stopMonitoringGamepads;
  38235. /** @hidden */
  38236. _checkGamepadsStatus(): void;
  38237. private _updateGamepadObjects;
  38238. }
  38239. }
  38240. declare module BABYLON {
  38241. interface Scene {
  38242. /** @hidden */
  38243. _gamepadManager: Nullable<GamepadManager>;
  38244. /**
  38245. * Gets the gamepad manager associated with the scene
  38246. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  38247. */
  38248. gamepadManager: GamepadManager;
  38249. }
  38250. /**
  38251. * Interface representing a free camera inputs manager
  38252. */
  38253. interface FreeCameraInputsManager {
  38254. /**
  38255. * Adds gamepad input support to the FreeCameraInputsManager.
  38256. * @returns the FreeCameraInputsManager
  38257. */
  38258. addGamepad(): FreeCameraInputsManager;
  38259. }
  38260. /**
  38261. * Interface representing an arc rotate camera inputs manager
  38262. */
  38263. interface ArcRotateCameraInputsManager {
  38264. /**
  38265. * Adds gamepad input support to the ArcRotateCamera InputManager.
  38266. * @returns the camera inputs manager
  38267. */
  38268. addGamepad(): ArcRotateCameraInputsManager;
  38269. }
  38270. /**
  38271. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  38272. */
  38273. export class GamepadSystemSceneComponent implements ISceneComponent {
  38274. /**
  38275. * The component name helpfull to identify the component in the list of scene components.
  38276. */
  38277. readonly name: string;
  38278. /**
  38279. * The scene the component belongs to.
  38280. */
  38281. scene: Scene;
  38282. /**
  38283. * Creates a new instance of the component for the given scene
  38284. * @param scene Defines the scene to register the component in
  38285. */
  38286. constructor(scene: Scene);
  38287. /**
  38288. * Registers the component in a given scene
  38289. */
  38290. register(): void;
  38291. /**
  38292. * Rebuilds the elements related to this component in case of
  38293. * context lost for instance.
  38294. */
  38295. rebuild(): void;
  38296. /**
  38297. * Disposes the component and the associated ressources
  38298. */
  38299. dispose(): void;
  38300. private _beforeCameraUpdate;
  38301. }
  38302. }
  38303. declare module BABYLON {
  38304. /**
  38305. * 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,
  38306. * which still works and will still be found in many Playgrounds.
  38307. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38308. */
  38309. export class UniversalCamera extends TouchCamera {
  38310. /**
  38311. * Defines the gamepad rotation sensiblity.
  38312. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38313. */
  38314. gamepadAngularSensibility: number;
  38315. /**
  38316. * Defines the gamepad move sensiblity.
  38317. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38318. */
  38319. gamepadMoveSensibility: number;
  38320. /**
  38321. * 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,
  38322. * which still works and will still be found in many Playgrounds.
  38323. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38324. * @param name Define the name of the camera in the scene
  38325. * @param position Define the start position of the camera in the scene
  38326. * @param scene Define the scene the camera belongs to
  38327. */
  38328. constructor(name: string, position: Vector3, scene: Scene);
  38329. /**
  38330. * Gets the current object class name.
  38331. * @return the class name
  38332. */
  38333. getClassName(): string;
  38334. }
  38335. }
  38336. declare module BABYLON {
  38337. /**
  38338. * This represents a FPS type of camera. This is only here for back compat purpose.
  38339. * Please use the UniversalCamera instead as both are identical.
  38340. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38341. */
  38342. export class GamepadCamera extends UniversalCamera {
  38343. /**
  38344. * Instantiates a new Gamepad Camera
  38345. * This represents a FPS type of camera. This is only here for back compat purpose.
  38346. * Please use the UniversalCamera instead as both are identical.
  38347. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38348. * @param name Define the name of the camera in the scene
  38349. * @param position Define the start position of the camera in the scene
  38350. * @param scene Define the scene the camera belongs to
  38351. */
  38352. constructor(name: string, position: Vector3, scene: Scene);
  38353. /**
  38354. * Gets the current object class name.
  38355. * @return the class name
  38356. */
  38357. getClassName(): string;
  38358. }
  38359. }
  38360. declare module BABYLON {
  38361. /** @hidden */
  38362. export var passPixelShader: {
  38363. name: string;
  38364. shader: string;
  38365. };
  38366. }
  38367. declare module BABYLON {
  38368. /** @hidden */
  38369. export var passCubePixelShader: {
  38370. name: string;
  38371. shader: string;
  38372. };
  38373. }
  38374. declare module BABYLON {
  38375. /**
  38376. * PassPostProcess which produces an output the same as it's input
  38377. */
  38378. export class PassPostProcess extends PostProcess {
  38379. /**
  38380. * Creates the PassPostProcess
  38381. * @param name The name of the effect.
  38382. * @param options The required width/height ratio to downsize to before computing the render pass.
  38383. * @param camera The camera to apply the render pass to.
  38384. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38385. * @param engine The engine which the post process will be applied. (default: current engine)
  38386. * @param reusable If the post process can be reused on the same frame. (default: false)
  38387. * @param textureType The type of texture to be used when performing the post processing.
  38388. * @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)
  38389. */
  38390. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38391. }
  38392. /**
  38393. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  38394. */
  38395. export class PassCubePostProcess extends PostProcess {
  38396. private _face;
  38397. /**
  38398. * Gets or sets the cube face to display.
  38399. * * 0 is +X
  38400. * * 1 is -X
  38401. * * 2 is +Y
  38402. * * 3 is -Y
  38403. * * 4 is +Z
  38404. * * 5 is -Z
  38405. */
  38406. face: number;
  38407. /**
  38408. * Creates the PassCubePostProcess
  38409. * @param name The name of the effect.
  38410. * @param options The required width/height ratio to downsize to before computing the render pass.
  38411. * @param camera The camera to apply the render pass to.
  38412. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38413. * @param engine The engine which the post process will be applied. (default: current engine)
  38414. * @param reusable If the post process can be reused on the same frame. (default: false)
  38415. * @param textureType The type of texture to be used when performing the post processing.
  38416. * @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)
  38417. */
  38418. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38419. }
  38420. }
  38421. declare module BABYLON {
  38422. /** @hidden */
  38423. export var anaglyphPixelShader: {
  38424. name: string;
  38425. shader: string;
  38426. };
  38427. }
  38428. declare module BABYLON {
  38429. /**
  38430. * Postprocess used to generate anaglyphic rendering
  38431. */
  38432. export class AnaglyphPostProcess extends PostProcess {
  38433. private _passedProcess;
  38434. /**
  38435. * Creates a new AnaglyphPostProcess
  38436. * @param name defines postprocess name
  38437. * @param options defines creation options or target ratio scale
  38438. * @param rigCameras defines cameras using this postprocess
  38439. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  38440. * @param engine defines hosting engine
  38441. * @param reusable defines if the postprocess will be reused multiple times per frame
  38442. */
  38443. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  38444. }
  38445. }
  38446. declare module BABYLON {
  38447. /**
  38448. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  38449. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38450. */
  38451. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  38452. /**
  38453. * Creates a new AnaglyphArcRotateCamera
  38454. * @param name defines camera name
  38455. * @param alpha defines alpha angle (in radians)
  38456. * @param beta defines beta angle (in radians)
  38457. * @param radius defines radius
  38458. * @param target defines camera target
  38459. * @param interaxialDistance defines distance between each color axis
  38460. * @param scene defines the hosting scene
  38461. */
  38462. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  38463. /**
  38464. * Gets camera class name
  38465. * @returns AnaglyphArcRotateCamera
  38466. */
  38467. getClassName(): string;
  38468. }
  38469. }
  38470. declare module BABYLON {
  38471. /**
  38472. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  38473. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38474. */
  38475. export class AnaglyphFreeCamera extends FreeCamera {
  38476. /**
  38477. * Creates a new AnaglyphFreeCamera
  38478. * @param name defines camera name
  38479. * @param position defines initial position
  38480. * @param interaxialDistance defines distance between each color axis
  38481. * @param scene defines the hosting scene
  38482. */
  38483. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38484. /**
  38485. * Gets camera class name
  38486. * @returns AnaglyphFreeCamera
  38487. */
  38488. getClassName(): string;
  38489. }
  38490. }
  38491. declare module BABYLON {
  38492. /**
  38493. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  38494. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38495. */
  38496. export class AnaglyphGamepadCamera extends GamepadCamera {
  38497. /**
  38498. * Creates a new AnaglyphGamepadCamera
  38499. * @param name defines camera name
  38500. * @param position defines initial position
  38501. * @param interaxialDistance defines distance between each color axis
  38502. * @param scene defines the hosting scene
  38503. */
  38504. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38505. /**
  38506. * Gets camera class name
  38507. * @returns AnaglyphGamepadCamera
  38508. */
  38509. getClassName(): string;
  38510. }
  38511. }
  38512. declare module BABYLON {
  38513. /**
  38514. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  38515. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38516. */
  38517. export class AnaglyphUniversalCamera extends UniversalCamera {
  38518. /**
  38519. * Creates a new AnaglyphUniversalCamera
  38520. * @param name defines camera name
  38521. * @param position defines initial position
  38522. * @param interaxialDistance defines distance between each color axis
  38523. * @param scene defines the hosting scene
  38524. */
  38525. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38526. /**
  38527. * Gets camera class name
  38528. * @returns AnaglyphUniversalCamera
  38529. */
  38530. getClassName(): string;
  38531. }
  38532. }
  38533. declare module BABYLON {
  38534. /** @hidden */
  38535. export var stereoscopicInterlacePixelShader: {
  38536. name: string;
  38537. shader: string;
  38538. };
  38539. }
  38540. declare module BABYLON {
  38541. /**
  38542. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  38543. */
  38544. export class StereoscopicInterlacePostProcess extends PostProcess {
  38545. private _stepSize;
  38546. private _passedProcess;
  38547. /**
  38548. * Initializes a StereoscopicInterlacePostProcess
  38549. * @param name The name of the effect.
  38550. * @param rigCameras The rig cameras to be appled to the post process
  38551. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  38552. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38553. * @param engine The engine which the post process will be applied. (default: current engine)
  38554. * @param reusable If the post process can be reused on the same frame. (default: false)
  38555. */
  38556. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  38557. }
  38558. }
  38559. declare module BABYLON {
  38560. /**
  38561. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  38562. * @see http://doc.babylonjs.com/features/cameras
  38563. */
  38564. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  38565. /**
  38566. * Creates a new StereoscopicArcRotateCamera
  38567. * @param name defines camera name
  38568. * @param alpha defines alpha angle (in radians)
  38569. * @param beta defines beta angle (in radians)
  38570. * @param radius defines radius
  38571. * @param target defines camera target
  38572. * @param interaxialDistance defines distance between each color axis
  38573. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38574. * @param scene defines the hosting scene
  38575. */
  38576. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38577. /**
  38578. * Gets camera class name
  38579. * @returns StereoscopicArcRotateCamera
  38580. */
  38581. getClassName(): string;
  38582. }
  38583. }
  38584. declare module BABYLON {
  38585. /**
  38586. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  38587. * @see http://doc.babylonjs.com/features/cameras
  38588. */
  38589. export class StereoscopicFreeCamera extends FreeCamera {
  38590. /**
  38591. * Creates a new StereoscopicFreeCamera
  38592. * @param name defines camera name
  38593. * @param position defines initial position
  38594. * @param interaxialDistance defines distance between each color axis
  38595. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38596. * @param scene defines the hosting scene
  38597. */
  38598. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38599. /**
  38600. * Gets camera class name
  38601. * @returns StereoscopicFreeCamera
  38602. */
  38603. getClassName(): string;
  38604. }
  38605. }
  38606. declare module BABYLON {
  38607. /**
  38608. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  38609. * @see http://doc.babylonjs.com/features/cameras
  38610. */
  38611. export class StereoscopicGamepadCamera extends GamepadCamera {
  38612. /**
  38613. * Creates a new StereoscopicGamepadCamera
  38614. * @param name defines camera name
  38615. * @param position defines initial position
  38616. * @param interaxialDistance defines distance between each color axis
  38617. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38618. * @param scene defines the hosting scene
  38619. */
  38620. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38621. /**
  38622. * Gets camera class name
  38623. * @returns StereoscopicGamepadCamera
  38624. */
  38625. getClassName(): string;
  38626. }
  38627. }
  38628. declare module BABYLON {
  38629. /**
  38630. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  38631. * @see http://doc.babylonjs.com/features/cameras
  38632. */
  38633. export class StereoscopicUniversalCamera extends UniversalCamera {
  38634. /**
  38635. * Creates a new StereoscopicUniversalCamera
  38636. * @param name defines camera name
  38637. * @param position defines initial position
  38638. * @param interaxialDistance defines distance between each color axis
  38639. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38640. * @param scene defines the hosting scene
  38641. */
  38642. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38643. /**
  38644. * Gets camera class name
  38645. * @returns StereoscopicUniversalCamera
  38646. */
  38647. getClassName(): string;
  38648. }
  38649. }
  38650. declare module BABYLON {
  38651. /**
  38652. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38653. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38654. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38655. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38656. */
  38657. export class VirtualJoysticksCamera extends FreeCamera {
  38658. /**
  38659. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38660. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38661. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38662. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38663. * @param name Define the name of the camera in the scene
  38664. * @param position Define the start position of the camera in the scene
  38665. * @param scene Define the scene the camera belongs to
  38666. */
  38667. constructor(name: string, position: Vector3, scene: Scene);
  38668. /**
  38669. * Gets the current object class name.
  38670. * @return the class name
  38671. */
  38672. getClassName(): string;
  38673. }
  38674. }
  38675. declare module BABYLON {
  38676. /**
  38677. * This represents all the required metrics to create a VR camera.
  38678. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  38679. */
  38680. export class VRCameraMetrics {
  38681. /**
  38682. * Define the horizontal resolution off the screen.
  38683. */
  38684. hResolution: number;
  38685. /**
  38686. * Define the vertical resolution off the screen.
  38687. */
  38688. vResolution: number;
  38689. /**
  38690. * Define the horizontal screen size.
  38691. */
  38692. hScreenSize: number;
  38693. /**
  38694. * Define the vertical screen size.
  38695. */
  38696. vScreenSize: number;
  38697. /**
  38698. * Define the vertical screen center position.
  38699. */
  38700. vScreenCenter: number;
  38701. /**
  38702. * Define the distance of the eyes to the screen.
  38703. */
  38704. eyeToScreenDistance: number;
  38705. /**
  38706. * Define the distance between both lenses
  38707. */
  38708. lensSeparationDistance: number;
  38709. /**
  38710. * Define the distance between both viewer's eyes.
  38711. */
  38712. interpupillaryDistance: number;
  38713. /**
  38714. * Define the distortion factor of the VR postprocess.
  38715. * Please, touch with care.
  38716. */
  38717. distortionK: number[];
  38718. /**
  38719. * Define the chromatic aberration correction factors for the VR post process.
  38720. */
  38721. chromaAbCorrection: number[];
  38722. /**
  38723. * Define the scale factor of the post process.
  38724. * The smaller the better but the slower.
  38725. */
  38726. postProcessScaleFactor: number;
  38727. /**
  38728. * Define an offset for the lens center.
  38729. */
  38730. lensCenterOffset: number;
  38731. /**
  38732. * Define if the current vr camera should compensate the distortion of the lense or not.
  38733. */
  38734. compensateDistortion: boolean;
  38735. /**
  38736. * Defines if multiview should be enabled when rendering (Default: false)
  38737. */
  38738. multiviewEnabled: boolean;
  38739. /**
  38740. * Gets the rendering aspect ratio based on the provided resolutions.
  38741. */
  38742. readonly aspectRatio: number;
  38743. /**
  38744. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  38745. */
  38746. readonly aspectRatioFov: number;
  38747. /**
  38748. * @hidden
  38749. */
  38750. readonly leftHMatrix: Matrix;
  38751. /**
  38752. * @hidden
  38753. */
  38754. readonly rightHMatrix: Matrix;
  38755. /**
  38756. * @hidden
  38757. */
  38758. readonly leftPreViewMatrix: Matrix;
  38759. /**
  38760. * @hidden
  38761. */
  38762. readonly rightPreViewMatrix: Matrix;
  38763. /**
  38764. * Get the default VRMetrics based on the most generic setup.
  38765. * @returns the default vr metrics
  38766. */
  38767. static GetDefault(): VRCameraMetrics;
  38768. }
  38769. }
  38770. declare module BABYLON {
  38771. /** @hidden */
  38772. export var vrDistortionCorrectionPixelShader: {
  38773. name: string;
  38774. shader: string;
  38775. };
  38776. }
  38777. declare module BABYLON {
  38778. /**
  38779. * VRDistortionCorrectionPostProcess used for mobile VR
  38780. */
  38781. export class VRDistortionCorrectionPostProcess extends PostProcess {
  38782. private _isRightEye;
  38783. private _distortionFactors;
  38784. private _postProcessScaleFactor;
  38785. private _lensCenterOffset;
  38786. private _scaleIn;
  38787. private _scaleFactor;
  38788. private _lensCenter;
  38789. /**
  38790. * Initializes the VRDistortionCorrectionPostProcess
  38791. * @param name The name of the effect.
  38792. * @param camera The camera to apply the render pass to.
  38793. * @param isRightEye If this is for the right eye distortion
  38794. * @param vrMetrics All the required metrics for the VR camera
  38795. */
  38796. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  38797. }
  38798. }
  38799. declare module BABYLON {
  38800. /**
  38801. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  38802. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38803. */
  38804. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  38805. /**
  38806. * Creates a new VRDeviceOrientationArcRotateCamera
  38807. * @param name defines camera name
  38808. * @param alpha defines the camera rotation along the logitudinal axis
  38809. * @param beta defines the camera rotation along the latitudinal axis
  38810. * @param radius defines the camera distance from its target
  38811. * @param target defines the camera target
  38812. * @param scene defines the scene the camera belongs to
  38813. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38814. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38815. */
  38816. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38817. /**
  38818. * Gets camera class name
  38819. * @returns VRDeviceOrientationArcRotateCamera
  38820. */
  38821. getClassName(): string;
  38822. }
  38823. }
  38824. declare module BABYLON {
  38825. /**
  38826. * Camera used to simulate VR rendering (based on FreeCamera)
  38827. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38828. */
  38829. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  38830. /**
  38831. * Creates a new VRDeviceOrientationFreeCamera
  38832. * @param name defines camera name
  38833. * @param position defines the start position of the camera
  38834. * @param scene defines the scene the camera belongs to
  38835. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38836. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38837. */
  38838. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38839. /**
  38840. * Gets camera class name
  38841. * @returns VRDeviceOrientationFreeCamera
  38842. */
  38843. getClassName(): string;
  38844. }
  38845. }
  38846. declare module BABYLON {
  38847. /**
  38848. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  38849. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38850. */
  38851. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  38852. /**
  38853. * Creates a new VRDeviceOrientationGamepadCamera
  38854. * @param name defines camera name
  38855. * @param position defines the start position of the camera
  38856. * @param scene defines the scene the camera belongs to
  38857. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38858. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38859. */
  38860. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38861. /**
  38862. * Gets camera class name
  38863. * @returns VRDeviceOrientationGamepadCamera
  38864. */
  38865. getClassName(): string;
  38866. }
  38867. }
  38868. declare module BABYLON {
  38869. /**
  38870. * Base class of materials working in push mode in babylon JS
  38871. * @hidden
  38872. */
  38873. export class PushMaterial extends Material {
  38874. protected _activeEffect: Effect;
  38875. protected _normalMatrix: Matrix;
  38876. /**
  38877. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  38878. * This means that the material can keep using a previous shader while a new one is being compiled.
  38879. * This is mostly used when shader parallel compilation is supported (true by default)
  38880. */
  38881. allowShaderHotSwapping: boolean;
  38882. constructor(name: string, scene: Scene);
  38883. getEffect(): Effect;
  38884. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  38885. /**
  38886. * Binds the given world matrix to the active effect
  38887. *
  38888. * @param world the matrix to bind
  38889. */
  38890. bindOnlyWorldMatrix(world: Matrix): void;
  38891. /**
  38892. * Binds the given normal matrix to the active effect
  38893. *
  38894. * @param normalMatrix the matrix to bind
  38895. */
  38896. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  38897. bind(world: Matrix, mesh?: Mesh): void;
  38898. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  38899. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  38900. }
  38901. }
  38902. declare module BABYLON {
  38903. /**
  38904. * This groups all the flags used to control the materials channel.
  38905. */
  38906. export class MaterialFlags {
  38907. private static _DiffuseTextureEnabled;
  38908. /**
  38909. * Are diffuse textures enabled in the application.
  38910. */
  38911. static DiffuseTextureEnabled: boolean;
  38912. private static _AmbientTextureEnabled;
  38913. /**
  38914. * Are ambient textures enabled in the application.
  38915. */
  38916. static AmbientTextureEnabled: boolean;
  38917. private static _OpacityTextureEnabled;
  38918. /**
  38919. * Are opacity textures enabled in the application.
  38920. */
  38921. static OpacityTextureEnabled: boolean;
  38922. private static _ReflectionTextureEnabled;
  38923. /**
  38924. * Are reflection textures enabled in the application.
  38925. */
  38926. static ReflectionTextureEnabled: boolean;
  38927. private static _EmissiveTextureEnabled;
  38928. /**
  38929. * Are emissive textures enabled in the application.
  38930. */
  38931. static EmissiveTextureEnabled: boolean;
  38932. private static _SpecularTextureEnabled;
  38933. /**
  38934. * Are specular textures enabled in the application.
  38935. */
  38936. static SpecularTextureEnabled: boolean;
  38937. private static _BumpTextureEnabled;
  38938. /**
  38939. * Are bump textures enabled in the application.
  38940. */
  38941. static BumpTextureEnabled: boolean;
  38942. private static _LightmapTextureEnabled;
  38943. /**
  38944. * Are lightmap textures enabled in the application.
  38945. */
  38946. static LightmapTextureEnabled: boolean;
  38947. private static _RefractionTextureEnabled;
  38948. /**
  38949. * Are refraction textures enabled in the application.
  38950. */
  38951. static RefractionTextureEnabled: boolean;
  38952. private static _ColorGradingTextureEnabled;
  38953. /**
  38954. * Are color grading textures enabled in the application.
  38955. */
  38956. static ColorGradingTextureEnabled: boolean;
  38957. private static _FresnelEnabled;
  38958. /**
  38959. * Are fresnels enabled in the application.
  38960. */
  38961. static FresnelEnabled: boolean;
  38962. private static _ClearCoatTextureEnabled;
  38963. /**
  38964. * Are clear coat textures enabled in the application.
  38965. */
  38966. static ClearCoatTextureEnabled: boolean;
  38967. private static _ClearCoatBumpTextureEnabled;
  38968. /**
  38969. * Are clear coat bump textures enabled in the application.
  38970. */
  38971. static ClearCoatBumpTextureEnabled: boolean;
  38972. private static _ClearCoatTintTextureEnabled;
  38973. /**
  38974. * Are clear coat tint textures enabled in the application.
  38975. */
  38976. static ClearCoatTintTextureEnabled: boolean;
  38977. private static _SheenTextureEnabled;
  38978. /**
  38979. * Are sheen textures enabled in the application.
  38980. */
  38981. static SheenTextureEnabled: boolean;
  38982. private static _AnisotropicTextureEnabled;
  38983. /**
  38984. * Are anisotropic textures enabled in the application.
  38985. */
  38986. static AnisotropicTextureEnabled: boolean;
  38987. private static _ThicknessTextureEnabled;
  38988. /**
  38989. * Are thickness textures enabled in the application.
  38990. */
  38991. static ThicknessTextureEnabled: boolean;
  38992. }
  38993. }
  38994. declare module BABYLON {
  38995. /** @hidden */
  38996. export var defaultFragmentDeclaration: {
  38997. name: string;
  38998. shader: string;
  38999. };
  39000. }
  39001. declare module BABYLON {
  39002. /** @hidden */
  39003. export var defaultUboDeclaration: {
  39004. name: string;
  39005. shader: string;
  39006. };
  39007. }
  39008. declare module BABYLON {
  39009. /** @hidden */
  39010. export var lightFragmentDeclaration: {
  39011. name: string;
  39012. shader: string;
  39013. };
  39014. }
  39015. declare module BABYLON {
  39016. /** @hidden */
  39017. export var lightUboDeclaration: {
  39018. name: string;
  39019. shader: string;
  39020. };
  39021. }
  39022. declare module BABYLON {
  39023. /** @hidden */
  39024. export var lightsFragmentFunctions: {
  39025. name: string;
  39026. shader: string;
  39027. };
  39028. }
  39029. declare module BABYLON {
  39030. /** @hidden */
  39031. export var shadowsFragmentFunctions: {
  39032. name: string;
  39033. shader: string;
  39034. };
  39035. }
  39036. declare module BABYLON {
  39037. /** @hidden */
  39038. export var fresnelFunction: {
  39039. name: string;
  39040. shader: string;
  39041. };
  39042. }
  39043. declare module BABYLON {
  39044. /** @hidden */
  39045. export var reflectionFunction: {
  39046. name: string;
  39047. shader: string;
  39048. };
  39049. }
  39050. declare module BABYLON {
  39051. /** @hidden */
  39052. export var bumpFragmentFunctions: {
  39053. name: string;
  39054. shader: string;
  39055. };
  39056. }
  39057. declare module BABYLON {
  39058. /** @hidden */
  39059. export var logDepthDeclaration: {
  39060. name: string;
  39061. shader: string;
  39062. };
  39063. }
  39064. declare module BABYLON {
  39065. /** @hidden */
  39066. export var bumpFragment: {
  39067. name: string;
  39068. shader: string;
  39069. };
  39070. }
  39071. declare module BABYLON {
  39072. /** @hidden */
  39073. export var depthPrePass: {
  39074. name: string;
  39075. shader: string;
  39076. };
  39077. }
  39078. declare module BABYLON {
  39079. /** @hidden */
  39080. export var lightFragment: {
  39081. name: string;
  39082. shader: string;
  39083. };
  39084. }
  39085. declare module BABYLON {
  39086. /** @hidden */
  39087. export var logDepthFragment: {
  39088. name: string;
  39089. shader: string;
  39090. };
  39091. }
  39092. declare module BABYLON {
  39093. /** @hidden */
  39094. export var defaultPixelShader: {
  39095. name: string;
  39096. shader: string;
  39097. };
  39098. }
  39099. declare module BABYLON {
  39100. /** @hidden */
  39101. export var defaultVertexDeclaration: {
  39102. name: string;
  39103. shader: string;
  39104. };
  39105. }
  39106. declare module BABYLON {
  39107. /** @hidden */
  39108. export var bumpVertexDeclaration: {
  39109. name: string;
  39110. shader: string;
  39111. };
  39112. }
  39113. declare module BABYLON {
  39114. /** @hidden */
  39115. export var bumpVertex: {
  39116. name: string;
  39117. shader: string;
  39118. };
  39119. }
  39120. declare module BABYLON {
  39121. /** @hidden */
  39122. export var fogVertex: {
  39123. name: string;
  39124. shader: string;
  39125. };
  39126. }
  39127. declare module BABYLON {
  39128. /** @hidden */
  39129. export var shadowsVertex: {
  39130. name: string;
  39131. shader: string;
  39132. };
  39133. }
  39134. declare module BABYLON {
  39135. /** @hidden */
  39136. export var pointCloudVertex: {
  39137. name: string;
  39138. shader: string;
  39139. };
  39140. }
  39141. declare module BABYLON {
  39142. /** @hidden */
  39143. export var logDepthVertex: {
  39144. name: string;
  39145. shader: string;
  39146. };
  39147. }
  39148. declare module BABYLON {
  39149. /** @hidden */
  39150. export var defaultVertexShader: {
  39151. name: string;
  39152. shader: string;
  39153. };
  39154. }
  39155. declare module BABYLON {
  39156. /** @hidden */
  39157. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39158. MAINUV1: boolean;
  39159. MAINUV2: boolean;
  39160. DIFFUSE: boolean;
  39161. DIFFUSEDIRECTUV: number;
  39162. AMBIENT: boolean;
  39163. AMBIENTDIRECTUV: number;
  39164. OPACITY: boolean;
  39165. OPACITYDIRECTUV: number;
  39166. OPACITYRGB: boolean;
  39167. REFLECTION: boolean;
  39168. EMISSIVE: boolean;
  39169. EMISSIVEDIRECTUV: number;
  39170. SPECULAR: boolean;
  39171. SPECULARDIRECTUV: number;
  39172. BUMP: boolean;
  39173. BUMPDIRECTUV: number;
  39174. PARALLAX: boolean;
  39175. PARALLAXOCCLUSION: boolean;
  39176. SPECULAROVERALPHA: boolean;
  39177. CLIPPLANE: boolean;
  39178. CLIPPLANE2: boolean;
  39179. CLIPPLANE3: boolean;
  39180. CLIPPLANE4: boolean;
  39181. ALPHATEST: boolean;
  39182. DEPTHPREPASS: boolean;
  39183. ALPHAFROMDIFFUSE: boolean;
  39184. POINTSIZE: boolean;
  39185. FOG: boolean;
  39186. SPECULARTERM: boolean;
  39187. DIFFUSEFRESNEL: boolean;
  39188. OPACITYFRESNEL: boolean;
  39189. REFLECTIONFRESNEL: boolean;
  39190. REFRACTIONFRESNEL: boolean;
  39191. EMISSIVEFRESNEL: boolean;
  39192. FRESNEL: boolean;
  39193. NORMAL: boolean;
  39194. UV1: boolean;
  39195. UV2: boolean;
  39196. VERTEXCOLOR: boolean;
  39197. VERTEXALPHA: boolean;
  39198. NUM_BONE_INFLUENCERS: number;
  39199. BonesPerMesh: number;
  39200. BONETEXTURE: boolean;
  39201. INSTANCES: boolean;
  39202. GLOSSINESS: boolean;
  39203. ROUGHNESS: boolean;
  39204. EMISSIVEASILLUMINATION: boolean;
  39205. LINKEMISSIVEWITHDIFFUSE: boolean;
  39206. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39207. LIGHTMAP: boolean;
  39208. LIGHTMAPDIRECTUV: number;
  39209. OBJECTSPACE_NORMALMAP: boolean;
  39210. USELIGHTMAPASSHADOWMAP: boolean;
  39211. REFLECTIONMAP_3D: boolean;
  39212. REFLECTIONMAP_SPHERICAL: boolean;
  39213. REFLECTIONMAP_PLANAR: boolean;
  39214. REFLECTIONMAP_CUBIC: boolean;
  39215. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  39216. REFLECTIONMAP_PROJECTION: boolean;
  39217. REFLECTIONMAP_SKYBOX: boolean;
  39218. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  39219. REFLECTIONMAP_EXPLICIT: boolean;
  39220. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  39221. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  39222. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39223. INVERTCUBICMAP: boolean;
  39224. LOGARITHMICDEPTH: boolean;
  39225. REFRACTION: boolean;
  39226. REFRACTIONMAP_3D: boolean;
  39227. REFLECTIONOVERALPHA: boolean;
  39228. TWOSIDEDLIGHTING: boolean;
  39229. SHADOWFLOAT: boolean;
  39230. MORPHTARGETS: boolean;
  39231. MORPHTARGETS_NORMAL: boolean;
  39232. MORPHTARGETS_TANGENT: boolean;
  39233. MORPHTARGETS_UV: boolean;
  39234. NUM_MORPH_INFLUENCERS: number;
  39235. NONUNIFORMSCALING: boolean;
  39236. PREMULTIPLYALPHA: boolean;
  39237. IMAGEPROCESSING: boolean;
  39238. VIGNETTE: boolean;
  39239. VIGNETTEBLENDMODEMULTIPLY: boolean;
  39240. VIGNETTEBLENDMODEOPAQUE: boolean;
  39241. TONEMAPPING: boolean;
  39242. TONEMAPPING_ACES: boolean;
  39243. CONTRAST: boolean;
  39244. COLORCURVES: boolean;
  39245. COLORGRADING: boolean;
  39246. COLORGRADING3D: boolean;
  39247. SAMPLER3DGREENDEPTH: boolean;
  39248. SAMPLER3DBGRMAP: boolean;
  39249. IMAGEPROCESSINGPOSTPROCESS: boolean;
  39250. MULTIVIEW: boolean;
  39251. /**
  39252. * If the reflection texture on this material is in linear color space
  39253. * @hidden
  39254. */
  39255. IS_REFLECTION_LINEAR: boolean;
  39256. /**
  39257. * If the refraction texture on this material is in linear color space
  39258. * @hidden
  39259. */
  39260. IS_REFRACTION_LINEAR: boolean;
  39261. EXPOSURE: boolean;
  39262. constructor();
  39263. setReflectionMode(modeToEnable: string): void;
  39264. }
  39265. /**
  39266. * This is the default material used in Babylon. It is the best trade off between quality
  39267. * and performances.
  39268. * @see http://doc.babylonjs.com/babylon101/materials
  39269. */
  39270. export class StandardMaterial extends PushMaterial {
  39271. private _diffuseTexture;
  39272. /**
  39273. * The basic texture of the material as viewed under a light.
  39274. */
  39275. diffuseTexture: Nullable<BaseTexture>;
  39276. private _ambientTexture;
  39277. /**
  39278. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39279. */
  39280. ambientTexture: Nullable<BaseTexture>;
  39281. private _opacityTexture;
  39282. /**
  39283. * Define the transparency of the material from a texture.
  39284. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39285. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39286. */
  39287. opacityTexture: Nullable<BaseTexture>;
  39288. private _reflectionTexture;
  39289. /**
  39290. * Define the texture used to display the reflection.
  39291. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39292. */
  39293. reflectionTexture: Nullable<BaseTexture>;
  39294. private _emissiveTexture;
  39295. /**
  39296. * Define texture of the material as if self lit.
  39297. * This will be mixed in the final result even in the absence of light.
  39298. */
  39299. emissiveTexture: Nullable<BaseTexture>;
  39300. private _specularTexture;
  39301. /**
  39302. * Define how the color and intensity of the highlight given by the light in the material.
  39303. */
  39304. specularTexture: Nullable<BaseTexture>;
  39305. private _bumpTexture;
  39306. /**
  39307. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39308. * 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.
  39309. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39310. */
  39311. bumpTexture: Nullable<BaseTexture>;
  39312. private _lightmapTexture;
  39313. /**
  39314. * Complex lighting can be computationally expensive to compute at runtime.
  39315. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39316. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39317. */
  39318. lightmapTexture: Nullable<BaseTexture>;
  39319. private _refractionTexture;
  39320. /**
  39321. * Define the texture used to display the refraction.
  39322. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39323. */
  39324. refractionTexture: Nullable<BaseTexture>;
  39325. /**
  39326. * The color of the material lit by the environmental background lighting.
  39327. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39328. */
  39329. ambientColor: Color3;
  39330. /**
  39331. * The basic color of the material as viewed under a light.
  39332. */
  39333. diffuseColor: Color3;
  39334. /**
  39335. * Define how the color and intensity of the highlight given by the light in the material.
  39336. */
  39337. specularColor: Color3;
  39338. /**
  39339. * Define the color of the material as if self lit.
  39340. * This will be mixed in the final result even in the absence of light.
  39341. */
  39342. emissiveColor: Color3;
  39343. /**
  39344. * Defines how sharp are the highlights in the material.
  39345. * The bigger the value the sharper giving a more glossy feeling to the result.
  39346. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  39347. */
  39348. specularPower: number;
  39349. private _useAlphaFromDiffuseTexture;
  39350. /**
  39351. * Does the transparency come from the diffuse texture alpha channel.
  39352. */
  39353. useAlphaFromDiffuseTexture: boolean;
  39354. private _useEmissiveAsIllumination;
  39355. /**
  39356. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  39357. */
  39358. useEmissiveAsIllumination: boolean;
  39359. private _linkEmissiveWithDiffuse;
  39360. /**
  39361. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  39362. * the emissive level when the final color is close to one.
  39363. */
  39364. linkEmissiveWithDiffuse: boolean;
  39365. private _useSpecularOverAlpha;
  39366. /**
  39367. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  39368. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  39369. */
  39370. useSpecularOverAlpha: boolean;
  39371. private _useReflectionOverAlpha;
  39372. /**
  39373. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  39374. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  39375. */
  39376. useReflectionOverAlpha: boolean;
  39377. private _disableLighting;
  39378. /**
  39379. * Does lights from the scene impacts this material.
  39380. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  39381. */
  39382. disableLighting: boolean;
  39383. private _useObjectSpaceNormalMap;
  39384. /**
  39385. * Allows using an object space normal map (instead of tangent space).
  39386. */
  39387. useObjectSpaceNormalMap: boolean;
  39388. private _useParallax;
  39389. /**
  39390. * Is parallax enabled or not.
  39391. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39392. */
  39393. useParallax: boolean;
  39394. private _useParallaxOcclusion;
  39395. /**
  39396. * Is parallax occlusion enabled or not.
  39397. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  39398. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39399. */
  39400. useParallaxOcclusion: boolean;
  39401. /**
  39402. * 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.
  39403. */
  39404. parallaxScaleBias: number;
  39405. private _roughness;
  39406. /**
  39407. * Helps to define how blurry the reflections should appears in the material.
  39408. */
  39409. roughness: number;
  39410. /**
  39411. * In case of refraction, define the value of the index of refraction.
  39412. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39413. */
  39414. indexOfRefraction: number;
  39415. /**
  39416. * Invert the refraction texture alongside the y axis.
  39417. * It can be useful with procedural textures or probe for instance.
  39418. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39419. */
  39420. invertRefractionY: boolean;
  39421. /**
  39422. * Defines the alpha limits in alpha test mode.
  39423. */
  39424. alphaCutOff: number;
  39425. private _useLightmapAsShadowmap;
  39426. /**
  39427. * In case of light mapping, define whether the map contains light or shadow informations.
  39428. */
  39429. useLightmapAsShadowmap: boolean;
  39430. private _diffuseFresnelParameters;
  39431. /**
  39432. * Define the diffuse fresnel parameters of the material.
  39433. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39434. */
  39435. diffuseFresnelParameters: FresnelParameters;
  39436. private _opacityFresnelParameters;
  39437. /**
  39438. * Define the opacity fresnel parameters of the material.
  39439. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39440. */
  39441. opacityFresnelParameters: FresnelParameters;
  39442. private _reflectionFresnelParameters;
  39443. /**
  39444. * Define the reflection fresnel parameters of the material.
  39445. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39446. */
  39447. reflectionFresnelParameters: FresnelParameters;
  39448. private _refractionFresnelParameters;
  39449. /**
  39450. * Define the refraction fresnel parameters of the material.
  39451. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39452. */
  39453. refractionFresnelParameters: FresnelParameters;
  39454. private _emissiveFresnelParameters;
  39455. /**
  39456. * Define the emissive fresnel parameters of the material.
  39457. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39458. */
  39459. emissiveFresnelParameters: FresnelParameters;
  39460. private _useReflectionFresnelFromSpecular;
  39461. /**
  39462. * If true automatically deducts the fresnels values from the material specularity.
  39463. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39464. */
  39465. useReflectionFresnelFromSpecular: boolean;
  39466. private _useGlossinessFromSpecularMapAlpha;
  39467. /**
  39468. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39469. */
  39470. useGlossinessFromSpecularMapAlpha: boolean;
  39471. private _maxSimultaneousLights;
  39472. /**
  39473. * Defines the maximum number of lights that can be used in the material
  39474. */
  39475. maxSimultaneousLights: number;
  39476. private _invertNormalMapX;
  39477. /**
  39478. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39479. */
  39480. invertNormalMapX: boolean;
  39481. private _invertNormalMapY;
  39482. /**
  39483. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39484. */
  39485. invertNormalMapY: boolean;
  39486. private _twoSidedLighting;
  39487. /**
  39488. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39489. */
  39490. twoSidedLighting: boolean;
  39491. /**
  39492. * Default configuration related to image processing available in the standard Material.
  39493. */
  39494. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39495. /**
  39496. * Gets the image processing configuration used either in this material.
  39497. */
  39498. /**
  39499. * Sets the Default image processing configuration used either in the this material.
  39500. *
  39501. * If sets to null, the scene one is in use.
  39502. */
  39503. imageProcessingConfiguration: ImageProcessingConfiguration;
  39504. /**
  39505. * Keep track of the image processing observer to allow dispose and replace.
  39506. */
  39507. private _imageProcessingObserver;
  39508. /**
  39509. * Attaches a new image processing configuration to the Standard Material.
  39510. * @param configuration
  39511. */
  39512. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39513. /**
  39514. * Gets wether the color curves effect is enabled.
  39515. */
  39516. /**
  39517. * Sets wether the color curves effect is enabled.
  39518. */
  39519. cameraColorCurvesEnabled: boolean;
  39520. /**
  39521. * Gets wether the color grading effect is enabled.
  39522. */
  39523. /**
  39524. * Gets wether the color grading effect is enabled.
  39525. */
  39526. cameraColorGradingEnabled: boolean;
  39527. /**
  39528. * Gets wether tonemapping is enabled or not.
  39529. */
  39530. /**
  39531. * Sets wether tonemapping is enabled or not
  39532. */
  39533. cameraToneMappingEnabled: boolean;
  39534. /**
  39535. * The camera exposure used on this material.
  39536. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39537. * This corresponds to a photographic exposure.
  39538. */
  39539. /**
  39540. * The camera exposure used on this material.
  39541. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39542. * This corresponds to a photographic exposure.
  39543. */
  39544. cameraExposure: number;
  39545. /**
  39546. * Gets The camera contrast used on this material.
  39547. */
  39548. /**
  39549. * Sets The camera contrast used on this material.
  39550. */
  39551. cameraContrast: number;
  39552. /**
  39553. * Gets the Color Grading 2D Lookup Texture.
  39554. */
  39555. /**
  39556. * Sets the Color Grading 2D Lookup Texture.
  39557. */
  39558. cameraColorGradingTexture: Nullable<BaseTexture>;
  39559. /**
  39560. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39561. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39562. * 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;
  39563. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39564. */
  39565. /**
  39566. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39567. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39568. * 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;
  39569. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39570. */
  39571. cameraColorCurves: Nullable<ColorCurves>;
  39572. /**
  39573. * Custom callback helping to override the default shader used in the material.
  39574. */
  39575. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39576. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39577. protected _worldViewProjectionMatrix: Matrix;
  39578. protected _globalAmbientColor: Color3;
  39579. protected _useLogarithmicDepth: boolean;
  39580. /**
  39581. * Instantiates a new standard material.
  39582. * This is the default material used in Babylon. It is the best trade off between quality
  39583. * and performances.
  39584. * @see http://doc.babylonjs.com/babylon101/materials
  39585. * @param name Define the name of the material in the scene
  39586. * @param scene Define the scene the material belong to
  39587. */
  39588. constructor(name: string, scene: Scene);
  39589. /**
  39590. * Gets a boolean indicating that current material needs to register RTT
  39591. */
  39592. readonly hasRenderTargetTextures: boolean;
  39593. /**
  39594. * Gets the current class name of the material e.g. "StandardMaterial"
  39595. * Mainly use in serialization.
  39596. * @returns the class name
  39597. */
  39598. getClassName(): string;
  39599. /**
  39600. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39601. * You can try switching to logarithmic depth.
  39602. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  39603. */
  39604. useLogarithmicDepth: boolean;
  39605. /**
  39606. * Specifies if the material will require alpha blending
  39607. * @returns a boolean specifying if alpha blending is needed
  39608. */
  39609. needAlphaBlending(): boolean;
  39610. /**
  39611. * Specifies if this material should be rendered in alpha test mode
  39612. * @returns a boolean specifying if an alpha test is needed.
  39613. */
  39614. needAlphaTesting(): boolean;
  39615. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  39616. /**
  39617. * Get the texture used for alpha test purpose.
  39618. * @returns the diffuse texture in case of the standard material.
  39619. */
  39620. getAlphaTestTexture(): Nullable<BaseTexture>;
  39621. /**
  39622. * Get if the submesh is ready to be used and all its information available.
  39623. * Child classes can use it to update shaders
  39624. * @param mesh defines the mesh to check
  39625. * @param subMesh defines which submesh to check
  39626. * @param useInstances specifies that instances should be used
  39627. * @returns a boolean indicating that the submesh is ready or not
  39628. */
  39629. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39630. /**
  39631. * Builds the material UBO layouts.
  39632. * Used internally during the effect preparation.
  39633. */
  39634. buildUniformLayout(): void;
  39635. /**
  39636. * Unbinds the material from the mesh
  39637. */
  39638. unbind(): void;
  39639. /**
  39640. * Binds the submesh to this material by preparing the effect and shader to draw
  39641. * @param world defines the world transformation matrix
  39642. * @param mesh defines the mesh containing the submesh
  39643. * @param subMesh defines the submesh to bind the material to
  39644. */
  39645. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  39646. /**
  39647. * Get the list of animatables in the material.
  39648. * @returns the list of animatables object used in the material
  39649. */
  39650. getAnimatables(): IAnimatable[];
  39651. /**
  39652. * Gets the active textures from the material
  39653. * @returns an array of textures
  39654. */
  39655. getActiveTextures(): BaseTexture[];
  39656. /**
  39657. * Specifies if the material uses a texture
  39658. * @param texture defines the texture to check against the material
  39659. * @returns a boolean specifying if the material uses the texture
  39660. */
  39661. hasTexture(texture: BaseTexture): boolean;
  39662. /**
  39663. * Disposes the material
  39664. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  39665. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  39666. */
  39667. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  39668. /**
  39669. * Makes a duplicate of the material, and gives it a new name
  39670. * @param name defines the new name for the duplicated material
  39671. * @returns the cloned material
  39672. */
  39673. clone(name: string): StandardMaterial;
  39674. /**
  39675. * Serializes this material in a JSON representation
  39676. * @returns the serialized material object
  39677. */
  39678. serialize(): any;
  39679. /**
  39680. * Creates a standard material from parsed material data
  39681. * @param source defines the JSON representation of the material
  39682. * @param scene defines the hosting scene
  39683. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  39684. * @returns a new standard material
  39685. */
  39686. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  39687. /**
  39688. * Are diffuse textures enabled in the application.
  39689. */
  39690. static DiffuseTextureEnabled: boolean;
  39691. /**
  39692. * Are ambient textures enabled in the application.
  39693. */
  39694. static AmbientTextureEnabled: boolean;
  39695. /**
  39696. * Are opacity textures enabled in the application.
  39697. */
  39698. static OpacityTextureEnabled: boolean;
  39699. /**
  39700. * Are reflection textures enabled in the application.
  39701. */
  39702. static ReflectionTextureEnabled: boolean;
  39703. /**
  39704. * Are emissive textures enabled in the application.
  39705. */
  39706. static EmissiveTextureEnabled: boolean;
  39707. /**
  39708. * Are specular textures enabled in the application.
  39709. */
  39710. static SpecularTextureEnabled: boolean;
  39711. /**
  39712. * Are bump textures enabled in the application.
  39713. */
  39714. static BumpTextureEnabled: boolean;
  39715. /**
  39716. * Are lightmap textures enabled in the application.
  39717. */
  39718. static LightmapTextureEnabled: boolean;
  39719. /**
  39720. * Are refraction textures enabled in the application.
  39721. */
  39722. static RefractionTextureEnabled: boolean;
  39723. /**
  39724. * Are color grading textures enabled in the application.
  39725. */
  39726. static ColorGradingTextureEnabled: boolean;
  39727. /**
  39728. * Are fresnels enabled in the application.
  39729. */
  39730. static FresnelEnabled: boolean;
  39731. }
  39732. }
  39733. declare module BABYLON {
  39734. /**
  39735. * A class extending Texture allowing drawing on a texture
  39736. * @see http://doc.babylonjs.com/how_to/dynamictexture
  39737. */
  39738. export class DynamicTexture extends Texture {
  39739. private _generateMipMaps;
  39740. private _canvas;
  39741. private _context;
  39742. private _engine;
  39743. /**
  39744. * Creates a DynamicTexture
  39745. * @param name defines the name of the texture
  39746. * @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
  39747. * @param scene defines the scene where you want the texture
  39748. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  39749. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  39750. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  39751. */
  39752. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  39753. /**
  39754. * Get the current class name of the texture useful for serialization or dynamic coding.
  39755. * @returns "DynamicTexture"
  39756. */
  39757. getClassName(): string;
  39758. /**
  39759. * Gets the current state of canRescale
  39760. */
  39761. readonly canRescale: boolean;
  39762. private _recreate;
  39763. /**
  39764. * Scales the texture
  39765. * @param ratio the scale factor to apply to both width and height
  39766. */
  39767. scale(ratio: number): void;
  39768. /**
  39769. * Resizes the texture
  39770. * @param width the new width
  39771. * @param height the new height
  39772. */
  39773. scaleTo(width: number, height: number): void;
  39774. /**
  39775. * Gets the context of the canvas used by the texture
  39776. * @returns the canvas context of the dynamic texture
  39777. */
  39778. getContext(): CanvasRenderingContext2D;
  39779. /**
  39780. * Clears the texture
  39781. */
  39782. clear(): void;
  39783. /**
  39784. * Updates the texture
  39785. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39786. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  39787. */
  39788. update(invertY?: boolean, premulAlpha?: boolean): void;
  39789. /**
  39790. * Draws text onto the texture
  39791. * @param text defines the text to be drawn
  39792. * @param x defines the placement of the text from the left
  39793. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  39794. * @param font defines the font to be used with font-style, font-size, font-name
  39795. * @param color defines the color used for the text
  39796. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  39797. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39798. * @param update defines whether texture is immediately update (default is true)
  39799. */
  39800. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  39801. /**
  39802. * Clones the texture
  39803. * @returns the clone of the texture.
  39804. */
  39805. clone(): DynamicTexture;
  39806. /**
  39807. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  39808. * @returns a serialized dynamic texture object
  39809. */
  39810. serialize(): any;
  39811. /** @hidden */
  39812. _rebuild(): void;
  39813. }
  39814. }
  39815. declare module BABYLON {
  39816. /** @hidden */
  39817. export var imageProcessingPixelShader: {
  39818. name: string;
  39819. shader: string;
  39820. };
  39821. }
  39822. declare module BABYLON {
  39823. /**
  39824. * ImageProcessingPostProcess
  39825. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  39826. */
  39827. export class ImageProcessingPostProcess extends PostProcess {
  39828. /**
  39829. * Default configuration related to image processing available in the PBR Material.
  39830. */
  39831. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39832. /**
  39833. * Gets the image processing configuration used either in this material.
  39834. */
  39835. /**
  39836. * Sets the Default image processing configuration used either in the this material.
  39837. *
  39838. * If sets to null, the scene one is in use.
  39839. */
  39840. imageProcessingConfiguration: ImageProcessingConfiguration;
  39841. /**
  39842. * Keep track of the image processing observer to allow dispose and replace.
  39843. */
  39844. private _imageProcessingObserver;
  39845. /**
  39846. * Attaches a new image processing configuration to the PBR Material.
  39847. * @param configuration
  39848. */
  39849. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  39850. /**
  39851. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39852. */
  39853. /**
  39854. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39855. */
  39856. colorCurves: Nullable<ColorCurves>;
  39857. /**
  39858. * Gets wether the color curves effect is enabled.
  39859. */
  39860. /**
  39861. * Sets wether the color curves effect is enabled.
  39862. */
  39863. colorCurvesEnabled: boolean;
  39864. /**
  39865. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39866. */
  39867. /**
  39868. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39869. */
  39870. colorGradingTexture: Nullable<BaseTexture>;
  39871. /**
  39872. * Gets wether the color grading effect is enabled.
  39873. */
  39874. /**
  39875. * Gets wether the color grading effect is enabled.
  39876. */
  39877. colorGradingEnabled: boolean;
  39878. /**
  39879. * Gets exposure used in the effect.
  39880. */
  39881. /**
  39882. * Sets exposure used in the effect.
  39883. */
  39884. exposure: number;
  39885. /**
  39886. * Gets wether tonemapping is enabled or not.
  39887. */
  39888. /**
  39889. * Sets wether tonemapping is enabled or not
  39890. */
  39891. toneMappingEnabled: boolean;
  39892. /**
  39893. * Gets the type of tone mapping effect.
  39894. */
  39895. /**
  39896. * Sets the type of tone mapping effect.
  39897. */
  39898. toneMappingType: number;
  39899. /**
  39900. * Gets contrast used in the effect.
  39901. */
  39902. /**
  39903. * Sets contrast used in the effect.
  39904. */
  39905. contrast: number;
  39906. /**
  39907. * Gets Vignette stretch size.
  39908. */
  39909. /**
  39910. * Sets Vignette stretch size.
  39911. */
  39912. vignetteStretch: number;
  39913. /**
  39914. * Gets Vignette centre X Offset.
  39915. */
  39916. /**
  39917. * Sets Vignette centre X Offset.
  39918. */
  39919. vignetteCentreX: number;
  39920. /**
  39921. * Gets Vignette centre Y Offset.
  39922. */
  39923. /**
  39924. * Sets Vignette centre Y Offset.
  39925. */
  39926. vignetteCentreY: number;
  39927. /**
  39928. * Gets Vignette weight or intensity of the vignette effect.
  39929. */
  39930. /**
  39931. * Sets Vignette weight or intensity of the vignette effect.
  39932. */
  39933. vignetteWeight: number;
  39934. /**
  39935. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39936. * if vignetteEnabled is set to true.
  39937. */
  39938. /**
  39939. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39940. * if vignetteEnabled is set to true.
  39941. */
  39942. vignetteColor: Color4;
  39943. /**
  39944. * Gets Camera field of view used by the Vignette effect.
  39945. */
  39946. /**
  39947. * Sets Camera field of view used by the Vignette effect.
  39948. */
  39949. vignetteCameraFov: number;
  39950. /**
  39951. * Gets the vignette blend mode allowing different kind of effect.
  39952. */
  39953. /**
  39954. * Sets the vignette blend mode allowing different kind of effect.
  39955. */
  39956. vignetteBlendMode: number;
  39957. /**
  39958. * Gets wether the vignette effect is enabled.
  39959. */
  39960. /**
  39961. * Sets wether the vignette effect is enabled.
  39962. */
  39963. vignetteEnabled: boolean;
  39964. private _fromLinearSpace;
  39965. /**
  39966. * Gets wether the input of the processing is in Gamma or Linear Space.
  39967. */
  39968. /**
  39969. * Sets wether the input of the processing is in Gamma or Linear Space.
  39970. */
  39971. fromLinearSpace: boolean;
  39972. /**
  39973. * Defines cache preventing GC.
  39974. */
  39975. private _defines;
  39976. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  39977. /**
  39978. * "ImageProcessingPostProcess"
  39979. * @returns "ImageProcessingPostProcess"
  39980. */
  39981. getClassName(): string;
  39982. protected _updateParameters(): void;
  39983. dispose(camera?: Camera): void;
  39984. }
  39985. }
  39986. declare module BABYLON {
  39987. /**
  39988. * Class containing static functions to help procedurally build meshes
  39989. */
  39990. export class GroundBuilder {
  39991. /**
  39992. * Creates a ground mesh
  39993. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  39994. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  39995. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39996. * @param name defines the name of the mesh
  39997. * @param options defines the options used to create the mesh
  39998. * @param scene defines the hosting scene
  39999. * @returns the ground mesh
  40000. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40001. */
  40002. static CreateGround(name: string, options: {
  40003. width?: number;
  40004. height?: number;
  40005. subdivisions?: number;
  40006. subdivisionsX?: number;
  40007. subdivisionsY?: number;
  40008. updatable?: boolean;
  40009. }, scene: any): Mesh;
  40010. /**
  40011. * Creates a tiled ground mesh
  40012. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40013. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40014. * * 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
  40015. * * 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
  40016. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40017. * @param name defines the name of the mesh
  40018. * @param options defines the options used to create the mesh
  40019. * @param scene defines the hosting scene
  40020. * @returns the tiled ground mesh
  40021. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40022. */
  40023. static CreateTiledGround(name: string, options: {
  40024. xmin: number;
  40025. zmin: number;
  40026. xmax: number;
  40027. zmax: number;
  40028. subdivisions?: {
  40029. w: number;
  40030. h: number;
  40031. };
  40032. precision?: {
  40033. w: number;
  40034. h: number;
  40035. };
  40036. updatable?: boolean;
  40037. }, scene?: Nullable<Scene>): Mesh;
  40038. /**
  40039. * Creates a ground mesh from a height map
  40040. * * The parameter `url` sets the URL of the height map image resource.
  40041. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40042. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40043. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40044. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40045. * * 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.
  40046. * * 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).
  40047. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40048. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40049. * @param name defines the name of the mesh
  40050. * @param url defines the url to the height map
  40051. * @param options defines the options used to create the mesh
  40052. * @param scene defines the hosting scene
  40053. * @returns the ground mesh
  40054. * @see https://doc.babylonjs.com/babylon101/height_map
  40055. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40056. */
  40057. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40058. width?: number;
  40059. height?: number;
  40060. subdivisions?: number;
  40061. minHeight?: number;
  40062. maxHeight?: number;
  40063. colorFilter?: Color3;
  40064. alphaFilter?: number;
  40065. updatable?: boolean;
  40066. onReady?: (mesh: GroundMesh) => void;
  40067. }, scene?: Nullable<Scene>): GroundMesh;
  40068. }
  40069. }
  40070. declare module BABYLON {
  40071. /**
  40072. * Class containing static functions to help procedurally build meshes
  40073. */
  40074. export class TorusBuilder {
  40075. /**
  40076. * Creates a torus mesh
  40077. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40078. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40079. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40080. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40081. * * 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
  40082. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40083. * @param name defines the name of the mesh
  40084. * @param options defines the options used to create the mesh
  40085. * @param scene defines the hosting scene
  40086. * @returns the torus mesh
  40087. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40088. */
  40089. static CreateTorus(name: string, options: {
  40090. diameter?: number;
  40091. thickness?: number;
  40092. tessellation?: number;
  40093. updatable?: boolean;
  40094. sideOrientation?: number;
  40095. frontUVs?: Vector4;
  40096. backUVs?: Vector4;
  40097. }, scene: any): Mesh;
  40098. }
  40099. }
  40100. declare module BABYLON {
  40101. /**
  40102. * Class containing static functions to help procedurally build meshes
  40103. */
  40104. export class CylinderBuilder {
  40105. /**
  40106. * Creates a cylinder or a cone mesh
  40107. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40108. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40109. * * 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.
  40110. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40111. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40112. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40113. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40114. * * 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).
  40115. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40116. * * 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).
  40117. * * 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
  40118. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40119. * * 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
  40120. * * 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.
  40121. * * If `enclose` is false, a ring surface is one element.
  40122. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40123. * * 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
  40124. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40125. * * 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
  40126. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40127. * @param name defines the name of the mesh
  40128. * @param options defines the options used to create the mesh
  40129. * @param scene defines the hosting scene
  40130. * @returns the cylinder mesh
  40131. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40132. */
  40133. static CreateCylinder(name: string, options: {
  40134. height?: number;
  40135. diameterTop?: number;
  40136. diameterBottom?: number;
  40137. diameter?: number;
  40138. tessellation?: number;
  40139. subdivisions?: number;
  40140. arc?: number;
  40141. faceColors?: Color4[];
  40142. faceUV?: Vector4[];
  40143. updatable?: boolean;
  40144. hasRings?: boolean;
  40145. enclose?: boolean;
  40146. cap?: number;
  40147. sideOrientation?: number;
  40148. frontUVs?: Vector4;
  40149. backUVs?: Vector4;
  40150. }, scene: any): Mesh;
  40151. }
  40152. }
  40153. declare module BABYLON {
  40154. /**
  40155. * Options to modify the vr teleportation behavior.
  40156. */
  40157. export interface VRTeleportationOptions {
  40158. /**
  40159. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40160. */
  40161. floorMeshName?: string;
  40162. /**
  40163. * A list of meshes to be used as the teleportation floor. (default: empty)
  40164. */
  40165. floorMeshes?: Mesh[];
  40166. }
  40167. /**
  40168. * Options to modify the vr experience helper's behavior.
  40169. */
  40170. export interface VRExperienceHelperOptions extends WebVROptions {
  40171. /**
  40172. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40173. */
  40174. createDeviceOrientationCamera?: boolean;
  40175. /**
  40176. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40177. */
  40178. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40179. /**
  40180. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40181. */
  40182. laserToggle?: boolean;
  40183. /**
  40184. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40185. */
  40186. floorMeshes?: Mesh[];
  40187. /**
  40188. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  40189. */
  40190. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  40191. }
  40192. /**
  40193. * Event containing information after VR has been entered
  40194. */
  40195. export class OnAfterEnteringVRObservableEvent {
  40196. /**
  40197. * If entering vr was successful
  40198. */
  40199. success: boolean;
  40200. }
  40201. /**
  40202. * Helps to quickly add VR support to an existing scene.
  40203. * See http://doc.babylonjs.com/how_to/webvr_helper
  40204. */
  40205. export class VRExperienceHelper {
  40206. /** Options to modify the vr experience helper's behavior. */
  40207. webVROptions: VRExperienceHelperOptions;
  40208. private _scene;
  40209. private _position;
  40210. private _btnVR;
  40211. private _btnVRDisplayed;
  40212. private _webVRsupported;
  40213. private _webVRready;
  40214. private _webVRrequesting;
  40215. private _webVRpresenting;
  40216. private _hasEnteredVR;
  40217. private _fullscreenVRpresenting;
  40218. private _canvas;
  40219. private _webVRCamera;
  40220. private _vrDeviceOrientationCamera;
  40221. private _deviceOrientationCamera;
  40222. private _existingCamera;
  40223. private _onKeyDown;
  40224. private _onVrDisplayPresentChange;
  40225. private _onVRDisplayChanged;
  40226. private _onVRRequestPresentStart;
  40227. private _onVRRequestPresentComplete;
  40228. /**
  40229. * Observable raised right before entering VR.
  40230. */
  40231. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40232. /**
  40233. * Observable raised when entering VR has completed.
  40234. */
  40235. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40236. /**
  40237. * Observable raised when exiting VR.
  40238. */
  40239. onExitingVRObservable: Observable<VRExperienceHelper>;
  40240. /**
  40241. * Observable raised when controller mesh is loaded.
  40242. */
  40243. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40244. /** Return this.onEnteringVRObservable
  40245. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40246. */
  40247. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40248. /** Return this.onExitingVRObservable
  40249. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40250. */
  40251. readonly onExitingVR: Observable<VRExperienceHelper>;
  40252. /** Return this.onControllerMeshLoadedObservable
  40253. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40254. */
  40255. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40256. private _rayLength;
  40257. private _useCustomVRButton;
  40258. private _teleportationRequested;
  40259. private _teleportActive;
  40260. private _floorMeshName;
  40261. private _floorMeshesCollection;
  40262. private _rotationAllowed;
  40263. private _teleportBackwardsVector;
  40264. private _teleportationTarget;
  40265. private _isDefaultTeleportationTarget;
  40266. private _postProcessMove;
  40267. private _teleportationFillColor;
  40268. private _teleportationBorderColor;
  40269. private _rotationAngle;
  40270. private _haloCenter;
  40271. private _cameraGazer;
  40272. private _padSensibilityUp;
  40273. private _padSensibilityDown;
  40274. private _leftController;
  40275. private _rightController;
  40276. /**
  40277. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40278. */
  40279. onNewMeshSelected: Observable<AbstractMesh>;
  40280. /**
  40281. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40282. */
  40283. onNewMeshPicked: Observable<PickingInfo>;
  40284. private _circleEase;
  40285. /**
  40286. * Observable raised before camera teleportation
  40287. */
  40288. onBeforeCameraTeleport: Observable<Vector3>;
  40289. /**
  40290. * Observable raised after camera teleportation
  40291. */
  40292. onAfterCameraTeleport: Observable<Vector3>;
  40293. /**
  40294. * Observable raised when current selected mesh gets unselected
  40295. */
  40296. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40297. private _raySelectionPredicate;
  40298. /**
  40299. * To be optionaly changed by user to define custom ray selection
  40300. */
  40301. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40302. /**
  40303. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40304. */
  40305. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40306. /**
  40307. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40308. */
  40309. teleportationEnabled: boolean;
  40310. private _defaultHeight;
  40311. private _teleportationInitialized;
  40312. private _interactionsEnabled;
  40313. private _interactionsRequested;
  40314. private _displayGaze;
  40315. private _displayLaserPointer;
  40316. /**
  40317. * The mesh used to display where the user is going to teleport.
  40318. */
  40319. /**
  40320. * Sets the mesh to be used to display where the user is going to teleport.
  40321. */
  40322. teleportationTarget: Mesh;
  40323. /**
  40324. * 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
  40325. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40326. * See http://doc.babylonjs.com/resources/baking_transformations
  40327. */
  40328. gazeTrackerMesh: Mesh;
  40329. /**
  40330. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40331. */
  40332. updateGazeTrackerScale: boolean;
  40333. /**
  40334. * If the gaze trackers color should be updated when selecting meshes
  40335. */
  40336. updateGazeTrackerColor: boolean;
  40337. /**
  40338. * The gaze tracking mesh corresponding to the left controller
  40339. */
  40340. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40341. /**
  40342. * The gaze tracking mesh corresponding to the right controller
  40343. */
  40344. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40345. /**
  40346. * If the ray of the gaze should be displayed.
  40347. */
  40348. /**
  40349. * Sets if the ray of the gaze should be displayed.
  40350. */
  40351. displayGaze: boolean;
  40352. /**
  40353. * If the ray of the LaserPointer should be displayed.
  40354. */
  40355. /**
  40356. * Sets if the ray of the LaserPointer should be displayed.
  40357. */
  40358. displayLaserPointer: boolean;
  40359. /**
  40360. * The deviceOrientationCamera used as the camera when not in VR.
  40361. */
  40362. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40363. /**
  40364. * Based on the current WebVR support, returns the current VR camera used.
  40365. */
  40366. readonly currentVRCamera: Nullable<Camera>;
  40367. /**
  40368. * The webVRCamera which is used when in VR.
  40369. */
  40370. readonly webVRCamera: WebVRFreeCamera;
  40371. /**
  40372. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40373. */
  40374. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40375. private readonly _teleportationRequestInitiated;
  40376. /**
  40377. * Defines wether or not Pointer lock should be requested when switching to
  40378. * full screen.
  40379. */
  40380. requestPointerLockOnFullScreen: boolean;
  40381. /**
  40382. * Instantiates a VRExperienceHelper.
  40383. * Helps to quickly add VR support to an existing scene.
  40384. * @param scene The scene the VRExperienceHelper belongs to.
  40385. * @param webVROptions Options to modify the vr experience helper's behavior.
  40386. */
  40387. constructor(scene: Scene,
  40388. /** Options to modify the vr experience helper's behavior. */
  40389. webVROptions?: VRExperienceHelperOptions);
  40390. private _onDefaultMeshLoaded;
  40391. private _onResize;
  40392. private _onFullscreenChange;
  40393. /**
  40394. * Gets a value indicating if we are currently in VR mode.
  40395. */
  40396. readonly isInVRMode: boolean;
  40397. private onVrDisplayPresentChange;
  40398. private onVRDisplayChanged;
  40399. private moveButtonToBottomRight;
  40400. private displayVRButton;
  40401. private updateButtonVisibility;
  40402. private _cachedAngularSensibility;
  40403. /**
  40404. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40405. * Otherwise, will use the fullscreen API.
  40406. */
  40407. enterVR(): void;
  40408. /**
  40409. * Attempt to exit VR, or fullscreen.
  40410. */
  40411. exitVR(): void;
  40412. /**
  40413. * The position of the vr experience helper.
  40414. */
  40415. /**
  40416. * Sets the position of the vr experience helper.
  40417. */
  40418. position: Vector3;
  40419. /**
  40420. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40421. */
  40422. enableInteractions(): void;
  40423. private readonly _noControllerIsActive;
  40424. private beforeRender;
  40425. private _isTeleportationFloor;
  40426. /**
  40427. * Adds a floor mesh to be used for teleportation.
  40428. * @param floorMesh the mesh to be used for teleportation.
  40429. */
  40430. addFloorMesh(floorMesh: Mesh): void;
  40431. /**
  40432. * Removes a floor mesh from being used for teleportation.
  40433. * @param floorMesh the mesh to be removed.
  40434. */
  40435. removeFloorMesh(floorMesh: Mesh): void;
  40436. /**
  40437. * Enables interactions and teleportation using the VR controllers and gaze.
  40438. * @param vrTeleportationOptions options to modify teleportation behavior.
  40439. */
  40440. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40441. private _onNewGamepadConnected;
  40442. private _tryEnableInteractionOnController;
  40443. private _onNewGamepadDisconnected;
  40444. private _enableInteractionOnController;
  40445. private _checkTeleportWithRay;
  40446. private _checkRotate;
  40447. private _checkTeleportBackwards;
  40448. private _enableTeleportationOnController;
  40449. private _createTeleportationCircles;
  40450. private _displayTeleportationTarget;
  40451. private _hideTeleportationTarget;
  40452. private _rotateCamera;
  40453. private _moveTeleportationSelectorTo;
  40454. private _workingVector;
  40455. private _workingQuaternion;
  40456. private _workingMatrix;
  40457. /**
  40458. * Teleports the users feet to the desired location
  40459. * @param location The location where the user's feet should be placed
  40460. */
  40461. teleportCamera(location: Vector3): void;
  40462. private _convertNormalToDirectionOfRay;
  40463. private _castRayAndSelectObject;
  40464. private _notifySelectedMeshUnselected;
  40465. /**
  40466. * Sets the color of the laser ray from the vr controllers.
  40467. * @param color new color for the ray.
  40468. */
  40469. changeLaserColor(color: Color3): void;
  40470. /**
  40471. * Sets the color of the ray from the vr headsets gaze.
  40472. * @param color new color for the ray.
  40473. */
  40474. changeGazeColor(color: Color3): void;
  40475. /**
  40476. * Exits VR and disposes of the vr experience helper
  40477. */
  40478. dispose(): void;
  40479. /**
  40480. * Gets the name of the VRExperienceHelper class
  40481. * @returns "VRExperienceHelper"
  40482. */
  40483. getClassName(): string;
  40484. }
  40485. }
  40486. declare module BABYLON {
  40487. /**
  40488. * Manages an XRSession to work with Babylon's engine
  40489. * @see https://doc.babylonjs.com/how_to/webxr
  40490. */
  40491. export class WebXRSessionManager implements IDisposable {
  40492. private scene;
  40493. /**
  40494. * Fires every time a new xrFrame arrives which can be used to update the camera
  40495. */
  40496. onXRFrameObservable: Observable<any>;
  40497. /**
  40498. * Fires when the xr session is ended either by the device or manually done
  40499. */
  40500. onXRSessionEnded: Observable<any>;
  40501. /**
  40502. * Underlying xr session
  40503. */
  40504. session: XRSession;
  40505. /**
  40506. * Type of reference space used when creating the session
  40507. */
  40508. referenceSpace: XRReferenceSpace;
  40509. /** @hidden */
  40510. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  40511. /**
  40512. * Current XR frame
  40513. */
  40514. currentFrame: Nullable<XRFrame>;
  40515. private _xrNavigator;
  40516. private baseLayer;
  40517. /**
  40518. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  40519. * @param scene The scene which the session should be created for
  40520. */
  40521. constructor(scene: Scene);
  40522. /**
  40523. * Initializes the manager
  40524. * After initialization enterXR can be called to start an XR session
  40525. * @returns Promise which resolves after it is initialized
  40526. */
  40527. initializeAsync(): Promise<void>;
  40528. /**
  40529. * Initializes an xr session
  40530. * @param xrSessionMode mode to initialize
  40531. * @returns a promise which will resolve once the session has been initialized
  40532. */
  40533. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  40534. /**
  40535. * Sets the reference space on the xr session
  40536. * @param referenceSpace space to set
  40537. * @returns a promise that will resolve once the reference space has been set
  40538. */
  40539. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  40540. /**
  40541. * Updates the render state of the session
  40542. * @param state state to set
  40543. * @returns a promise that resolves once the render state has been updated
  40544. */
  40545. updateRenderStateAsync(state: any): Promise<void>;
  40546. /**
  40547. * Starts rendering to the xr layer
  40548. * @returns a promise that will resolve once rendering has started
  40549. */
  40550. startRenderingToXRAsync(): Promise<void>;
  40551. /**
  40552. * Stops the xrSession and restores the renderloop
  40553. * @returns Promise which resolves after it exits XR
  40554. */
  40555. exitXRAsync(): Promise<void>;
  40556. /**
  40557. * Checks if a session would be supported for the creation options specified
  40558. * @param sessionMode session mode to check if supported eg. immersive-vr
  40559. * @returns true if supported
  40560. */
  40561. supportsSessionAsync(sessionMode: XRSessionMode): any;
  40562. /**
  40563. * @hidden
  40564. * Converts the render layer of xrSession to a render target
  40565. * @param session session to create render target for
  40566. * @param scene scene the new render target should be created for
  40567. */
  40568. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  40569. /**
  40570. * Disposes of the session manager
  40571. */
  40572. dispose(): void;
  40573. }
  40574. }
  40575. declare module BABYLON {
  40576. /**
  40577. * WebXR Camera which holds the views for the xrSession
  40578. * @see https://doc.babylonjs.com/how_to/webxr
  40579. */
  40580. export class WebXRCamera extends FreeCamera {
  40581. private static _TmpMatrix;
  40582. /**
  40583. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  40584. * @param name the name of the camera
  40585. * @param scene the scene to add the camera to
  40586. */
  40587. constructor(name: string, scene: Scene);
  40588. private _updateNumberOfRigCameras;
  40589. /** @hidden */
  40590. _updateForDualEyeDebugging(pupilDistance?: number): void;
  40591. /**
  40592. * Updates the cameras position from the current pose information of the XR session
  40593. * @param xrSessionManager the session containing pose information
  40594. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  40595. */
  40596. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  40597. }
  40598. }
  40599. declare module BABYLON {
  40600. /**
  40601. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40602. */
  40603. export class WebXRManagedOutputCanvas implements IDisposable {
  40604. private helper;
  40605. private _canvas;
  40606. /**
  40607. * xrpresent context of the canvas which can be used to display/mirror xr content
  40608. */
  40609. canvasContext: WebGLRenderingContext;
  40610. /**
  40611. * xr layer for the canvas
  40612. */
  40613. xrLayer: Nullable<XRWebGLLayer>;
  40614. /**
  40615. * Initializes the xr layer for the session
  40616. * @param xrSession xr session
  40617. * @returns a promise that will resolve once the XR Layer has been created
  40618. */
  40619. initializeXRLayerAsync(xrSession: any): any;
  40620. /**
  40621. * Initializes the canvas to be added/removed upon entering/exiting xr
  40622. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  40623. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40624. */
  40625. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  40626. /**
  40627. * Disposes of the object
  40628. */
  40629. dispose(): void;
  40630. private _setManagedOutputCanvas;
  40631. private _addCanvas;
  40632. private _removeCanvas;
  40633. }
  40634. }
  40635. declare module BABYLON {
  40636. /**
  40637. * States of the webXR experience
  40638. */
  40639. export enum WebXRState {
  40640. /**
  40641. * Transitioning to being in XR mode
  40642. */
  40643. ENTERING_XR = 0,
  40644. /**
  40645. * Transitioning to non XR mode
  40646. */
  40647. EXITING_XR = 1,
  40648. /**
  40649. * In XR mode and presenting
  40650. */
  40651. IN_XR = 2,
  40652. /**
  40653. * Not entered XR mode
  40654. */
  40655. NOT_IN_XR = 3
  40656. }
  40657. /**
  40658. * Helper class used to enable XR
  40659. * @see https://doc.babylonjs.com/how_to/webxr
  40660. */
  40661. export class WebXRExperienceHelper implements IDisposable {
  40662. private scene;
  40663. /**
  40664. * 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
  40665. */
  40666. container: AbstractMesh;
  40667. /**
  40668. * Camera used to render xr content
  40669. */
  40670. camera: WebXRCamera;
  40671. /**
  40672. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  40673. */
  40674. state: WebXRState;
  40675. private _setState;
  40676. private static _TmpVector;
  40677. /**
  40678. * Fires when the state of the experience helper has changed
  40679. */
  40680. onStateChangedObservable: Observable<WebXRState>;
  40681. /** Session manager used to keep track of xr session */
  40682. sessionManager: WebXRSessionManager;
  40683. private _nonVRCamera;
  40684. private _originalSceneAutoClear;
  40685. private _supported;
  40686. /**
  40687. * Creates the experience helper
  40688. * @param scene the scene to attach the experience helper to
  40689. * @returns a promise for the experience helper
  40690. */
  40691. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  40692. /**
  40693. * Creates a WebXRExperienceHelper
  40694. * @param scene The scene the helper should be created in
  40695. */
  40696. private constructor();
  40697. /**
  40698. * Exits XR mode and returns the scene to its original state
  40699. * @returns promise that resolves after xr mode has exited
  40700. */
  40701. exitXRAsync(): Promise<void>;
  40702. /**
  40703. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  40704. * @param sessionCreationOptions options for the XR session
  40705. * @param referenceSpaceType frame of reference of the XR session
  40706. * @param outputCanvas the output canvas that will be used to enter XR mode
  40707. * @returns promise that resolves after xr mode has entered
  40708. */
  40709. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  40710. /**
  40711. * Updates the global position of the camera by moving the camera's container
  40712. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  40713. * @param position The desired global position of the camera
  40714. */
  40715. setPositionOfCameraUsingContainer(position: Vector3): void;
  40716. /**
  40717. * Rotates the xr camera by rotating the camera's container around the camera's position
  40718. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  40719. * @param rotation the desired quaternion rotation to apply to the camera
  40720. */
  40721. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  40722. /**
  40723. * Disposes of the experience helper
  40724. */
  40725. dispose(): void;
  40726. }
  40727. }
  40728. declare module BABYLON {
  40729. /**
  40730. * Button which can be used to enter a different mode of XR
  40731. */
  40732. export class WebXREnterExitUIButton {
  40733. /** button element */
  40734. element: HTMLElement;
  40735. /** XR initialization options for the button */
  40736. sessionMode: XRSessionMode;
  40737. /** Reference space type */
  40738. referenceSpaceType: XRReferenceSpaceType;
  40739. /**
  40740. * Creates a WebXREnterExitUIButton
  40741. * @param element button element
  40742. * @param sessionMode XR initialization session mode
  40743. * @param referenceSpaceType the type of reference space to be used
  40744. */
  40745. constructor(
  40746. /** button element */
  40747. element: HTMLElement,
  40748. /** XR initialization options for the button */
  40749. sessionMode: XRSessionMode,
  40750. /** Reference space type */
  40751. referenceSpaceType: XRReferenceSpaceType);
  40752. /**
  40753. * Overwritable function which can be used to update the button's visuals when the state changes
  40754. * @param activeButton the current active button in the UI
  40755. */
  40756. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  40757. }
  40758. /**
  40759. * Options to create the webXR UI
  40760. */
  40761. export class WebXREnterExitUIOptions {
  40762. /**
  40763. * Context to enter xr with
  40764. */
  40765. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  40766. /**
  40767. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  40768. */
  40769. customButtons?: Array<WebXREnterExitUIButton>;
  40770. }
  40771. /**
  40772. * UI to allow the user to enter/exit XR mode
  40773. */
  40774. export class WebXREnterExitUI implements IDisposable {
  40775. private scene;
  40776. private _overlay;
  40777. private _buttons;
  40778. private _activeButton;
  40779. /**
  40780. * Fired every time the active button is changed.
  40781. *
  40782. * When xr is entered via a button that launches xr that button will be the callback parameter
  40783. *
  40784. * When exiting xr the callback parameter will be null)
  40785. */
  40786. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  40787. /**
  40788. * Creates UI to allow the user to enter/exit XR mode
  40789. * @param scene the scene to add the ui to
  40790. * @param helper the xr experience helper to enter/exit xr with
  40791. * @param options options to configure the UI
  40792. * @returns the created ui
  40793. */
  40794. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  40795. private constructor();
  40796. private _updateButtons;
  40797. /**
  40798. * Disposes of the object
  40799. */
  40800. dispose(): void;
  40801. }
  40802. }
  40803. declare module BABYLON {
  40804. /**
  40805. * Represents an XR input
  40806. */
  40807. export class WebXRController {
  40808. private scene;
  40809. /** The underlying input source for the controller */
  40810. inputSource: XRInputSource;
  40811. private parentContainer;
  40812. /**
  40813. * 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
  40814. */
  40815. grip?: AbstractMesh;
  40816. /**
  40817. * Pointer which can be used to select objects or attach a visible laser to
  40818. */
  40819. pointer: AbstractMesh;
  40820. private _tmpMatrix;
  40821. /**
  40822. * Creates the controller
  40823. * @see https://doc.babylonjs.com/how_to/webxr
  40824. * @param scene the scene which the controller should be associated to
  40825. * @param inputSource the underlying input source for the controller
  40826. * @param parentContainer parent that the controller meshes should be children of
  40827. */
  40828. constructor(scene: Scene,
  40829. /** The underlying input source for the controller */
  40830. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  40831. /**
  40832. * Updates the controller pose based on the given XRFrame
  40833. * @param xrFrame xr frame to update the pose with
  40834. * @param referenceSpace reference space to use
  40835. */
  40836. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  40837. /**
  40838. * Disposes of the object
  40839. */
  40840. dispose(): void;
  40841. }
  40842. /**
  40843. * XR input used to track XR inputs such as controllers/rays
  40844. */
  40845. export class WebXRInput implements IDisposable {
  40846. private helper;
  40847. /**
  40848. * XR controllers being tracked
  40849. */
  40850. controllers: Array<WebXRController>;
  40851. private _frameObserver;
  40852. /**
  40853. * Event when a controller has been connected/added
  40854. */
  40855. onControllerAddedObservable: Observable<WebXRController>;
  40856. /**
  40857. * Event when a controller has been removed/disconnected
  40858. */
  40859. onControllerRemovedObservable: Observable<WebXRController>;
  40860. /**
  40861. * Initializes the WebXRInput
  40862. * @param helper experience helper which the input should be created for
  40863. */
  40864. constructor(helper: WebXRExperienceHelper);
  40865. private _onInputSourcesChange;
  40866. private _addAndRemoveControllers;
  40867. /**
  40868. * Disposes of the object
  40869. */
  40870. dispose(): void;
  40871. }
  40872. }
  40873. declare module BABYLON {
  40874. /**
  40875. * Contains an array of blocks representing the octree
  40876. */
  40877. export interface IOctreeContainer<T> {
  40878. /**
  40879. * Blocks within the octree
  40880. */
  40881. blocks: Array<OctreeBlock<T>>;
  40882. }
  40883. /**
  40884. * Class used to store a cell in an octree
  40885. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40886. */
  40887. export class OctreeBlock<T> {
  40888. /**
  40889. * Gets the content of the current block
  40890. */
  40891. entries: T[];
  40892. /**
  40893. * Gets the list of block children
  40894. */
  40895. blocks: Array<OctreeBlock<T>>;
  40896. private _depth;
  40897. private _maxDepth;
  40898. private _capacity;
  40899. private _minPoint;
  40900. private _maxPoint;
  40901. private _boundingVectors;
  40902. private _creationFunc;
  40903. /**
  40904. * Creates a new block
  40905. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  40906. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  40907. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40908. * @param depth defines the current depth of this block in the octree
  40909. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  40910. * @param creationFunc defines a callback to call when an element is added to the block
  40911. */
  40912. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  40913. /**
  40914. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40915. */
  40916. readonly capacity: number;
  40917. /**
  40918. * Gets the minimum vector (in world space) of the block's bounding box
  40919. */
  40920. readonly minPoint: Vector3;
  40921. /**
  40922. * Gets the maximum vector (in world space) of the block's bounding box
  40923. */
  40924. readonly maxPoint: Vector3;
  40925. /**
  40926. * Add a new element to this block
  40927. * @param entry defines the element to add
  40928. */
  40929. addEntry(entry: T): void;
  40930. /**
  40931. * Remove an element from this block
  40932. * @param entry defines the element to remove
  40933. */
  40934. removeEntry(entry: T): void;
  40935. /**
  40936. * Add an array of elements to this block
  40937. * @param entries defines the array of elements to add
  40938. */
  40939. addEntries(entries: T[]): void;
  40940. /**
  40941. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  40942. * @param frustumPlanes defines the frustum planes to test
  40943. * @param selection defines the array to store current content if selection is positive
  40944. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40945. */
  40946. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40947. /**
  40948. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  40949. * @param sphereCenter defines the bounding sphere center
  40950. * @param sphereRadius defines the bounding sphere radius
  40951. * @param selection defines the array to store current content if selection is positive
  40952. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40953. */
  40954. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40955. /**
  40956. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  40957. * @param ray defines the ray to test with
  40958. * @param selection defines the array to store current content if selection is positive
  40959. */
  40960. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  40961. /**
  40962. * Subdivide the content into child blocks (this block will then be empty)
  40963. */
  40964. createInnerBlocks(): void;
  40965. /**
  40966. * @hidden
  40967. */
  40968. 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;
  40969. }
  40970. }
  40971. declare module BABYLON {
  40972. /**
  40973. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  40974. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40975. */
  40976. export class Octree<T> {
  40977. /** 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.) */
  40978. maxDepth: number;
  40979. /**
  40980. * Blocks within the octree containing objects
  40981. */
  40982. blocks: Array<OctreeBlock<T>>;
  40983. /**
  40984. * Content stored in the octree
  40985. */
  40986. dynamicContent: T[];
  40987. private _maxBlockCapacity;
  40988. private _selectionContent;
  40989. private _creationFunc;
  40990. /**
  40991. * Creates a octree
  40992. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40993. * @param creationFunc function to be used to instatiate the octree
  40994. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  40995. * @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.)
  40996. */
  40997. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  40998. /** 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.) */
  40999. maxDepth?: number);
  41000. /**
  41001. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  41002. * @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);
  41003. * @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);
  41004. * @param entries meshes to be added to the octree blocks
  41005. */
  41006. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  41007. /**
  41008. * Adds a mesh to the octree
  41009. * @param entry Mesh to add to the octree
  41010. */
  41011. addMesh(entry: T): void;
  41012. /**
  41013. * Remove an element from the octree
  41014. * @param entry defines the element to remove
  41015. */
  41016. removeMesh(entry: T): void;
  41017. /**
  41018. * Selects an array of meshes within the frustum
  41019. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  41020. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  41021. * @returns array of meshes within the frustum
  41022. */
  41023. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  41024. /**
  41025. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  41026. * @param sphereCenter defines the bounding sphere center
  41027. * @param sphereRadius defines the bounding sphere radius
  41028. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41029. * @returns an array of objects that intersect the sphere
  41030. */
  41031. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  41032. /**
  41033. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  41034. * @param ray defines the ray to test with
  41035. * @returns array of intersected objects
  41036. */
  41037. intersectsRay(ray: Ray): SmartArray<T>;
  41038. /**
  41039. * Adds a mesh into the octree block if it intersects the block
  41040. */
  41041. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  41042. /**
  41043. * Adds a submesh into the octree block if it intersects the block
  41044. */
  41045. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  41046. }
  41047. }
  41048. declare module BABYLON {
  41049. interface Scene {
  41050. /**
  41051. * @hidden
  41052. * Backing Filed
  41053. */
  41054. _selectionOctree: Octree<AbstractMesh>;
  41055. /**
  41056. * Gets the octree used to boost mesh selection (picking)
  41057. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41058. */
  41059. selectionOctree: Octree<AbstractMesh>;
  41060. /**
  41061. * Creates or updates the octree used to boost selection (picking)
  41062. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41063. * @param maxCapacity defines the maximum capacity per leaf
  41064. * @param maxDepth defines the maximum depth of the octree
  41065. * @returns an octree of AbstractMesh
  41066. */
  41067. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  41068. }
  41069. interface AbstractMesh {
  41070. /**
  41071. * @hidden
  41072. * Backing Field
  41073. */
  41074. _submeshesOctree: Octree<SubMesh>;
  41075. /**
  41076. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  41077. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  41078. * @param maxCapacity defines the maximum size of each block (64 by default)
  41079. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  41080. * @returns the new octree
  41081. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  41082. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41083. */
  41084. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  41085. }
  41086. /**
  41087. * Defines the octree scene component responsible to manage any octrees
  41088. * in a given scene.
  41089. */
  41090. export class OctreeSceneComponent {
  41091. /**
  41092. * The component name help to identify the component in the list of scene components.
  41093. */
  41094. readonly name: string;
  41095. /**
  41096. * The scene the component belongs to.
  41097. */
  41098. scene: Scene;
  41099. /**
  41100. * Indicates if the meshes have been checked to make sure they are isEnabled()
  41101. */
  41102. readonly checksIsEnabled: boolean;
  41103. /**
  41104. * Creates a new instance of the component for the given scene
  41105. * @param scene Defines the scene to register the component in
  41106. */
  41107. constructor(scene: Scene);
  41108. /**
  41109. * Registers the component in a given scene
  41110. */
  41111. register(): void;
  41112. /**
  41113. * Return the list of active meshes
  41114. * @returns the list of active meshes
  41115. */
  41116. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41117. /**
  41118. * Return the list of active sub meshes
  41119. * @param mesh The mesh to get the candidates sub meshes from
  41120. * @returns the list of active sub meshes
  41121. */
  41122. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41123. private _tempRay;
  41124. /**
  41125. * Return the list of sub meshes intersecting with a given local ray
  41126. * @param mesh defines the mesh to find the submesh for
  41127. * @param localRay defines the ray in local space
  41128. * @returns the list of intersecting sub meshes
  41129. */
  41130. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  41131. /**
  41132. * Return the list of sub meshes colliding with a collider
  41133. * @param mesh defines the mesh to find the submesh for
  41134. * @param collider defines the collider to evaluate the collision against
  41135. * @returns the list of colliding sub meshes
  41136. */
  41137. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  41138. /**
  41139. * Rebuilds the elements related to this component in case of
  41140. * context lost for instance.
  41141. */
  41142. rebuild(): void;
  41143. /**
  41144. * Disposes the component and the associated ressources.
  41145. */
  41146. dispose(): void;
  41147. }
  41148. }
  41149. declare module BABYLON {
  41150. /**
  41151. * Renders a layer on top of an existing scene
  41152. */
  41153. export class UtilityLayerRenderer implements IDisposable {
  41154. /** the original scene that will be rendered on top of */
  41155. originalScene: Scene;
  41156. private _pointerCaptures;
  41157. private _lastPointerEvents;
  41158. private static _DefaultUtilityLayer;
  41159. private static _DefaultKeepDepthUtilityLayer;
  41160. private _sharedGizmoLight;
  41161. private _renderCamera;
  41162. /**
  41163. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  41164. * @returns the camera that is used when rendering the utility layer
  41165. */
  41166. getRenderCamera(): Nullable<Camera>;
  41167. /**
  41168. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  41169. * @param cam the camera that should be used when rendering the utility layer
  41170. */
  41171. setRenderCamera(cam: Nullable<Camera>): void;
  41172. /**
  41173. * @hidden
  41174. * Light which used by gizmos to get light shading
  41175. */
  41176. _getSharedGizmoLight(): HemisphericLight;
  41177. /**
  41178. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  41179. */
  41180. pickUtilitySceneFirst: boolean;
  41181. /**
  41182. * 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)
  41183. */
  41184. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  41185. /**
  41186. * 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)
  41187. */
  41188. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  41189. /**
  41190. * The scene that is rendered on top of the original scene
  41191. */
  41192. utilityLayerScene: Scene;
  41193. /**
  41194. * If the utility layer should automatically be rendered on top of existing scene
  41195. */
  41196. shouldRender: boolean;
  41197. /**
  41198. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  41199. */
  41200. onlyCheckPointerDownEvents: boolean;
  41201. /**
  41202. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  41203. */
  41204. processAllEvents: boolean;
  41205. /**
  41206. * Observable raised when the pointer move from the utility layer scene to the main scene
  41207. */
  41208. onPointerOutObservable: Observable<number>;
  41209. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  41210. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  41211. private _afterRenderObserver;
  41212. private _sceneDisposeObserver;
  41213. private _originalPointerObserver;
  41214. /**
  41215. * Instantiates a UtilityLayerRenderer
  41216. * @param originalScene the original scene that will be rendered on top of
  41217. * @param handleEvents boolean indicating if the utility layer should handle events
  41218. */
  41219. constructor(
  41220. /** the original scene that will be rendered on top of */
  41221. originalScene: Scene, handleEvents?: boolean);
  41222. private _notifyObservers;
  41223. /**
  41224. * Renders the utility layers scene on top of the original scene
  41225. */
  41226. render(): void;
  41227. /**
  41228. * Disposes of the renderer
  41229. */
  41230. dispose(): void;
  41231. private _updateCamera;
  41232. }
  41233. }
  41234. declare module BABYLON {
  41235. /**
  41236. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  41237. */
  41238. export class Gizmo implements IDisposable {
  41239. /** The utility layer the gizmo will be added to */
  41240. gizmoLayer: UtilityLayerRenderer;
  41241. /**
  41242. * The root mesh of the gizmo
  41243. */
  41244. _rootMesh: Mesh;
  41245. private _attachedMesh;
  41246. /**
  41247. * Ratio for the scale of the gizmo (Default: 1)
  41248. */
  41249. scaleRatio: number;
  41250. /**
  41251. * If a custom mesh has been set (Default: false)
  41252. */
  41253. protected _customMeshSet: boolean;
  41254. /**
  41255. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  41256. * * When set, interactions will be enabled
  41257. */
  41258. attachedMesh: Nullable<AbstractMesh>;
  41259. /**
  41260. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41261. * @param mesh The mesh to replace the default mesh of the gizmo
  41262. */
  41263. setCustomMesh(mesh: Mesh): void;
  41264. /**
  41265. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  41266. */
  41267. updateGizmoRotationToMatchAttachedMesh: boolean;
  41268. /**
  41269. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  41270. */
  41271. updateGizmoPositionToMatchAttachedMesh: boolean;
  41272. /**
  41273. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  41274. */
  41275. protected _updateScale: boolean;
  41276. protected _interactionsEnabled: boolean;
  41277. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41278. private _beforeRenderObserver;
  41279. private _tempVector;
  41280. /**
  41281. * Creates a gizmo
  41282. * @param gizmoLayer The utility layer the gizmo will be added to
  41283. */
  41284. constructor(
  41285. /** The utility layer the gizmo will be added to */
  41286. gizmoLayer?: UtilityLayerRenderer);
  41287. /**
  41288. * Updates the gizmo to match the attached mesh's position/rotation
  41289. */
  41290. protected _update(): void;
  41291. /**
  41292. * Disposes of the gizmo
  41293. */
  41294. dispose(): void;
  41295. }
  41296. }
  41297. declare module BABYLON {
  41298. /**
  41299. * Single plane drag gizmo
  41300. */
  41301. export class PlaneDragGizmo extends Gizmo {
  41302. /**
  41303. * Drag behavior responsible for the gizmos dragging interactions
  41304. */
  41305. dragBehavior: PointerDragBehavior;
  41306. private _pointerObserver;
  41307. /**
  41308. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41309. */
  41310. snapDistance: number;
  41311. /**
  41312. * Event that fires each time the gizmo snaps to a new location.
  41313. * * snapDistance is the the change in distance
  41314. */
  41315. onSnapObservable: Observable<{
  41316. snapDistance: number;
  41317. }>;
  41318. private _plane;
  41319. private _coloredMaterial;
  41320. private _hoverMaterial;
  41321. private _isEnabled;
  41322. private _parent;
  41323. /** @hidden */
  41324. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  41325. /** @hidden */
  41326. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  41327. /**
  41328. * Creates a PlaneDragGizmo
  41329. * @param gizmoLayer The utility layer the gizmo will be added to
  41330. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  41331. * @param color The color of the gizmo
  41332. */
  41333. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  41334. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41335. /**
  41336. * If the gizmo is enabled
  41337. */
  41338. isEnabled: boolean;
  41339. /**
  41340. * Disposes of the gizmo
  41341. */
  41342. dispose(): void;
  41343. }
  41344. }
  41345. declare module BABYLON {
  41346. /**
  41347. * Gizmo that enables dragging a mesh along 3 axis
  41348. */
  41349. export class PositionGizmo extends Gizmo {
  41350. /**
  41351. * Internal gizmo used for interactions on the x axis
  41352. */
  41353. xGizmo: AxisDragGizmo;
  41354. /**
  41355. * Internal gizmo used for interactions on the y axis
  41356. */
  41357. yGizmo: AxisDragGizmo;
  41358. /**
  41359. * Internal gizmo used for interactions on the z axis
  41360. */
  41361. zGizmo: AxisDragGizmo;
  41362. /**
  41363. * Internal gizmo used for interactions on the yz plane
  41364. */
  41365. xPlaneGizmo: PlaneDragGizmo;
  41366. /**
  41367. * Internal gizmo used for interactions on the xz plane
  41368. */
  41369. yPlaneGizmo: PlaneDragGizmo;
  41370. /**
  41371. * Internal gizmo used for interactions on the xy plane
  41372. */
  41373. zPlaneGizmo: PlaneDragGizmo;
  41374. /**
  41375. * private variables
  41376. */
  41377. private _meshAttached;
  41378. private _updateGizmoRotationToMatchAttachedMesh;
  41379. private _snapDistance;
  41380. private _scaleRatio;
  41381. /** Fires an event when any of it's sub gizmos are dragged */
  41382. onDragStartObservable: Observable<unknown>;
  41383. /** Fires an event when any of it's sub gizmos are released from dragging */
  41384. onDragEndObservable: Observable<unknown>;
  41385. /**
  41386. * If set to true, planar drag is enabled
  41387. */
  41388. private _planarGizmoEnabled;
  41389. attachedMesh: Nullable<AbstractMesh>;
  41390. /**
  41391. * Creates a PositionGizmo
  41392. * @param gizmoLayer The utility layer the gizmo will be added to
  41393. */
  41394. constructor(gizmoLayer?: UtilityLayerRenderer);
  41395. /**
  41396. * If the planar drag gizmo is enabled
  41397. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  41398. */
  41399. planarGizmoEnabled: boolean;
  41400. updateGizmoRotationToMatchAttachedMesh: boolean;
  41401. /**
  41402. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41403. */
  41404. snapDistance: number;
  41405. /**
  41406. * Ratio for the scale of the gizmo (Default: 1)
  41407. */
  41408. scaleRatio: number;
  41409. /**
  41410. * Disposes of the gizmo
  41411. */
  41412. dispose(): void;
  41413. /**
  41414. * CustomMeshes are not supported by this gizmo
  41415. * @param mesh The mesh to replace the default mesh of the gizmo
  41416. */
  41417. setCustomMesh(mesh: Mesh): void;
  41418. }
  41419. }
  41420. declare module BABYLON {
  41421. /**
  41422. * Single axis drag gizmo
  41423. */
  41424. export class AxisDragGizmo extends Gizmo {
  41425. /**
  41426. * Drag behavior responsible for the gizmos dragging interactions
  41427. */
  41428. dragBehavior: PointerDragBehavior;
  41429. private _pointerObserver;
  41430. /**
  41431. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41432. */
  41433. snapDistance: number;
  41434. /**
  41435. * Event that fires each time the gizmo snaps to a new location.
  41436. * * snapDistance is the the change in distance
  41437. */
  41438. onSnapObservable: Observable<{
  41439. snapDistance: number;
  41440. }>;
  41441. private _isEnabled;
  41442. private _parent;
  41443. private _arrow;
  41444. private _coloredMaterial;
  41445. private _hoverMaterial;
  41446. /** @hidden */
  41447. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  41448. /** @hidden */
  41449. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  41450. /**
  41451. * Creates an AxisDragGizmo
  41452. * @param gizmoLayer The utility layer the gizmo will be added to
  41453. * @param dragAxis The axis which the gizmo will be able to drag on
  41454. * @param color The color of the gizmo
  41455. */
  41456. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  41457. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41458. /**
  41459. * If the gizmo is enabled
  41460. */
  41461. isEnabled: boolean;
  41462. /**
  41463. * Disposes of the gizmo
  41464. */
  41465. dispose(): void;
  41466. }
  41467. }
  41468. declare module BABYLON.Debug {
  41469. /**
  41470. * The Axes viewer will show 3 axes in a specific point in space
  41471. */
  41472. export class AxesViewer {
  41473. private _xAxis;
  41474. private _yAxis;
  41475. private _zAxis;
  41476. private _scaleLinesFactor;
  41477. private _instanced;
  41478. /**
  41479. * Gets the hosting scene
  41480. */
  41481. scene: Scene;
  41482. /**
  41483. * Gets or sets a number used to scale line length
  41484. */
  41485. scaleLines: number;
  41486. /** Gets the node hierarchy used to render x-axis */
  41487. readonly xAxis: TransformNode;
  41488. /** Gets the node hierarchy used to render y-axis */
  41489. readonly yAxis: TransformNode;
  41490. /** Gets the node hierarchy used to render z-axis */
  41491. readonly zAxis: TransformNode;
  41492. /**
  41493. * Creates a new AxesViewer
  41494. * @param scene defines the hosting scene
  41495. * @param scaleLines defines a number used to scale line length (1 by default)
  41496. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  41497. * @param xAxis defines the node hierarchy used to render the x-axis
  41498. * @param yAxis defines the node hierarchy used to render the y-axis
  41499. * @param zAxis defines the node hierarchy used to render the z-axis
  41500. */
  41501. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  41502. /**
  41503. * Force the viewer to update
  41504. * @param position defines the position of the viewer
  41505. * @param xaxis defines the x axis of the viewer
  41506. * @param yaxis defines the y axis of the viewer
  41507. * @param zaxis defines the z axis of the viewer
  41508. */
  41509. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  41510. /**
  41511. * Creates an instance of this axes viewer.
  41512. * @returns a new axes viewer with instanced meshes
  41513. */
  41514. createInstance(): AxesViewer;
  41515. /** Releases resources */
  41516. dispose(): void;
  41517. private static _SetRenderingGroupId;
  41518. }
  41519. }
  41520. declare module BABYLON.Debug {
  41521. /**
  41522. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  41523. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  41524. */
  41525. export class BoneAxesViewer extends AxesViewer {
  41526. /**
  41527. * Gets or sets the target mesh where to display the axes viewer
  41528. */
  41529. mesh: Nullable<Mesh>;
  41530. /**
  41531. * Gets or sets the target bone where to display the axes viewer
  41532. */
  41533. bone: Nullable<Bone>;
  41534. /** Gets current position */
  41535. pos: Vector3;
  41536. /** Gets direction of X axis */
  41537. xaxis: Vector3;
  41538. /** Gets direction of Y axis */
  41539. yaxis: Vector3;
  41540. /** Gets direction of Z axis */
  41541. zaxis: Vector3;
  41542. /**
  41543. * Creates a new BoneAxesViewer
  41544. * @param scene defines the hosting scene
  41545. * @param bone defines the target bone
  41546. * @param mesh defines the target mesh
  41547. * @param scaleLines defines a scaling factor for line length (1 by default)
  41548. */
  41549. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  41550. /**
  41551. * Force the viewer to update
  41552. */
  41553. update(): void;
  41554. /** Releases resources */
  41555. dispose(): void;
  41556. }
  41557. }
  41558. declare module BABYLON {
  41559. /**
  41560. * Interface used to define scene explorer extensibility option
  41561. */
  41562. export interface IExplorerExtensibilityOption {
  41563. /**
  41564. * Define the option label
  41565. */
  41566. label: string;
  41567. /**
  41568. * Defines the action to execute on click
  41569. */
  41570. action: (entity: any) => void;
  41571. }
  41572. /**
  41573. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  41574. */
  41575. export interface IExplorerExtensibilityGroup {
  41576. /**
  41577. * Defines a predicate to test if a given type mut be extended
  41578. */
  41579. predicate: (entity: any) => boolean;
  41580. /**
  41581. * Gets the list of options added to a type
  41582. */
  41583. entries: IExplorerExtensibilityOption[];
  41584. }
  41585. /**
  41586. * Interface used to define the options to use to create the Inspector
  41587. */
  41588. export interface IInspectorOptions {
  41589. /**
  41590. * Display in overlay mode (default: false)
  41591. */
  41592. overlay?: boolean;
  41593. /**
  41594. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  41595. */
  41596. globalRoot?: HTMLElement;
  41597. /**
  41598. * Display the Scene explorer
  41599. */
  41600. showExplorer?: boolean;
  41601. /**
  41602. * Display the property inspector
  41603. */
  41604. showInspector?: boolean;
  41605. /**
  41606. * Display in embed mode (both panes on the right)
  41607. */
  41608. embedMode?: boolean;
  41609. /**
  41610. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  41611. */
  41612. handleResize?: boolean;
  41613. /**
  41614. * Allow the panes to popup (default: true)
  41615. */
  41616. enablePopup?: boolean;
  41617. /**
  41618. * Allow the panes to be closed by users (default: true)
  41619. */
  41620. enableClose?: boolean;
  41621. /**
  41622. * Optional list of extensibility entries
  41623. */
  41624. explorerExtensibility?: IExplorerExtensibilityGroup[];
  41625. /**
  41626. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  41627. */
  41628. inspectorURL?: string;
  41629. }
  41630. interface Scene {
  41631. /**
  41632. * @hidden
  41633. * Backing field
  41634. */
  41635. _debugLayer: DebugLayer;
  41636. /**
  41637. * Gets the debug layer (aka Inspector) associated with the scene
  41638. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41639. */
  41640. debugLayer: DebugLayer;
  41641. }
  41642. /**
  41643. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41644. * what is happening in your scene
  41645. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41646. */
  41647. export class DebugLayer {
  41648. /**
  41649. * Define the url to get the inspector script from.
  41650. * By default it uses the babylonjs CDN.
  41651. * @ignoreNaming
  41652. */
  41653. static InspectorURL: string;
  41654. private _scene;
  41655. private BJSINSPECTOR;
  41656. private _onPropertyChangedObservable?;
  41657. /**
  41658. * Observable triggered when a property is changed through the inspector.
  41659. */
  41660. readonly onPropertyChangedObservable: any;
  41661. /**
  41662. * Instantiates a new debug layer.
  41663. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41664. * what is happening in your scene
  41665. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41666. * @param scene Defines the scene to inspect
  41667. */
  41668. constructor(scene: Scene);
  41669. /** Creates the inspector window. */
  41670. private _createInspector;
  41671. /**
  41672. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  41673. * @param entity defines the entity to select
  41674. * @param lineContainerTitle defines the specific block to highlight
  41675. */
  41676. select(entity: any, lineContainerTitle?: string): void;
  41677. /** Get the inspector from bundle or global */
  41678. private _getGlobalInspector;
  41679. /**
  41680. * Get if the inspector is visible or not.
  41681. * @returns true if visible otherwise, false
  41682. */
  41683. isVisible(): boolean;
  41684. /**
  41685. * Hide the inspector and close its window.
  41686. */
  41687. hide(): void;
  41688. /**
  41689. * Launch the debugLayer.
  41690. * @param config Define the configuration of the inspector
  41691. * @return a promise fulfilled when the debug layer is visible
  41692. */
  41693. show(config?: IInspectorOptions): Promise<DebugLayer>;
  41694. }
  41695. }
  41696. declare module BABYLON {
  41697. /**
  41698. * Class containing static functions to help procedurally build meshes
  41699. */
  41700. export class BoxBuilder {
  41701. /**
  41702. * Creates a box mesh
  41703. * * The parameter `size` sets the size (float) of each box side (default 1)
  41704. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  41705. * * 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)
  41706. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  41707. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41708. * * 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
  41709. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41710. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  41711. * @param name defines the name of the mesh
  41712. * @param options defines the options used to create the mesh
  41713. * @param scene defines the hosting scene
  41714. * @returns the box mesh
  41715. */
  41716. static CreateBox(name: string, options: {
  41717. size?: number;
  41718. width?: number;
  41719. height?: number;
  41720. depth?: number;
  41721. faceUV?: Vector4[];
  41722. faceColors?: Color4[];
  41723. sideOrientation?: number;
  41724. frontUVs?: Vector4;
  41725. backUVs?: Vector4;
  41726. wrap?: boolean;
  41727. topBaseAt?: number;
  41728. bottomBaseAt?: number;
  41729. updatable?: boolean;
  41730. }, scene?: Nullable<Scene>): Mesh;
  41731. }
  41732. }
  41733. declare module BABYLON {
  41734. /**
  41735. * Class containing static functions to help procedurally build meshes
  41736. */
  41737. export class SphereBuilder {
  41738. /**
  41739. * Creates a sphere mesh
  41740. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  41741. * * 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`)
  41742. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  41743. * * 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
  41744. * * 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)
  41745. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41746. * * 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
  41747. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41748. * @param name defines the name of the mesh
  41749. * @param options defines the options used to create the mesh
  41750. * @param scene defines the hosting scene
  41751. * @returns the sphere mesh
  41752. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  41753. */
  41754. static CreateSphere(name: string, options: {
  41755. segments?: number;
  41756. diameter?: number;
  41757. diameterX?: number;
  41758. diameterY?: number;
  41759. diameterZ?: number;
  41760. arc?: number;
  41761. slice?: number;
  41762. sideOrientation?: number;
  41763. frontUVs?: Vector4;
  41764. backUVs?: Vector4;
  41765. updatable?: boolean;
  41766. }, scene: any): Mesh;
  41767. }
  41768. }
  41769. declare module BABYLON.Debug {
  41770. /**
  41771. * Used to show the physics impostor around the specific mesh
  41772. */
  41773. export class PhysicsViewer {
  41774. /** @hidden */
  41775. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  41776. /** @hidden */
  41777. protected _meshes: Array<Nullable<AbstractMesh>>;
  41778. /** @hidden */
  41779. protected _scene: Nullable<Scene>;
  41780. /** @hidden */
  41781. protected _numMeshes: number;
  41782. /** @hidden */
  41783. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  41784. private _renderFunction;
  41785. private _utilityLayer;
  41786. private _debugBoxMesh;
  41787. private _debugSphereMesh;
  41788. private _debugCylinderMesh;
  41789. private _debugMaterial;
  41790. private _debugMeshMeshes;
  41791. /**
  41792. * Creates a new PhysicsViewer
  41793. * @param scene defines the hosting scene
  41794. */
  41795. constructor(scene: Scene);
  41796. /** @hidden */
  41797. protected _updateDebugMeshes(): void;
  41798. /**
  41799. * Renders a specified physic impostor
  41800. * @param impostor defines the impostor to render
  41801. * @param targetMesh defines the mesh represented by the impostor
  41802. * @returns the new debug mesh used to render the impostor
  41803. */
  41804. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  41805. /**
  41806. * Hides a specified physic impostor
  41807. * @param impostor defines the impostor to hide
  41808. */
  41809. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  41810. private _getDebugMaterial;
  41811. private _getDebugBoxMesh;
  41812. private _getDebugSphereMesh;
  41813. private _getDebugCylinderMesh;
  41814. private _getDebugMeshMesh;
  41815. private _getDebugMesh;
  41816. /** Releases all resources */
  41817. dispose(): void;
  41818. }
  41819. }
  41820. declare module BABYLON {
  41821. /**
  41822. * Class containing static functions to help procedurally build meshes
  41823. */
  41824. export class LinesBuilder {
  41825. /**
  41826. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  41827. * * 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
  41828. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  41829. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  41830. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  41831. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  41832. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  41833. * * 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
  41834. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  41835. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41836. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  41837. * @param name defines the name of the new line system
  41838. * @param options defines the options used to create the line system
  41839. * @param scene defines the hosting scene
  41840. * @returns a new line system mesh
  41841. */
  41842. static CreateLineSystem(name: string, options: {
  41843. lines: Vector3[][];
  41844. updatable?: boolean;
  41845. instance?: Nullable<LinesMesh>;
  41846. colors?: Nullable<Color4[][]>;
  41847. useVertexAlpha?: boolean;
  41848. }, scene: Nullable<Scene>): LinesMesh;
  41849. /**
  41850. * Creates a line mesh
  41851. * 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
  41852. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41853. * * The parameter `points` is an array successive Vector3
  41854. * * 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
  41855. * * The optional parameter `colors` is an array of successive Color4, one per line point
  41856. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  41857. * * When updating an instance, remember that only point positions can change, not the number of points
  41858. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41859. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  41860. * @param name defines the name of the new line system
  41861. * @param options defines the options used to create the line system
  41862. * @param scene defines the hosting scene
  41863. * @returns a new line mesh
  41864. */
  41865. static CreateLines(name: string, options: {
  41866. points: Vector3[];
  41867. updatable?: boolean;
  41868. instance?: Nullable<LinesMesh>;
  41869. colors?: Color4[];
  41870. useVertexAlpha?: boolean;
  41871. }, scene?: Nullable<Scene>): LinesMesh;
  41872. /**
  41873. * Creates a dashed line mesh
  41874. * * 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
  41875. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41876. * * The parameter `points` is an array successive Vector3
  41877. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  41878. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  41879. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  41880. * * 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
  41881. * * When updating an instance, remember that only point positions can change, not the number of points
  41882. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41883. * @param name defines the name of the mesh
  41884. * @param options defines the options used to create the mesh
  41885. * @param scene defines the hosting scene
  41886. * @returns the dashed line mesh
  41887. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  41888. */
  41889. static CreateDashedLines(name: string, options: {
  41890. points: Vector3[];
  41891. dashSize?: number;
  41892. gapSize?: number;
  41893. dashNb?: number;
  41894. updatable?: boolean;
  41895. instance?: LinesMesh;
  41896. }, scene?: Nullable<Scene>): LinesMesh;
  41897. }
  41898. }
  41899. declare module BABYLON {
  41900. /**
  41901. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41902. * in order to better appreciate the issue one might have.
  41903. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41904. */
  41905. export class RayHelper {
  41906. /**
  41907. * Defines the ray we are currently tryin to visualize.
  41908. */
  41909. ray: Nullable<Ray>;
  41910. private _renderPoints;
  41911. private _renderLine;
  41912. private _renderFunction;
  41913. private _scene;
  41914. private _updateToMeshFunction;
  41915. private _attachedToMesh;
  41916. private _meshSpaceDirection;
  41917. private _meshSpaceOrigin;
  41918. /**
  41919. * Helper function to create a colored helper in a scene in one line.
  41920. * @param ray Defines the ray we are currently tryin to visualize
  41921. * @param scene Defines the scene the ray is used in
  41922. * @param color Defines the color we want to see the ray in
  41923. * @returns The newly created ray helper.
  41924. */
  41925. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  41926. /**
  41927. * Instantiate a new ray helper.
  41928. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41929. * in order to better appreciate the issue one might have.
  41930. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41931. * @param ray Defines the ray we are currently tryin to visualize
  41932. */
  41933. constructor(ray: Ray);
  41934. /**
  41935. * Shows the ray we are willing to debug.
  41936. * @param scene Defines the scene the ray needs to be rendered in
  41937. * @param color Defines the color the ray needs to be rendered in
  41938. */
  41939. show(scene: Scene, color?: Color3): void;
  41940. /**
  41941. * Hides the ray we are debugging.
  41942. */
  41943. hide(): void;
  41944. private _render;
  41945. /**
  41946. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  41947. * @param mesh Defines the mesh we want the helper attached to
  41948. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  41949. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  41950. * @param length Defines the length of the ray
  41951. */
  41952. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  41953. /**
  41954. * Detach the ray helper from the mesh it has previously been attached to.
  41955. */
  41956. detachFromMesh(): void;
  41957. private _updateToMesh;
  41958. /**
  41959. * Dispose the helper and release its associated resources.
  41960. */
  41961. dispose(): void;
  41962. }
  41963. }
  41964. declare module BABYLON.Debug {
  41965. /**
  41966. * Class used to render a debug view of a given skeleton
  41967. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  41968. */
  41969. export class SkeletonViewer {
  41970. /** defines the skeleton to render */
  41971. skeleton: Skeleton;
  41972. /** defines the mesh attached to the skeleton */
  41973. mesh: AbstractMesh;
  41974. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41975. autoUpdateBonesMatrices: boolean;
  41976. /** defines the rendering group id to use with the viewer */
  41977. renderingGroupId: number;
  41978. /** Gets or sets the color used to render the skeleton */
  41979. color: Color3;
  41980. private _scene;
  41981. private _debugLines;
  41982. private _debugMesh;
  41983. private _isEnabled;
  41984. private _renderFunction;
  41985. private _utilityLayer;
  41986. /**
  41987. * Returns the mesh used to render the bones
  41988. */
  41989. readonly debugMesh: Nullable<LinesMesh>;
  41990. /**
  41991. * Creates a new SkeletonViewer
  41992. * @param skeleton defines the skeleton to render
  41993. * @param mesh defines the mesh attached to the skeleton
  41994. * @param scene defines the hosting scene
  41995. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  41996. * @param renderingGroupId defines the rendering group id to use with the viewer
  41997. */
  41998. constructor(
  41999. /** defines the skeleton to render */
  42000. skeleton: Skeleton,
  42001. /** defines the mesh attached to the skeleton */
  42002. mesh: AbstractMesh, scene: Scene,
  42003. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42004. autoUpdateBonesMatrices?: boolean,
  42005. /** defines the rendering group id to use with the viewer */
  42006. renderingGroupId?: number);
  42007. /** Gets or sets a boolean indicating if the viewer is enabled */
  42008. isEnabled: boolean;
  42009. private _getBonePosition;
  42010. private _getLinesForBonesWithLength;
  42011. private _getLinesForBonesNoLength;
  42012. /** Update the viewer to sync with current skeleton state */
  42013. update(): void;
  42014. /** Release associated resources */
  42015. dispose(): void;
  42016. }
  42017. }
  42018. declare module BABYLON {
  42019. /**
  42020. * Options to create the null engine
  42021. */
  42022. export class NullEngineOptions {
  42023. /**
  42024. * Render width (Default: 512)
  42025. */
  42026. renderWidth: number;
  42027. /**
  42028. * Render height (Default: 256)
  42029. */
  42030. renderHeight: number;
  42031. /**
  42032. * Texture size (Default: 512)
  42033. */
  42034. textureSize: number;
  42035. /**
  42036. * If delta time between frames should be constant
  42037. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42038. */
  42039. deterministicLockstep: boolean;
  42040. /**
  42041. * Maximum about of steps between frames (Default: 4)
  42042. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42043. */
  42044. lockstepMaxSteps: number;
  42045. }
  42046. /**
  42047. * The null engine class provides support for headless version of babylon.js.
  42048. * This can be used in server side scenario or for testing purposes
  42049. */
  42050. export class NullEngine extends Engine {
  42051. private _options;
  42052. /**
  42053. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42054. */
  42055. isDeterministicLockStep(): boolean;
  42056. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  42057. getLockstepMaxSteps(): number;
  42058. /**
  42059. * Sets hardware scaling, used to save performance if needed
  42060. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  42061. */
  42062. getHardwareScalingLevel(): number;
  42063. constructor(options?: NullEngineOptions);
  42064. createVertexBuffer(vertices: FloatArray): DataBuffer;
  42065. createIndexBuffer(indices: IndicesArray): DataBuffer;
  42066. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  42067. getRenderWidth(useScreen?: boolean): number;
  42068. getRenderHeight(useScreen?: boolean): number;
  42069. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  42070. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  42071. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  42072. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  42073. bindSamplers(effect: Effect): void;
  42074. enableEffect(effect: Effect): void;
  42075. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42076. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  42077. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  42078. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  42079. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  42080. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  42081. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  42082. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  42083. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  42084. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  42085. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  42086. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  42087. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  42088. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  42089. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  42090. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42091. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42092. setFloat(uniform: WebGLUniformLocation, value: number): void;
  42093. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  42094. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  42095. setBool(uniform: WebGLUniformLocation, bool: number): void;
  42096. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  42097. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  42098. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  42099. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  42100. bindBuffers(vertexBuffers: {
  42101. [key: string]: VertexBuffer;
  42102. }, indexBuffer: DataBuffer, effect: Effect): void;
  42103. wipeCaches(bruteForce?: boolean): void;
  42104. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  42105. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  42106. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  42107. /** @hidden */
  42108. _createTexture(): WebGLTexture;
  42109. /** @hidden */
  42110. _releaseTexture(texture: InternalTexture): void;
  42111. 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;
  42112. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  42113. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  42114. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  42115. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  42116. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  42117. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  42118. areAllEffectsReady(): boolean;
  42119. /**
  42120. * @hidden
  42121. * Get the current error code of the webGL context
  42122. * @returns the error code
  42123. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  42124. */
  42125. getError(): number;
  42126. /** @hidden */
  42127. _getUnpackAlignement(): number;
  42128. /** @hidden */
  42129. _unpackFlipY(value: boolean): void;
  42130. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  42131. /**
  42132. * Updates a dynamic vertex buffer.
  42133. * @param vertexBuffer the vertex buffer to update
  42134. * @param data the data used to update the vertex buffer
  42135. * @param byteOffset the byte offset of the data (optional)
  42136. * @param byteLength the byte length of the data (optional)
  42137. */
  42138. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  42139. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  42140. /** @hidden */
  42141. _bindTexture(channel: number, texture: InternalTexture): void;
  42142. /** @hidden */
  42143. _releaseBuffer(buffer: DataBuffer): boolean;
  42144. releaseEffects(): void;
  42145. displayLoadingUI(): void;
  42146. hideLoadingUI(): void;
  42147. /** @hidden */
  42148. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42149. /** @hidden */
  42150. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42151. /** @hidden */
  42152. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42153. /** @hidden */
  42154. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  42155. }
  42156. }
  42157. declare module BABYLON {
  42158. /** @hidden */
  42159. export class _OcclusionDataStorage {
  42160. /** @hidden */
  42161. occlusionInternalRetryCounter: number;
  42162. /** @hidden */
  42163. isOcclusionQueryInProgress: boolean;
  42164. /** @hidden */
  42165. isOccluded: boolean;
  42166. /** @hidden */
  42167. occlusionRetryCount: number;
  42168. /** @hidden */
  42169. occlusionType: number;
  42170. /** @hidden */
  42171. occlusionQueryAlgorithmType: number;
  42172. }
  42173. interface Engine {
  42174. /**
  42175. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  42176. * @return the new query
  42177. */
  42178. createQuery(): WebGLQuery;
  42179. /**
  42180. * Delete and release a webGL query
  42181. * @param query defines the query to delete
  42182. * @return the current engine
  42183. */
  42184. deleteQuery(query: WebGLQuery): Engine;
  42185. /**
  42186. * Check if a given query has resolved and got its value
  42187. * @param query defines the query to check
  42188. * @returns true if the query got its value
  42189. */
  42190. isQueryResultAvailable(query: WebGLQuery): boolean;
  42191. /**
  42192. * Gets the value of a given query
  42193. * @param query defines the query to check
  42194. * @returns the value of the query
  42195. */
  42196. getQueryResult(query: WebGLQuery): number;
  42197. /**
  42198. * Initiates an occlusion query
  42199. * @param algorithmType defines the algorithm to use
  42200. * @param query defines the query to use
  42201. * @returns the current engine
  42202. * @see http://doc.babylonjs.com/features/occlusionquery
  42203. */
  42204. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  42205. /**
  42206. * Ends an occlusion query
  42207. * @see http://doc.babylonjs.com/features/occlusionquery
  42208. * @param algorithmType defines the algorithm to use
  42209. * @returns the current engine
  42210. */
  42211. endOcclusionQuery(algorithmType: number): Engine;
  42212. /**
  42213. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  42214. * Please note that only one query can be issued at a time
  42215. * @returns a time token used to track the time span
  42216. */
  42217. startTimeQuery(): Nullable<_TimeToken>;
  42218. /**
  42219. * Ends a time query
  42220. * @param token defines the token used to measure the time span
  42221. * @returns the time spent (in ns)
  42222. */
  42223. endTimeQuery(token: _TimeToken): int;
  42224. /** @hidden */
  42225. _currentNonTimestampToken: Nullable<_TimeToken>;
  42226. /** @hidden */
  42227. _createTimeQuery(): WebGLQuery;
  42228. /** @hidden */
  42229. _deleteTimeQuery(query: WebGLQuery): void;
  42230. /** @hidden */
  42231. _getGlAlgorithmType(algorithmType: number): number;
  42232. /** @hidden */
  42233. _getTimeQueryResult(query: WebGLQuery): any;
  42234. /** @hidden */
  42235. _getTimeQueryAvailability(query: WebGLQuery): any;
  42236. }
  42237. interface AbstractMesh {
  42238. /**
  42239. * Backing filed
  42240. * @hidden
  42241. */
  42242. __occlusionDataStorage: _OcclusionDataStorage;
  42243. /**
  42244. * Access property
  42245. * @hidden
  42246. */
  42247. _occlusionDataStorage: _OcclusionDataStorage;
  42248. /**
  42249. * 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.
  42250. * The default value is -1 which means don't break the query and wait till the result
  42251. * @see http://doc.babylonjs.com/features/occlusionquery
  42252. */
  42253. occlusionRetryCount: number;
  42254. /**
  42255. * 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:
  42256. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  42257. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  42258. * * 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.
  42259. * @see http://doc.babylonjs.com/features/occlusionquery
  42260. */
  42261. occlusionType: number;
  42262. /**
  42263. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  42264. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  42265. * * 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.
  42266. * @see http://doc.babylonjs.com/features/occlusionquery
  42267. */
  42268. occlusionQueryAlgorithmType: number;
  42269. /**
  42270. * 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
  42271. * @see http://doc.babylonjs.com/features/occlusionquery
  42272. */
  42273. isOccluded: boolean;
  42274. /**
  42275. * Flag to check the progress status of the query
  42276. * @see http://doc.babylonjs.com/features/occlusionquery
  42277. */
  42278. isOcclusionQueryInProgress: boolean;
  42279. }
  42280. }
  42281. declare module BABYLON {
  42282. /** @hidden */
  42283. export var _forceTransformFeedbackToBundle: boolean;
  42284. interface Engine {
  42285. /**
  42286. * Creates a webGL transform feedback object
  42287. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  42288. * @returns the webGL transform feedback object
  42289. */
  42290. createTransformFeedback(): WebGLTransformFeedback;
  42291. /**
  42292. * Delete a webGL transform feedback object
  42293. * @param value defines the webGL transform feedback object to delete
  42294. */
  42295. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  42296. /**
  42297. * Bind a webGL transform feedback object to the webgl context
  42298. * @param value defines the webGL transform feedback object to bind
  42299. */
  42300. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  42301. /**
  42302. * Begins a transform feedback operation
  42303. * @param usePoints defines if points or triangles must be used
  42304. */
  42305. beginTransformFeedback(usePoints: boolean): void;
  42306. /**
  42307. * Ends a transform feedback operation
  42308. */
  42309. endTransformFeedback(): void;
  42310. /**
  42311. * Specify the varyings to use with transform feedback
  42312. * @param program defines the associated webGL program
  42313. * @param value defines the list of strings representing the varying names
  42314. */
  42315. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  42316. /**
  42317. * Bind a webGL buffer for a transform feedback operation
  42318. * @param value defines the webGL buffer to bind
  42319. */
  42320. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  42321. }
  42322. }
  42323. declare module BABYLON {
  42324. /**
  42325. * Creation options of the multi render target texture.
  42326. */
  42327. export interface IMultiRenderTargetOptions {
  42328. /**
  42329. * Define if the texture needs to create mip maps after render.
  42330. */
  42331. generateMipMaps?: boolean;
  42332. /**
  42333. * Define the types of all the draw buffers we want to create
  42334. */
  42335. types?: number[];
  42336. /**
  42337. * Define the sampling modes of all the draw buffers we want to create
  42338. */
  42339. samplingModes?: number[];
  42340. /**
  42341. * Define if a depth buffer is required
  42342. */
  42343. generateDepthBuffer?: boolean;
  42344. /**
  42345. * Define if a stencil buffer is required
  42346. */
  42347. generateStencilBuffer?: boolean;
  42348. /**
  42349. * Define if a depth texture is required instead of a depth buffer
  42350. */
  42351. generateDepthTexture?: boolean;
  42352. /**
  42353. * Define the number of desired draw buffers
  42354. */
  42355. textureCount?: number;
  42356. /**
  42357. * Define if aspect ratio should be adapted to the texture or stay the scene one
  42358. */
  42359. doNotChangeAspectRatio?: boolean;
  42360. /**
  42361. * Define the default type of the buffers we are creating
  42362. */
  42363. defaultType?: number;
  42364. }
  42365. /**
  42366. * A multi render target, like a render target provides the ability to render to a texture.
  42367. * Unlike the render target, it can render to several draw buffers in one draw.
  42368. * This is specially interesting in deferred rendering or for any effects requiring more than
  42369. * just one color from a single pass.
  42370. */
  42371. export class MultiRenderTarget extends RenderTargetTexture {
  42372. private _internalTextures;
  42373. private _textures;
  42374. private _multiRenderTargetOptions;
  42375. /**
  42376. * Get if draw buffers are currently supported by the used hardware and browser.
  42377. */
  42378. readonly isSupported: boolean;
  42379. /**
  42380. * Get the list of textures generated by the multi render target.
  42381. */
  42382. readonly textures: Texture[];
  42383. /**
  42384. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  42385. */
  42386. readonly depthTexture: Texture;
  42387. /**
  42388. * Set the wrapping mode on U of all the textures we are rendering to.
  42389. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  42390. */
  42391. wrapU: number;
  42392. /**
  42393. * Set the wrapping mode on V of all the textures we are rendering to.
  42394. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  42395. */
  42396. wrapV: number;
  42397. /**
  42398. * Instantiate a new multi render target texture.
  42399. * A multi render target, like a render target provides the ability to render to a texture.
  42400. * Unlike the render target, it can render to several draw buffers in one draw.
  42401. * This is specially interesting in deferred rendering or for any effects requiring more than
  42402. * just one color from a single pass.
  42403. * @param name Define the name of the texture
  42404. * @param size Define the size of the buffers to render to
  42405. * @param count Define the number of target we are rendering into
  42406. * @param scene Define the scene the texture belongs to
  42407. * @param options Define the options used to create the multi render target
  42408. */
  42409. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  42410. /** @hidden */
  42411. _rebuild(): void;
  42412. private _createInternalTextures;
  42413. private _createTextures;
  42414. /**
  42415. * Define the number of samples used if MSAA is enabled.
  42416. */
  42417. samples: number;
  42418. /**
  42419. * Resize all the textures in the multi render target.
  42420. * Be carrefull as it will recreate all the data in the new texture.
  42421. * @param size Define the new size
  42422. */
  42423. resize(size: any): void;
  42424. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  42425. /**
  42426. * Dispose the render targets and their associated resources
  42427. */
  42428. dispose(): void;
  42429. /**
  42430. * Release all the underlying texture used as draw buffers.
  42431. */
  42432. releaseInternalTextures(): void;
  42433. }
  42434. }
  42435. declare module BABYLON {
  42436. interface Engine {
  42437. /**
  42438. * Unbind a list of render target textures from the webGL context
  42439. * This is used only when drawBuffer extension or webGL2 are active
  42440. * @param textures defines the render target textures to unbind
  42441. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  42442. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  42443. */
  42444. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  42445. /**
  42446. * Create a multi render target texture
  42447. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  42448. * @param size defines the size of the texture
  42449. * @param options defines the creation options
  42450. * @returns the cube texture as an InternalTexture
  42451. */
  42452. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  42453. /**
  42454. * Update the sample count for a given multiple render target texture
  42455. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  42456. * @param textures defines the textures to update
  42457. * @param samples defines the sample count to set
  42458. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  42459. */
  42460. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  42461. }
  42462. }
  42463. declare module BABYLON {
  42464. /**
  42465. * Gather the list of clipboard event types as constants.
  42466. */
  42467. export class ClipboardEventTypes {
  42468. /**
  42469. * The clipboard event is fired when a copy command is active (pressed).
  42470. */
  42471. static readonly COPY: number;
  42472. /**
  42473. * The clipboard event is fired when a cut command is active (pressed).
  42474. */
  42475. static readonly CUT: number;
  42476. /**
  42477. * The clipboard event is fired when a paste command is active (pressed).
  42478. */
  42479. static readonly PASTE: number;
  42480. }
  42481. /**
  42482. * This class is used to store clipboard related info for the onClipboardObservable event.
  42483. */
  42484. export class ClipboardInfo {
  42485. /**
  42486. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42487. */
  42488. type: number;
  42489. /**
  42490. * Defines the related dom event
  42491. */
  42492. event: ClipboardEvent;
  42493. /**
  42494. *Creates an instance of ClipboardInfo.
  42495. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  42496. * @param event Defines the related dom event
  42497. */
  42498. constructor(
  42499. /**
  42500. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42501. */
  42502. type: number,
  42503. /**
  42504. * Defines the related dom event
  42505. */
  42506. event: ClipboardEvent);
  42507. /**
  42508. * Get the clipboard event's type from the keycode.
  42509. * @param keyCode Defines the keyCode for the current keyboard event.
  42510. * @return {number}
  42511. */
  42512. static GetTypeFromCharacter(keyCode: number): number;
  42513. }
  42514. }
  42515. declare module BABYLON {
  42516. /**
  42517. * Class used to represent data loading progression
  42518. */
  42519. export class SceneLoaderProgressEvent {
  42520. /** defines if data length to load can be evaluated */
  42521. readonly lengthComputable: boolean;
  42522. /** defines the loaded data length */
  42523. readonly loaded: number;
  42524. /** defines the data length to load */
  42525. readonly total: number;
  42526. /**
  42527. * Create a new progress event
  42528. * @param lengthComputable defines if data length to load can be evaluated
  42529. * @param loaded defines the loaded data length
  42530. * @param total defines the data length to load
  42531. */
  42532. constructor(
  42533. /** defines if data length to load can be evaluated */
  42534. lengthComputable: boolean,
  42535. /** defines the loaded data length */
  42536. loaded: number,
  42537. /** defines the data length to load */
  42538. total: number);
  42539. /**
  42540. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42541. * @param event defines the source event
  42542. * @returns a new SceneLoaderProgressEvent
  42543. */
  42544. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42545. }
  42546. /**
  42547. * Interface used by SceneLoader plugins to define supported file extensions
  42548. */
  42549. export interface ISceneLoaderPluginExtensions {
  42550. /**
  42551. * Defines the list of supported extensions
  42552. */
  42553. [extension: string]: {
  42554. isBinary: boolean;
  42555. };
  42556. }
  42557. /**
  42558. * Interface used by SceneLoader plugin factory
  42559. */
  42560. export interface ISceneLoaderPluginFactory {
  42561. /**
  42562. * Defines the name of the factory
  42563. */
  42564. name: string;
  42565. /**
  42566. * Function called to create a new plugin
  42567. * @return the new plugin
  42568. */
  42569. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42570. /**
  42571. * Boolean indicating if the plugin can direct load specific data
  42572. */
  42573. canDirectLoad?: (data: string) => boolean;
  42574. }
  42575. /**
  42576. * Interface used to define a SceneLoader plugin
  42577. */
  42578. export interface ISceneLoaderPlugin {
  42579. /**
  42580. * The friendly name of this plugin.
  42581. */
  42582. name: string;
  42583. /**
  42584. * The file extensions supported by this plugin.
  42585. */
  42586. extensions: string | ISceneLoaderPluginExtensions;
  42587. /**
  42588. * Import meshes into a scene.
  42589. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42590. * @param scene The scene to import into
  42591. * @param data The data to import
  42592. * @param rootUrl The root url for scene and resources
  42593. * @param meshes The meshes array to import into
  42594. * @param particleSystems The particle systems array to import into
  42595. * @param skeletons The skeletons array to import into
  42596. * @param onError The callback when import fails
  42597. * @returns True if successful or false otherwise
  42598. */
  42599. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  42600. /**
  42601. * Load into a scene.
  42602. * @param scene The scene to load into
  42603. * @param data The data to import
  42604. * @param rootUrl The root url for scene and resources
  42605. * @param onError The callback when import fails
  42606. * @returns true if successful or false otherwise
  42607. */
  42608. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  42609. /**
  42610. * The callback that returns true if the data can be directly loaded.
  42611. */
  42612. canDirectLoad?: (data: string) => boolean;
  42613. /**
  42614. * The callback that allows custom handling of the root url based on the response url.
  42615. */
  42616. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42617. /**
  42618. * Load into an asset container.
  42619. * @param scene The scene to load into
  42620. * @param data The data to import
  42621. * @param rootUrl The root url for scene and resources
  42622. * @param onError The callback when import fails
  42623. * @returns The loaded asset container
  42624. */
  42625. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  42626. }
  42627. /**
  42628. * Interface used to define an async SceneLoader plugin
  42629. */
  42630. export interface ISceneLoaderPluginAsync {
  42631. /**
  42632. * The friendly name of this plugin.
  42633. */
  42634. name: string;
  42635. /**
  42636. * The file extensions supported by this plugin.
  42637. */
  42638. extensions: string | ISceneLoaderPluginExtensions;
  42639. /**
  42640. * Import meshes into a scene.
  42641. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42642. * @param scene The scene to import into
  42643. * @param data The data to import
  42644. * @param rootUrl The root url for scene and resources
  42645. * @param onProgress The callback when the load progresses
  42646. * @param fileName Defines the name of the file to load
  42647. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42648. */
  42649. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42650. meshes: AbstractMesh[];
  42651. particleSystems: IParticleSystem[];
  42652. skeletons: Skeleton[];
  42653. animationGroups: AnimationGroup[];
  42654. }>;
  42655. /**
  42656. * Load into a scene.
  42657. * @param scene The scene to load into
  42658. * @param data The data to import
  42659. * @param rootUrl The root url for scene and resources
  42660. * @param onProgress The callback when the load progresses
  42661. * @param fileName Defines the name of the file to load
  42662. * @returns Nothing
  42663. */
  42664. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42665. /**
  42666. * The callback that returns true if the data can be directly loaded.
  42667. */
  42668. canDirectLoad?: (data: string) => boolean;
  42669. /**
  42670. * The callback that allows custom handling of the root url based on the response url.
  42671. */
  42672. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42673. /**
  42674. * Load into an asset container.
  42675. * @param scene The scene to load into
  42676. * @param data The data to import
  42677. * @param rootUrl The root url for scene and resources
  42678. * @param onProgress The callback when the load progresses
  42679. * @param fileName Defines the name of the file to load
  42680. * @returns The loaded asset container
  42681. */
  42682. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42683. }
  42684. /**
  42685. * Class used to load scene from various file formats using registered plugins
  42686. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42687. */
  42688. export class SceneLoader {
  42689. /**
  42690. * No logging while loading
  42691. */
  42692. static readonly NO_LOGGING: number;
  42693. /**
  42694. * Minimal logging while loading
  42695. */
  42696. static readonly MINIMAL_LOGGING: number;
  42697. /**
  42698. * Summary logging while loading
  42699. */
  42700. static readonly SUMMARY_LOGGING: number;
  42701. /**
  42702. * Detailled logging while loading
  42703. */
  42704. static readonly DETAILED_LOGGING: number;
  42705. /**
  42706. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42707. */
  42708. static ForceFullSceneLoadingForIncremental: boolean;
  42709. /**
  42710. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42711. */
  42712. static ShowLoadingScreen: boolean;
  42713. /**
  42714. * Defines the current logging level (while loading the scene)
  42715. * @ignorenaming
  42716. */
  42717. static loggingLevel: number;
  42718. /**
  42719. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42720. */
  42721. static CleanBoneMatrixWeights: boolean;
  42722. /**
  42723. * Event raised when a plugin is used to load a scene
  42724. */
  42725. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42726. private static _registeredPlugins;
  42727. private static _getDefaultPlugin;
  42728. private static _getPluginForExtension;
  42729. private static _getPluginForDirectLoad;
  42730. private static _getPluginForFilename;
  42731. private static _getDirectLoad;
  42732. private static _loadData;
  42733. private static _getFileInfo;
  42734. /**
  42735. * Gets a plugin that can load the given extension
  42736. * @param extension defines the extension to load
  42737. * @returns a plugin or null if none works
  42738. */
  42739. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42740. /**
  42741. * Gets a boolean indicating that the given extension can be loaded
  42742. * @param extension defines the extension to load
  42743. * @returns true if the extension is supported
  42744. */
  42745. static IsPluginForExtensionAvailable(extension: string): boolean;
  42746. /**
  42747. * Adds a new plugin to the list of registered plugins
  42748. * @param plugin defines the plugin to add
  42749. */
  42750. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42751. /**
  42752. * Import meshes into a scene
  42753. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42754. * @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)
  42755. * @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)
  42756. * @param scene the instance of BABYLON.Scene to append to
  42757. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42758. * @param onProgress a callback with a progress event for each file being loaded
  42759. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42760. * @param pluginExtension the extension used to determine the plugin
  42761. * @returns The loaded plugin
  42762. */
  42763. 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>;
  42764. /**
  42765. * Import meshes into a scene
  42766. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42767. * @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)
  42768. * @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)
  42769. * @param scene the instance of BABYLON.Scene to append to
  42770. * @param onProgress a callback with a progress event for each file being loaded
  42771. * @param pluginExtension the extension used to determine the plugin
  42772. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42773. */
  42774. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42775. meshes: AbstractMesh[];
  42776. particleSystems: IParticleSystem[];
  42777. skeletons: Skeleton[];
  42778. animationGroups: AnimationGroup[];
  42779. }>;
  42780. /**
  42781. * Load a scene
  42782. * @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)
  42783. * @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)
  42784. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42785. * @param onSuccess a callback with the scene when import succeeds
  42786. * @param onProgress a callback with a progress event for each file being loaded
  42787. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42788. * @param pluginExtension the extension used to determine the plugin
  42789. * @returns The loaded plugin
  42790. */
  42791. 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>;
  42792. /**
  42793. * Load a scene
  42794. * @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)
  42795. * @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)
  42796. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42797. * @param onProgress a callback with a progress event for each file being loaded
  42798. * @param pluginExtension the extension used to determine the plugin
  42799. * @returns The loaded scene
  42800. */
  42801. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42802. /**
  42803. * Append a scene
  42804. * @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)
  42805. * @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)
  42806. * @param scene is the instance of BABYLON.Scene to append to
  42807. * @param onSuccess a callback with the scene when import succeeds
  42808. * @param onProgress a callback with a progress event for each file being loaded
  42809. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42810. * @param pluginExtension the extension used to determine the plugin
  42811. * @returns The loaded plugin
  42812. */
  42813. 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>;
  42814. /**
  42815. * Append a scene
  42816. * @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)
  42817. * @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)
  42818. * @param scene is the instance of BABYLON.Scene to append to
  42819. * @param onProgress a callback with a progress event for each file being loaded
  42820. * @param pluginExtension the extension used to determine the plugin
  42821. * @returns The given scene
  42822. */
  42823. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42824. /**
  42825. * Load a scene into an asset container
  42826. * @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)
  42827. * @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)
  42828. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42829. * @param onSuccess a callback with the scene when import succeeds
  42830. * @param onProgress a callback with a progress event for each file being loaded
  42831. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42832. * @param pluginExtension the extension used to determine the plugin
  42833. * @returns The loaded plugin
  42834. */
  42835. 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>;
  42836. /**
  42837. * Load a scene into an asset container
  42838. * @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)
  42839. * @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)
  42840. * @param scene is the instance of Scene to append to
  42841. * @param onProgress a callback with a progress event for each file being loaded
  42842. * @param pluginExtension the extension used to determine the plugin
  42843. * @returns The loaded asset container
  42844. */
  42845. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42846. }
  42847. }
  42848. declare module BABYLON {
  42849. /**
  42850. * Google Daydream controller
  42851. */
  42852. export class DaydreamController extends WebVRController {
  42853. /**
  42854. * Base Url for the controller model.
  42855. */
  42856. static MODEL_BASE_URL: string;
  42857. /**
  42858. * File name for the controller model.
  42859. */
  42860. static MODEL_FILENAME: string;
  42861. /**
  42862. * Gamepad Id prefix used to identify Daydream Controller.
  42863. */
  42864. static readonly GAMEPAD_ID_PREFIX: string;
  42865. /**
  42866. * Creates a new DaydreamController from a gamepad
  42867. * @param vrGamepad the gamepad that the controller should be created from
  42868. */
  42869. constructor(vrGamepad: any);
  42870. /**
  42871. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42872. * @param scene scene in which to add meshes
  42873. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42874. */
  42875. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42876. /**
  42877. * Called once for each button that changed state since the last frame
  42878. * @param buttonIdx Which button index changed
  42879. * @param state New state of the button
  42880. * @param changes Which properties on the state changed since last frame
  42881. */
  42882. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42883. }
  42884. }
  42885. declare module BABYLON {
  42886. /**
  42887. * Gear VR Controller
  42888. */
  42889. export class GearVRController extends WebVRController {
  42890. /**
  42891. * Base Url for the controller model.
  42892. */
  42893. static MODEL_BASE_URL: string;
  42894. /**
  42895. * File name for the controller model.
  42896. */
  42897. static MODEL_FILENAME: string;
  42898. /**
  42899. * Gamepad Id prefix used to identify this controller.
  42900. */
  42901. static readonly GAMEPAD_ID_PREFIX: string;
  42902. private readonly _buttonIndexToObservableNameMap;
  42903. /**
  42904. * Creates a new GearVRController from a gamepad
  42905. * @param vrGamepad the gamepad that the controller should be created from
  42906. */
  42907. constructor(vrGamepad: any);
  42908. /**
  42909. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42910. * @param scene scene in which to add meshes
  42911. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42912. */
  42913. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42914. /**
  42915. * Called once for each button that changed state since the last frame
  42916. * @param buttonIdx Which button index changed
  42917. * @param state New state of the button
  42918. * @param changes Which properties on the state changed since last frame
  42919. */
  42920. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42921. }
  42922. }
  42923. declare module BABYLON {
  42924. /**
  42925. * Generic Controller
  42926. */
  42927. export class GenericController extends WebVRController {
  42928. /**
  42929. * Base Url for the controller model.
  42930. */
  42931. static readonly MODEL_BASE_URL: string;
  42932. /**
  42933. * File name for the controller model.
  42934. */
  42935. static readonly MODEL_FILENAME: string;
  42936. /**
  42937. * Creates a new GenericController from a gamepad
  42938. * @param vrGamepad the gamepad that the controller should be created from
  42939. */
  42940. constructor(vrGamepad: any);
  42941. /**
  42942. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42943. * @param scene scene in which to add meshes
  42944. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42945. */
  42946. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42947. /**
  42948. * Called once for each button that changed state since the last frame
  42949. * @param buttonIdx Which button index changed
  42950. * @param state New state of the button
  42951. * @param changes Which properties on the state changed since last frame
  42952. */
  42953. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42954. }
  42955. }
  42956. declare module BABYLON {
  42957. /**
  42958. * Oculus Touch Controller
  42959. */
  42960. export class OculusTouchController extends WebVRController {
  42961. /**
  42962. * Base Url for the controller model.
  42963. */
  42964. static MODEL_BASE_URL: string;
  42965. /**
  42966. * File name for the left controller model.
  42967. */
  42968. static MODEL_LEFT_FILENAME: string;
  42969. /**
  42970. * File name for the right controller model.
  42971. */
  42972. static MODEL_RIGHT_FILENAME: string;
  42973. /**
  42974. * Base Url for the Quest controller model.
  42975. */
  42976. static QUEST_MODEL_BASE_URL: string;
  42977. /**
  42978. * @hidden
  42979. * If the controllers are running on a device that needs the updated Quest controller models
  42980. */
  42981. static _IsQuest: boolean;
  42982. /**
  42983. * Fired when the secondary trigger on this controller is modified
  42984. */
  42985. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42986. /**
  42987. * Fired when the thumb rest on this controller is modified
  42988. */
  42989. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42990. /**
  42991. * Creates a new OculusTouchController from a gamepad
  42992. * @param vrGamepad the gamepad that the controller should be created from
  42993. */
  42994. constructor(vrGamepad: any);
  42995. /**
  42996. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42997. * @param scene scene in which to add meshes
  42998. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42999. */
  43000. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43001. /**
  43002. * Fired when the A button on this controller is modified
  43003. */
  43004. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43005. /**
  43006. * Fired when the B button on this controller is modified
  43007. */
  43008. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43009. /**
  43010. * Fired when the X button on this controller is modified
  43011. */
  43012. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43013. /**
  43014. * Fired when the Y button on this controller is modified
  43015. */
  43016. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43017. /**
  43018. * Called once for each button that changed state since the last frame
  43019. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43020. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43021. * 2) secondary trigger (same)
  43022. * 3) A (right) X (left), touch, pressed = value
  43023. * 4) B / Y
  43024. * 5) thumb rest
  43025. * @param buttonIdx Which button index changed
  43026. * @param state New state of the button
  43027. * @param changes Which properties on the state changed since last frame
  43028. */
  43029. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43030. }
  43031. }
  43032. declare module BABYLON {
  43033. /**
  43034. * Vive Controller
  43035. */
  43036. export class ViveController extends WebVRController {
  43037. /**
  43038. * Base Url for the controller model.
  43039. */
  43040. static MODEL_BASE_URL: string;
  43041. /**
  43042. * File name for the controller model.
  43043. */
  43044. static MODEL_FILENAME: string;
  43045. /**
  43046. * Creates a new ViveController from a gamepad
  43047. * @param vrGamepad the gamepad that the controller should be created from
  43048. */
  43049. constructor(vrGamepad: any);
  43050. /**
  43051. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43052. * @param scene scene in which to add meshes
  43053. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43054. */
  43055. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43056. /**
  43057. * Fired when the left button on this controller is modified
  43058. */
  43059. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43060. /**
  43061. * Fired when the right button on this controller is modified
  43062. */
  43063. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43064. /**
  43065. * Fired when the menu button on this controller is modified
  43066. */
  43067. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43068. /**
  43069. * Called once for each button that changed state since the last frame
  43070. * Vive mapping:
  43071. * 0: touchpad
  43072. * 1: trigger
  43073. * 2: left AND right buttons
  43074. * 3: menu button
  43075. * @param buttonIdx Which button index changed
  43076. * @param state New state of the button
  43077. * @param changes Which properties on the state changed since last frame
  43078. */
  43079. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43080. }
  43081. }
  43082. declare module BABYLON {
  43083. /**
  43084. * Defines the WindowsMotionController object that the state of the windows motion controller
  43085. */
  43086. export class WindowsMotionController extends WebVRController {
  43087. /**
  43088. * The base url used to load the left and right controller models
  43089. */
  43090. static MODEL_BASE_URL: string;
  43091. /**
  43092. * The name of the left controller model file
  43093. */
  43094. static MODEL_LEFT_FILENAME: string;
  43095. /**
  43096. * The name of the right controller model file
  43097. */
  43098. static MODEL_RIGHT_FILENAME: string;
  43099. /**
  43100. * The controller name prefix for this controller type
  43101. */
  43102. static readonly GAMEPAD_ID_PREFIX: string;
  43103. /**
  43104. * The controller id pattern for this controller type
  43105. */
  43106. private static readonly GAMEPAD_ID_PATTERN;
  43107. private _loadedMeshInfo;
  43108. private readonly _mapping;
  43109. /**
  43110. * Fired when the trackpad on this controller is clicked
  43111. */
  43112. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43113. /**
  43114. * Fired when the trackpad on this controller is modified
  43115. */
  43116. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43117. /**
  43118. * The current x and y values of this controller's trackpad
  43119. */
  43120. trackpad: StickValues;
  43121. /**
  43122. * Creates a new WindowsMotionController from a gamepad
  43123. * @param vrGamepad the gamepad that the controller should be created from
  43124. */
  43125. constructor(vrGamepad: any);
  43126. /**
  43127. * Fired when the trigger on this controller is modified
  43128. */
  43129. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43130. /**
  43131. * Fired when the menu button on this controller is modified
  43132. */
  43133. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43134. /**
  43135. * Fired when the grip button on this controller is modified
  43136. */
  43137. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43138. /**
  43139. * Fired when the thumbstick button on this controller is modified
  43140. */
  43141. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43142. /**
  43143. * Fired when the touchpad button on this controller is modified
  43144. */
  43145. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43146. /**
  43147. * Fired when the touchpad values on this controller are modified
  43148. */
  43149. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43150. private _updateTrackpad;
  43151. /**
  43152. * Called once per frame by the engine.
  43153. */
  43154. update(): void;
  43155. /**
  43156. * Called once for each button that changed state since the last frame
  43157. * @param buttonIdx Which button index changed
  43158. * @param state New state of the button
  43159. * @param changes Which properties on the state changed since last frame
  43160. */
  43161. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43162. /**
  43163. * Moves the buttons on the controller mesh based on their current state
  43164. * @param buttonName the name of the button to move
  43165. * @param buttonValue the value of the button which determines the buttons new position
  43166. */
  43167. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43168. /**
  43169. * Moves the axis on the controller mesh based on its current state
  43170. * @param axis the index of the axis
  43171. * @param axisValue the value of the axis which determines the meshes new position
  43172. * @hidden
  43173. */
  43174. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43175. /**
  43176. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43177. * @param scene scene in which to add meshes
  43178. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43179. */
  43180. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43181. /**
  43182. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43183. * can be transformed by button presses and axes values, based on this._mapping.
  43184. *
  43185. * @param scene scene in which the meshes exist
  43186. * @param meshes list of meshes that make up the controller model to process
  43187. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43188. */
  43189. private processModel;
  43190. private createMeshInfo;
  43191. /**
  43192. * Gets the ray of the controller in the direction the controller is pointing
  43193. * @param length the length the resulting ray should be
  43194. * @returns a ray in the direction the controller is pointing
  43195. */
  43196. getForwardRay(length?: number): Ray;
  43197. /**
  43198. * Disposes of the controller
  43199. */
  43200. dispose(): void;
  43201. }
  43202. }
  43203. declare module BABYLON {
  43204. /**
  43205. * Class containing static functions to help procedurally build meshes
  43206. */
  43207. export class PolyhedronBuilder {
  43208. /**
  43209. * Creates a polyhedron mesh
  43210. * * 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
  43211. * * The parameter `size` (positive float, default 1) sets the polygon size
  43212. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  43213. * * 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`
  43214. * * 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
  43215. * * 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)`)
  43216. * * 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
  43217. * * 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
  43218. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43219. * * 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
  43220. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43221. * @param name defines the name of the mesh
  43222. * @param options defines the options used to create the mesh
  43223. * @param scene defines the hosting scene
  43224. * @returns the polyhedron mesh
  43225. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  43226. */
  43227. static CreatePolyhedron(name: string, options: {
  43228. type?: number;
  43229. size?: number;
  43230. sizeX?: number;
  43231. sizeY?: number;
  43232. sizeZ?: number;
  43233. custom?: any;
  43234. faceUV?: Vector4[];
  43235. faceColors?: Color4[];
  43236. flat?: boolean;
  43237. updatable?: boolean;
  43238. sideOrientation?: number;
  43239. frontUVs?: Vector4;
  43240. backUVs?: Vector4;
  43241. }, scene?: Nullable<Scene>): Mesh;
  43242. }
  43243. }
  43244. declare module BABYLON {
  43245. /**
  43246. * Gizmo that enables scaling a mesh along 3 axis
  43247. */
  43248. export class ScaleGizmo extends Gizmo {
  43249. /**
  43250. * Internal gizmo used for interactions on the x axis
  43251. */
  43252. xGizmo: AxisScaleGizmo;
  43253. /**
  43254. * Internal gizmo used for interactions on the y axis
  43255. */
  43256. yGizmo: AxisScaleGizmo;
  43257. /**
  43258. * Internal gizmo used for interactions on the z axis
  43259. */
  43260. zGizmo: AxisScaleGizmo;
  43261. /**
  43262. * Internal gizmo used to scale all axis equally
  43263. */
  43264. uniformScaleGizmo: AxisScaleGizmo;
  43265. private _meshAttached;
  43266. private _updateGizmoRotationToMatchAttachedMesh;
  43267. private _snapDistance;
  43268. private _scaleRatio;
  43269. private _uniformScalingMesh;
  43270. private _octahedron;
  43271. /** Fires an event when any of it's sub gizmos are dragged */
  43272. onDragStartObservable: Observable<unknown>;
  43273. /** Fires an event when any of it's sub gizmos are released from dragging */
  43274. onDragEndObservable: Observable<unknown>;
  43275. attachedMesh: Nullable<AbstractMesh>;
  43276. /**
  43277. * Creates a ScaleGizmo
  43278. * @param gizmoLayer The utility layer the gizmo will be added to
  43279. */
  43280. constructor(gizmoLayer?: UtilityLayerRenderer);
  43281. updateGizmoRotationToMatchAttachedMesh: boolean;
  43282. /**
  43283. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43284. */
  43285. snapDistance: number;
  43286. /**
  43287. * Ratio for the scale of the gizmo (Default: 1)
  43288. */
  43289. scaleRatio: number;
  43290. /**
  43291. * Disposes of the gizmo
  43292. */
  43293. dispose(): void;
  43294. }
  43295. }
  43296. declare module BABYLON {
  43297. /**
  43298. * Single axis scale gizmo
  43299. */
  43300. export class AxisScaleGizmo extends Gizmo {
  43301. /**
  43302. * Drag behavior responsible for the gizmos dragging interactions
  43303. */
  43304. dragBehavior: PointerDragBehavior;
  43305. private _pointerObserver;
  43306. /**
  43307. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43308. */
  43309. snapDistance: number;
  43310. /**
  43311. * Event that fires each time the gizmo snaps to a new location.
  43312. * * snapDistance is the the change in distance
  43313. */
  43314. onSnapObservable: Observable<{
  43315. snapDistance: number;
  43316. }>;
  43317. /**
  43318. * If the scaling operation should be done on all axis (default: false)
  43319. */
  43320. uniformScaling: boolean;
  43321. private _isEnabled;
  43322. private _parent;
  43323. private _arrow;
  43324. private _coloredMaterial;
  43325. private _hoverMaterial;
  43326. /**
  43327. * Creates an AxisScaleGizmo
  43328. * @param gizmoLayer The utility layer the gizmo will be added to
  43329. * @param dragAxis The axis which the gizmo will be able to scale on
  43330. * @param color The color of the gizmo
  43331. */
  43332. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  43333. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43334. /**
  43335. * If the gizmo is enabled
  43336. */
  43337. isEnabled: boolean;
  43338. /**
  43339. * Disposes of the gizmo
  43340. */
  43341. dispose(): void;
  43342. /**
  43343. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43344. * @param mesh The mesh to replace the default mesh of the gizmo
  43345. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  43346. */
  43347. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  43348. }
  43349. }
  43350. declare module BABYLON {
  43351. /**
  43352. * Bounding box gizmo
  43353. */
  43354. export class BoundingBoxGizmo extends Gizmo {
  43355. private _lineBoundingBox;
  43356. private _rotateSpheresParent;
  43357. private _scaleBoxesParent;
  43358. private _boundingDimensions;
  43359. private _renderObserver;
  43360. private _pointerObserver;
  43361. private _scaleDragSpeed;
  43362. private _tmpQuaternion;
  43363. private _tmpVector;
  43364. private _tmpRotationMatrix;
  43365. /**
  43366. * 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)
  43367. */
  43368. ignoreChildren: boolean;
  43369. /**
  43370. * 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)
  43371. */
  43372. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  43373. /**
  43374. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  43375. */
  43376. rotationSphereSize: number;
  43377. /**
  43378. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  43379. */
  43380. scaleBoxSize: number;
  43381. /**
  43382. * 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)
  43383. */
  43384. fixedDragMeshScreenSize: boolean;
  43385. /**
  43386. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  43387. */
  43388. fixedDragMeshScreenSizeDistanceFactor: number;
  43389. /**
  43390. * Fired when a rotation sphere or scale box is dragged
  43391. */
  43392. onDragStartObservable: Observable<{}>;
  43393. /**
  43394. * Fired when a scale box is dragged
  43395. */
  43396. onScaleBoxDragObservable: Observable<{}>;
  43397. /**
  43398. * Fired when a scale box drag is ended
  43399. */
  43400. onScaleBoxDragEndObservable: Observable<{}>;
  43401. /**
  43402. * Fired when a rotation sphere is dragged
  43403. */
  43404. onRotationSphereDragObservable: Observable<{}>;
  43405. /**
  43406. * Fired when a rotation sphere drag is ended
  43407. */
  43408. onRotationSphereDragEndObservable: Observable<{}>;
  43409. /**
  43410. * 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)
  43411. */
  43412. scalePivot: Nullable<Vector3>;
  43413. /**
  43414. * Mesh used as a pivot to rotate the attached mesh
  43415. */
  43416. private _anchorMesh;
  43417. private _existingMeshScale;
  43418. private _dragMesh;
  43419. private pointerDragBehavior;
  43420. private coloredMaterial;
  43421. private hoverColoredMaterial;
  43422. /**
  43423. * Sets the color of the bounding box gizmo
  43424. * @param color the color to set
  43425. */
  43426. setColor(color: Color3): void;
  43427. /**
  43428. * Creates an BoundingBoxGizmo
  43429. * @param gizmoLayer The utility layer the gizmo will be added to
  43430. * @param color The color of the gizmo
  43431. */
  43432. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43433. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43434. private _selectNode;
  43435. /**
  43436. * Updates the bounding box information for the Gizmo
  43437. */
  43438. updateBoundingBox(): void;
  43439. private _updateRotationSpheres;
  43440. private _updateScaleBoxes;
  43441. /**
  43442. * Enables rotation on the specified axis and disables rotation on the others
  43443. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  43444. */
  43445. setEnabledRotationAxis(axis: string): void;
  43446. /**
  43447. * Enables/disables scaling
  43448. * @param enable if scaling should be enabled
  43449. */
  43450. setEnabledScaling(enable: boolean): void;
  43451. private _updateDummy;
  43452. /**
  43453. * Enables a pointer drag behavior on the bounding box of the gizmo
  43454. */
  43455. enableDragBehavior(): void;
  43456. /**
  43457. * Disposes of the gizmo
  43458. */
  43459. dispose(): void;
  43460. /**
  43461. * 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)
  43462. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  43463. * @returns the bounding box mesh with the passed in mesh as a child
  43464. */
  43465. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  43466. /**
  43467. * CustomMeshes are not supported by this gizmo
  43468. * @param mesh The mesh to replace the default mesh of the gizmo
  43469. */
  43470. setCustomMesh(mesh: Mesh): void;
  43471. }
  43472. }
  43473. declare module BABYLON {
  43474. /**
  43475. * Single plane rotation gizmo
  43476. */
  43477. export class PlaneRotationGizmo extends Gizmo {
  43478. /**
  43479. * Drag behavior responsible for the gizmos dragging interactions
  43480. */
  43481. dragBehavior: PointerDragBehavior;
  43482. private _pointerObserver;
  43483. /**
  43484. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  43485. */
  43486. snapDistance: number;
  43487. /**
  43488. * Event that fires each time the gizmo snaps to a new location.
  43489. * * snapDistance is the the change in distance
  43490. */
  43491. onSnapObservable: Observable<{
  43492. snapDistance: number;
  43493. }>;
  43494. private _isEnabled;
  43495. private _parent;
  43496. /**
  43497. * Creates a PlaneRotationGizmo
  43498. * @param gizmoLayer The utility layer the gizmo will be added to
  43499. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  43500. * @param color The color of the gizmo
  43501. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43502. */
  43503. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  43504. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43505. /**
  43506. * If the gizmo is enabled
  43507. */
  43508. isEnabled: boolean;
  43509. /**
  43510. * Disposes of the gizmo
  43511. */
  43512. dispose(): void;
  43513. }
  43514. }
  43515. declare module BABYLON {
  43516. /**
  43517. * Gizmo that enables rotating a mesh along 3 axis
  43518. */
  43519. export class RotationGizmo extends Gizmo {
  43520. /**
  43521. * Internal gizmo used for interactions on the x axis
  43522. */
  43523. xGizmo: PlaneRotationGizmo;
  43524. /**
  43525. * Internal gizmo used for interactions on the y axis
  43526. */
  43527. yGizmo: PlaneRotationGizmo;
  43528. /**
  43529. * Internal gizmo used for interactions on the z axis
  43530. */
  43531. zGizmo: PlaneRotationGizmo;
  43532. /** Fires an event when any of it's sub gizmos are dragged */
  43533. onDragStartObservable: Observable<unknown>;
  43534. /** Fires an event when any of it's sub gizmos are released from dragging */
  43535. onDragEndObservable: Observable<unknown>;
  43536. private _meshAttached;
  43537. attachedMesh: Nullable<AbstractMesh>;
  43538. /**
  43539. * Creates a RotationGizmo
  43540. * @param gizmoLayer The utility layer the gizmo will be added to
  43541. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43542. */
  43543. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43544. updateGizmoRotationToMatchAttachedMesh: boolean;
  43545. /**
  43546. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43547. */
  43548. snapDistance: number;
  43549. /**
  43550. * Ratio for the scale of the gizmo (Default: 1)
  43551. */
  43552. scaleRatio: number;
  43553. /**
  43554. * Disposes of the gizmo
  43555. */
  43556. dispose(): void;
  43557. /**
  43558. * CustomMeshes are not supported by this gizmo
  43559. * @param mesh The mesh to replace the default mesh of the gizmo
  43560. */
  43561. setCustomMesh(mesh: Mesh): void;
  43562. }
  43563. }
  43564. declare module BABYLON {
  43565. /**
  43566. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  43567. */
  43568. export class GizmoManager implements IDisposable {
  43569. private scene;
  43570. /**
  43571. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  43572. */
  43573. gizmos: {
  43574. positionGizmo: Nullable<PositionGizmo>;
  43575. rotationGizmo: Nullable<RotationGizmo>;
  43576. scaleGizmo: Nullable<ScaleGizmo>;
  43577. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  43578. };
  43579. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  43580. clearGizmoOnEmptyPointerEvent: boolean;
  43581. /** Fires an event when the manager is attached to a mesh */
  43582. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  43583. private _gizmosEnabled;
  43584. private _pointerObserver;
  43585. private _attachedMesh;
  43586. private _boundingBoxColor;
  43587. private _defaultUtilityLayer;
  43588. private _defaultKeepDepthUtilityLayer;
  43589. /**
  43590. * When bounding box gizmo is enabled, this can be used to track drag/end events
  43591. */
  43592. boundingBoxDragBehavior: SixDofDragBehavior;
  43593. /**
  43594. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  43595. */
  43596. attachableMeshes: Nullable<Array<AbstractMesh>>;
  43597. /**
  43598. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  43599. */
  43600. usePointerToAttachGizmos: boolean;
  43601. /**
  43602. * Utility layer that the bounding box gizmo belongs to
  43603. */
  43604. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  43605. /**
  43606. * Utility layer that all gizmos besides bounding box belong to
  43607. */
  43608. readonly utilityLayer: UtilityLayerRenderer;
  43609. /**
  43610. * Instatiates a gizmo manager
  43611. * @param scene the scene to overlay the gizmos on top of
  43612. */
  43613. constructor(scene: Scene);
  43614. /**
  43615. * Attaches a set of gizmos to the specified mesh
  43616. * @param mesh The mesh the gizmo's should be attached to
  43617. */
  43618. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  43619. /**
  43620. * If the position gizmo is enabled
  43621. */
  43622. positionGizmoEnabled: boolean;
  43623. /**
  43624. * If the rotation gizmo is enabled
  43625. */
  43626. rotationGizmoEnabled: boolean;
  43627. /**
  43628. * If the scale gizmo is enabled
  43629. */
  43630. scaleGizmoEnabled: boolean;
  43631. /**
  43632. * If the boundingBox gizmo is enabled
  43633. */
  43634. boundingBoxGizmoEnabled: boolean;
  43635. /**
  43636. * Disposes of the gizmo manager
  43637. */
  43638. dispose(): void;
  43639. }
  43640. }
  43641. declare module BABYLON {
  43642. /**
  43643. * A directional light is defined by a direction (what a surprise!).
  43644. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  43645. * 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.
  43646. * Documentation: https://doc.babylonjs.com/babylon101/lights
  43647. */
  43648. export class DirectionalLight extends ShadowLight {
  43649. private _shadowFrustumSize;
  43650. /**
  43651. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  43652. */
  43653. /**
  43654. * Specifies a fix frustum size for the shadow generation.
  43655. */
  43656. shadowFrustumSize: number;
  43657. private _shadowOrthoScale;
  43658. /**
  43659. * Gets the shadow projection scale against the optimal computed one.
  43660. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  43661. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  43662. */
  43663. /**
  43664. * Sets the shadow projection scale against the optimal computed one.
  43665. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  43666. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  43667. */
  43668. shadowOrthoScale: number;
  43669. /**
  43670. * Automatically compute the projection matrix to best fit (including all the casters)
  43671. * on each frame.
  43672. */
  43673. autoUpdateExtends: boolean;
  43674. private _orthoLeft;
  43675. private _orthoRight;
  43676. private _orthoTop;
  43677. private _orthoBottom;
  43678. /**
  43679. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  43680. * The directional light is emitted from everywhere in the given direction.
  43681. * It can cast shadows.
  43682. * Documentation : https://doc.babylonjs.com/babylon101/lights
  43683. * @param name The friendly name of the light
  43684. * @param direction The direction of the light
  43685. * @param scene The scene the light belongs to
  43686. */
  43687. constructor(name: string, direction: Vector3, scene: Scene);
  43688. /**
  43689. * Returns the string "DirectionalLight".
  43690. * @return The class name
  43691. */
  43692. getClassName(): string;
  43693. /**
  43694. * Returns the integer 1.
  43695. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  43696. */
  43697. getTypeID(): number;
  43698. /**
  43699. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  43700. * Returns the DirectionalLight Shadow projection matrix.
  43701. */
  43702. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43703. /**
  43704. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  43705. * Returns the DirectionalLight Shadow projection matrix.
  43706. */
  43707. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  43708. /**
  43709. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  43710. * Returns the DirectionalLight Shadow projection matrix.
  43711. */
  43712. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43713. protected _buildUniformLayout(): void;
  43714. /**
  43715. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  43716. * @param effect The effect to update
  43717. * @param lightIndex The index of the light in the effect to update
  43718. * @returns The directional light
  43719. */
  43720. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  43721. /**
  43722. * Gets the minZ used for shadow according to both the scene and the light.
  43723. *
  43724. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  43725. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  43726. * @param activeCamera The camera we are returning the min for
  43727. * @returns the depth min z
  43728. */
  43729. getDepthMinZ(activeCamera: Camera): number;
  43730. /**
  43731. * Gets the maxZ used for shadow according to both the scene and the light.
  43732. *
  43733. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  43734. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  43735. * @param activeCamera The camera we are returning the max for
  43736. * @returns the depth max z
  43737. */
  43738. getDepthMaxZ(activeCamera: Camera): number;
  43739. /**
  43740. * Prepares the list of defines specific to the light type.
  43741. * @param defines the list of defines
  43742. * @param lightIndex defines the index of the light for the effect
  43743. */
  43744. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  43745. }
  43746. }
  43747. declare module BABYLON {
  43748. /**
  43749. * Class containing static functions to help procedurally build meshes
  43750. */
  43751. export class HemisphereBuilder {
  43752. /**
  43753. * Creates a hemisphere mesh
  43754. * @param name defines the name of the mesh
  43755. * @param options defines the options used to create the mesh
  43756. * @param scene defines the hosting scene
  43757. * @returns the hemisphere mesh
  43758. */
  43759. static CreateHemisphere(name: string, options: {
  43760. segments?: number;
  43761. diameter?: number;
  43762. sideOrientation?: number;
  43763. }, scene: any): Mesh;
  43764. }
  43765. }
  43766. declare module BABYLON {
  43767. /**
  43768. * A spot light is defined by a position, a direction, an angle, and an exponent.
  43769. * These values define a cone of light starting from the position, emitting toward the direction.
  43770. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  43771. * and the exponent defines the speed of the decay of the light with distance (reach).
  43772. * Documentation: https://doc.babylonjs.com/babylon101/lights
  43773. */
  43774. export class SpotLight extends ShadowLight {
  43775. private _angle;
  43776. private _innerAngle;
  43777. private _cosHalfAngle;
  43778. private _lightAngleScale;
  43779. private _lightAngleOffset;
  43780. /**
  43781. * Gets the cone angle of the spot light in Radians.
  43782. */
  43783. /**
  43784. * Sets the cone angle of the spot light in Radians.
  43785. */
  43786. angle: number;
  43787. /**
  43788. * Only used in gltf falloff mode, this defines the angle where
  43789. * the directional falloff will start before cutting at angle which could be seen
  43790. * as outer angle.
  43791. */
  43792. /**
  43793. * Only used in gltf falloff mode, this defines the angle where
  43794. * the directional falloff will start before cutting at angle which could be seen
  43795. * as outer angle.
  43796. */
  43797. innerAngle: number;
  43798. private _shadowAngleScale;
  43799. /**
  43800. * Allows scaling the angle of the light for shadow generation only.
  43801. */
  43802. /**
  43803. * Allows scaling the angle of the light for shadow generation only.
  43804. */
  43805. shadowAngleScale: number;
  43806. /**
  43807. * The light decay speed with the distance from the emission spot.
  43808. */
  43809. exponent: number;
  43810. private _projectionTextureMatrix;
  43811. /**
  43812. * Allows reading the projecton texture
  43813. */
  43814. readonly projectionTextureMatrix: Matrix;
  43815. protected _projectionTextureLightNear: number;
  43816. /**
  43817. * Gets the near clip of the Spotlight for texture projection.
  43818. */
  43819. /**
  43820. * Sets the near clip of the Spotlight for texture projection.
  43821. */
  43822. projectionTextureLightNear: number;
  43823. protected _projectionTextureLightFar: number;
  43824. /**
  43825. * Gets the far clip of the Spotlight for texture projection.
  43826. */
  43827. /**
  43828. * Sets the far clip of the Spotlight for texture projection.
  43829. */
  43830. projectionTextureLightFar: number;
  43831. protected _projectionTextureUpDirection: Vector3;
  43832. /**
  43833. * Gets the Up vector of the Spotlight for texture projection.
  43834. */
  43835. /**
  43836. * Sets the Up vector of the Spotlight for texture projection.
  43837. */
  43838. projectionTextureUpDirection: Vector3;
  43839. private _projectionTexture;
  43840. /**
  43841. * Gets the projection texture of the light.
  43842. */
  43843. /**
  43844. * Sets the projection texture of the light.
  43845. */
  43846. projectionTexture: Nullable<BaseTexture>;
  43847. private _projectionTextureViewLightDirty;
  43848. private _projectionTextureProjectionLightDirty;
  43849. private _projectionTextureDirty;
  43850. private _projectionTextureViewTargetVector;
  43851. private _projectionTextureViewLightMatrix;
  43852. private _projectionTextureProjectionLightMatrix;
  43853. private _projectionTextureScalingMatrix;
  43854. /**
  43855. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  43856. * It can cast shadows.
  43857. * Documentation : https://doc.babylonjs.com/babylon101/lights
  43858. * @param name The light friendly name
  43859. * @param position The position of the spot light in the scene
  43860. * @param direction The direction of the light in the scene
  43861. * @param angle The cone angle of the light in Radians
  43862. * @param exponent The light decay speed with the distance from the emission spot
  43863. * @param scene The scene the lights belongs to
  43864. */
  43865. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  43866. /**
  43867. * Returns the string "SpotLight".
  43868. * @returns the class name
  43869. */
  43870. getClassName(): string;
  43871. /**
  43872. * Returns the integer 2.
  43873. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  43874. */
  43875. getTypeID(): number;
  43876. /**
  43877. * Overrides the direction setter to recompute the projection texture view light Matrix.
  43878. */
  43879. protected _setDirection(value: Vector3): void;
  43880. /**
  43881. * Overrides the position setter to recompute the projection texture view light Matrix.
  43882. */
  43883. protected _setPosition(value: Vector3): void;
  43884. /**
  43885. * 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.
  43886. * Returns the SpotLight.
  43887. */
  43888. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43889. protected _computeProjectionTextureViewLightMatrix(): void;
  43890. protected _computeProjectionTextureProjectionLightMatrix(): void;
  43891. /**
  43892. * Main function for light texture projection matrix computing.
  43893. */
  43894. protected _computeProjectionTextureMatrix(): void;
  43895. protected _buildUniformLayout(): void;
  43896. private _computeAngleValues;
  43897. /**
  43898. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  43899. * @param effect The effect to update
  43900. * @param lightIndex The index of the light in the effect to update
  43901. * @returns The spot light
  43902. */
  43903. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  43904. /**
  43905. * Disposes the light and the associated resources.
  43906. */
  43907. dispose(): void;
  43908. /**
  43909. * Prepares the list of defines specific to the light type.
  43910. * @param defines the list of defines
  43911. * @param lightIndex defines the index of the light for the effect
  43912. */
  43913. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  43914. }
  43915. }
  43916. declare module BABYLON {
  43917. /**
  43918. * Gizmo that enables viewing a light
  43919. */
  43920. export class LightGizmo extends Gizmo {
  43921. private _lightMesh;
  43922. private _material;
  43923. private cachedPosition;
  43924. private cachedForward;
  43925. /**
  43926. * Creates a LightGizmo
  43927. * @param gizmoLayer The utility layer the gizmo will be added to
  43928. */
  43929. constructor(gizmoLayer?: UtilityLayerRenderer);
  43930. private _light;
  43931. /**
  43932. * The light that the gizmo is attached to
  43933. */
  43934. light: Nullable<Light>;
  43935. /**
  43936. * @hidden
  43937. * Updates the gizmo to match the attached mesh's position/rotation
  43938. */
  43939. protected _update(): void;
  43940. private static _Scale;
  43941. /**
  43942. * Creates the lines for a light mesh
  43943. */
  43944. private static _createLightLines;
  43945. /**
  43946. * Disposes of the light gizmo
  43947. */
  43948. dispose(): void;
  43949. private static _CreateHemisphericLightMesh;
  43950. private static _CreatePointLightMesh;
  43951. private static _CreateSpotLightMesh;
  43952. private static _CreateDirectionalLightMesh;
  43953. }
  43954. }
  43955. declare module BABYLON {
  43956. /** @hidden */
  43957. export var backgroundFragmentDeclaration: {
  43958. name: string;
  43959. shader: string;
  43960. };
  43961. }
  43962. declare module BABYLON {
  43963. /** @hidden */
  43964. export var backgroundUboDeclaration: {
  43965. name: string;
  43966. shader: string;
  43967. };
  43968. }
  43969. declare module BABYLON {
  43970. /** @hidden */
  43971. export var backgroundPixelShader: {
  43972. name: string;
  43973. shader: string;
  43974. };
  43975. }
  43976. declare module BABYLON {
  43977. /** @hidden */
  43978. export var backgroundVertexDeclaration: {
  43979. name: string;
  43980. shader: string;
  43981. };
  43982. }
  43983. declare module BABYLON {
  43984. /** @hidden */
  43985. export var backgroundVertexShader: {
  43986. name: string;
  43987. shader: string;
  43988. };
  43989. }
  43990. declare module BABYLON {
  43991. /**
  43992. * Background material used to create an efficient environement around your scene.
  43993. */
  43994. export class BackgroundMaterial extends PushMaterial {
  43995. /**
  43996. * Standard reflectance value at parallel view angle.
  43997. */
  43998. static StandardReflectance0: number;
  43999. /**
  44000. * Standard reflectance value at grazing angle.
  44001. */
  44002. static StandardReflectance90: number;
  44003. protected _primaryColor: Color3;
  44004. /**
  44005. * Key light Color (multiply against the environement texture)
  44006. */
  44007. primaryColor: Color3;
  44008. protected __perceptualColor: Nullable<Color3>;
  44009. /**
  44010. * Experimental Internal Use Only.
  44011. *
  44012. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  44013. * This acts as a helper to set the primary color to a more "human friendly" value.
  44014. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  44015. * output color as close as possible from the chosen value.
  44016. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  44017. * part of lighting setup.)
  44018. */
  44019. _perceptualColor: Nullable<Color3>;
  44020. protected _primaryColorShadowLevel: float;
  44021. /**
  44022. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  44023. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  44024. */
  44025. primaryColorShadowLevel: float;
  44026. protected _primaryColorHighlightLevel: float;
  44027. /**
  44028. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  44029. * The primary color is used at the level chosen to define what the white area would look.
  44030. */
  44031. primaryColorHighlightLevel: float;
  44032. protected _reflectionTexture: Nullable<BaseTexture>;
  44033. /**
  44034. * Reflection Texture used in the material.
  44035. * Should be author in a specific way for the best result (refer to the documentation).
  44036. */
  44037. reflectionTexture: Nullable<BaseTexture>;
  44038. protected _reflectionBlur: float;
  44039. /**
  44040. * Reflection Texture level of blur.
  44041. *
  44042. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  44043. * texture twice.
  44044. */
  44045. reflectionBlur: float;
  44046. protected _diffuseTexture: Nullable<BaseTexture>;
  44047. /**
  44048. * Diffuse Texture used in the material.
  44049. * Should be author in a specific way for the best result (refer to the documentation).
  44050. */
  44051. diffuseTexture: Nullable<BaseTexture>;
  44052. protected _shadowLights: Nullable<IShadowLight[]>;
  44053. /**
  44054. * Specify the list of lights casting shadow on the material.
  44055. * All scene shadow lights will be included if null.
  44056. */
  44057. shadowLights: Nullable<IShadowLight[]>;
  44058. protected _shadowLevel: float;
  44059. /**
  44060. * Helps adjusting the shadow to a softer level if required.
  44061. * 0 means black shadows and 1 means no shadows.
  44062. */
  44063. shadowLevel: float;
  44064. protected _sceneCenter: Vector3;
  44065. /**
  44066. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  44067. * It is usually zero but might be interesting to modify according to your setup.
  44068. */
  44069. sceneCenter: Vector3;
  44070. protected _opacityFresnel: boolean;
  44071. /**
  44072. * This helps specifying that the material is falling off to the sky box at grazing angle.
  44073. * This helps ensuring a nice transition when the camera goes under the ground.
  44074. */
  44075. opacityFresnel: boolean;
  44076. protected _reflectionFresnel: boolean;
  44077. /**
  44078. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  44079. * This helps adding a mirror texture on the ground.
  44080. */
  44081. reflectionFresnel: boolean;
  44082. protected _reflectionFalloffDistance: number;
  44083. /**
  44084. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  44085. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  44086. */
  44087. reflectionFalloffDistance: number;
  44088. protected _reflectionAmount: number;
  44089. /**
  44090. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  44091. */
  44092. reflectionAmount: number;
  44093. protected _reflectionReflectance0: number;
  44094. /**
  44095. * This specifies the weight of the reflection at grazing angle.
  44096. */
  44097. reflectionReflectance0: number;
  44098. protected _reflectionReflectance90: number;
  44099. /**
  44100. * This specifies the weight of the reflection at a perpendicular point of view.
  44101. */
  44102. reflectionReflectance90: number;
  44103. /**
  44104. * Sets the reflection reflectance fresnel values according to the default standard
  44105. * empirically know to work well :-)
  44106. */
  44107. reflectionStandardFresnelWeight: number;
  44108. protected _useRGBColor: boolean;
  44109. /**
  44110. * Helps to directly use the maps channels instead of their level.
  44111. */
  44112. useRGBColor: boolean;
  44113. protected _enableNoise: boolean;
  44114. /**
  44115. * This helps reducing the banding effect that could occur on the background.
  44116. */
  44117. enableNoise: boolean;
  44118. /**
  44119. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44120. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  44121. * Recommended to be keep at 1.0 except for special cases.
  44122. */
  44123. fovMultiplier: number;
  44124. private _fovMultiplier;
  44125. /**
  44126. * Enable the FOV adjustment feature controlled by fovMultiplier.
  44127. */
  44128. useEquirectangularFOV: boolean;
  44129. private _maxSimultaneousLights;
  44130. /**
  44131. * Number of Simultaneous lights allowed on the material.
  44132. */
  44133. maxSimultaneousLights: int;
  44134. /**
  44135. * Default configuration related to image processing available in the Background Material.
  44136. */
  44137. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44138. /**
  44139. * Keep track of the image processing observer to allow dispose and replace.
  44140. */
  44141. private _imageProcessingObserver;
  44142. /**
  44143. * Attaches a new image processing configuration to the PBR Material.
  44144. * @param configuration (if null the scene configuration will be use)
  44145. */
  44146. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44147. /**
  44148. * Gets the image processing configuration used either in this material.
  44149. */
  44150. /**
  44151. * Sets the Default image processing configuration used either in the this material.
  44152. *
  44153. * If sets to null, the scene one is in use.
  44154. */
  44155. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  44156. /**
  44157. * Gets wether the color curves effect is enabled.
  44158. */
  44159. /**
  44160. * Sets wether the color curves effect is enabled.
  44161. */
  44162. cameraColorCurvesEnabled: boolean;
  44163. /**
  44164. * Gets wether the color grading effect is enabled.
  44165. */
  44166. /**
  44167. * Gets wether the color grading effect is enabled.
  44168. */
  44169. cameraColorGradingEnabled: boolean;
  44170. /**
  44171. * Gets wether tonemapping is enabled or not.
  44172. */
  44173. /**
  44174. * Sets wether tonemapping is enabled or not
  44175. */
  44176. cameraToneMappingEnabled: boolean;
  44177. /**
  44178. * The camera exposure used on this material.
  44179. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44180. * This corresponds to a photographic exposure.
  44181. */
  44182. /**
  44183. * The camera exposure used on this material.
  44184. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44185. * This corresponds to a photographic exposure.
  44186. */
  44187. cameraExposure: float;
  44188. /**
  44189. * Gets The camera contrast used on this material.
  44190. */
  44191. /**
  44192. * Sets The camera contrast used on this material.
  44193. */
  44194. cameraContrast: float;
  44195. /**
  44196. * Gets the Color Grading 2D Lookup Texture.
  44197. */
  44198. /**
  44199. * Sets the Color Grading 2D Lookup Texture.
  44200. */
  44201. cameraColorGradingTexture: Nullable<BaseTexture>;
  44202. /**
  44203. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44204. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44205. * 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;
  44206. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44207. */
  44208. /**
  44209. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44210. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44211. * 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;
  44212. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44213. */
  44214. cameraColorCurves: Nullable<ColorCurves>;
  44215. /**
  44216. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  44217. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  44218. */
  44219. switchToBGR: boolean;
  44220. private _renderTargets;
  44221. private _reflectionControls;
  44222. private _white;
  44223. private _primaryShadowColor;
  44224. private _primaryHighlightColor;
  44225. /**
  44226. * Instantiates a Background Material in the given scene
  44227. * @param name The friendly name of the material
  44228. * @param scene The scene to add the material to
  44229. */
  44230. constructor(name: string, scene: Scene);
  44231. /**
  44232. * Gets a boolean indicating that current material needs to register RTT
  44233. */
  44234. readonly hasRenderTargetTextures: boolean;
  44235. /**
  44236. * The entire material has been created in order to prevent overdraw.
  44237. * @returns false
  44238. */
  44239. needAlphaTesting(): boolean;
  44240. /**
  44241. * The entire material has been created in order to prevent overdraw.
  44242. * @returns true if blending is enable
  44243. */
  44244. needAlphaBlending(): boolean;
  44245. /**
  44246. * Checks wether the material is ready to be rendered for a given mesh.
  44247. * @param mesh The mesh to render
  44248. * @param subMesh The submesh to check against
  44249. * @param useInstances Specify wether or not the material is used with instances
  44250. * @returns true if all the dependencies are ready (Textures, Effects...)
  44251. */
  44252. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44253. /**
  44254. * Compute the primary color according to the chosen perceptual color.
  44255. */
  44256. private _computePrimaryColorFromPerceptualColor;
  44257. /**
  44258. * Compute the highlights and shadow colors according to their chosen levels.
  44259. */
  44260. private _computePrimaryColors;
  44261. /**
  44262. * Build the uniform buffer used in the material.
  44263. */
  44264. buildUniformLayout(): void;
  44265. /**
  44266. * Unbind the material.
  44267. */
  44268. unbind(): void;
  44269. /**
  44270. * Bind only the world matrix to the material.
  44271. * @param world The world matrix to bind.
  44272. */
  44273. bindOnlyWorldMatrix(world: Matrix): void;
  44274. /**
  44275. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  44276. * @param world The world matrix to bind.
  44277. * @param subMesh The submesh to bind for.
  44278. */
  44279. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44280. /**
  44281. * Dispose the material.
  44282. * @param forceDisposeEffect Force disposal of the associated effect.
  44283. * @param forceDisposeTextures Force disposal of the associated textures.
  44284. */
  44285. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44286. /**
  44287. * Clones the material.
  44288. * @param name The cloned name.
  44289. * @returns The cloned material.
  44290. */
  44291. clone(name: string): BackgroundMaterial;
  44292. /**
  44293. * Serializes the current material to its JSON representation.
  44294. * @returns The JSON representation.
  44295. */
  44296. serialize(): any;
  44297. /**
  44298. * Gets the class name of the material
  44299. * @returns "BackgroundMaterial"
  44300. */
  44301. getClassName(): string;
  44302. /**
  44303. * Parse a JSON input to create back a background material.
  44304. * @param source The JSON data to parse
  44305. * @param scene The scene to create the parsed material in
  44306. * @param rootUrl The root url of the assets the material depends upon
  44307. * @returns the instantiated BackgroundMaterial.
  44308. */
  44309. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  44310. }
  44311. }
  44312. declare module BABYLON {
  44313. /**
  44314. * Represents the different options available during the creation of
  44315. * a Environment helper.
  44316. *
  44317. * This can control the default ground, skybox and image processing setup of your scene.
  44318. */
  44319. export interface IEnvironmentHelperOptions {
  44320. /**
  44321. * Specifies wether or not to create a ground.
  44322. * True by default.
  44323. */
  44324. createGround: boolean;
  44325. /**
  44326. * Specifies the ground size.
  44327. * 15 by default.
  44328. */
  44329. groundSize: number;
  44330. /**
  44331. * The texture used on the ground for the main color.
  44332. * Comes from the BabylonJS CDN by default.
  44333. *
  44334. * Remarks: Can be either a texture or a url.
  44335. */
  44336. groundTexture: string | BaseTexture;
  44337. /**
  44338. * The color mixed in the ground texture by default.
  44339. * BabylonJS clearColor by default.
  44340. */
  44341. groundColor: Color3;
  44342. /**
  44343. * Specifies the ground opacity.
  44344. * 1 by default.
  44345. */
  44346. groundOpacity: number;
  44347. /**
  44348. * Enables the ground to receive shadows.
  44349. * True by default.
  44350. */
  44351. enableGroundShadow: boolean;
  44352. /**
  44353. * Helps preventing the shadow to be fully black on the ground.
  44354. * 0.5 by default.
  44355. */
  44356. groundShadowLevel: number;
  44357. /**
  44358. * Creates a mirror texture attach to the ground.
  44359. * false by default.
  44360. */
  44361. enableGroundMirror: boolean;
  44362. /**
  44363. * Specifies the ground mirror size ratio.
  44364. * 0.3 by default as the default kernel is 64.
  44365. */
  44366. groundMirrorSizeRatio: number;
  44367. /**
  44368. * Specifies the ground mirror blur kernel size.
  44369. * 64 by default.
  44370. */
  44371. groundMirrorBlurKernel: number;
  44372. /**
  44373. * Specifies the ground mirror visibility amount.
  44374. * 1 by default
  44375. */
  44376. groundMirrorAmount: number;
  44377. /**
  44378. * Specifies the ground mirror reflectance weight.
  44379. * This uses the standard weight of the background material to setup the fresnel effect
  44380. * of the mirror.
  44381. * 1 by default.
  44382. */
  44383. groundMirrorFresnelWeight: number;
  44384. /**
  44385. * Specifies the ground mirror Falloff distance.
  44386. * This can helps reducing the size of the reflection.
  44387. * 0 by Default.
  44388. */
  44389. groundMirrorFallOffDistance: number;
  44390. /**
  44391. * Specifies the ground mirror texture type.
  44392. * Unsigned Int by Default.
  44393. */
  44394. groundMirrorTextureType: number;
  44395. /**
  44396. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  44397. * the shown objects.
  44398. */
  44399. groundYBias: number;
  44400. /**
  44401. * Specifies wether or not to create a skybox.
  44402. * True by default.
  44403. */
  44404. createSkybox: boolean;
  44405. /**
  44406. * Specifies the skybox size.
  44407. * 20 by default.
  44408. */
  44409. skyboxSize: number;
  44410. /**
  44411. * The texture used on the skybox for the main color.
  44412. * Comes from the BabylonJS CDN by default.
  44413. *
  44414. * Remarks: Can be either a texture or a url.
  44415. */
  44416. skyboxTexture: string | BaseTexture;
  44417. /**
  44418. * The color mixed in the skybox texture by default.
  44419. * BabylonJS clearColor by default.
  44420. */
  44421. skyboxColor: Color3;
  44422. /**
  44423. * The background rotation around the Y axis of the scene.
  44424. * This helps aligning the key lights of your scene with the background.
  44425. * 0 by default.
  44426. */
  44427. backgroundYRotation: number;
  44428. /**
  44429. * Compute automatically the size of the elements to best fit with the scene.
  44430. */
  44431. sizeAuto: boolean;
  44432. /**
  44433. * Default position of the rootMesh if autoSize is not true.
  44434. */
  44435. rootPosition: Vector3;
  44436. /**
  44437. * Sets up the image processing in the scene.
  44438. * true by default.
  44439. */
  44440. setupImageProcessing: boolean;
  44441. /**
  44442. * The texture used as your environment texture in the scene.
  44443. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  44444. *
  44445. * Remarks: Can be either a texture or a url.
  44446. */
  44447. environmentTexture: string | BaseTexture;
  44448. /**
  44449. * The value of the exposure to apply to the scene.
  44450. * 0.6 by default if setupImageProcessing is true.
  44451. */
  44452. cameraExposure: number;
  44453. /**
  44454. * The value of the contrast to apply to the scene.
  44455. * 1.6 by default if setupImageProcessing is true.
  44456. */
  44457. cameraContrast: number;
  44458. /**
  44459. * Specifies wether or not tonemapping should be enabled in the scene.
  44460. * true by default if setupImageProcessing is true.
  44461. */
  44462. toneMappingEnabled: boolean;
  44463. }
  44464. /**
  44465. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  44466. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  44467. * It also helps with the default setup of your imageProcessing configuration.
  44468. */
  44469. export class EnvironmentHelper {
  44470. /**
  44471. * Default ground texture URL.
  44472. */
  44473. private static _groundTextureCDNUrl;
  44474. /**
  44475. * Default skybox texture URL.
  44476. */
  44477. private static _skyboxTextureCDNUrl;
  44478. /**
  44479. * Default environment texture URL.
  44480. */
  44481. private static _environmentTextureCDNUrl;
  44482. /**
  44483. * Creates the default options for the helper.
  44484. */
  44485. private static _getDefaultOptions;
  44486. private _rootMesh;
  44487. /**
  44488. * Gets the root mesh created by the helper.
  44489. */
  44490. readonly rootMesh: Mesh;
  44491. private _skybox;
  44492. /**
  44493. * Gets the skybox created by the helper.
  44494. */
  44495. readonly skybox: Nullable<Mesh>;
  44496. private _skyboxTexture;
  44497. /**
  44498. * Gets the skybox texture created by the helper.
  44499. */
  44500. readonly skyboxTexture: Nullable<BaseTexture>;
  44501. private _skyboxMaterial;
  44502. /**
  44503. * Gets the skybox material created by the helper.
  44504. */
  44505. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  44506. private _ground;
  44507. /**
  44508. * Gets the ground mesh created by the helper.
  44509. */
  44510. readonly ground: Nullable<Mesh>;
  44511. private _groundTexture;
  44512. /**
  44513. * Gets the ground texture created by the helper.
  44514. */
  44515. readonly groundTexture: Nullable<BaseTexture>;
  44516. private _groundMirror;
  44517. /**
  44518. * Gets the ground mirror created by the helper.
  44519. */
  44520. readonly groundMirror: Nullable<MirrorTexture>;
  44521. /**
  44522. * Gets the ground mirror render list to helps pushing the meshes
  44523. * you wish in the ground reflection.
  44524. */
  44525. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  44526. private _groundMaterial;
  44527. /**
  44528. * Gets the ground material created by the helper.
  44529. */
  44530. readonly groundMaterial: Nullable<BackgroundMaterial>;
  44531. /**
  44532. * Stores the creation options.
  44533. */
  44534. private readonly _scene;
  44535. private _options;
  44536. /**
  44537. * This observable will be notified with any error during the creation of the environment,
  44538. * mainly texture creation errors.
  44539. */
  44540. onErrorObservable: Observable<{
  44541. message?: string;
  44542. exception?: any;
  44543. }>;
  44544. /**
  44545. * constructor
  44546. * @param options Defines the options we want to customize the helper
  44547. * @param scene The scene to add the material to
  44548. */
  44549. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  44550. /**
  44551. * Updates the background according to the new options
  44552. * @param options
  44553. */
  44554. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  44555. /**
  44556. * Sets the primary color of all the available elements.
  44557. * @param color the main color to affect to the ground and the background
  44558. */
  44559. setMainColor(color: Color3): void;
  44560. /**
  44561. * Setup the image processing according to the specified options.
  44562. */
  44563. private _setupImageProcessing;
  44564. /**
  44565. * Setup the environment texture according to the specified options.
  44566. */
  44567. private _setupEnvironmentTexture;
  44568. /**
  44569. * Setup the background according to the specified options.
  44570. */
  44571. private _setupBackground;
  44572. /**
  44573. * Get the scene sizes according to the setup.
  44574. */
  44575. private _getSceneSize;
  44576. /**
  44577. * Setup the ground according to the specified options.
  44578. */
  44579. private _setupGround;
  44580. /**
  44581. * Setup the ground material according to the specified options.
  44582. */
  44583. private _setupGroundMaterial;
  44584. /**
  44585. * Setup the ground diffuse texture according to the specified options.
  44586. */
  44587. private _setupGroundDiffuseTexture;
  44588. /**
  44589. * Setup the ground mirror texture according to the specified options.
  44590. */
  44591. private _setupGroundMirrorTexture;
  44592. /**
  44593. * Setup the ground to receive the mirror texture.
  44594. */
  44595. private _setupMirrorInGroundMaterial;
  44596. /**
  44597. * Setup the skybox according to the specified options.
  44598. */
  44599. private _setupSkybox;
  44600. /**
  44601. * Setup the skybox material according to the specified options.
  44602. */
  44603. private _setupSkyboxMaterial;
  44604. /**
  44605. * Setup the skybox reflection texture according to the specified options.
  44606. */
  44607. private _setupSkyboxReflectionTexture;
  44608. private _errorHandler;
  44609. /**
  44610. * Dispose all the elements created by the Helper.
  44611. */
  44612. dispose(): void;
  44613. }
  44614. }
  44615. declare module BABYLON {
  44616. /**
  44617. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  44618. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  44619. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  44620. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  44621. */
  44622. export class PhotoDome extends TransformNode {
  44623. /**
  44624. * Define the image as a Monoscopic panoramic 360 image.
  44625. */
  44626. static readonly MODE_MONOSCOPIC: number;
  44627. /**
  44628. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  44629. */
  44630. static readonly MODE_TOPBOTTOM: number;
  44631. /**
  44632. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  44633. */
  44634. static readonly MODE_SIDEBYSIDE: number;
  44635. private _useDirectMapping;
  44636. /**
  44637. * The texture being displayed on the sphere
  44638. */
  44639. protected _photoTexture: Texture;
  44640. /**
  44641. * Gets or sets the texture being displayed on the sphere
  44642. */
  44643. photoTexture: Texture;
  44644. /**
  44645. * Observable raised when an error occured while loading the 360 image
  44646. */
  44647. onLoadErrorObservable: Observable<string>;
  44648. /**
  44649. * The skybox material
  44650. */
  44651. protected _material: BackgroundMaterial;
  44652. /**
  44653. * The surface used for the skybox
  44654. */
  44655. protected _mesh: Mesh;
  44656. /**
  44657. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44658. * Also see the options.resolution property.
  44659. */
  44660. fovMultiplier: number;
  44661. private _imageMode;
  44662. /**
  44663. * Gets or set the current video mode for the video. It can be:
  44664. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  44665. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  44666. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  44667. */
  44668. imageMode: number;
  44669. /**
  44670. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  44671. * @param name Element's name, child elements will append suffixes for their own names.
  44672. * @param urlsOfPhoto defines the url of the photo to display
  44673. * @param options defines an object containing optional or exposed sub element properties
  44674. * @param onError defines a callback called when an error occured while loading the texture
  44675. */
  44676. constructor(name: string, urlOfPhoto: string, options: {
  44677. resolution?: number;
  44678. size?: number;
  44679. useDirectMapping?: boolean;
  44680. faceForward?: boolean;
  44681. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  44682. private _onBeforeCameraRenderObserver;
  44683. private _changeImageMode;
  44684. /**
  44685. * Releases resources associated with this node.
  44686. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  44687. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  44688. */
  44689. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  44690. }
  44691. }
  44692. declare module BABYLON {
  44693. /** @hidden */
  44694. export var rgbdDecodePixelShader: {
  44695. name: string;
  44696. shader: string;
  44697. };
  44698. }
  44699. declare module BABYLON {
  44700. /**
  44701. * Class used to host texture specific utilities
  44702. */
  44703. export class BRDFTextureTools {
  44704. /**
  44705. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  44706. * @param texture the texture to expand.
  44707. */
  44708. private static _ExpandDefaultBRDFTexture;
  44709. /**
  44710. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  44711. * @param scene defines the hosting scene
  44712. * @returns the environment BRDF texture
  44713. */
  44714. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  44715. private static _environmentBRDFBase64Texture;
  44716. }
  44717. }
  44718. declare module BABYLON {
  44719. /**
  44720. * @hidden
  44721. */
  44722. export interface IMaterialClearCoatDefines {
  44723. CLEARCOAT: boolean;
  44724. CLEARCOAT_DEFAULTIOR: boolean;
  44725. CLEARCOAT_TEXTURE: boolean;
  44726. CLEARCOAT_TEXTUREDIRECTUV: number;
  44727. CLEARCOAT_BUMP: boolean;
  44728. CLEARCOAT_BUMPDIRECTUV: number;
  44729. CLEARCOAT_TINT: boolean;
  44730. CLEARCOAT_TINT_TEXTURE: boolean;
  44731. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  44732. /** @hidden */
  44733. _areTexturesDirty: boolean;
  44734. }
  44735. /**
  44736. * Define the code related to the clear coat parameters of the pbr material.
  44737. */
  44738. export class PBRClearCoatConfiguration {
  44739. /**
  44740. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44741. * The default fits with a polyurethane material.
  44742. */
  44743. private static readonly _DefaultIndexOfRefraction;
  44744. private _isEnabled;
  44745. /**
  44746. * Defines if the clear coat is enabled in the material.
  44747. */
  44748. isEnabled: boolean;
  44749. /**
  44750. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  44751. */
  44752. intensity: number;
  44753. /**
  44754. * Defines the clear coat layer roughness.
  44755. */
  44756. roughness: number;
  44757. private _indexOfRefraction;
  44758. /**
  44759. * Defines the index of refraction of the clear coat.
  44760. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44761. * The default fits with a polyurethane material.
  44762. * Changing the default value is more performance intensive.
  44763. */
  44764. indexOfRefraction: number;
  44765. private _texture;
  44766. /**
  44767. * Stores the clear coat values in a texture.
  44768. */
  44769. texture: Nullable<BaseTexture>;
  44770. private _bumpTexture;
  44771. /**
  44772. * Define the clear coat specific bump texture.
  44773. */
  44774. bumpTexture: Nullable<BaseTexture>;
  44775. private _isTintEnabled;
  44776. /**
  44777. * Defines if the clear coat tint is enabled in the material.
  44778. */
  44779. isTintEnabled: boolean;
  44780. /**
  44781. * Defines the clear coat tint of the material.
  44782. * This is only use if tint is enabled
  44783. */
  44784. tintColor: Color3;
  44785. /**
  44786. * Defines the distance at which the tint color should be found in the
  44787. * clear coat media.
  44788. * This is only use if tint is enabled
  44789. */
  44790. tintColorAtDistance: number;
  44791. /**
  44792. * Defines the clear coat layer thickness.
  44793. * This is only use if tint is enabled
  44794. */
  44795. tintThickness: number;
  44796. private _tintTexture;
  44797. /**
  44798. * Stores the clear tint values in a texture.
  44799. * rgb is tint
  44800. * a is a thickness factor
  44801. */
  44802. tintTexture: Nullable<BaseTexture>;
  44803. /** @hidden */
  44804. private _internalMarkAllSubMeshesAsTexturesDirty;
  44805. /** @hidden */
  44806. _markAllSubMeshesAsTexturesDirty(): void;
  44807. /**
  44808. * Instantiate a new istance of clear coat configuration.
  44809. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44810. */
  44811. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44812. /**
  44813. * Gets wehter the submesh is ready to be used or not.
  44814. * @param defines the list of "defines" to update.
  44815. * @param scene defines the scene the material belongs to.
  44816. * @param engine defines the engine the material belongs to.
  44817. * @param disableBumpMap defines wether the material disables bump or not.
  44818. * @returns - boolean indicating that the submesh is ready or not.
  44819. */
  44820. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  44821. /**
  44822. * Checks to see if a texture is used in the material.
  44823. * @param defines the list of "defines" to update.
  44824. * @param scene defines the scene to the material belongs to.
  44825. */
  44826. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  44827. /**
  44828. * Binds the material data.
  44829. * @param uniformBuffer defines the Uniform buffer to fill in.
  44830. * @param scene defines the scene the material belongs to.
  44831. * @param engine defines the engine the material belongs to.
  44832. * @param disableBumpMap defines wether the material disables bump or not.
  44833. * @param isFrozen defines wether the material is frozen or not.
  44834. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44835. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44836. */
  44837. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  44838. /**
  44839. * Checks to see if a texture is used in the material.
  44840. * @param texture - Base texture to use.
  44841. * @returns - Boolean specifying if a texture is used in the material.
  44842. */
  44843. hasTexture(texture: BaseTexture): boolean;
  44844. /**
  44845. * Returns an array of the actively used textures.
  44846. * @param activeTextures Array of BaseTextures
  44847. */
  44848. getActiveTextures(activeTextures: BaseTexture[]): void;
  44849. /**
  44850. * Returns the animatable textures.
  44851. * @param animatables Array of animatable textures.
  44852. */
  44853. getAnimatables(animatables: IAnimatable[]): void;
  44854. /**
  44855. * Disposes the resources of the material.
  44856. * @param forceDisposeTextures - Forces the disposal of all textures.
  44857. */
  44858. dispose(forceDisposeTextures?: boolean): void;
  44859. /**
  44860. * Get the current class name of the texture useful for serialization or dynamic coding.
  44861. * @returns "PBRClearCoatConfiguration"
  44862. */
  44863. getClassName(): string;
  44864. /**
  44865. * Add fallbacks to the effect fallbacks list.
  44866. * @param defines defines the Base texture to use.
  44867. * @param fallbacks defines the current fallback list.
  44868. * @param currentRank defines the current fallback rank.
  44869. * @returns the new fallback rank.
  44870. */
  44871. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44872. /**
  44873. * Add the required uniforms to the current list.
  44874. * @param uniforms defines the current uniform list.
  44875. */
  44876. static AddUniforms(uniforms: string[]): void;
  44877. /**
  44878. * Add the required samplers to the current list.
  44879. * @param samplers defines the current sampler list.
  44880. */
  44881. static AddSamplers(samplers: string[]): void;
  44882. /**
  44883. * Add the required uniforms to the current buffer.
  44884. * @param uniformBuffer defines the current uniform buffer.
  44885. */
  44886. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44887. /**
  44888. * Makes a duplicate of the current configuration into another one.
  44889. * @param clearCoatConfiguration define the config where to copy the info
  44890. */
  44891. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  44892. /**
  44893. * Serializes this clear coat configuration.
  44894. * @returns - An object with the serialized config.
  44895. */
  44896. serialize(): any;
  44897. /**
  44898. * Parses a anisotropy Configuration from a serialized object.
  44899. * @param source - Serialized object.
  44900. * @param scene Defines the scene we are parsing for
  44901. * @param rootUrl Defines the rootUrl to load from
  44902. */
  44903. parse(source: any, scene: Scene, rootUrl: string): void;
  44904. }
  44905. }
  44906. declare module BABYLON {
  44907. /**
  44908. * @hidden
  44909. */
  44910. export interface IMaterialAnisotropicDefines {
  44911. ANISOTROPIC: boolean;
  44912. ANISOTROPIC_TEXTURE: boolean;
  44913. ANISOTROPIC_TEXTUREDIRECTUV: number;
  44914. MAINUV1: boolean;
  44915. _areTexturesDirty: boolean;
  44916. _needUVs: boolean;
  44917. }
  44918. /**
  44919. * Define the code related to the anisotropic parameters of the pbr material.
  44920. */
  44921. export class PBRAnisotropicConfiguration {
  44922. private _isEnabled;
  44923. /**
  44924. * Defines if the anisotropy is enabled in the material.
  44925. */
  44926. isEnabled: boolean;
  44927. /**
  44928. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  44929. */
  44930. intensity: number;
  44931. /**
  44932. * Defines if the effect is along the tangents, bitangents or in between.
  44933. * By default, the effect is "strectching" the highlights along the tangents.
  44934. */
  44935. direction: Vector2;
  44936. private _texture;
  44937. /**
  44938. * Stores the anisotropy values in a texture.
  44939. * rg is direction (like normal from -1 to 1)
  44940. * b is a intensity
  44941. */
  44942. texture: Nullable<BaseTexture>;
  44943. /** @hidden */
  44944. private _internalMarkAllSubMeshesAsTexturesDirty;
  44945. /** @hidden */
  44946. _markAllSubMeshesAsTexturesDirty(): void;
  44947. /**
  44948. * Instantiate a new istance of anisotropy configuration.
  44949. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44950. */
  44951. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44952. /**
  44953. * Specifies that the submesh is ready to be used.
  44954. * @param defines the list of "defines" to update.
  44955. * @param scene defines the scene the material belongs to.
  44956. * @returns - boolean indicating that the submesh is ready or not.
  44957. */
  44958. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  44959. /**
  44960. * Checks to see if a texture is used in the material.
  44961. * @param defines the list of "defines" to update.
  44962. * @param mesh the mesh we are preparing the defines for.
  44963. * @param scene defines the scene the material belongs to.
  44964. */
  44965. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  44966. /**
  44967. * Binds the material data.
  44968. * @param uniformBuffer defines the Uniform buffer to fill in.
  44969. * @param scene defines the scene the material belongs to.
  44970. * @param isFrozen defines wether the material is frozen or not.
  44971. */
  44972. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44973. /**
  44974. * Checks to see if a texture is used in the material.
  44975. * @param texture - Base texture to use.
  44976. * @returns - Boolean specifying if a texture is used in the material.
  44977. */
  44978. hasTexture(texture: BaseTexture): boolean;
  44979. /**
  44980. * Returns an array of the actively used textures.
  44981. * @param activeTextures Array of BaseTextures
  44982. */
  44983. getActiveTextures(activeTextures: BaseTexture[]): void;
  44984. /**
  44985. * Returns the animatable textures.
  44986. * @param animatables Array of animatable textures.
  44987. */
  44988. getAnimatables(animatables: IAnimatable[]): void;
  44989. /**
  44990. * Disposes the resources of the material.
  44991. * @param forceDisposeTextures - Forces the disposal of all textures.
  44992. */
  44993. dispose(forceDisposeTextures?: boolean): void;
  44994. /**
  44995. * Get the current class name of the texture useful for serialization or dynamic coding.
  44996. * @returns "PBRAnisotropicConfiguration"
  44997. */
  44998. getClassName(): string;
  44999. /**
  45000. * Add fallbacks to the effect fallbacks list.
  45001. * @param defines defines the Base texture to use.
  45002. * @param fallbacks defines the current fallback list.
  45003. * @param currentRank defines the current fallback rank.
  45004. * @returns the new fallback rank.
  45005. */
  45006. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45007. /**
  45008. * Add the required uniforms to the current list.
  45009. * @param uniforms defines the current uniform list.
  45010. */
  45011. static AddUniforms(uniforms: string[]): void;
  45012. /**
  45013. * Add the required uniforms to the current buffer.
  45014. * @param uniformBuffer defines the current uniform buffer.
  45015. */
  45016. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45017. /**
  45018. * Add the required samplers to the current list.
  45019. * @param samplers defines the current sampler list.
  45020. */
  45021. static AddSamplers(samplers: string[]): void;
  45022. /**
  45023. * Makes a duplicate of the current configuration into another one.
  45024. * @param anisotropicConfiguration define the config where to copy the info
  45025. */
  45026. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  45027. /**
  45028. * Serializes this anisotropy configuration.
  45029. * @returns - An object with the serialized config.
  45030. */
  45031. serialize(): any;
  45032. /**
  45033. * Parses a anisotropy Configuration from a serialized object.
  45034. * @param source - Serialized object.
  45035. * @param scene Defines the scene we are parsing for
  45036. * @param rootUrl Defines the rootUrl to load from
  45037. */
  45038. parse(source: any, scene: Scene, rootUrl: string): void;
  45039. }
  45040. }
  45041. declare module BABYLON {
  45042. /**
  45043. * @hidden
  45044. */
  45045. export interface IMaterialBRDFDefines {
  45046. BRDF_V_HEIGHT_CORRELATED: boolean;
  45047. MS_BRDF_ENERGY_CONSERVATION: boolean;
  45048. SPHERICAL_HARMONICS: boolean;
  45049. /** @hidden */
  45050. _areMiscDirty: boolean;
  45051. }
  45052. /**
  45053. * Define the code related to the BRDF parameters of the pbr material.
  45054. */
  45055. export class PBRBRDFConfiguration {
  45056. /**
  45057. * Default value used for the energy conservation.
  45058. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  45059. */
  45060. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  45061. /**
  45062. * Default value used for the Smith Visibility Height Correlated mode.
  45063. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  45064. */
  45065. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  45066. /**
  45067. * Default value used for the IBL diffuse part.
  45068. * This can help switching back to the polynomials mode globally which is a tiny bit
  45069. * less GPU intensive at the drawback of a lower quality.
  45070. */
  45071. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  45072. private _useEnergyConservation;
  45073. /**
  45074. * Defines if the material uses energy conservation.
  45075. */
  45076. useEnergyConservation: boolean;
  45077. private _useSmithVisibilityHeightCorrelated;
  45078. /**
  45079. * LEGACY Mode set to false
  45080. * Defines if the material uses height smith correlated visibility term.
  45081. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  45082. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45083. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  45084. * Not relying on height correlated will also disable energy conservation.
  45085. */
  45086. useSmithVisibilityHeightCorrelated: boolean;
  45087. private _useSphericalHarmonics;
  45088. /**
  45089. * LEGACY Mode set to false
  45090. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  45091. * diffuse part of the IBL.
  45092. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  45093. * to the ground truth.
  45094. */
  45095. useSphericalHarmonics: boolean;
  45096. /** @hidden */
  45097. private _internalMarkAllSubMeshesAsMiscDirty;
  45098. /** @hidden */
  45099. _markAllSubMeshesAsMiscDirty(): void;
  45100. /**
  45101. * Instantiate a new istance of clear coat configuration.
  45102. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  45103. */
  45104. constructor(markAllSubMeshesAsMiscDirty: () => void);
  45105. /**
  45106. * Checks to see if a texture is used in the material.
  45107. * @param defines the list of "defines" to update.
  45108. */
  45109. prepareDefines(defines: IMaterialBRDFDefines): void;
  45110. /**
  45111. * Get the current class name of the texture useful for serialization or dynamic coding.
  45112. * @returns "PBRClearCoatConfiguration"
  45113. */
  45114. getClassName(): string;
  45115. /**
  45116. * Makes a duplicate of the current configuration into another one.
  45117. * @param brdfConfiguration define the config where to copy the info
  45118. */
  45119. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  45120. /**
  45121. * Serializes this BRDF configuration.
  45122. * @returns - An object with the serialized config.
  45123. */
  45124. serialize(): any;
  45125. /**
  45126. * Parses a anisotropy Configuration from a serialized object.
  45127. * @param source - Serialized object.
  45128. * @param scene Defines the scene we are parsing for
  45129. * @param rootUrl Defines the rootUrl to load from
  45130. */
  45131. parse(source: any, scene: Scene, rootUrl: string): void;
  45132. }
  45133. }
  45134. declare module BABYLON {
  45135. /**
  45136. * @hidden
  45137. */
  45138. export interface IMaterialSheenDefines {
  45139. SHEEN: boolean;
  45140. SHEEN_TEXTURE: boolean;
  45141. SHEEN_TEXTUREDIRECTUV: number;
  45142. SHEEN_LINKWITHALBEDO: boolean;
  45143. /** @hidden */
  45144. _areTexturesDirty: boolean;
  45145. }
  45146. /**
  45147. * Define the code related to the Sheen parameters of the pbr material.
  45148. */
  45149. export class PBRSheenConfiguration {
  45150. private _isEnabled;
  45151. /**
  45152. * Defines if the material uses sheen.
  45153. */
  45154. isEnabled: boolean;
  45155. private _linkSheenWithAlbedo;
  45156. /**
  45157. * Defines if the sheen is linked to the sheen color.
  45158. */
  45159. linkSheenWithAlbedo: boolean;
  45160. /**
  45161. * Defines the sheen intensity.
  45162. */
  45163. intensity: number;
  45164. /**
  45165. * Defines the sheen color.
  45166. */
  45167. color: Color3;
  45168. private _texture;
  45169. /**
  45170. * Stores the sheen tint values in a texture.
  45171. * rgb is tint
  45172. * a is a intensity
  45173. */
  45174. texture: Nullable<BaseTexture>;
  45175. /** @hidden */
  45176. private _internalMarkAllSubMeshesAsTexturesDirty;
  45177. /** @hidden */
  45178. _markAllSubMeshesAsTexturesDirty(): void;
  45179. /**
  45180. * Instantiate a new istance of clear coat configuration.
  45181. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45182. */
  45183. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45184. /**
  45185. * Specifies that the submesh is ready to be used.
  45186. * @param defines the list of "defines" to update.
  45187. * @param scene defines the scene the material belongs to.
  45188. * @returns - boolean indicating that the submesh is ready or not.
  45189. */
  45190. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  45191. /**
  45192. * Checks to see if a texture is used in the material.
  45193. * @param defines the list of "defines" to update.
  45194. * @param scene defines the scene the material belongs to.
  45195. */
  45196. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  45197. /**
  45198. * Binds the material data.
  45199. * @param uniformBuffer defines the Uniform buffer to fill in.
  45200. * @param scene defines the scene the material belongs to.
  45201. * @param isFrozen defines wether the material is frozen or not.
  45202. */
  45203. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45204. /**
  45205. * Checks to see if a texture is used in the material.
  45206. * @param texture - Base texture to use.
  45207. * @returns - Boolean specifying if a texture is used in the material.
  45208. */
  45209. hasTexture(texture: BaseTexture): boolean;
  45210. /**
  45211. * Returns an array of the actively used textures.
  45212. * @param activeTextures Array of BaseTextures
  45213. */
  45214. getActiveTextures(activeTextures: BaseTexture[]): void;
  45215. /**
  45216. * Returns the animatable textures.
  45217. * @param animatables Array of animatable textures.
  45218. */
  45219. getAnimatables(animatables: IAnimatable[]): void;
  45220. /**
  45221. * Disposes the resources of the material.
  45222. * @param forceDisposeTextures - Forces the disposal of all textures.
  45223. */
  45224. dispose(forceDisposeTextures?: boolean): void;
  45225. /**
  45226. * Get the current class name of the texture useful for serialization or dynamic coding.
  45227. * @returns "PBRSheenConfiguration"
  45228. */
  45229. getClassName(): string;
  45230. /**
  45231. * Add fallbacks to the effect fallbacks list.
  45232. * @param defines defines the Base texture to use.
  45233. * @param fallbacks defines the current fallback list.
  45234. * @param currentRank defines the current fallback rank.
  45235. * @returns the new fallback rank.
  45236. */
  45237. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45238. /**
  45239. * Add the required uniforms to the current list.
  45240. * @param uniforms defines the current uniform list.
  45241. */
  45242. static AddUniforms(uniforms: string[]): void;
  45243. /**
  45244. * Add the required uniforms to the current buffer.
  45245. * @param uniformBuffer defines the current uniform buffer.
  45246. */
  45247. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45248. /**
  45249. * Add the required samplers to the current list.
  45250. * @param samplers defines the current sampler list.
  45251. */
  45252. static AddSamplers(samplers: string[]): void;
  45253. /**
  45254. * Makes a duplicate of the current configuration into another one.
  45255. * @param sheenConfiguration define the config where to copy the info
  45256. */
  45257. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  45258. /**
  45259. * Serializes this BRDF configuration.
  45260. * @returns - An object with the serialized config.
  45261. */
  45262. serialize(): any;
  45263. /**
  45264. * Parses a anisotropy Configuration from a serialized object.
  45265. * @param source - Serialized object.
  45266. * @param scene Defines the scene we are parsing for
  45267. * @param rootUrl Defines the rootUrl to load from
  45268. */
  45269. parse(source: any, scene: Scene, rootUrl: string): void;
  45270. }
  45271. }
  45272. declare module BABYLON {
  45273. /**
  45274. * @hidden
  45275. */
  45276. export interface IMaterialSubSurfaceDefines {
  45277. SUBSURFACE: boolean;
  45278. SS_REFRACTION: boolean;
  45279. SS_TRANSLUCENCY: boolean;
  45280. SS_SCATERRING: boolean;
  45281. SS_THICKNESSANDMASK_TEXTURE: boolean;
  45282. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  45283. SS_REFRACTIONMAP_3D: boolean;
  45284. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  45285. SS_LODINREFRACTIONALPHA: boolean;
  45286. SS_GAMMAREFRACTION: boolean;
  45287. SS_RGBDREFRACTION: boolean;
  45288. SS_LINEARSPECULARREFRACTION: boolean;
  45289. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  45290. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  45291. /** @hidden */
  45292. _areTexturesDirty: boolean;
  45293. }
  45294. /**
  45295. * Define the code related to the sub surface parameters of the pbr material.
  45296. */
  45297. export class PBRSubSurfaceConfiguration {
  45298. private _isRefractionEnabled;
  45299. /**
  45300. * Defines if the refraction is enabled in the material.
  45301. */
  45302. isRefractionEnabled: boolean;
  45303. private _isTranslucencyEnabled;
  45304. /**
  45305. * Defines if the translucency is enabled in the material.
  45306. */
  45307. isTranslucencyEnabled: boolean;
  45308. private _isScatteringEnabled;
  45309. /**
  45310. * Defines the refraction intensity of the material.
  45311. * The refraction when enabled replaces the Diffuse part of the material.
  45312. * The intensity helps transitionning between diffuse and refraction.
  45313. */
  45314. refractionIntensity: number;
  45315. /**
  45316. * Defines the translucency intensity of the material.
  45317. * When translucency has been enabled, this defines how much of the "translucency"
  45318. * is addded to the diffuse part of the material.
  45319. */
  45320. translucencyIntensity: number;
  45321. /**
  45322. * Defines the scattering intensity of the material.
  45323. * When scattering has been enabled, this defines how much of the "scattered light"
  45324. * is addded to the diffuse part of the material.
  45325. */
  45326. scatteringIntensity: number;
  45327. private _thicknessTexture;
  45328. /**
  45329. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  45330. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  45331. * 0 would mean minimumThickness
  45332. * 1 would mean maximumThickness
  45333. * The other channels might be use as a mask to vary the different effects intensity.
  45334. */
  45335. thicknessTexture: Nullable<BaseTexture>;
  45336. private _refractionTexture;
  45337. /**
  45338. * Defines the texture to use for refraction.
  45339. */
  45340. refractionTexture: Nullable<BaseTexture>;
  45341. private _indexOfRefraction;
  45342. /**
  45343. * Defines the index of refraction used in the material.
  45344. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  45345. */
  45346. indexOfRefraction: number;
  45347. private _invertRefractionY;
  45348. /**
  45349. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45350. */
  45351. invertRefractionY: boolean;
  45352. private _linkRefractionWithTransparency;
  45353. /**
  45354. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45355. * Materials half opaque for instance using refraction could benefit from this control.
  45356. */
  45357. linkRefractionWithTransparency: boolean;
  45358. /**
  45359. * Defines the minimum thickness stored in the thickness map.
  45360. * If no thickness map is defined, this value will be used to simulate thickness.
  45361. */
  45362. minimumThickness: number;
  45363. /**
  45364. * Defines the maximum thickness stored in the thickness map.
  45365. */
  45366. maximumThickness: number;
  45367. /**
  45368. * Defines the volume tint of the material.
  45369. * This is used for both translucency and scattering.
  45370. */
  45371. tintColor: Color3;
  45372. /**
  45373. * Defines the distance at which the tint color should be found in the media.
  45374. * This is used for refraction only.
  45375. */
  45376. tintColorAtDistance: number;
  45377. /**
  45378. * Defines how far each channel transmit through the media.
  45379. * It is defined as a color to simplify it selection.
  45380. */
  45381. diffusionDistance: Color3;
  45382. private _useMaskFromThicknessTexture;
  45383. /**
  45384. * Stores the intensity of the different subsurface effects in the thickness texture.
  45385. * * the green channel is the translucency intensity.
  45386. * * the blue channel is the scattering intensity.
  45387. * * the alpha channel is the refraction intensity.
  45388. */
  45389. useMaskFromThicknessTexture: boolean;
  45390. /** @hidden */
  45391. private _internalMarkAllSubMeshesAsTexturesDirty;
  45392. /** @hidden */
  45393. _markAllSubMeshesAsTexturesDirty(): void;
  45394. /**
  45395. * Instantiate a new istance of sub surface configuration.
  45396. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45397. */
  45398. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45399. /**
  45400. * Gets wehter the submesh is ready to be used or not.
  45401. * @param defines the list of "defines" to update.
  45402. * @param scene defines the scene the material belongs to.
  45403. * @returns - boolean indicating that the submesh is ready or not.
  45404. */
  45405. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  45406. /**
  45407. * Checks to see if a texture is used in the material.
  45408. * @param defines the list of "defines" to update.
  45409. * @param scene defines the scene to the material belongs to.
  45410. */
  45411. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  45412. /**
  45413. * Binds the material data.
  45414. * @param uniformBuffer defines the Uniform buffer to fill in.
  45415. * @param scene defines the scene the material belongs to.
  45416. * @param engine defines the engine the material belongs to.
  45417. * @param isFrozen defines wether the material is frozen or not.
  45418. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  45419. */
  45420. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  45421. /**
  45422. * Unbinds the material from the mesh.
  45423. * @param activeEffect defines the effect that should be unbound from.
  45424. * @returns true if unbound, otherwise false
  45425. */
  45426. unbind(activeEffect: Effect): boolean;
  45427. /**
  45428. * Returns the texture used for refraction or null if none is used.
  45429. * @param scene defines the scene the material belongs to.
  45430. * @returns - Refraction texture if present. If no refraction texture and refraction
  45431. * is linked with transparency, returns environment texture. Otherwise, returns null.
  45432. */
  45433. private _getRefractionTexture;
  45434. /**
  45435. * Returns true if alpha blending should be disabled.
  45436. */
  45437. readonly disableAlphaBlending: boolean;
  45438. /**
  45439. * Fills the list of render target textures.
  45440. * @param renderTargets the list of render targets to update
  45441. */
  45442. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  45443. /**
  45444. * Checks to see if a texture is used in the material.
  45445. * @param texture - Base texture to use.
  45446. * @returns - Boolean specifying if a texture is used in the material.
  45447. */
  45448. hasTexture(texture: BaseTexture): boolean;
  45449. /**
  45450. * Gets a boolean indicating that current material needs to register RTT
  45451. * @returns true if this uses a render target otherwise false.
  45452. */
  45453. hasRenderTargetTextures(): boolean;
  45454. /**
  45455. * Returns an array of the actively used textures.
  45456. * @param activeTextures Array of BaseTextures
  45457. */
  45458. getActiveTextures(activeTextures: BaseTexture[]): void;
  45459. /**
  45460. * Returns the animatable textures.
  45461. * @param animatables Array of animatable textures.
  45462. */
  45463. getAnimatables(animatables: IAnimatable[]): void;
  45464. /**
  45465. * Disposes the resources of the material.
  45466. * @param forceDisposeTextures - Forces the disposal of all textures.
  45467. */
  45468. dispose(forceDisposeTextures?: boolean): void;
  45469. /**
  45470. * Get the current class name of the texture useful for serialization or dynamic coding.
  45471. * @returns "PBRSubSurfaceConfiguration"
  45472. */
  45473. getClassName(): string;
  45474. /**
  45475. * Add fallbacks to the effect fallbacks list.
  45476. * @param defines defines the Base texture to use.
  45477. * @param fallbacks defines the current fallback list.
  45478. * @param currentRank defines the current fallback rank.
  45479. * @returns the new fallback rank.
  45480. */
  45481. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45482. /**
  45483. * Add the required uniforms to the current list.
  45484. * @param uniforms defines the current uniform list.
  45485. */
  45486. static AddUniforms(uniforms: string[]): void;
  45487. /**
  45488. * Add the required samplers to the current list.
  45489. * @param samplers defines the current sampler list.
  45490. */
  45491. static AddSamplers(samplers: string[]): void;
  45492. /**
  45493. * Add the required uniforms to the current buffer.
  45494. * @param uniformBuffer defines the current uniform buffer.
  45495. */
  45496. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45497. /**
  45498. * Makes a duplicate of the current configuration into another one.
  45499. * @param configuration define the config where to copy the info
  45500. */
  45501. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  45502. /**
  45503. * Serializes this Sub Surface configuration.
  45504. * @returns - An object with the serialized config.
  45505. */
  45506. serialize(): any;
  45507. /**
  45508. * Parses a anisotropy Configuration from a serialized object.
  45509. * @param source - Serialized object.
  45510. * @param scene Defines the scene we are parsing for
  45511. * @param rootUrl Defines the rootUrl to load from
  45512. */
  45513. parse(source: any, scene: Scene, rootUrl: string): void;
  45514. }
  45515. }
  45516. declare module BABYLON {
  45517. /** @hidden */
  45518. export var pbrFragmentDeclaration: {
  45519. name: string;
  45520. shader: string;
  45521. };
  45522. }
  45523. declare module BABYLON {
  45524. /** @hidden */
  45525. export var pbrUboDeclaration: {
  45526. name: string;
  45527. shader: string;
  45528. };
  45529. }
  45530. declare module BABYLON {
  45531. /** @hidden */
  45532. export var pbrFragmentExtraDeclaration: {
  45533. name: string;
  45534. shader: string;
  45535. };
  45536. }
  45537. declare module BABYLON {
  45538. /** @hidden */
  45539. export var pbrFragmentSamplersDeclaration: {
  45540. name: string;
  45541. shader: string;
  45542. };
  45543. }
  45544. declare module BABYLON {
  45545. /** @hidden */
  45546. export var pbrHelperFunctions: {
  45547. name: string;
  45548. shader: string;
  45549. };
  45550. }
  45551. declare module BABYLON {
  45552. /** @hidden */
  45553. export var harmonicsFunctions: {
  45554. name: string;
  45555. shader: string;
  45556. };
  45557. }
  45558. declare module BABYLON {
  45559. /** @hidden */
  45560. export var pbrDirectLightingSetupFunctions: {
  45561. name: string;
  45562. shader: string;
  45563. };
  45564. }
  45565. declare module BABYLON {
  45566. /** @hidden */
  45567. export var pbrDirectLightingFalloffFunctions: {
  45568. name: string;
  45569. shader: string;
  45570. };
  45571. }
  45572. declare module BABYLON {
  45573. /** @hidden */
  45574. export var pbrBRDFFunctions: {
  45575. name: string;
  45576. shader: string;
  45577. };
  45578. }
  45579. declare module BABYLON {
  45580. /** @hidden */
  45581. export var pbrDirectLightingFunctions: {
  45582. name: string;
  45583. shader: string;
  45584. };
  45585. }
  45586. declare module BABYLON {
  45587. /** @hidden */
  45588. export var pbrIBLFunctions: {
  45589. name: string;
  45590. shader: string;
  45591. };
  45592. }
  45593. declare module BABYLON {
  45594. /** @hidden */
  45595. export var pbrDebug: {
  45596. name: string;
  45597. shader: string;
  45598. };
  45599. }
  45600. declare module BABYLON {
  45601. /** @hidden */
  45602. export var pbrPixelShader: {
  45603. name: string;
  45604. shader: string;
  45605. };
  45606. }
  45607. declare module BABYLON {
  45608. /** @hidden */
  45609. export var pbrVertexDeclaration: {
  45610. name: string;
  45611. shader: string;
  45612. };
  45613. }
  45614. declare module BABYLON {
  45615. /** @hidden */
  45616. export var pbrVertexShader: {
  45617. name: string;
  45618. shader: string;
  45619. };
  45620. }
  45621. declare module BABYLON {
  45622. /**
  45623. * Manages the defines for the PBR Material.
  45624. * @hidden
  45625. */
  45626. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  45627. PBR: boolean;
  45628. MAINUV1: boolean;
  45629. MAINUV2: boolean;
  45630. UV1: boolean;
  45631. UV2: boolean;
  45632. ALBEDO: boolean;
  45633. ALBEDODIRECTUV: number;
  45634. VERTEXCOLOR: boolean;
  45635. AMBIENT: boolean;
  45636. AMBIENTDIRECTUV: number;
  45637. AMBIENTINGRAYSCALE: boolean;
  45638. OPACITY: boolean;
  45639. VERTEXALPHA: boolean;
  45640. OPACITYDIRECTUV: number;
  45641. OPACITYRGB: boolean;
  45642. ALPHATEST: boolean;
  45643. DEPTHPREPASS: boolean;
  45644. ALPHABLEND: boolean;
  45645. ALPHAFROMALBEDO: boolean;
  45646. ALPHATESTVALUE: string;
  45647. SPECULAROVERALPHA: boolean;
  45648. RADIANCEOVERALPHA: boolean;
  45649. ALPHAFRESNEL: boolean;
  45650. LINEARALPHAFRESNEL: boolean;
  45651. PREMULTIPLYALPHA: boolean;
  45652. EMISSIVE: boolean;
  45653. EMISSIVEDIRECTUV: number;
  45654. REFLECTIVITY: boolean;
  45655. REFLECTIVITYDIRECTUV: number;
  45656. SPECULARTERM: boolean;
  45657. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  45658. MICROSURFACEAUTOMATIC: boolean;
  45659. LODBASEDMICROSFURACE: boolean;
  45660. MICROSURFACEMAP: boolean;
  45661. MICROSURFACEMAPDIRECTUV: number;
  45662. METALLICWORKFLOW: boolean;
  45663. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  45664. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  45665. METALLNESSSTOREINMETALMAPBLUE: boolean;
  45666. AOSTOREINMETALMAPRED: boolean;
  45667. ENVIRONMENTBRDF: boolean;
  45668. ENVIRONMENTBRDF_RGBD: boolean;
  45669. NORMAL: boolean;
  45670. TANGENT: boolean;
  45671. BUMP: boolean;
  45672. BUMPDIRECTUV: number;
  45673. OBJECTSPACE_NORMALMAP: boolean;
  45674. PARALLAX: boolean;
  45675. PARALLAXOCCLUSION: boolean;
  45676. NORMALXYSCALE: boolean;
  45677. LIGHTMAP: boolean;
  45678. LIGHTMAPDIRECTUV: number;
  45679. USELIGHTMAPASSHADOWMAP: boolean;
  45680. GAMMALIGHTMAP: boolean;
  45681. REFLECTION: boolean;
  45682. REFLECTIONMAP_3D: boolean;
  45683. REFLECTIONMAP_SPHERICAL: boolean;
  45684. REFLECTIONMAP_PLANAR: boolean;
  45685. REFLECTIONMAP_CUBIC: boolean;
  45686. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  45687. REFLECTIONMAP_PROJECTION: boolean;
  45688. REFLECTIONMAP_SKYBOX: boolean;
  45689. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  45690. REFLECTIONMAP_EXPLICIT: boolean;
  45691. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  45692. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  45693. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  45694. INVERTCUBICMAP: boolean;
  45695. USESPHERICALFROMREFLECTIONMAP: boolean;
  45696. USEIRRADIANCEMAP: boolean;
  45697. SPHERICAL_HARMONICS: boolean;
  45698. USESPHERICALINVERTEX: boolean;
  45699. REFLECTIONMAP_OPPOSITEZ: boolean;
  45700. LODINREFLECTIONALPHA: boolean;
  45701. GAMMAREFLECTION: boolean;
  45702. RGBDREFLECTION: boolean;
  45703. LINEARSPECULARREFLECTION: boolean;
  45704. RADIANCEOCCLUSION: boolean;
  45705. HORIZONOCCLUSION: boolean;
  45706. INSTANCES: boolean;
  45707. NUM_BONE_INFLUENCERS: number;
  45708. BonesPerMesh: number;
  45709. BONETEXTURE: boolean;
  45710. NONUNIFORMSCALING: boolean;
  45711. MORPHTARGETS: boolean;
  45712. MORPHTARGETS_NORMAL: boolean;
  45713. MORPHTARGETS_TANGENT: boolean;
  45714. MORPHTARGETS_UV: boolean;
  45715. NUM_MORPH_INFLUENCERS: number;
  45716. IMAGEPROCESSING: boolean;
  45717. VIGNETTE: boolean;
  45718. VIGNETTEBLENDMODEMULTIPLY: boolean;
  45719. VIGNETTEBLENDMODEOPAQUE: boolean;
  45720. TONEMAPPING: boolean;
  45721. TONEMAPPING_ACES: boolean;
  45722. CONTRAST: boolean;
  45723. COLORCURVES: boolean;
  45724. COLORGRADING: boolean;
  45725. COLORGRADING3D: boolean;
  45726. SAMPLER3DGREENDEPTH: boolean;
  45727. SAMPLER3DBGRMAP: boolean;
  45728. IMAGEPROCESSINGPOSTPROCESS: boolean;
  45729. EXPOSURE: boolean;
  45730. MULTIVIEW: boolean;
  45731. USEPHYSICALLIGHTFALLOFF: boolean;
  45732. USEGLTFLIGHTFALLOFF: boolean;
  45733. TWOSIDEDLIGHTING: boolean;
  45734. SHADOWFLOAT: boolean;
  45735. CLIPPLANE: boolean;
  45736. CLIPPLANE2: boolean;
  45737. CLIPPLANE3: boolean;
  45738. CLIPPLANE4: boolean;
  45739. POINTSIZE: boolean;
  45740. FOG: boolean;
  45741. LOGARITHMICDEPTH: boolean;
  45742. FORCENORMALFORWARD: boolean;
  45743. SPECULARAA: boolean;
  45744. CLEARCOAT: boolean;
  45745. CLEARCOAT_DEFAULTIOR: boolean;
  45746. CLEARCOAT_TEXTURE: boolean;
  45747. CLEARCOAT_TEXTUREDIRECTUV: number;
  45748. CLEARCOAT_BUMP: boolean;
  45749. CLEARCOAT_BUMPDIRECTUV: number;
  45750. CLEARCOAT_TINT: boolean;
  45751. CLEARCOAT_TINT_TEXTURE: boolean;
  45752. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45753. ANISOTROPIC: boolean;
  45754. ANISOTROPIC_TEXTURE: boolean;
  45755. ANISOTROPIC_TEXTUREDIRECTUV: number;
  45756. BRDF_V_HEIGHT_CORRELATED: boolean;
  45757. MS_BRDF_ENERGY_CONSERVATION: boolean;
  45758. SHEEN: boolean;
  45759. SHEEN_TEXTURE: boolean;
  45760. SHEEN_TEXTUREDIRECTUV: number;
  45761. SHEEN_LINKWITHALBEDO: boolean;
  45762. SUBSURFACE: boolean;
  45763. SS_REFRACTION: boolean;
  45764. SS_TRANSLUCENCY: boolean;
  45765. SS_SCATERRING: boolean;
  45766. SS_THICKNESSANDMASK_TEXTURE: boolean;
  45767. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  45768. SS_REFRACTIONMAP_3D: boolean;
  45769. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  45770. SS_LODINREFRACTIONALPHA: boolean;
  45771. SS_GAMMAREFRACTION: boolean;
  45772. SS_RGBDREFRACTION: boolean;
  45773. SS_LINEARSPECULARREFRACTION: boolean;
  45774. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  45775. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  45776. UNLIT: boolean;
  45777. DEBUGMODE: number;
  45778. /**
  45779. * Initializes the PBR Material defines.
  45780. */
  45781. constructor();
  45782. /**
  45783. * Resets the PBR Material defines.
  45784. */
  45785. reset(): void;
  45786. }
  45787. /**
  45788. * The Physically based material base class of BJS.
  45789. *
  45790. * This offers the main features of a standard PBR material.
  45791. * For more information, please refer to the documentation :
  45792. * https://doc.babylonjs.com/how_to/physically_based_rendering
  45793. */
  45794. export abstract class PBRBaseMaterial extends PushMaterial {
  45795. /**
  45796. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45797. */
  45798. static readonly PBRMATERIAL_OPAQUE: number;
  45799. /**
  45800. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45801. */
  45802. static readonly PBRMATERIAL_ALPHATEST: number;
  45803. /**
  45804. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45805. */
  45806. static readonly PBRMATERIAL_ALPHABLEND: number;
  45807. /**
  45808. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45809. * They are also discarded below the alpha cutoff threshold to improve performances.
  45810. */
  45811. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45812. /**
  45813. * Defines the default value of how much AO map is occluding the analytical lights
  45814. * (point spot...).
  45815. */
  45816. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45817. /**
  45818. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  45819. */
  45820. static readonly LIGHTFALLOFF_PHYSICAL: number;
  45821. /**
  45822. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  45823. * to enhance interoperability with other engines.
  45824. */
  45825. static readonly LIGHTFALLOFF_GLTF: number;
  45826. /**
  45827. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  45828. * to enhance interoperability with other materials.
  45829. */
  45830. static readonly LIGHTFALLOFF_STANDARD: number;
  45831. /**
  45832. * Intensity of the direct lights e.g. the four lights available in your scene.
  45833. * This impacts both the direct diffuse and specular highlights.
  45834. */
  45835. protected _directIntensity: number;
  45836. /**
  45837. * Intensity of the emissive part of the material.
  45838. * This helps controlling the emissive effect without modifying the emissive color.
  45839. */
  45840. protected _emissiveIntensity: number;
  45841. /**
  45842. * Intensity of the environment e.g. how much the environment will light the object
  45843. * either through harmonics for rough material or through the refelction for shiny ones.
  45844. */
  45845. protected _environmentIntensity: number;
  45846. /**
  45847. * This is a special control allowing the reduction of the specular highlights coming from the
  45848. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45849. */
  45850. protected _specularIntensity: number;
  45851. /**
  45852. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  45853. */
  45854. private _lightingInfos;
  45855. /**
  45856. * Debug Control allowing disabling the bump map on this material.
  45857. */
  45858. protected _disableBumpMap: boolean;
  45859. /**
  45860. * AKA Diffuse Texture in standard nomenclature.
  45861. */
  45862. protected _albedoTexture: Nullable<BaseTexture>;
  45863. /**
  45864. * AKA Occlusion Texture in other nomenclature.
  45865. */
  45866. protected _ambientTexture: Nullable<BaseTexture>;
  45867. /**
  45868. * AKA Occlusion Texture Intensity in other nomenclature.
  45869. */
  45870. protected _ambientTextureStrength: number;
  45871. /**
  45872. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45873. * 1 means it completely occludes it
  45874. * 0 mean it has no impact
  45875. */
  45876. protected _ambientTextureImpactOnAnalyticalLights: number;
  45877. /**
  45878. * Stores the alpha values in a texture.
  45879. */
  45880. protected _opacityTexture: Nullable<BaseTexture>;
  45881. /**
  45882. * Stores the reflection values in a texture.
  45883. */
  45884. protected _reflectionTexture: Nullable<BaseTexture>;
  45885. /**
  45886. * Stores the emissive values in a texture.
  45887. */
  45888. protected _emissiveTexture: Nullable<BaseTexture>;
  45889. /**
  45890. * AKA Specular texture in other nomenclature.
  45891. */
  45892. protected _reflectivityTexture: Nullable<BaseTexture>;
  45893. /**
  45894. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45895. */
  45896. protected _metallicTexture: Nullable<BaseTexture>;
  45897. /**
  45898. * Specifies the metallic scalar of the metallic/roughness workflow.
  45899. * Can also be used to scale the metalness values of the metallic texture.
  45900. */
  45901. protected _metallic: Nullable<number>;
  45902. /**
  45903. * Specifies the roughness scalar of the metallic/roughness workflow.
  45904. * Can also be used to scale the roughness values of the metallic texture.
  45905. */
  45906. protected _roughness: Nullable<number>;
  45907. /**
  45908. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45909. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45910. */
  45911. protected _microSurfaceTexture: Nullable<BaseTexture>;
  45912. /**
  45913. * Stores surface normal data used to displace a mesh in a texture.
  45914. */
  45915. protected _bumpTexture: Nullable<BaseTexture>;
  45916. /**
  45917. * Stores the pre-calculated light information of a mesh in a texture.
  45918. */
  45919. protected _lightmapTexture: Nullable<BaseTexture>;
  45920. /**
  45921. * The color of a material in ambient lighting.
  45922. */
  45923. protected _ambientColor: Color3;
  45924. /**
  45925. * AKA Diffuse Color in other nomenclature.
  45926. */
  45927. protected _albedoColor: Color3;
  45928. /**
  45929. * AKA Specular Color in other nomenclature.
  45930. */
  45931. protected _reflectivityColor: Color3;
  45932. /**
  45933. * The color applied when light is reflected from a material.
  45934. */
  45935. protected _reflectionColor: Color3;
  45936. /**
  45937. * The color applied when light is emitted from a material.
  45938. */
  45939. protected _emissiveColor: Color3;
  45940. /**
  45941. * AKA Glossiness in other nomenclature.
  45942. */
  45943. protected _microSurface: number;
  45944. /**
  45945. * Specifies that the material will use the light map as a show map.
  45946. */
  45947. protected _useLightmapAsShadowmap: boolean;
  45948. /**
  45949. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45950. * makes the reflect vector face the model (under horizon).
  45951. */
  45952. protected _useHorizonOcclusion: boolean;
  45953. /**
  45954. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45955. * too much the area relying on ambient texture to define their ambient occlusion.
  45956. */
  45957. protected _useRadianceOcclusion: boolean;
  45958. /**
  45959. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45960. */
  45961. protected _useAlphaFromAlbedoTexture: boolean;
  45962. /**
  45963. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  45964. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45965. */
  45966. protected _useSpecularOverAlpha: boolean;
  45967. /**
  45968. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45969. */
  45970. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45971. /**
  45972. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45973. */
  45974. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  45975. /**
  45976. * Specifies if the metallic texture contains the roughness information in its green channel.
  45977. */
  45978. protected _useRoughnessFromMetallicTextureGreen: boolean;
  45979. /**
  45980. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45981. */
  45982. protected _useMetallnessFromMetallicTextureBlue: boolean;
  45983. /**
  45984. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45985. */
  45986. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  45987. /**
  45988. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45989. */
  45990. protected _useAmbientInGrayScale: boolean;
  45991. /**
  45992. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45993. * The material will try to infer what glossiness each pixel should be.
  45994. */
  45995. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  45996. /**
  45997. * Defines the falloff type used in this material.
  45998. * It by default is Physical.
  45999. */
  46000. protected _lightFalloff: number;
  46001. /**
  46002. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46003. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46004. */
  46005. protected _useRadianceOverAlpha: boolean;
  46006. /**
  46007. * Allows using an object space normal map (instead of tangent space).
  46008. */
  46009. protected _useObjectSpaceNormalMap: boolean;
  46010. /**
  46011. * Allows using the bump map in parallax mode.
  46012. */
  46013. protected _useParallax: boolean;
  46014. /**
  46015. * Allows using the bump map in parallax occlusion mode.
  46016. */
  46017. protected _useParallaxOcclusion: boolean;
  46018. /**
  46019. * Controls the scale bias of the parallax mode.
  46020. */
  46021. protected _parallaxScaleBias: number;
  46022. /**
  46023. * If sets to true, disables all the lights affecting the material.
  46024. */
  46025. protected _disableLighting: boolean;
  46026. /**
  46027. * Number of Simultaneous lights allowed on the material.
  46028. */
  46029. protected _maxSimultaneousLights: number;
  46030. /**
  46031. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46032. */
  46033. protected _invertNormalMapX: boolean;
  46034. /**
  46035. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46036. */
  46037. protected _invertNormalMapY: boolean;
  46038. /**
  46039. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46040. */
  46041. protected _twoSidedLighting: boolean;
  46042. /**
  46043. * Defines the alpha limits in alpha test mode.
  46044. */
  46045. protected _alphaCutOff: number;
  46046. /**
  46047. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  46048. */
  46049. protected _forceAlphaTest: boolean;
  46050. /**
  46051. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46052. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46053. */
  46054. protected _useAlphaFresnel: boolean;
  46055. /**
  46056. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46057. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46058. */
  46059. protected _useLinearAlphaFresnel: boolean;
  46060. /**
  46061. * The transparency mode of the material.
  46062. */
  46063. protected _transparencyMode: Nullable<number>;
  46064. /**
  46065. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  46066. * from cos thetav and roughness:
  46067. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  46068. */
  46069. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  46070. /**
  46071. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46072. */
  46073. protected _forceIrradianceInFragment: boolean;
  46074. /**
  46075. * Force normal to face away from face.
  46076. */
  46077. protected _forceNormalForward: boolean;
  46078. /**
  46079. * Enables specular anti aliasing in the PBR shader.
  46080. * It will both interacts on the Geometry for analytical and IBL lighting.
  46081. * It also prefilter the roughness map based on the bump values.
  46082. */
  46083. protected _enableSpecularAntiAliasing: boolean;
  46084. /**
  46085. * Default configuration related to image processing available in the PBR Material.
  46086. */
  46087. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46088. /**
  46089. * Keep track of the image processing observer to allow dispose and replace.
  46090. */
  46091. private _imageProcessingObserver;
  46092. /**
  46093. * Attaches a new image processing configuration to the PBR Material.
  46094. * @param configuration
  46095. */
  46096. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  46097. /**
  46098. * Stores the available render targets.
  46099. */
  46100. private _renderTargets;
  46101. /**
  46102. * Sets the global ambient color for the material used in lighting calculations.
  46103. */
  46104. private _globalAmbientColor;
  46105. /**
  46106. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  46107. */
  46108. private _useLogarithmicDepth;
  46109. /**
  46110. * If set to true, no lighting calculations will be applied.
  46111. */
  46112. private _unlit;
  46113. private _debugMode;
  46114. /**
  46115. * @hidden
  46116. * This is reserved for the inspector.
  46117. * Defines the material debug mode.
  46118. * It helps seeing only some components of the material while troubleshooting.
  46119. */
  46120. debugMode: number;
  46121. /**
  46122. * @hidden
  46123. * This is reserved for the inspector.
  46124. * Specify from where on screen the debug mode should start.
  46125. * The value goes from -1 (full screen) to 1 (not visible)
  46126. * It helps with side by side comparison against the final render
  46127. * This defaults to -1
  46128. */
  46129. private debugLimit;
  46130. /**
  46131. * @hidden
  46132. * This is reserved for the inspector.
  46133. * As the default viewing range might not be enough (if the ambient is really small for instance)
  46134. * You can use the factor to better multiply the final value.
  46135. */
  46136. private debugFactor;
  46137. /**
  46138. * Defines the clear coat layer parameters for the material.
  46139. */
  46140. readonly clearCoat: PBRClearCoatConfiguration;
  46141. /**
  46142. * Defines the anisotropic parameters for the material.
  46143. */
  46144. readonly anisotropy: PBRAnisotropicConfiguration;
  46145. /**
  46146. * Defines the BRDF parameters for the material.
  46147. */
  46148. readonly brdf: PBRBRDFConfiguration;
  46149. /**
  46150. * Defines the Sheen parameters for the material.
  46151. */
  46152. readonly sheen: PBRSheenConfiguration;
  46153. /**
  46154. * Defines the SubSurface parameters for the material.
  46155. */
  46156. readonly subSurface: PBRSubSurfaceConfiguration;
  46157. /**
  46158. * Custom callback helping to override the default shader used in the material.
  46159. */
  46160. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  46161. /**
  46162. * Instantiates a new PBRMaterial instance.
  46163. *
  46164. * @param name The material name
  46165. * @param scene The scene the material will be use in.
  46166. */
  46167. constructor(name: string, scene: Scene);
  46168. /**
  46169. * Gets a boolean indicating that current material needs to register RTT
  46170. */
  46171. readonly hasRenderTargetTextures: boolean;
  46172. /**
  46173. * Gets the name of the material class.
  46174. */
  46175. getClassName(): string;
  46176. /**
  46177. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  46178. */
  46179. /**
  46180. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  46181. */
  46182. useLogarithmicDepth: boolean;
  46183. /**
  46184. * Gets the current transparency mode.
  46185. */
  46186. /**
  46187. * Sets the transparency mode of the material.
  46188. *
  46189. * | Value | Type | Description |
  46190. * | ----- | ----------------------------------- | ----------- |
  46191. * | 0 | OPAQUE | |
  46192. * | 1 | ALPHATEST | |
  46193. * | 2 | ALPHABLEND | |
  46194. * | 3 | ALPHATESTANDBLEND | |
  46195. *
  46196. */
  46197. transparencyMode: Nullable<number>;
  46198. /**
  46199. * Returns true if alpha blending should be disabled.
  46200. */
  46201. private readonly _disableAlphaBlending;
  46202. /**
  46203. * Specifies whether or not this material should be rendered in alpha blend mode.
  46204. */
  46205. needAlphaBlending(): boolean;
  46206. /**
  46207. * Specifies if the mesh will require alpha blending.
  46208. * @param mesh - BJS mesh.
  46209. */
  46210. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  46211. /**
  46212. * Specifies whether or not this material should be rendered in alpha test mode.
  46213. */
  46214. needAlphaTesting(): boolean;
  46215. /**
  46216. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  46217. */
  46218. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  46219. /**
  46220. * Gets the texture used for the alpha test.
  46221. */
  46222. getAlphaTestTexture(): Nullable<BaseTexture>;
  46223. /**
  46224. * Specifies that the submesh is ready to be used.
  46225. * @param mesh - BJS mesh.
  46226. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  46227. * @param useInstances - Specifies that instances should be used.
  46228. * @returns - boolean indicating that the submesh is ready or not.
  46229. */
  46230. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  46231. /**
  46232. * Specifies if the material uses metallic roughness workflow.
  46233. * @returns boolean specifiying if the material uses metallic roughness workflow.
  46234. */
  46235. isMetallicWorkflow(): boolean;
  46236. private _prepareEffect;
  46237. private _prepareDefines;
  46238. /**
  46239. * Force shader compilation
  46240. */
  46241. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  46242. clipPlane: boolean;
  46243. }>): void;
  46244. /**
  46245. * Initializes the uniform buffer layout for the shader.
  46246. */
  46247. buildUniformLayout(): void;
  46248. /**
  46249. * Unbinds the material from the mesh
  46250. */
  46251. unbind(): void;
  46252. /**
  46253. * Binds the submesh data.
  46254. * @param world - The world matrix.
  46255. * @param mesh - The BJS mesh.
  46256. * @param subMesh - A submesh of the BJS mesh.
  46257. */
  46258. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  46259. /**
  46260. * Returns the animatable textures.
  46261. * @returns - Array of animatable textures.
  46262. */
  46263. getAnimatables(): IAnimatable[];
  46264. /**
  46265. * Returns the texture used for reflections.
  46266. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  46267. */
  46268. private _getReflectionTexture;
  46269. /**
  46270. * Returns an array of the actively used textures.
  46271. * @returns - Array of BaseTextures
  46272. */
  46273. getActiveTextures(): BaseTexture[];
  46274. /**
  46275. * Checks to see if a texture is used in the material.
  46276. * @param texture - Base texture to use.
  46277. * @returns - Boolean specifying if a texture is used in the material.
  46278. */
  46279. hasTexture(texture: BaseTexture): boolean;
  46280. /**
  46281. * Disposes the resources of the material.
  46282. * @param forceDisposeEffect - Forces the disposal of effects.
  46283. * @param forceDisposeTextures - Forces the disposal of all textures.
  46284. */
  46285. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  46286. }
  46287. }
  46288. declare module BABYLON {
  46289. /**
  46290. * The Physically based material of BJS.
  46291. *
  46292. * This offers the main features of a standard PBR material.
  46293. * For more information, please refer to the documentation :
  46294. * https://doc.babylonjs.com/how_to/physically_based_rendering
  46295. */
  46296. export class PBRMaterial extends PBRBaseMaterial {
  46297. /**
  46298. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46299. */
  46300. static readonly PBRMATERIAL_OPAQUE: number;
  46301. /**
  46302. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46303. */
  46304. static readonly PBRMATERIAL_ALPHATEST: number;
  46305. /**
  46306. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46307. */
  46308. static readonly PBRMATERIAL_ALPHABLEND: number;
  46309. /**
  46310. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46311. * They are also discarded below the alpha cutoff threshold to improve performances.
  46312. */
  46313. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46314. /**
  46315. * Defines the default value of how much AO map is occluding the analytical lights
  46316. * (point spot...).
  46317. */
  46318. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46319. /**
  46320. * Intensity of the direct lights e.g. the four lights available in your scene.
  46321. * This impacts both the direct diffuse and specular highlights.
  46322. */
  46323. directIntensity: number;
  46324. /**
  46325. * Intensity of the emissive part of the material.
  46326. * This helps controlling the emissive effect without modifying the emissive color.
  46327. */
  46328. emissiveIntensity: number;
  46329. /**
  46330. * Intensity of the environment e.g. how much the environment will light the object
  46331. * either through harmonics for rough material or through the refelction for shiny ones.
  46332. */
  46333. environmentIntensity: number;
  46334. /**
  46335. * This is a special control allowing the reduction of the specular highlights coming from the
  46336. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  46337. */
  46338. specularIntensity: number;
  46339. /**
  46340. * Debug Control allowing disabling the bump map on this material.
  46341. */
  46342. disableBumpMap: boolean;
  46343. /**
  46344. * AKA Diffuse Texture in standard nomenclature.
  46345. */
  46346. albedoTexture: BaseTexture;
  46347. /**
  46348. * AKA Occlusion Texture in other nomenclature.
  46349. */
  46350. ambientTexture: BaseTexture;
  46351. /**
  46352. * AKA Occlusion Texture Intensity in other nomenclature.
  46353. */
  46354. ambientTextureStrength: number;
  46355. /**
  46356. * Defines how much the AO map is occluding the analytical lights (point spot...).
  46357. * 1 means it completely occludes it
  46358. * 0 mean it has no impact
  46359. */
  46360. ambientTextureImpactOnAnalyticalLights: number;
  46361. /**
  46362. * Stores the alpha values in a texture.
  46363. */
  46364. opacityTexture: BaseTexture;
  46365. /**
  46366. * Stores the reflection values in a texture.
  46367. */
  46368. reflectionTexture: Nullable<BaseTexture>;
  46369. /**
  46370. * Stores the emissive values in a texture.
  46371. */
  46372. emissiveTexture: BaseTexture;
  46373. /**
  46374. * AKA Specular texture in other nomenclature.
  46375. */
  46376. reflectivityTexture: BaseTexture;
  46377. /**
  46378. * Used to switch from specular/glossiness to metallic/roughness workflow.
  46379. */
  46380. metallicTexture: BaseTexture;
  46381. /**
  46382. * Specifies the metallic scalar of the metallic/roughness workflow.
  46383. * Can also be used to scale the metalness values of the metallic texture.
  46384. */
  46385. metallic: Nullable<number>;
  46386. /**
  46387. * Specifies the roughness scalar of the metallic/roughness workflow.
  46388. * Can also be used to scale the roughness values of the metallic texture.
  46389. */
  46390. roughness: Nullable<number>;
  46391. /**
  46392. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  46393. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  46394. */
  46395. microSurfaceTexture: BaseTexture;
  46396. /**
  46397. * Stores surface normal data used to displace a mesh in a texture.
  46398. */
  46399. bumpTexture: BaseTexture;
  46400. /**
  46401. * Stores the pre-calculated light information of a mesh in a texture.
  46402. */
  46403. lightmapTexture: BaseTexture;
  46404. /**
  46405. * Stores the refracted light information in a texture.
  46406. */
  46407. refractionTexture: Nullable<BaseTexture>;
  46408. /**
  46409. * The color of a material in ambient lighting.
  46410. */
  46411. ambientColor: Color3;
  46412. /**
  46413. * AKA Diffuse Color in other nomenclature.
  46414. */
  46415. albedoColor: Color3;
  46416. /**
  46417. * AKA Specular Color in other nomenclature.
  46418. */
  46419. reflectivityColor: Color3;
  46420. /**
  46421. * The color reflected from the material.
  46422. */
  46423. reflectionColor: Color3;
  46424. /**
  46425. * The color emitted from the material.
  46426. */
  46427. emissiveColor: Color3;
  46428. /**
  46429. * AKA Glossiness in other nomenclature.
  46430. */
  46431. microSurface: number;
  46432. /**
  46433. * source material index of refraction (IOR)' / 'destination material IOR.
  46434. */
  46435. indexOfRefraction: number;
  46436. /**
  46437. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46438. */
  46439. invertRefractionY: boolean;
  46440. /**
  46441. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46442. * Materials half opaque for instance using refraction could benefit from this control.
  46443. */
  46444. linkRefractionWithTransparency: boolean;
  46445. /**
  46446. * If true, the light map contains occlusion information instead of lighting info.
  46447. */
  46448. useLightmapAsShadowmap: boolean;
  46449. /**
  46450. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  46451. */
  46452. useAlphaFromAlbedoTexture: boolean;
  46453. /**
  46454. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  46455. */
  46456. forceAlphaTest: boolean;
  46457. /**
  46458. * Defines the alpha limits in alpha test mode.
  46459. */
  46460. alphaCutOff: number;
  46461. /**
  46462. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  46463. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  46464. */
  46465. useSpecularOverAlpha: boolean;
  46466. /**
  46467. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  46468. */
  46469. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  46470. /**
  46471. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  46472. */
  46473. useRoughnessFromMetallicTextureAlpha: boolean;
  46474. /**
  46475. * Specifies if the metallic texture contains the roughness information in its green channel.
  46476. */
  46477. useRoughnessFromMetallicTextureGreen: boolean;
  46478. /**
  46479. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46480. */
  46481. useMetallnessFromMetallicTextureBlue: boolean;
  46482. /**
  46483. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46484. */
  46485. useAmbientOcclusionFromMetallicTextureRed: boolean;
  46486. /**
  46487. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46488. */
  46489. useAmbientInGrayScale: boolean;
  46490. /**
  46491. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46492. * The material will try to infer what glossiness each pixel should be.
  46493. */
  46494. useAutoMicroSurfaceFromReflectivityMap: boolean;
  46495. /**
  46496. * BJS is using an harcoded light falloff based on a manually sets up range.
  46497. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46498. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46499. */
  46500. /**
  46501. * BJS is using an harcoded light falloff based on a manually sets up range.
  46502. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46503. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46504. */
  46505. usePhysicalLightFalloff: boolean;
  46506. /**
  46507. * In order to support the falloff compatibility with gltf, a special mode has been added
  46508. * to reproduce the gltf light falloff.
  46509. */
  46510. /**
  46511. * In order to support the falloff compatibility with gltf, a special mode has been added
  46512. * to reproduce the gltf light falloff.
  46513. */
  46514. useGLTFLightFalloff: boolean;
  46515. /**
  46516. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46517. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46518. */
  46519. useRadianceOverAlpha: boolean;
  46520. /**
  46521. * Allows using an object space normal map (instead of tangent space).
  46522. */
  46523. useObjectSpaceNormalMap: boolean;
  46524. /**
  46525. * Allows using the bump map in parallax mode.
  46526. */
  46527. useParallax: boolean;
  46528. /**
  46529. * Allows using the bump map in parallax occlusion mode.
  46530. */
  46531. useParallaxOcclusion: boolean;
  46532. /**
  46533. * Controls the scale bias of the parallax mode.
  46534. */
  46535. parallaxScaleBias: number;
  46536. /**
  46537. * If sets to true, disables all the lights affecting the material.
  46538. */
  46539. disableLighting: boolean;
  46540. /**
  46541. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46542. */
  46543. forceIrradianceInFragment: boolean;
  46544. /**
  46545. * Number of Simultaneous lights allowed on the material.
  46546. */
  46547. maxSimultaneousLights: number;
  46548. /**
  46549. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  46550. */
  46551. invertNormalMapX: boolean;
  46552. /**
  46553. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  46554. */
  46555. invertNormalMapY: boolean;
  46556. /**
  46557. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46558. */
  46559. twoSidedLighting: boolean;
  46560. /**
  46561. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46562. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46563. */
  46564. useAlphaFresnel: boolean;
  46565. /**
  46566. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46567. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46568. */
  46569. useLinearAlphaFresnel: boolean;
  46570. /**
  46571. * Let user defines the brdf lookup texture used for IBL.
  46572. * A default 8bit version is embedded but you could point at :
  46573. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  46574. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  46575. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  46576. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  46577. */
  46578. environmentBRDFTexture: Nullable<BaseTexture>;
  46579. /**
  46580. * Force normal to face away from face.
  46581. */
  46582. forceNormalForward: boolean;
  46583. /**
  46584. * Enables specular anti aliasing in the PBR shader.
  46585. * It will both interacts on the Geometry for analytical and IBL lighting.
  46586. * It also prefilter the roughness map based on the bump values.
  46587. */
  46588. enableSpecularAntiAliasing: boolean;
  46589. /**
  46590. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46591. * makes the reflect vector face the model (under horizon).
  46592. */
  46593. useHorizonOcclusion: boolean;
  46594. /**
  46595. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  46596. * too much the area relying on ambient texture to define their ambient occlusion.
  46597. */
  46598. useRadianceOcclusion: boolean;
  46599. /**
  46600. * If set to true, no lighting calculations will be applied.
  46601. */
  46602. unlit: boolean;
  46603. /**
  46604. * Gets the image processing configuration used either in this material.
  46605. */
  46606. /**
  46607. * Sets the Default image processing configuration used either in the this material.
  46608. *
  46609. * If sets to null, the scene one is in use.
  46610. */
  46611. imageProcessingConfiguration: ImageProcessingConfiguration;
  46612. /**
  46613. * Gets wether the color curves effect is enabled.
  46614. */
  46615. /**
  46616. * Sets wether the color curves effect is enabled.
  46617. */
  46618. cameraColorCurvesEnabled: boolean;
  46619. /**
  46620. * Gets wether the color grading effect is enabled.
  46621. */
  46622. /**
  46623. * Gets wether the color grading effect is enabled.
  46624. */
  46625. cameraColorGradingEnabled: boolean;
  46626. /**
  46627. * Gets wether tonemapping is enabled or not.
  46628. */
  46629. /**
  46630. * Sets wether tonemapping is enabled or not
  46631. */
  46632. cameraToneMappingEnabled: boolean;
  46633. /**
  46634. * The camera exposure used on this material.
  46635. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46636. * This corresponds to a photographic exposure.
  46637. */
  46638. /**
  46639. * The camera exposure used on this material.
  46640. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46641. * This corresponds to a photographic exposure.
  46642. */
  46643. cameraExposure: number;
  46644. /**
  46645. * Gets The camera contrast used on this material.
  46646. */
  46647. /**
  46648. * Sets The camera contrast used on this material.
  46649. */
  46650. cameraContrast: number;
  46651. /**
  46652. * Gets the Color Grading 2D Lookup Texture.
  46653. */
  46654. /**
  46655. * Sets the Color Grading 2D Lookup Texture.
  46656. */
  46657. cameraColorGradingTexture: Nullable<BaseTexture>;
  46658. /**
  46659. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46660. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46661. * 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;
  46662. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46663. */
  46664. /**
  46665. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46666. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46667. * 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;
  46668. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46669. */
  46670. cameraColorCurves: Nullable<ColorCurves>;
  46671. /**
  46672. * Instantiates a new PBRMaterial instance.
  46673. *
  46674. * @param name The material name
  46675. * @param scene The scene the material will be use in.
  46676. */
  46677. constructor(name: string, scene: Scene);
  46678. /**
  46679. * Returns the name of this material class.
  46680. */
  46681. getClassName(): string;
  46682. /**
  46683. * Makes a duplicate of the current material.
  46684. * @param name - name to use for the new material.
  46685. */
  46686. clone(name: string): PBRMaterial;
  46687. /**
  46688. * Serializes this PBR Material.
  46689. * @returns - An object with the serialized material.
  46690. */
  46691. serialize(): any;
  46692. /**
  46693. * Parses a PBR Material from a serialized object.
  46694. * @param source - Serialized object.
  46695. * @param scene - BJS scene instance.
  46696. * @param rootUrl - url for the scene object
  46697. * @returns - PBRMaterial
  46698. */
  46699. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  46700. }
  46701. }
  46702. declare module BABYLON {
  46703. /**
  46704. * Direct draw surface info
  46705. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  46706. */
  46707. export interface DDSInfo {
  46708. /**
  46709. * Width of the texture
  46710. */
  46711. width: number;
  46712. /**
  46713. * Width of the texture
  46714. */
  46715. height: number;
  46716. /**
  46717. * Number of Mipmaps for the texture
  46718. * @see https://en.wikipedia.org/wiki/Mipmap
  46719. */
  46720. mipmapCount: number;
  46721. /**
  46722. * If the textures format is a known fourCC format
  46723. * @see https://www.fourcc.org/
  46724. */
  46725. isFourCC: boolean;
  46726. /**
  46727. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  46728. */
  46729. isRGB: boolean;
  46730. /**
  46731. * If the texture is a lumincance format
  46732. */
  46733. isLuminance: boolean;
  46734. /**
  46735. * If this is a cube texture
  46736. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  46737. */
  46738. isCube: boolean;
  46739. /**
  46740. * If the texture is a compressed format eg. FOURCC_DXT1
  46741. */
  46742. isCompressed: boolean;
  46743. /**
  46744. * The dxgiFormat of the texture
  46745. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  46746. */
  46747. dxgiFormat: number;
  46748. /**
  46749. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  46750. */
  46751. textureType: number;
  46752. /**
  46753. * Sphericle polynomial created for the dds texture
  46754. */
  46755. sphericalPolynomial?: SphericalPolynomial;
  46756. }
  46757. /**
  46758. * Class used to provide DDS decompression tools
  46759. */
  46760. export class DDSTools {
  46761. /**
  46762. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  46763. */
  46764. static StoreLODInAlphaChannel: boolean;
  46765. /**
  46766. * Gets DDS information from an array buffer
  46767. * @param arrayBuffer defines the array buffer to read data from
  46768. * @returns the DDS information
  46769. */
  46770. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  46771. private static _FloatView;
  46772. private static _Int32View;
  46773. private static _ToHalfFloat;
  46774. private static _FromHalfFloat;
  46775. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  46776. private static _GetHalfFloatRGBAArrayBuffer;
  46777. private static _GetFloatRGBAArrayBuffer;
  46778. private static _GetFloatAsUIntRGBAArrayBuffer;
  46779. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  46780. private static _GetRGBAArrayBuffer;
  46781. private static _ExtractLongWordOrder;
  46782. private static _GetRGBArrayBuffer;
  46783. private static _GetLuminanceArrayBuffer;
  46784. /**
  46785. * Uploads DDS Levels to a Babylon Texture
  46786. * @hidden
  46787. */
  46788. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  46789. }
  46790. interface Engine {
  46791. /**
  46792. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  46793. * @param rootUrl defines the url where the file to load is located
  46794. * @param scene defines the current scene
  46795. * @param lodScale defines scale to apply to the mip map selection
  46796. * @param lodOffset defines offset to apply to the mip map selection
  46797. * @param onLoad defines an optional callback raised when the texture is loaded
  46798. * @param onError defines an optional callback raised if there is an issue to load the texture
  46799. * @param format defines the format of the data
  46800. * @param forcedExtension defines the extension to use to pick the right loader
  46801. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  46802. * @returns the cube texture as an InternalTexture
  46803. */
  46804. 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;
  46805. }
  46806. }
  46807. declare module BABYLON {
  46808. /**
  46809. * Implementation of the DDS Texture Loader.
  46810. * @hidden
  46811. */
  46812. export class _DDSTextureLoader implements IInternalTextureLoader {
  46813. /**
  46814. * Defines wether the loader supports cascade loading the different faces.
  46815. */
  46816. readonly supportCascades: boolean;
  46817. /**
  46818. * This returns if the loader support the current file information.
  46819. * @param extension defines the file extension of the file being loaded
  46820. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46821. * @param fallback defines the fallback internal texture if any
  46822. * @param isBase64 defines whether the texture is encoded as a base64
  46823. * @param isBuffer defines whether the texture data are stored as a buffer
  46824. * @returns true if the loader can load the specified file
  46825. */
  46826. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46827. /**
  46828. * Transform the url before loading if required.
  46829. * @param rootUrl the url of the texture
  46830. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46831. * @returns the transformed texture
  46832. */
  46833. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46834. /**
  46835. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46836. * @param rootUrl the url of the texture
  46837. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46838. * @returns the fallback texture
  46839. */
  46840. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46841. /**
  46842. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46843. * @param data contains the texture data
  46844. * @param texture defines the BabylonJS internal texture
  46845. * @param createPolynomials will be true if polynomials have been requested
  46846. * @param onLoad defines the callback to trigger once the texture is ready
  46847. * @param onError defines the callback to trigger in case of error
  46848. */
  46849. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46850. /**
  46851. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46852. * @param data contains the texture data
  46853. * @param texture defines the BabylonJS internal texture
  46854. * @param callback defines the method to call once ready to upload
  46855. */
  46856. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46857. }
  46858. }
  46859. declare module BABYLON {
  46860. /** @hidden */
  46861. export var rgbdEncodePixelShader: {
  46862. name: string;
  46863. shader: string;
  46864. };
  46865. }
  46866. declare module BABYLON {
  46867. /**
  46868. * Raw texture data and descriptor sufficient for WebGL texture upload
  46869. */
  46870. export interface EnvironmentTextureInfo {
  46871. /**
  46872. * Version of the environment map
  46873. */
  46874. version: number;
  46875. /**
  46876. * Width of image
  46877. */
  46878. width: number;
  46879. /**
  46880. * Irradiance information stored in the file.
  46881. */
  46882. irradiance: any;
  46883. /**
  46884. * Specular information stored in the file.
  46885. */
  46886. specular: any;
  46887. }
  46888. /**
  46889. * Sets of helpers addressing the serialization and deserialization of environment texture
  46890. * stored in a BabylonJS env file.
  46891. * Those files are usually stored as .env files.
  46892. */
  46893. export class EnvironmentTextureTools {
  46894. /**
  46895. * Magic number identifying the env file.
  46896. */
  46897. private static _MagicBytes;
  46898. /**
  46899. * Gets the environment info from an env file.
  46900. * @param data The array buffer containing the .env bytes.
  46901. * @returns the environment file info (the json header) if successfully parsed.
  46902. */
  46903. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46904. /**
  46905. * Creates an environment texture from a loaded cube texture.
  46906. * @param texture defines the cube texture to convert in env file
  46907. * @return a promise containing the environment data if succesfull.
  46908. */
  46909. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46910. /**
  46911. * Creates a JSON representation of the spherical data.
  46912. * @param texture defines the texture containing the polynomials
  46913. * @return the JSON representation of the spherical info
  46914. */
  46915. private static _CreateEnvTextureIrradiance;
  46916. /**
  46917. * Uploads the texture info contained in the env file to the GPU.
  46918. * @param texture defines the internal texture to upload to
  46919. * @param arrayBuffer defines the buffer cotaining the data to load
  46920. * @param info defines the texture info retrieved through the GetEnvInfo method
  46921. * @returns a promise
  46922. */
  46923. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46924. /**
  46925. * Uploads the levels of image data to the GPU.
  46926. * @param texture defines the internal texture to upload to
  46927. * @param imageData defines the array buffer views of image data [mipmap][face]
  46928. * @returns a promise
  46929. */
  46930. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46931. /**
  46932. * Uploads spherical polynomials information to the texture.
  46933. * @param texture defines the texture we are trying to upload the information to
  46934. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46935. */
  46936. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46937. /** @hidden */
  46938. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46939. }
  46940. }
  46941. declare module BABYLON {
  46942. /**
  46943. * Implementation of the ENV Texture Loader.
  46944. * @hidden
  46945. */
  46946. export class _ENVTextureLoader implements IInternalTextureLoader {
  46947. /**
  46948. * Defines wether the loader supports cascade loading the different faces.
  46949. */
  46950. readonly supportCascades: boolean;
  46951. /**
  46952. * This returns if the loader support the current file information.
  46953. * @param extension defines the file extension of the file being loaded
  46954. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46955. * @param fallback defines the fallback internal texture if any
  46956. * @param isBase64 defines whether the texture is encoded as a base64
  46957. * @param isBuffer defines whether the texture data are stored as a buffer
  46958. * @returns true if the loader can load the specified file
  46959. */
  46960. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46961. /**
  46962. * Transform the url before loading if required.
  46963. * @param rootUrl the url of the texture
  46964. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46965. * @returns the transformed texture
  46966. */
  46967. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46968. /**
  46969. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46970. * @param rootUrl the url of the texture
  46971. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46972. * @returns the fallback texture
  46973. */
  46974. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46975. /**
  46976. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46977. * @param data contains the texture data
  46978. * @param texture defines the BabylonJS internal texture
  46979. * @param createPolynomials will be true if polynomials have been requested
  46980. * @param onLoad defines the callback to trigger once the texture is ready
  46981. * @param onError defines the callback to trigger in case of error
  46982. */
  46983. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46984. /**
  46985. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46986. * @param data contains the texture data
  46987. * @param texture defines the BabylonJS internal texture
  46988. * @param callback defines the method to call once ready to upload
  46989. */
  46990. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46991. }
  46992. }
  46993. declare module BABYLON {
  46994. /**
  46995. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  46996. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  46997. */
  46998. export class KhronosTextureContainer {
  46999. /** contents of the KTX container file */
  47000. arrayBuffer: any;
  47001. private static HEADER_LEN;
  47002. private static COMPRESSED_2D;
  47003. private static COMPRESSED_3D;
  47004. private static TEX_2D;
  47005. private static TEX_3D;
  47006. /**
  47007. * Gets the openGL type
  47008. */
  47009. glType: number;
  47010. /**
  47011. * Gets the openGL type size
  47012. */
  47013. glTypeSize: number;
  47014. /**
  47015. * Gets the openGL format
  47016. */
  47017. glFormat: number;
  47018. /**
  47019. * Gets the openGL internal format
  47020. */
  47021. glInternalFormat: number;
  47022. /**
  47023. * Gets the base internal format
  47024. */
  47025. glBaseInternalFormat: number;
  47026. /**
  47027. * Gets image width in pixel
  47028. */
  47029. pixelWidth: number;
  47030. /**
  47031. * Gets image height in pixel
  47032. */
  47033. pixelHeight: number;
  47034. /**
  47035. * Gets image depth in pixels
  47036. */
  47037. pixelDepth: number;
  47038. /**
  47039. * Gets the number of array elements
  47040. */
  47041. numberOfArrayElements: number;
  47042. /**
  47043. * Gets the number of faces
  47044. */
  47045. numberOfFaces: number;
  47046. /**
  47047. * Gets the number of mipmap levels
  47048. */
  47049. numberOfMipmapLevels: number;
  47050. /**
  47051. * Gets the bytes of key value data
  47052. */
  47053. bytesOfKeyValueData: number;
  47054. /**
  47055. * Gets the load type
  47056. */
  47057. loadType: number;
  47058. /**
  47059. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  47060. */
  47061. isInvalid: boolean;
  47062. /**
  47063. * Creates a new KhronosTextureContainer
  47064. * @param arrayBuffer contents of the KTX container file
  47065. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  47066. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  47067. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  47068. */
  47069. constructor(
  47070. /** contents of the KTX container file */
  47071. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  47072. /**
  47073. * Uploads KTX content to a Babylon Texture.
  47074. * It is assumed that the texture has already been created & is currently bound
  47075. * @hidden
  47076. */
  47077. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  47078. private _upload2DCompressedLevels;
  47079. }
  47080. }
  47081. declare module BABYLON {
  47082. /**
  47083. * Implementation of the KTX Texture Loader.
  47084. * @hidden
  47085. */
  47086. export class _KTXTextureLoader implements IInternalTextureLoader {
  47087. /**
  47088. * Defines wether the loader supports cascade loading the different faces.
  47089. */
  47090. readonly supportCascades: boolean;
  47091. /**
  47092. * This returns if the loader support the current file information.
  47093. * @param extension defines the file extension of the file being loaded
  47094. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47095. * @param fallback defines the fallback internal texture if any
  47096. * @param isBase64 defines whether the texture is encoded as a base64
  47097. * @param isBuffer defines whether the texture data are stored as a buffer
  47098. * @returns true if the loader can load the specified file
  47099. */
  47100. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47101. /**
  47102. * Transform the url before loading if required.
  47103. * @param rootUrl the url of the texture
  47104. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47105. * @returns the transformed texture
  47106. */
  47107. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47108. /**
  47109. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47110. * @param rootUrl the url of the texture
  47111. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47112. * @returns the fallback texture
  47113. */
  47114. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47115. /**
  47116. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47117. * @param data contains the texture data
  47118. * @param texture defines the BabylonJS internal texture
  47119. * @param createPolynomials will be true if polynomials have been requested
  47120. * @param onLoad defines the callback to trigger once the texture is ready
  47121. * @param onError defines the callback to trigger in case of error
  47122. */
  47123. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47124. /**
  47125. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47126. * @param data contains the texture data
  47127. * @param texture defines the BabylonJS internal texture
  47128. * @param callback defines the method to call once ready to upload
  47129. */
  47130. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  47131. }
  47132. }
  47133. declare module BABYLON {
  47134. /** @hidden */
  47135. export var _forceSceneHelpersToBundle: boolean;
  47136. interface Scene {
  47137. /**
  47138. * Creates a default light for the scene.
  47139. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  47140. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  47141. */
  47142. createDefaultLight(replace?: boolean): void;
  47143. /**
  47144. * Creates a default camera for the scene.
  47145. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  47146. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47147. * @param replace has default false, when true replaces the active camera in the scene
  47148. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  47149. */
  47150. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47151. /**
  47152. * Creates a default camera and a default light.
  47153. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  47154. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47155. * @param replace has the default false, when true replaces the active camera/light in the scene
  47156. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  47157. */
  47158. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47159. /**
  47160. * Creates a new sky box
  47161. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  47162. * @param environmentTexture defines the texture to use as environment texture
  47163. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  47164. * @param scale defines the overall scale of the skybox
  47165. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  47166. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  47167. * @returns a new mesh holding the sky box
  47168. */
  47169. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  47170. /**
  47171. * Creates a new environment
  47172. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  47173. * @param options defines the options you can use to configure the environment
  47174. * @returns the new EnvironmentHelper
  47175. */
  47176. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  47177. /**
  47178. * Creates a new VREXperienceHelper
  47179. * @see http://doc.babylonjs.com/how_to/webvr_helper
  47180. * @param webVROptions defines the options used to create the new VREXperienceHelper
  47181. * @returns a new VREXperienceHelper
  47182. */
  47183. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  47184. /**
  47185. * Creates a new XREXperienceHelper
  47186. * @see http://doc.babylonjs.com/how_to/webxr
  47187. * @returns a promise for a new XREXperienceHelper
  47188. */
  47189. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  47190. }
  47191. }
  47192. declare module BABYLON {
  47193. /**
  47194. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  47195. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  47196. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  47197. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  47198. */
  47199. export class VideoDome extends TransformNode {
  47200. /**
  47201. * Define the video source as a Monoscopic panoramic 360 video.
  47202. */
  47203. static readonly MODE_MONOSCOPIC: number;
  47204. /**
  47205. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  47206. */
  47207. static readonly MODE_TOPBOTTOM: number;
  47208. /**
  47209. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  47210. */
  47211. static readonly MODE_SIDEBYSIDE: number;
  47212. private _useDirectMapping;
  47213. /**
  47214. * The video texture being displayed on the sphere
  47215. */
  47216. protected _videoTexture: VideoTexture;
  47217. /**
  47218. * Gets the video texture being displayed on the sphere
  47219. */
  47220. readonly videoTexture: VideoTexture;
  47221. /**
  47222. * The skybox material
  47223. */
  47224. protected _material: BackgroundMaterial;
  47225. /**
  47226. * The surface used for the skybox
  47227. */
  47228. protected _mesh: Mesh;
  47229. /**
  47230. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47231. * Also see the options.resolution property.
  47232. */
  47233. fovMultiplier: number;
  47234. private _videoMode;
  47235. /**
  47236. * Gets or set the current video mode for the video. It can be:
  47237. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  47238. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  47239. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  47240. */
  47241. videoMode: number;
  47242. /**
  47243. * Oberserver used in Stereoscopic VR Mode.
  47244. */
  47245. private _onBeforeCameraRenderObserver;
  47246. /**
  47247. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  47248. * @param name Element's name, child elements will append suffixes for their own names.
  47249. * @param urlsOrVideo defines the url(s) or the video element to use
  47250. * @param options An object containing optional or exposed sub element properties
  47251. */
  47252. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  47253. resolution?: number;
  47254. clickToPlay?: boolean;
  47255. autoPlay?: boolean;
  47256. loop?: boolean;
  47257. size?: number;
  47258. poster?: string;
  47259. faceForward?: boolean;
  47260. useDirectMapping?: boolean;
  47261. }, scene: Scene);
  47262. private _changeVideoMode;
  47263. /**
  47264. * Releases resources associated with this node.
  47265. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  47266. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  47267. */
  47268. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  47269. }
  47270. }
  47271. declare module BABYLON {
  47272. /**
  47273. * This class can be used to get instrumentation data from a Babylon engine
  47274. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  47275. */
  47276. export class EngineInstrumentation implements IDisposable {
  47277. /**
  47278. * Define the instrumented engine.
  47279. */
  47280. engine: Engine;
  47281. private _captureGPUFrameTime;
  47282. private _gpuFrameTimeToken;
  47283. private _gpuFrameTime;
  47284. private _captureShaderCompilationTime;
  47285. private _shaderCompilationTime;
  47286. private _onBeginFrameObserver;
  47287. private _onEndFrameObserver;
  47288. private _onBeforeShaderCompilationObserver;
  47289. private _onAfterShaderCompilationObserver;
  47290. /**
  47291. * Gets the perf counter used for GPU frame time
  47292. */
  47293. readonly gpuFrameTimeCounter: PerfCounter;
  47294. /**
  47295. * Gets the GPU frame time capture status
  47296. */
  47297. /**
  47298. * Enable or disable the GPU frame time capture
  47299. */
  47300. captureGPUFrameTime: boolean;
  47301. /**
  47302. * Gets the perf counter used for shader compilation time
  47303. */
  47304. readonly shaderCompilationTimeCounter: PerfCounter;
  47305. /**
  47306. * Gets the shader compilation time capture status
  47307. */
  47308. /**
  47309. * Enable or disable the shader compilation time capture
  47310. */
  47311. captureShaderCompilationTime: boolean;
  47312. /**
  47313. * Instantiates a new engine instrumentation.
  47314. * This class can be used to get instrumentation data from a Babylon engine
  47315. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  47316. * @param engine Defines the engine to instrument
  47317. */
  47318. constructor(
  47319. /**
  47320. * Define the instrumented engine.
  47321. */
  47322. engine: Engine);
  47323. /**
  47324. * Dispose and release associated resources.
  47325. */
  47326. dispose(): void;
  47327. }
  47328. }
  47329. declare module BABYLON {
  47330. /**
  47331. * This class can be used to get instrumentation data from a Babylon engine
  47332. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  47333. */
  47334. export class SceneInstrumentation implements IDisposable {
  47335. /**
  47336. * Defines the scene to instrument
  47337. */
  47338. scene: Scene;
  47339. private _captureActiveMeshesEvaluationTime;
  47340. private _activeMeshesEvaluationTime;
  47341. private _captureRenderTargetsRenderTime;
  47342. private _renderTargetsRenderTime;
  47343. private _captureFrameTime;
  47344. private _frameTime;
  47345. private _captureRenderTime;
  47346. private _renderTime;
  47347. private _captureInterFrameTime;
  47348. private _interFrameTime;
  47349. private _captureParticlesRenderTime;
  47350. private _particlesRenderTime;
  47351. private _captureSpritesRenderTime;
  47352. private _spritesRenderTime;
  47353. private _capturePhysicsTime;
  47354. private _physicsTime;
  47355. private _captureAnimationsTime;
  47356. private _animationsTime;
  47357. private _captureCameraRenderTime;
  47358. private _cameraRenderTime;
  47359. private _onBeforeActiveMeshesEvaluationObserver;
  47360. private _onAfterActiveMeshesEvaluationObserver;
  47361. private _onBeforeRenderTargetsRenderObserver;
  47362. private _onAfterRenderTargetsRenderObserver;
  47363. private _onAfterRenderObserver;
  47364. private _onBeforeDrawPhaseObserver;
  47365. private _onAfterDrawPhaseObserver;
  47366. private _onBeforeAnimationsObserver;
  47367. private _onBeforeParticlesRenderingObserver;
  47368. private _onAfterParticlesRenderingObserver;
  47369. private _onBeforeSpritesRenderingObserver;
  47370. private _onAfterSpritesRenderingObserver;
  47371. private _onBeforePhysicsObserver;
  47372. private _onAfterPhysicsObserver;
  47373. private _onAfterAnimationsObserver;
  47374. private _onBeforeCameraRenderObserver;
  47375. private _onAfterCameraRenderObserver;
  47376. /**
  47377. * Gets the perf counter used for active meshes evaluation time
  47378. */
  47379. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  47380. /**
  47381. * Gets the active meshes evaluation time capture status
  47382. */
  47383. /**
  47384. * Enable or disable the active meshes evaluation time capture
  47385. */
  47386. captureActiveMeshesEvaluationTime: boolean;
  47387. /**
  47388. * Gets the perf counter used for render targets render time
  47389. */
  47390. readonly renderTargetsRenderTimeCounter: PerfCounter;
  47391. /**
  47392. * Gets the render targets render time capture status
  47393. */
  47394. /**
  47395. * Enable or disable the render targets render time capture
  47396. */
  47397. captureRenderTargetsRenderTime: boolean;
  47398. /**
  47399. * Gets the perf counter used for particles render time
  47400. */
  47401. readonly particlesRenderTimeCounter: PerfCounter;
  47402. /**
  47403. * Gets the particles render time capture status
  47404. */
  47405. /**
  47406. * Enable or disable the particles render time capture
  47407. */
  47408. captureParticlesRenderTime: boolean;
  47409. /**
  47410. * Gets the perf counter used for sprites render time
  47411. */
  47412. readonly spritesRenderTimeCounter: PerfCounter;
  47413. /**
  47414. * Gets the sprites render time capture status
  47415. */
  47416. /**
  47417. * Enable or disable the sprites render time capture
  47418. */
  47419. captureSpritesRenderTime: boolean;
  47420. /**
  47421. * Gets the perf counter used for physics time
  47422. */
  47423. readonly physicsTimeCounter: PerfCounter;
  47424. /**
  47425. * Gets the physics time capture status
  47426. */
  47427. /**
  47428. * Enable or disable the physics time capture
  47429. */
  47430. capturePhysicsTime: boolean;
  47431. /**
  47432. * Gets the perf counter used for animations time
  47433. */
  47434. readonly animationsTimeCounter: PerfCounter;
  47435. /**
  47436. * Gets the animations time capture status
  47437. */
  47438. /**
  47439. * Enable or disable the animations time capture
  47440. */
  47441. captureAnimationsTime: boolean;
  47442. /**
  47443. * Gets the perf counter used for frame time capture
  47444. */
  47445. readonly frameTimeCounter: PerfCounter;
  47446. /**
  47447. * Gets the frame time capture status
  47448. */
  47449. /**
  47450. * Enable or disable the frame time capture
  47451. */
  47452. captureFrameTime: boolean;
  47453. /**
  47454. * Gets the perf counter used for inter-frames time capture
  47455. */
  47456. readonly interFrameTimeCounter: PerfCounter;
  47457. /**
  47458. * Gets the inter-frames time capture status
  47459. */
  47460. /**
  47461. * Enable or disable the inter-frames time capture
  47462. */
  47463. captureInterFrameTime: boolean;
  47464. /**
  47465. * Gets the perf counter used for render time capture
  47466. */
  47467. readonly renderTimeCounter: PerfCounter;
  47468. /**
  47469. * Gets the render time capture status
  47470. */
  47471. /**
  47472. * Enable or disable the render time capture
  47473. */
  47474. captureRenderTime: boolean;
  47475. /**
  47476. * Gets the perf counter used for camera render time capture
  47477. */
  47478. readonly cameraRenderTimeCounter: PerfCounter;
  47479. /**
  47480. * Gets the camera render time capture status
  47481. */
  47482. /**
  47483. * Enable or disable the camera render time capture
  47484. */
  47485. captureCameraRenderTime: boolean;
  47486. /**
  47487. * Gets the perf counter used for draw calls
  47488. */
  47489. readonly drawCallsCounter: PerfCounter;
  47490. /**
  47491. * Instantiates a new scene instrumentation.
  47492. * This class can be used to get instrumentation data from a Babylon engine
  47493. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  47494. * @param scene Defines the scene to instrument
  47495. */
  47496. constructor(
  47497. /**
  47498. * Defines the scene to instrument
  47499. */
  47500. scene: Scene);
  47501. /**
  47502. * Dispose and release associated resources.
  47503. */
  47504. dispose(): void;
  47505. }
  47506. }
  47507. declare module BABYLON {
  47508. /** @hidden */
  47509. export var glowMapGenerationPixelShader: {
  47510. name: string;
  47511. shader: string;
  47512. };
  47513. }
  47514. declare module BABYLON {
  47515. /** @hidden */
  47516. export var glowMapGenerationVertexShader: {
  47517. name: string;
  47518. shader: string;
  47519. };
  47520. }
  47521. declare module BABYLON {
  47522. /**
  47523. * Effect layer options. This helps customizing the behaviour
  47524. * of the effect layer.
  47525. */
  47526. export interface IEffectLayerOptions {
  47527. /**
  47528. * Multiplication factor apply to the canvas size to compute the render target size
  47529. * used to generated the objects (the smaller the faster).
  47530. */
  47531. mainTextureRatio: number;
  47532. /**
  47533. * Enforces a fixed size texture to ensure effect stability across devices.
  47534. */
  47535. mainTextureFixedSize?: number;
  47536. /**
  47537. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  47538. */
  47539. alphaBlendingMode: number;
  47540. /**
  47541. * The camera attached to the layer.
  47542. */
  47543. camera: Nullable<Camera>;
  47544. /**
  47545. * The rendering group to draw the layer in.
  47546. */
  47547. renderingGroupId: number;
  47548. }
  47549. /**
  47550. * The effect layer Helps adding post process effect blended with the main pass.
  47551. *
  47552. * This can be for instance use to generate glow or higlight effects on the scene.
  47553. *
  47554. * The effect layer class can not be used directly and is intented to inherited from to be
  47555. * customized per effects.
  47556. */
  47557. export abstract class EffectLayer {
  47558. private _vertexBuffers;
  47559. private _indexBuffer;
  47560. private _cachedDefines;
  47561. private _effectLayerMapGenerationEffect;
  47562. private _effectLayerOptions;
  47563. private _mergeEffect;
  47564. protected _scene: Scene;
  47565. protected _engine: Engine;
  47566. protected _maxSize: number;
  47567. protected _mainTextureDesiredSize: ISize;
  47568. protected _mainTexture: RenderTargetTexture;
  47569. protected _shouldRender: boolean;
  47570. protected _postProcesses: PostProcess[];
  47571. protected _textures: BaseTexture[];
  47572. protected _emissiveTextureAndColor: {
  47573. texture: Nullable<BaseTexture>;
  47574. color: Color4;
  47575. };
  47576. /**
  47577. * The name of the layer
  47578. */
  47579. name: string;
  47580. /**
  47581. * The clear color of the texture used to generate the glow map.
  47582. */
  47583. neutralColor: Color4;
  47584. /**
  47585. * Specifies wether the highlight layer is enabled or not.
  47586. */
  47587. isEnabled: boolean;
  47588. /**
  47589. * Gets the camera attached to the layer.
  47590. */
  47591. readonly camera: Nullable<Camera>;
  47592. /**
  47593. * Gets the rendering group id the layer should render in.
  47594. */
  47595. renderingGroupId: number;
  47596. /**
  47597. * An event triggered when the effect layer has been disposed.
  47598. */
  47599. onDisposeObservable: Observable<EffectLayer>;
  47600. /**
  47601. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  47602. */
  47603. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  47604. /**
  47605. * An event triggered when the generated texture is being merged in the scene.
  47606. */
  47607. onBeforeComposeObservable: Observable<EffectLayer>;
  47608. /**
  47609. * An event triggered when the generated texture has been merged in the scene.
  47610. */
  47611. onAfterComposeObservable: Observable<EffectLayer>;
  47612. /**
  47613. * An event triggered when the efffect layer changes its size.
  47614. */
  47615. onSizeChangedObservable: Observable<EffectLayer>;
  47616. /** @hidden */
  47617. static _SceneComponentInitialization: (scene: Scene) => void;
  47618. /**
  47619. * Instantiates a new effect Layer and references it in the scene.
  47620. * @param name The name of the layer
  47621. * @param scene The scene to use the layer in
  47622. */
  47623. constructor(
  47624. /** The Friendly of the effect in the scene */
  47625. name: string, scene: Scene);
  47626. /**
  47627. * Get the effect name of the layer.
  47628. * @return The effect name
  47629. */
  47630. abstract getEffectName(): string;
  47631. /**
  47632. * Checks for the readiness of the element composing the layer.
  47633. * @param subMesh the mesh to check for
  47634. * @param useInstances specify wether or not to use instances to render the mesh
  47635. * @return true if ready otherwise, false
  47636. */
  47637. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47638. /**
  47639. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47640. * @returns true if the effect requires stencil during the main canvas render pass.
  47641. */
  47642. abstract needStencil(): boolean;
  47643. /**
  47644. * Create the merge effect. This is the shader use to blit the information back
  47645. * to the main canvas at the end of the scene rendering.
  47646. * @returns The effect containing the shader used to merge the effect on the main canvas
  47647. */
  47648. protected abstract _createMergeEffect(): Effect;
  47649. /**
  47650. * Creates the render target textures and post processes used in the effect layer.
  47651. */
  47652. protected abstract _createTextureAndPostProcesses(): void;
  47653. /**
  47654. * Implementation specific of rendering the generating effect on the main canvas.
  47655. * @param effect The effect used to render through
  47656. */
  47657. protected abstract _internalRender(effect: Effect): void;
  47658. /**
  47659. * Sets the required values for both the emissive texture and and the main color.
  47660. */
  47661. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47662. /**
  47663. * Free any resources and references associated to a mesh.
  47664. * Internal use
  47665. * @param mesh The mesh to free.
  47666. */
  47667. abstract _disposeMesh(mesh: Mesh): void;
  47668. /**
  47669. * Serializes this layer (Glow or Highlight for example)
  47670. * @returns a serialized layer object
  47671. */
  47672. abstract serialize?(): any;
  47673. /**
  47674. * Initializes the effect layer with the required options.
  47675. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  47676. */
  47677. protected _init(options: Partial<IEffectLayerOptions>): void;
  47678. /**
  47679. * Generates the index buffer of the full screen quad blending to the main canvas.
  47680. */
  47681. private _generateIndexBuffer;
  47682. /**
  47683. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  47684. */
  47685. private _generateVertexBuffer;
  47686. /**
  47687. * Sets the main texture desired size which is the closest power of two
  47688. * of the engine canvas size.
  47689. */
  47690. private _setMainTextureSize;
  47691. /**
  47692. * Creates the main texture for the effect layer.
  47693. */
  47694. protected _createMainTexture(): void;
  47695. /**
  47696. * Adds specific effects defines.
  47697. * @param defines The defines to add specifics to.
  47698. */
  47699. protected _addCustomEffectDefines(defines: string[]): void;
  47700. /**
  47701. * Checks for the readiness of the element composing the layer.
  47702. * @param subMesh the mesh to check for
  47703. * @param useInstances specify wether or not to use instances to render the mesh
  47704. * @param emissiveTexture the associated emissive texture used to generate the glow
  47705. * @return true if ready otherwise, false
  47706. */
  47707. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  47708. /**
  47709. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  47710. */
  47711. render(): void;
  47712. /**
  47713. * Determine if a given mesh will be used in the current effect.
  47714. * @param mesh mesh to test
  47715. * @returns true if the mesh will be used
  47716. */
  47717. hasMesh(mesh: AbstractMesh): boolean;
  47718. /**
  47719. * Returns true if the layer contains information to display, otherwise false.
  47720. * @returns true if the glow layer should be rendered
  47721. */
  47722. shouldRender(): boolean;
  47723. /**
  47724. * Returns true if the mesh should render, otherwise false.
  47725. * @param mesh The mesh to render
  47726. * @returns true if it should render otherwise false
  47727. */
  47728. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  47729. /**
  47730. * Returns true if the mesh can be rendered, otherwise false.
  47731. * @param mesh The mesh to render
  47732. * @param material The material used on the mesh
  47733. * @returns true if it can be rendered otherwise false
  47734. */
  47735. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47736. /**
  47737. * Returns true if the mesh should render, otherwise false.
  47738. * @param mesh The mesh to render
  47739. * @returns true if it should render otherwise false
  47740. */
  47741. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  47742. /**
  47743. * Renders the submesh passed in parameter to the generation map.
  47744. */
  47745. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  47746. /**
  47747. * Rebuild the required buffers.
  47748. * @hidden Internal use only.
  47749. */
  47750. _rebuild(): void;
  47751. /**
  47752. * Dispose only the render target textures and post process.
  47753. */
  47754. private _disposeTextureAndPostProcesses;
  47755. /**
  47756. * Dispose the highlight layer and free resources.
  47757. */
  47758. dispose(): void;
  47759. /**
  47760. * Gets the class name of the effect layer
  47761. * @returns the string with the class name of the effect layer
  47762. */
  47763. getClassName(): string;
  47764. /**
  47765. * Creates an effect layer from parsed effect layer data
  47766. * @param parsedEffectLayer defines effect layer data
  47767. * @param scene defines the current scene
  47768. * @param rootUrl defines the root URL containing the effect layer information
  47769. * @returns a parsed effect Layer
  47770. */
  47771. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  47772. }
  47773. }
  47774. declare module BABYLON {
  47775. interface AbstractScene {
  47776. /**
  47777. * The list of effect layers (highlights/glow) added to the scene
  47778. * @see http://doc.babylonjs.com/how_to/highlight_layer
  47779. * @see http://doc.babylonjs.com/how_to/glow_layer
  47780. */
  47781. effectLayers: Array<EffectLayer>;
  47782. /**
  47783. * Removes the given effect layer from this scene.
  47784. * @param toRemove defines the effect layer to remove
  47785. * @returns the index of the removed effect layer
  47786. */
  47787. removeEffectLayer(toRemove: EffectLayer): number;
  47788. /**
  47789. * Adds the given effect layer to this scene
  47790. * @param newEffectLayer defines the effect layer to add
  47791. */
  47792. addEffectLayer(newEffectLayer: EffectLayer): void;
  47793. }
  47794. /**
  47795. * Defines the layer scene component responsible to manage any effect layers
  47796. * in a given scene.
  47797. */
  47798. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  47799. /**
  47800. * The component name helpfull to identify the component in the list of scene components.
  47801. */
  47802. readonly name: string;
  47803. /**
  47804. * The scene the component belongs to.
  47805. */
  47806. scene: Scene;
  47807. private _engine;
  47808. private _renderEffects;
  47809. private _needStencil;
  47810. private _previousStencilState;
  47811. /**
  47812. * Creates a new instance of the component for the given scene
  47813. * @param scene Defines the scene to register the component in
  47814. */
  47815. constructor(scene: Scene);
  47816. /**
  47817. * Registers the component in a given scene
  47818. */
  47819. register(): void;
  47820. /**
  47821. * Rebuilds the elements related to this component in case of
  47822. * context lost for instance.
  47823. */
  47824. rebuild(): void;
  47825. /**
  47826. * Serializes the component data to the specified json object
  47827. * @param serializationObject The object to serialize to
  47828. */
  47829. serialize(serializationObject: any): void;
  47830. /**
  47831. * Adds all the elements from the container to the scene
  47832. * @param container the container holding the elements
  47833. */
  47834. addFromContainer(container: AbstractScene): void;
  47835. /**
  47836. * Removes all the elements in the container from the scene
  47837. * @param container contains the elements to remove
  47838. * @param dispose if the removed element should be disposed (default: false)
  47839. */
  47840. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47841. /**
  47842. * Disposes the component and the associated ressources.
  47843. */
  47844. dispose(): void;
  47845. private _isReadyForMesh;
  47846. private _renderMainTexture;
  47847. private _setStencil;
  47848. private _setStencilBack;
  47849. private _draw;
  47850. private _drawCamera;
  47851. private _drawRenderingGroup;
  47852. }
  47853. }
  47854. declare module BABYLON {
  47855. /** @hidden */
  47856. export var glowMapMergePixelShader: {
  47857. name: string;
  47858. shader: string;
  47859. };
  47860. }
  47861. declare module BABYLON {
  47862. /** @hidden */
  47863. export var glowMapMergeVertexShader: {
  47864. name: string;
  47865. shader: string;
  47866. };
  47867. }
  47868. declare module BABYLON {
  47869. interface AbstractScene {
  47870. /**
  47871. * Return a the first highlight layer of the scene with a given name.
  47872. * @param name The name of the highlight layer to look for.
  47873. * @return The highlight layer if found otherwise null.
  47874. */
  47875. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  47876. }
  47877. /**
  47878. * Glow layer options. This helps customizing the behaviour
  47879. * of the glow layer.
  47880. */
  47881. export interface IGlowLayerOptions {
  47882. /**
  47883. * Multiplication factor apply to the canvas size to compute the render target size
  47884. * used to generated the glowing objects (the smaller the faster).
  47885. */
  47886. mainTextureRatio: number;
  47887. /**
  47888. * Enforces a fixed size texture to ensure resize independant blur.
  47889. */
  47890. mainTextureFixedSize?: number;
  47891. /**
  47892. * How big is the kernel of the blur texture.
  47893. */
  47894. blurKernelSize: number;
  47895. /**
  47896. * The camera attached to the layer.
  47897. */
  47898. camera: Nullable<Camera>;
  47899. /**
  47900. * Enable MSAA by chosing the number of samples.
  47901. */
  47902. mainTextureSamples?: number;
  47903. /**
  47904. * The rendering group to draw the layer in.
  47905. */
  47906. renderingGroupId: number;
  47907. }
  47908. /**
  47909. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  47910. *
  47911. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47912. * glowy meshes to your scene.
  47913. *
  47914. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  47915. */
  47916. export class GlowLayer extends EffectLayer {
  47917. /**
  47918. * Effect Name of the layer.
  47919. */
  47920. static readonly EffectName: string;
  47921. /**
  47922. * The default blur kernel size used for the glow.
  47923. */
  47924. static DefaultBlurKernelSize: number;
  47925. /**
  47926. * The default texture size ratio used for the glow.
  47927. */
  47928. static DefaultTextureRatio: number;
  47929. /**
  47930. * Sets the kernel size of the blur.
  47931. */
  47932. /**
  47933. * Gets the kernel size of the blur.
  47934. */
  47935. blurKernelSize: number;
  47936. /**
  47937. * Sets the glow intensity.
  47938. */
  47939. /**
  47940. * Gets the glow intensity.
  47941. */
  47942. intensity: number;
  47943. private _options;
  47944. private _intensity;
  47945. private _horizontalBlurPostprocess1;
  47946. private _verticalBlurPostprocess1;
  47947. private _horizontalBlurPostprocess2;
  47948. private _verticalBlurPostprocess2;
  47949. private _blurTexture1;
  47950. private _blurTexture2;
  47951. private _postProcesses1;
  47952. private _postProcesses2;
  47953. private _includedOnlyMeshes;
  47954. private _excludedMeshes;
  47955. /**
  47956. * Callback used to let the user override the color selection on a per mesh basis
  47957. */
  47958. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  47959. /**
  47960. * Callback used to let the user override the texture selection on a per mesh basis
  47961. */
  47962. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  47963. /**
  47964. * Instantiates a new glow Layer and references it to the scene.
  47965. * @param name The name of the layer
  47966. * @param scene The scene to use the layer in
  47967. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  47968. */
  47969. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  47970. /**
  47971. * Get the effect name of the layer.
  47972. * @return The effect name
  47973. */
  47974. getEffectName(): string;
  47975. /**
  47976. * Create the merge effect. This is the shader use to blit the information back
  47977. * to the main canvas at the end of the scene rendering.
  47978. */
  47979. protected _createMergeEffect(): Effect;
  47980. /**
  47981. * Creates the render target textures and post processes used in the glow layer.
  47982. */
  47983. protected _createTextureAndPostProcesses(): void;
  47984. /**
  47985. * Checks for the readiness of the element composing the layer.
  47986. * @param subMesh the mesh to check for
  47987. * @param useInstances specify wether or not to use instances to render the mesh
  47988. * @param emissiveTexture the associated emissive texture used to generate the glow
  47989. * @return true if ready otherwise, false
  47990. */
  47991. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47992. /**
  47993. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47994. */
  47995. needStencil(): boolean;
  47996. /**
  47997. * Returns true if the mesh can be rendered, otherwise false.
  47998. * @param mesh The mesh to render
  47999. * @param material The material used on the mesh
  48000. * @returns true if it can be rendered otherwise false
  48001. */
  48002. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48003. /**
  48004. * Implementation specific of rendering the generating effect on the main canvas.
  48005. * @param effect The effect used to render through
  48006. */
  48007. protected _internalRender(effect: Effect): void;
  48008. /**
  48009. * Sets the required values for both the emissive texture and and the main color.
  48010. */
  48011. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48012. /**
  48013. * Returns true if the mesh should render, otherwise false.
  48014. * @param mesh The mesh to render
  48015. * @returns true if it should render otherwise false
  48016. */
  48017. protected _shouldRenderMesh(mesh: Mesh): boolean;
  48018. /**
  48019. * Adds specific effects defines.
  48020. * @param defines The defines to add specifics to.
  48021. */
  48022. protected _addCustomEffectDefines(defines: string[]): void;
  48023. /**
  48024. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  48025. * @param mesh The mesh to exclude from the glow layer
  48026. */
  48027. addExcludedMesh(mesh: Mesh): void;
  48028. /**
  48029. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  48030. * @param mesh The mesh to remove
  48031. */
  48032. removeExcludedMesh(mesh: Mesh): void;
  48033. /**
  48034. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  48035. * @param mesh The mesh to include in the glow layer
  48036. */
  48037. addIncludedOnlyMesh(mesh: Mesh): void;
  48038. /**
  48039. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  48040. * @param mesh The mesh to remove
  48041. */
  48042. removeIncludedOnlyMesh(mesh: Mesh): void;
  48043. /**
  48044. * Determine if a given mesh will be used in the glow layer
  48045. * @param mesh The mesh to test
  48046. * @returns true if the mesh will be highlighted by the current glow layer
  48047. */
  48048. hasMesh(mesh: AbstractMesh): boolean;
  48049. /**
  48050. * Free any resources and references associated to a mesh.
  48051. * Internal use
  48052. * @param mesh The mesh to free.
  48053. * @hidden
  48054. */
  48055. _disposeMesh(mesh: Mesh): void;
  48056. /**
  48057. * Gets the class name of the effect layer
  48058. * @returns the string with the class name of the effect layer
  48059. */
  48060. getClassName(): string;
  48061. /**
  48062. * Serializes this glow layer
  48063. * @returns a serialized glow layer object
  48064. */
  48065. serialize(): any;
  48066. /**
  48067. * Creates a Glow Layer from parsed glow layer data
  48068. * @param parsedGlowLayer defines glow layer data
  48069. * @param scene defines the current scene
  48070. * @param rootUrl defines the root URL containing the glow layer information
  48071. * @returns a parsed Glow Layer
  48072. */
  48073. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  48074. }
  48075. }
  48076. declare module BABYLON {
  48077. /** @hidden */
  48078. export var glowBlurPostProcessPixelShader: {
  48079. name: string;
  48080. shader: string;
  48081. };
  48082. }
  48083. declare module BABYLON {
  48084. interface AbstractScene {
  48085. /**
  48086. * Return a the first highlight layer of the scene with a given name.
  48087. * @param name The name of the highlight layer to look for.
  48088. * @return The highlight layer if found otherwise null.
  48089. */
  48090. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  48091. }
  48092. /**
  48093. * Highlight layer options. This helps customizing the behaviour
  48094. * of the highlight layer.
  48095. */
  48096. export interface IHighlightLayerOptions {
  48097. /**
  48098. * Multiplication factor apply to the canvas size to compute the render target size
  48099. * used to generated the glowing objects (the smaller the faster).
  48100. */
  48101. mainTextureRatio: number;
  48102. /**
  48103. * Enforces a fixed size texture to ensure resize independant blur.
  48104. */
  48105. mainTextureFixedSize?: number;
  48106. /**
  48107. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  48108. * of the picture to blur (the smaller the faster).
  48109. */
  48110. blurTextureSizeRatio: number;
  48111. /**
  48112. * How big in texel of the blur texture is the vertical blur.
  48113. */
  48114. blurVerticalSize: number;
  48115. /**
  48116. * How big in texel of the blur texture is the horizontal blur.
  48117. */
  48118. blurHorizontalSize: number;
  48119. /**
  48120. * Alpha blending mode used to apply the blur. Default is combine.
  48121. */
  48122. alphaBlendingMode: number;
  48123. /**
  48124. * The camera attached to the layer.
  48125. */
  48126. camera: Nullable<Camera>;
  48127. /**
  48128. * Should we display highlight as a solid stroke?
  48129. */
  48130. isStroke?: boolean;
  48131. /**
  48132. * The rendering group to draw the layer in.
  48133. */
  48134. renderingGroupId: number;
  48135. }
  48136. /**
  48137. * The highlight layer Helps adding a glow effect around a mesh.
  48138. *
  48139. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  48140. * glowy meshes to your scene.
  48141. *
  48142. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  48143. */
  48144. export class HighlightLayer extends EffectLayer {
  48145. name: string;
  48146. /**
  48147. * Effect Name of the highlight layer.
  48148. */
  48149. static readonly EffectName: string;
  48150. /**
  48151. * The neutral color used during the preparation of the glow effect.
  48152. * This is black by default as the blend operation is a blend operation.
  48153. */
  48154. static NeutralColor: Color4;
  48155. /**
  48156. * Stencil value used for glowing meshes.
  48157. */
  48158. static GlowingMeshStencilReference: number;
  48159. /**
  48160. * Stencil value used for the other meshes in the scene.
  48161. */
  48162. static NormalMeshStencilReference: number;
  48163. /**
  48164. * Specifies whether or not the inner glow is ACTIVE in the layer.
  48165. */
  48166. innerGlow: boolean;
  48167. /**
  48168. * Specifies whether or not the outer glow is ACTIVE in the layer.
  48169. */
  48170. outerGlow: boolean;
  48171. /**
  48172. * Specifies the horizontal size of the blur.
  48173. */
  48174. /**
  48175. * Gets the horizontal size of the blur.
  48176. */
  48177. blurHorizontalSize: number;
  48178. /**
  48179. * Specifies the vertical size of the blur.
  48180. */
  48181. /**
  48182. * Gets the vertical size of the blur.
  48183. */
  48184. blurVerticalSize: number;
  48185. /**
  48186. * An event triggered when the highlight layer is being blurred.
  48187. */
  48188. onBeforeBlurObservable: Observable<HighlightLayer>;
  48189. /**
  48190. * An event triggered when the highlight layer has been blurred.
  48191. */
  48192. onAfterBlurObservable: Observable<HighlightLayer>;
  48193. private _instanceGlowingMeshStencilReference;
  48194. private _options;
  48195. private _downSamplePostprocess;
  48196. private _horizontalBlurPostprocess;
  48197. private _verticalBlurPostprocess;
  48198. private _blurTexture;
  48199. private _meshes;
  48200. private _excludedMeshes;
  48201. /**
  48202. * Instantiates a new highlight Layer and references it to the scene..
  48203. * @param name The name of the layer
  48204. * @param scene The scene to use the layer in
  48205. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  48206. */
  48207. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  48208. /**
  48209. * Get the effect name of the layer.
  48210. * @return The effect name
  48211. */
  48212. getEffectName(): string;
  48213. /**
  48214. * Create the merge effect. This is the shader use to blit the information back
  48215. * to the main canvas at the end of the scene rendering.
  48216. */
  48217. protected _createMergeEffect(): Effect;
  48218. /**
  48219. * Creates the render target textures and post processes used in the highlight layer.
  48220. */
  48221. protected _createTextureAndPostProcesses(): void;
  48222. /**
  48223. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48224. */
  48225. needStencil(): boolean;
  48226. /**
  48227. * Checks for the readiness of the element composing the layer.
  48228. * @param subMesh the mesh to check for
  48229. * @param useInstances specify wether or not to use instances to render the mesh
  48230. * @param emissiveTexture the associated emissive texture used to generate the glow
  48231. * @return true if ready otherwise, false
  48232. */
  48233. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48234. /**
  48235. * Implementation specific of rendering the generating effect on the main canvas.
  48236. * @param effect The effect used to render through
  48237. */
  48238. protected _internalRender(effect: Effect): void;
  48239. /**
  48240. * Returns true if the layer contains information to display, otherwise false.
  48241. */
  48242. shouldRender(): boolean;
  48243. /**
  48244. * Returns true if the mesh should render, otherwise false.
  48245. * @param mesh The mesh to render
  48246. * @returns true if it should render otherwise false
  48247. */
  48248. protected _shouldRenderMesh(mesh: Mesh): boolean;
  48249. /**
  48250. * Sets the required values for both the emissive texture and and the main color.
  48251. */
  48252. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48253. /**
  48254. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  48255. * @param mesh The mesh to exclude from the highlight layer
  48256. */
  48257. addExcludedMesh(mesh: Mesh): void;
  48258. /**
  48259. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  48260. * @param mesh The mesh to highlight
  48261. */
  48262. removeExcludedMesh(mesh: Mesh): void;
  48263. /**
  48264. * Determine if a given mesh will be highlighted by the current HighlightLayer
  48265. * @param mesh mesh to test
  48266. * @returns true if the mesh will be highlighted by the current HighlightLayer
  48267. */
  48268. hasMesh(mesh: AbstractMesh): boolean;
  48269. /**
  48270. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  48271. * @param mesh The mesh to highlight
  48272. * @param color The color of the highlight
  48273. * @param glowEmissiveOnly Extract the glow from the emissive texture
  48274. */
  48275. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  48276. /**
  48277. * Remove a mesh from the highlight layer in order to make it stop glowing.
  48278. * @param mesh The mesh to highlight
  48279. */
  48280. removeMesh(mesh: Mesh): void;
  48281. /**
  48282. * Force the stencil to the normal expected value for none glowing parts
  48283. */
  48284. private _defaultStencilReference;
  48285. /**
  48286. * Free any resources and references associated to a mesh.
  48287. * Internal use
  48288. * @param mesh The mesh to free.
  48289. * @hidden
  48290. */
  48291. _disposeMesh(mesh: Mesh): void;
  48292. /**
  48293. * Dispose the highlight layer and free resources.
  48294. */
  48295. dispose(): void;
  48296. /**
  48297. * Gets the class name of the effect layer
  48298. * @returns the string with the class name of the effect layer
  48299. */
  48300. getClassName(): string;
  48301. /**
  48302. * Serializes this Highlight layer
  48303. * @returns a serialized Highlight layer object
  48304. */
  48305. serialize(): any;
  48306. /**
  48307. * Creates a Highlight layer from parsed Highlight layer data
  48308. * @param parsedHightlightLayer defines the Highlight layer data
  48309. * @param scene defines the current scene
  48310. * @param rootUrl defines the root URL containing the Highlight layer information
  48311. * @returns a parsed Highlight layer
  48312. */
  48313. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  48314. }
  48315. }
  48316. declare module BABYLON {
  48317. interface AbstractScene {
  48318. /**
  48319. * The list of layers (background and foreground) of the scene
  48320. */
  48321. layers: Array<Layer>;
  48322. }
  48323. /**
  48324. * Defines the layer scene component responsible to manage any layers
  48325. * in a given scene.
  48326. */
  48327. export class LayerSceneComponent implements ISceneComponent {
  48328. /**
  48329. * The component name helpfull to identify the component in the list of scene components.
  48330. */
  48331. readonly name: string;
  48332. /**
  48333. * The scene the component belongs to.
  48334. */
  48335. scene: Scene;
  48336. private _engine;
  48337. /**
  48338. * Creates a new instance of the component for the given scene
  48339. * @param scene Defines the scene to register the component in
  48340. */
  48341. constructor(scene: Scene);
  48342. /**
  48343. * Registers the component in a given scene
  48344. */
  48345. register(): void;
  48346. /**
  48347. * Rebuilds the elements related to this component in case of
  48348. * context lost for instance.
  48349. */
  48350. rebuild(): void;
  48351. /**
  48352. * Disposes the component and the associated ressources.
  48353. */
  48354. dispose(): void;
  48355. private _draw;
  48356. private _drawCameraPredicate;
  48357. private _drawCameraBackground;
  48358. private _drawCameraForeground;
  48359. private _drawRenderTargetPredicate;
  48360. private _drawRenderTargetBackground;
  48361. private _drawRenderTargetForeground;
  48362. /**
  48363. * Adds all the elements from the container to the scene
  48364. * @param container the container holding the elements
  48365. */
  48366. addFromContainer(container: AbstractScene): void;
  48367. /**
  48368. * Removes all the elements in the container from the scene
  48369. * @param container contains the elements to remove
  48370. * @param dispose if the removed element should be disposed (default: false)
  48371. */
  48372. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48373. }
  48374. }
  48375. declare module BABYLON {
  48376. /** @hidden */
  48377. export var layerPixelShader: {
  48378. name: string;
  48379. shader: string;
  48380. };
  48381. }
  48382. declare module BABYLON {
  48383. /** @hidden */
  48384. export var layerVertexShader: {
  48385. name: string;
  48386. shader: string;
  48387. };
  48388. }
  48389. declare module BABYLON {
  48390. /**
  48391. * This represents a full screen 2d layer.
  48392. * This can be useful to display a picture in the background of your scene for instance.
  48393. * @see https://www.babylonjs-playground.com/#08A2BS#1
  48394. */
  48395. export class Layer {
  48396. /**
  48397. * Define the name of the layer.
  48398. */
  48399. name: string;
  48400. /**
  48401. * Define the texture the layer should display.
  48402. */
  48403. texture: Nullable<Texture>;
  48404. /**
  48405. * Is the layer in background or foreground.
  48406. */
  48407. isBackground: boolean;
  48408. /**
  48409. * Define the color of the layer (instead of texture).
  48410. */
  48411. color: Color4;
  48412. /**
  48413. * Define the scale of the layer in order to zoom in out of the texture.
  48414. */
  48415. scale: Vector2;
  48416. /**
  48417. * Define an offset for the layer in order to shift the texture.
  48418. */
  48419. offset: Vector2;
  48420. /**
  48421. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  48422. */
  48423. alphaBlendingMode: number;
  48424. /**
  48425. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  48426. * Alpha test will not mix with the background color in case of transparency.
  48427. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  48428. */
  48429. alphaTest: boolean;
  48430. /**
  48431. * Define a mask to restrict the layer to only some of the scene cameras.
  48432. */
  48433. layerMask: number;
  48434. /**
  48435. * Define the list of render target the layer is visible into.
  48436. */
  48437. renderTargetTextures: RenderTargetTexture[];
  48438. /**
  48439. * Define if the layer is only used in renderTarget or if it also
  48440. * renders in the main frame buffer of the canvas.
  48441. */
  48442. renderOnlyInRenderTargetTextures: boolean;
  48443. private _scene;
  48444. private _vertexBuffers;
  48445. private _indexBuffer;
  48446. private _effect;
  48447. private _alphaTestEffect;
  48448. /**
  48449. * An event triggered when the layer is disposed.
  48450. */
  48451. onDisposeObservable: Observable<Layer>;
  48452. private _onDisposeObserver;
  48453. /**
  48454. * Back compatibility with callback before the onDisposeObservable existed.
  48455. * The set callback will be triggered when the layer has been disposed.
  48456. */
  48457. onDispose: () => void;
  48458. /**
  48459. * An event triggered before rendering the scene
  48460. */
  48461. onBeforeRenderObservable: Observable<Layer>;
  48462. private _onBeforeRenderObserver;
  48463. /**
  48464. * Back compatibility with callback before the onBeforeRenderObservable existed.
  48465. * The set callback will be triggered just before rendering the layer.
  48466. */
  48467. onBeforeRender: () => void;
  48468. /**
  48469. * An event triggered after rendering the scene
  48470. */
  48471. onAfterRenderObservable: Observable<Layer>;
  48472. private _onAfterRenderObserver;
  48473. /**
  48474. * Back compatibility with callback before the onAfterRenderObservable existed.
  48475. * The set callback will be triggered just after rendering the layer.
  48476. */
  48477. onAfterRender: () => void;
  48478. /**
  48479. * Instantiates a new layer.
  48480. * This represents a full screen 2d layer.
  48481. * This can be useful to display a picture in the background of your scene for instance.
  48482. * @see https://www.babylonjs-playground.com/#08A2BS#1
  48483. * @param name Define the name of the layer in the scene
  48484. * @param imgUrl Define the url of the texture to display in the layer
  48485. * @param scene Define the scene the layer belongs to
  48486. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  48487. * @param color Defines a color for the layer
  48488. */
  48489. constructor(
  48490. /**
  48491. * Define the name of the layer.
  48492. */
  48493. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  48494. private _createIndexBuffer;
  48495. /** @hidden */
  48496. _rebuild(): void;
  48497. /**
  48498. * Renders the layer in the scene.
  48499. */
  48500. render(): void;
  48501. /**
  48502. * Disposes and releases the associated ressources.
  48503. */
  48504. dispose(): void;
  48505. }
  48506. }
  48507. declare module BABYLON {
  48508. /** @hidden */
  48509. export var lensFlarePixelShader: {
  48510. name: string;
  48511. shader: string;
  48512. };
  48513. }
  48514. declare module BABYLON {
  48515. /** @hidden */
  48516. export var lensFlareVertexShader: {
  48517. name: string;
  48518. shader: string;
  48519. };
  48520. }
  48521. declare module BABYLON {
  48522. /**
  48523. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  48524. * It is usually composed of several `lensFlare`.
  48525. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48526. */
  48527. export class LensFlareSystem {
  48528. /**
  48529. * Define the name of the lens flare system
  48530. */
  48531. name: string;
  48532. /**
  48533. * List of lens flares used in this system.
  48534. */
  48535. lensFlares: LensFlare[];
  48536. /**
  48537. * Define a limit from the border the lens flare can be visible.
  48538. */
  48539. borderLimit: number;
  48540. /**
  48541. * Define a viewport border we do not want to see the lens flare in.
  48542. */
  48543. viewportBorder: number;
  48544. /**
  48545. * Define a predicate which could limit the list of meshes able to occlude the effect.
  48546. */
  48547. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  48548. /**
  48549. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  48550. */
  48551. layerMask: number;
  48552. /**
  48553. * Define the id of the lens flare system in the scene.
  48554. * (equal to name by default)
  48555. */
  48556. id: string;
  48557. private _scene;
  48558. private _emitter;
  48559. private _vertexBuffers;
  48560. private _indexBuffer;
  48561. private _effect;
  48562. private _positionX;
  48563. private _positionY;
  48564. private _isEnabled;
  48565. /** @hidden */
  48566. static _SceneComponentInitialization: (scene: Scene) => void;
  48567. /**
  48568. * Instantiates a lens flare system.
  48569. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  48570. * It is usually composed of several `lensFlare`.
  48571. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48572. * @param name Define the name of the lens flare system in the scene
  48573. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  48574. * @param scene Define the scene the lens flare system belongs to
  48575. */
  48576. constructor(
  48577. /**
  48578. * Define the name of the lens flare system
  48579. */
  48580. name: string, emitter: any, scene: Scene);
  48581. /**
  48582. * Define if the lens flare system is enabled.
  48583. */
  48584. isEnabled: boolean;
  48585. /**
  48586. * Get the scene the effects belongs to.
  48587. * @returns the scene holding the lens flare system
  48588. */
  48589. getScene(): Scene;
  48590. /**
  48591. * Get the emitter of the lens flare system.
  48592. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  48593. * @returns the emitter of the lens flare system
  48594. */
  48595. getEmitter(): any;
  48596. /**
  48597. * Set the emitter of the lens flare system.
  48598. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  48599. * @param newEmitter Define the new emitter of the system
  48600. */
  48601. setEmitter(newEmitter: any): void;
  48602. /**
  48603. * Get the lens flare system emitter position.
  48604. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  48605. * @returns the position
  48606. */
  48607. getEmitterPosition(): Vector3;
  48608. /**
  48609. * @hidden
  48610. */
  48611. computeEffectivePosition(globalViewport: Viewport): boolean;
  48612. /** @hidden */
  48613. _isVisible(): boolean;
  48614. /**
  48615. * @hidden
  48616. */
  48617. render(): boolean;
  48618. /**
  48619. * Dispose and release the lens flare with its associated resources.
  48620. */
  48621. dispose(): void;
  48622. /**
  48623. * Parse a lens flare system from a JSON repressentation
  48624. * @param parsedLensFlareSystem Define the JSON to parse
  48625. * @param scene Define the scene the parsed system should be instantiated in
  48626. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  48627. * @returns the parsed system
  48628. */
  48629. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  48630. /**
  48631. * Serialize the current Lens Flare System into a JSON representation.
  48632. * @returns the serialized JSON
  48633. */
  48634. serialize(): any;
  48635. }
  48636. }
  48637. declare module BABYLON {
  48638. /**
  48639. * This represents one of the lens effect in a `lensFlareSystem`.
  48640. * It controls one of the indiviual texture used in the effect.
  48641. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48642. */
  48643. export class LensFlare {
  48644. /**
  48645. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  48646. */
  48647. size: number;
  48648. /**
  48649. * 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.
  48650. */
  48651. position: number;
  48652. /**
  48653. * Define the lens color.
  48654. */
  48655. color: Color3;
  48656. /**
  48657. * Define the lens texture.
  48658. */
  48659. texture: Nullable<Texture>;
  48660. /**
  48661. * Define the alpha mode to render this particular lens.
  48662. */
  48663. alphaMode: number;
  48664. private _system;
  48665. /**
  48666. * Creates a new Lens Flare.
  48667. * This represents one of the lens effect in a `lensFlareSystem`.
  48668. * It controls one of the indiviual texture used in the effect.
  48669. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48670. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  48671. * @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.
  48672. * @param color Define the lens color
  48673. * @param imgUrl Define the lens texture url
  48674. * @param system Define the `lensFlareSystem` this flare is part of
  48675. * @returns The newly created Lens Flare
  48676. */
  48677. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  48678. /**
  48679. * Instantiates a new Lens Flare.
  48680. * This represents one of the lens effect in a `lensFlareSystem`.
  48681. * It controls one of the indiviual texture used in the effect.
  48682. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48683. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  48684. * @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.
  48685. * @param color Define the lens color
  48686. * @param imgUrl Define the lens texture url
  48687. * @param system Define the `lensFlareSystem` this flare is part of
  48688. */
  48689. constructor(
  48690. /**
  48691. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  48692. */
  48693. size: number,
  48694. /**
  48695. * 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.
  48696. */
  48697. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  48698. /**
  48699. * Dispose and release the lens flare with its associated resources.
  48700. */
  48701. dispose(): void;
  48702. }
  48703. }
  48704. declare module BABYLON {
  48705. interface AbstractScene {
  48706. /**
  48707. * The list of lens flare system added to the scene
  48708. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48709. */
  48710. lensFlareSystems: Array<LensFlareSystem>;
  48711. /**
  48712. * Removes the given lens flare system from this scene.
  48713. * @param toRemove The lens flare system to remove
  48714. * @returns The index of the removed lens flare system
  48715. */
  48716. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  48717. /**
  48718. * Adds the given lens flare system to this scene
  48719. * @param newLensFlareSystem The lens flare system to add
  48720. */
  48721. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  48722. /**
  48723. * Gets a lens flare system using its name
  48724. * @param name defines the name to look for
  48725. * @returns the lens flare system or null if not found
  48726. */
  48727. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  48728. /**
  48729. * Gets a lens flare system using its id
  48730. * @param id defines the id to look for
  48731. * @returns the lens flare system or null if not found
  48732. */
  48733. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  48734. }
  48735. /**
  48736. * Defines the lens flare scene component responsible to manage any lens flares
  48737. * in a given scene.
  48738. */
  48739. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  48740. /**
  48741. * The component name helpfull to identify the component in the list of scene components.
  48742. */
  48743. readonly name: string;
  48744. /**
  48745. * The scene the component belongs to.
  48746. */
  48747. scene: Scene;
  48748. /**
  48749. * Creates a new instance of the component for the given scene
  48750. * @param scene Defines the scene to register the component in
  48751. */
  48752. constructor(scene: Scene);
  48753. /**
  48754. * Registers the component in a given scene
  48755. */
  48756. register(): void;
  48757. /**
  48758. * Rebuilds the elements related to this component in case of
  48759. * context lost for instance.
  48760. */
  48761. rebuild(): void;
  48762. /**
  48763. * Adds all the elements from the container to the scene
  48764. * @param container the container holding the elements
  48765. */
  48766. addFromContainer(container: AbstractScene): void;
  48767. /**
  48768. * Removes all the elements in the container from the scene
  48769. * @param container contains the elements to remove
  48770. * @param dispose if the removed element should be disposed (default: false)
  48771. */
  48772. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48773. /**
  48774. * Serializes the component data to the specified json object
  48775. * @param serializationObject The object to serialize to
  48776. */
  48777. serialize(serializationObject: any): void;
  48778. /**
  48779. * Disposes the component and the associated ressources.
  48780. */
  48781. dispose(): void;
  48782. private _draw;
  48783. }
  48784. }
  48785. declare module BABYLON {
  48786. /**
  48787. * Defines the shadow generator component responsible to manage any shadow generators
  48788. * in a given scene.
  48789. */
  48790. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  48791. /**
  48792. * The component name helpfull to identify the component in the list of scene components.
  48793. */
  48794. readonly name: string;
  48795. /**
  48796. * The scene the component belongs to.
  48797. */
  48798. scene: Scene;
  48799. /**
  48800. * Creates a new instance of the component for the given scene
  48801. * @param scene Defines the scene to register the component in
  48802. */
  48803. constructor(scene: Scene);
  48804. /**
  48805. * Registers the component in a given scene
  48806. */
  48807. register(): void;
  48808. /**
  48809. * Rebuilds the elements related to this component in case of
  48810. * context lost for instance.
  48811. */
  48812. rebuild(): void;
  48813. /**
  48814. * Serializes the component data to the specified json object
  48815. * @param serializationObject The object to serialize to
  48816. */
  48817. serialize(serializationObject: any): void;
  48818. /**
  48819. * Adds all the elements from the container to the scene
  48820. * @param container the container holding the elements
  48821. */
  48822. addFromContainer(container: AbstractScene): void;
  48823. /**
  48824. * Removes all the elements in the container from the scene
  48825. * @param container contains the elements to remove
  48826. * @param dispose if the removed element should be disposed (default: false)
  48827. */
  48828. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48829. /**
  48830. * Rebuilds the elements related to this component in case of
  48831. * context lost for instance.
  48832. */
  48833. dispose(): void;
  48834. private _gatherRenderTargets;
  48835. }
  48836. }
  48837. declare module BABYLON {
  48838. /**
  48839. * A point light is a light defined by an unique point in world space.
  48840. * The light is emitted in every direction from this point.
  48841. * A good example of a point light is a standard light bulb.
  48842. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48843. */
  48844. export class PointLight extends ShadowLight {
  48845. private _shadowAngle;
  48846. /**
  48847. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48848. * This specifies what angle the shadow will use to be created.
  48849. *
  48850. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48851. */
  48852. /**
  48853. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48854. * This specifies what angle the shadow will use to be created.
  48855. *
  48856. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48857. */
  48858. shadowAngle: number;
  48859. /**
  48860. * Gets the direction if it has been set.
  48861. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48862. */
  48863. /**
  48864. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48865. */
  48866. direction: Vector3;
  48867. /**
  48868. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  48869. * A PointLight emits the light in every direction.
  48870. * It can cast shadows.
  48871. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  48872. * ```javascript
  48873. * var pointLight = new PointLight("pl", camera.position, scene);
  48874. * ```
  48875. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48876. * @param name The light friendly name
  48877. * @param position The position of the point light in the scene
  48878. * @param scene The scene the lights belongs to
  48879. */
  48880. constructor(name: string, position: Vector3, scene: Scene);
  48881. /**
  48882. * Returns the string "PointLight"
  48883. * @returns the class name
  48884. */
  48885. getClassName(): string;
  48886. /**
  48887. * Returns the integer 0.
  48888. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48889. */
  48890. getTypeID(): number;
  48891. /**
  48892. * Specifies wether or not the shadowmap should be a cube texture.
  48893. * @returns true if the shadowmap needs to be a cube texture.
  48894. */
  48895. needCube(): boolean;
  48896. /**
  48897. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  48898. * @param faceIndex The index of the face we are computed the direction to generate shadow
  48899. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  48900. */
  48901. getShadowDirection(faceIndex?: number): Vector3;
  48902. /**
  48903. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  48904. * - fov = PI / 2
  48905. * - aspect ratio : 1.0
  48906. * - z-near and far equal to the active camera minZ and maxZ.
  48907. * Returns the PointLight.
  48908. */
  48909. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48910. protected _buildUniformLayout(): void;
  48911. /**
  48912. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  48913. * @param effect The effect to update
  48914. * @param lightIndex The index of the light in the effect to update
  48915. * @returns The point light
  48916. */
  48917. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  48918. /**
  48919. * Prepares the list of defines specific to the light type.
  48920. * @param defines the list of defines
  48921. * @param lightIndex defines the index of the light for the effect
  48922. */
  48923. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48924. }
  48925. }
  48926. declare module BABYLON {
  48927. /**
  48928. * Header information of HDR texture files.
  48929. */
  48930. export interface HDRInfo {
  48931. /**
  48932. * The height of the texture in pixels.
  48933. */
  48934. height: number;
  48935. /**
  48936. * The width of the texture in pixels.
  48937. */
  48938. width: number;
  48939. /**
  48940. * The index of the beginning of the data in the binary file.
  48941. */
  48942. dataPosition: number;
  48943. }
  48944. /**
  48945. * This groups tools to convert HDR texture to native colors array.
  48946. */
  48947. export class HDRTools {
  48948. private static Ldexp;
  48949. private static Rgbe2float;
  48950. private static readStringLine;
  48951. /**
  48952. * Reads header information from an RGBE texture stored in a native array.
  48953. * More information on this format are available here:
  48954. * https://en.wikipedia.org/wiki/RGBE_image_format
  48955. *
  48956. * @param uint8array The binary file stored in native array.
  48957. * @return The header information.
  48958. */
  48959. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  48960. /**
  48961. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  48962. * This RGBE texture needs to store the information as a panorama.
  48963. *
  48964. * More information on this format are available here:
  48965. * https://en.wikipedia.org/wiki/RGBE_image_format
  48966. *
  48967. * @param buffer The binary file stored in an array buffer.
  48968. * @param size The expected size of the extracted cubemap.
  48969. * @return The Cube Map information.
  48970. */
  48971. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  48972. /**
  48973. * Returns the pixels data extracted from an RGBE texture.
  48974. * This pixels will be stored left to right up to down in the R G B order in one array.
  48975. *
  48976. * More information on this format are available here:
  48977. * https://en.wikipedia.org/wiki/RGBE_image_format
  48978. *
  48979. * @param uint8array The binary file stored in an array buffer.
  48980. * @param hdrInfo The header information of the file.
  48981. * @return The pixels data in RGB right to left up to down order.
  48982. */
  48983. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  48984. private static RGBE_ReadPixels_RLE;
  48985. }
  48986. }
  48987. declare module BABYLON {
  48988. /**
  48989. * This represents a texture coming from an HDR input.
  48990. *
  48991. * The only supported format is currently panorama picture stored in RGBE format.
  48992. * Example of such files can be found on HDRLib: http://hdrlib.com/
  48993. */
  48994. export class HDRCubeTexture extends BaseTexture {
  48995. private static _facesMapping;
  48996. private _generateHarmonics;
  48997. private _noMipmap;
  48998. private _textureMatrix;
  48999. private _size;
  49000. private _onLoad;
  49001. private _onError;
  49002. /**
  49003. * The texture URL.
  49004. */
  49005. url: string;
  49006. /**
  49007. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  49008. */
  49009. coordinatesMode: number;
  49010. protected _isBlocking: boolean;
  49011. /**
  49012. * Sets wether or not the texture is blocking during loading.
  49013. */
  49014. /**
  49015. * Gets wether or not the texture is blocking during loading.
  49016. */
  49017. isBlocking: boolean;
  49018. protected _rotationY: number;
  49019. /**
  49020. * Sets texture matrix rotation angle around Y axis in radians.
  49021. */
  49022. /**
  49023. * Gets texture matrix rotation angle around Y axis radians.
  49024. */
  49025. rotationY: number;
  49026. /**
  49027. * Gets or sets the center of the bounding box associated with the cube texture
  49028. * It must define where the camera used to render the texture was set
  49029. */
  49030. boundingBoxPosition: Vector3;
  49031. private _boundingBoxSize;
  49032. /**
  49033. * Gets or sets the size of the bounding box associated with the cube texture
  49034. * When defined, the cubemap will switch to local mode
  49035. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  49036. * @example https://www.babylonjs-playground.com/#RNASML
  49037. */
  49038. boundingBoxSize: Vector3;
  49039. /**
  49040. * Instantiates an HDRTexture from the following parameters.
  49041. *
  49042. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  49043. * @param scene The scene the texture will be used in
  49044. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  49045. * @param noMipmap Forces to not generate the mipmap if true
  49046. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  49047. * @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)
  49048. * @param reserved Reserved flag for internal use.
  49049. */
  49050. 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>);
  49051. /**
  49052. * Get the current class name of the texture useful for serialization or dynamic coding.
  49053. * @returns "HDRCubeTexture"
  49054. */
  49055. getClassName(): string;
  49056. /**
  49057. * Occurs when the file is raw .hdr file.
  49058. */
  49059. private loadTexture;
  49060. clone(): HDRCubeTexture;
  49061. delayLoad(): void;
  49062. /**
  49063. * Get the texture reflection matrix used to rotate/transform the reflection.
  49064. * @returns the reflection matrix
  49065. */
  49066. getReflectionTextureMatrix(): Matrix;
  49067. /**
  49068. * Set the texture reflection matrix used to rotate/transform the reflection.
  49069. * @param value Define the reflection matrix to set
  49070. */
  49071. setReflectionTextureMatrix(value: Matrix): void;
  49072. /**
  49073. * Parses a JSON representation of an HDR Texture in order to create the texture
  49074. * @param parsedTexture Define the JSON representation
  49075. * @param scene Define the scene the texture should be created in
  49076. * @param rootUrl Define the root url in case we need to load relative dependencies
  49077. * @returns the newly created texture after parsing
  49078. */
  49079. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  49080. serialize(): any;
  49081. }
  49082. }
  49083. declare module BABYLON {
  49084. /**
  49085. * Class used to control physics engine
  49086. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  49087. */
  49088. export class PhysicsEngine implements IPhysicsEngine {
  49089. private _physicsPlugin;
  49090. /**
  49091. * Global value used to control the smallest number supported by the simulation
  49092. */
  49093. static Epsilon: number;
  49094. private _impostors;
  49095. private _joints;
  49096. /**
  49097. * Gets the gravity vector used by the simulation
  49098. */
  49099. gravity: Vector3;
  49100. /**
  49101. * Factory used to create the default physics plugin.
  49102. * @returns The default physics plugin
  49103. */
  49104. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  49105. /**
  49106. * Creates a new Physics Engine
  49107. * @param gravity defines the gravity vector used by the simulation
  49108. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  49109. */
  49110. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  49111. /**
  49112. * Sets the gravity vector used by the simulation
  49113. * @param gravity defines the gravity vector to use
  49114. */
  49115. setGravity(gravity: Vector3): void;
  49116. /**
  49117. * Set the time step of the physics engine.
  49118. * Default is 1/60.
  49119. * To slow it down, enter 1/600 for example.
  49120. * To speed it up, 1/30
  49121. * @param newTimeStep defines the new timestep to apply to this world.
  49122. */
  49123. setTimeStep(newTimeStep?: number): void;
  49124. /**
  49125. * Get the time step of the physics engine.
  49126. * @returns the current time step
  49127. */
  49128. getTimeStep(): number;
  49129. /**
  49130. * Release all resources
  49131. */
  49132. dispose(): void;
  49133. /**
  49134. * Gets the name of the current physics plugin
  49135. * @returns the name of the plugin
  49136. */
  49137. getPhysicsPluginName(): string;
  49138. /**
  49139. * Adding a new impostor for the impostor tracking.
  49140. * This will be done by the impostor itself.
  49141. * @param impostor the impostor to add
  49142. */
  49143. addImpostor(impostor: PhysicsImpostor): void;
  49144. /**
  49145. * Remove an impostor from the engine.
  49146. * This impostor and its mesh will not longer be updated by the physics engine.
  49147. * @param impostor the impostor to remove
  49148. */
  49149. removeImpostor(impostor: PhysicsImpostor): void;
  49150. /**
  49151. * Add a joint to the physics engine
  49152. * @param mainImpostor defines the main impostor to which the joint is added.
  49153. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  49154. * @param joint defines the joint that will connect both impostors.
  49155. */
  49156. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49157. /**
  49158. * Removes a joint from the simulation
  49159. * @param mainImpostor defines the impostor used with the joint
  49160. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  49161. * @param joint defines the joint to remove
  49162. */
  49163. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49164. /**
  49165. * Called by the scene. No need to call it.
  49166. * @param delta defines the timespam between frames
  49167. */
  49168. _step(delta: number): void;
  49169. /**
  49170. * Gets the current plugin used to run the simulation
  49171. * @returns current plugin
  49172. */
  49173. getPhysicsPlugin(): IPhysicsEnginePlugin;
  49174. /**
  49175. * Gets the list of physic impostors
  49176. * @returns an array of PhysicsImpostor
  49177. */
  49178. getImpostors(): Array<PhysicsImpostor>;
  49179. /**
  49180. * Gets the impostor for a physics enabled object
  49181. * @param object defines the object impersonated by the impostor
  49182. * @returns the PhysicsImpostor or null if not found
  49183. */
  49184. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  49185. /**
  49186. * Gets the impostor for a physics body object
  49187. * @param body defines physics body used by the impostor
  49188. * @returns the PhysicsImpostor or null if not found
  49189. */
  49190. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  49191. /**
  49192. * Does a raycast in the physics world
  49193. * @param from when should the ray start?
  49194. * @param to when should the ray end?
  49195. * @returns PhysicsRaycastResult
  49196. */
  49197. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49198. }
  49199. }
  49200. declare module BABYLON {
  49201. /** @hidden */
  49202. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  49203. private _useDeltaForWorldStep;
  49204. world: any;
  49205. name: string;
  49206. private _physicsMaterials;
  49207. private _fixedTimeStep;
  49208. private _cannonRaycastResult;
  49209. private _raycastResult;
  49210. private _physicsBodysToRemoveAfterStep;
  49211. BJSCANNON: any;
  49212. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  49213. setGravity(gravity: Vector3): void;
  49214. setTimeStep(timeStep: number): void;
  49215. getTimeStep(): number;
  49216. executeStep(delta: number): void;
  49217. private _removeMarkedPhysicsBodiesFromWorld;
  49218. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49219. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49220. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49221. private _processChildMeshes;
  49222. removePhysicsBody(impostor: PhysicsImpostor): void;
  49223. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49224. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49225. private _addMaterial;
  49226. private _checkWithEpsilon;
  49227. private _createShape;
  49228. private _createHeightmap;
  49229. private _minus90X;
  49230. private _plus90X;
  49231. private _tmpPosition;
  49232. private _tmpDeltaPosition;
  49233. private _tmpUnityRotation;
  49234. private _updatePhysicsBodyTransformation;
  49235. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49236. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49237. isSupported(): boolean;
  49238. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49239. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49240. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49241. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49242. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49243. getBodyMass(impostor: PhysicsImpostor): number;
  49244. getBodyFriction(impostor: PhysicsImpostor): number;
  49245. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49246. getBodyRestitution(impostor: PhysicsImpostor): number;
  49247. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49248. sleepBody(impostor: PhysicsImpostor): void;
  49249. wakeUpBody(impostor: PhysicsImpostor): void;
  49250. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  49251. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49252. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49253. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49254. getRadius(impostor: PhysicsImpostor): number;
  49255. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49256. dispose(): void;
  49257. private _extendNamespace;
  49258. /**
  49259. * Does a raycast in the physics world
  49260. * @param from when should the ray start?
  49261. * @param to when should the ray end?
  49262. * @returns PhysicsRaycastResult
  49263. */
  49264. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49265. }
  49266. }
  49267. declare module BABYLON {
  49268. /** @hidden */
  49269. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  49270. world: any;
  49271. name: string;
  49272. BJSOIMO: any;
  49273. private _raycastResult;
  49274. constructor(iterations?: number, oimoInjection?: any);
  49275. setGravity(gravity: Vector3): void;
  49276. setTimeStep(timeStep: number): void;
  49277. getTimeStep(): number;
  49278. private _tmpImpostorsArray;
  49279. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49280. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49281. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49282. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49283. private _tmpPositionVector;
  49284. removePhysicsBody(impostor: PhysicsImpostor): void;
  49285. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49286. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49287. isSupported(): boolean;
  49288. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49289. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49290. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49291. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49292. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49293. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49294. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49295. getBodyMass(impostor: PhysicsImpostor): number;
  49296. getBodyFriction(impostor: PhysicsImpostor): number;
  49297. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49298. getBodyRestitution(impostor: PhysicsImpostor): number;
  49299. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49300. sleepBody(impostor: PhysicsImpostor): void;
  49301. wakeUpBody(impostor: PhysicsImpostor): void;
  49302. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49303. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  49304. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  49305. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49306. getRadius(impostor: PhysicsImpostor): number;
  49307. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49308. dispose(): void;
  49309. /**
  49310. * Does a raycast in the physics world
  49311. * @param from when should the ray start?
  49312. * @param to when should the ray end?
  49313. * @returns PhysicsRaycastResult
  49314. */
  49315. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49316. }
  49317. }
  49318. declare module BABYLON {
  49319. /**
  49320. * Class containing static functions to help procedurally build meshes
  49321. */
  49322. export class RibbonBuilder {
  49323. /**
  49324. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49325. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  49326. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  49327. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  49328. * * 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
  49329. * * 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
  49330. * * 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
  49331. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49332. * * 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
  49333. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49334. * * 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
  49335. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  49336. * * 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
  49337. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  49338. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49339. * @param name defines the name of the mesh
  49340. * @param options defines the options used to create the mesh
  49341. * @param scene defines the hosting scene
  49342. * @returns the ribbon mesh
  49343. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  49344. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49345. */
  49346. static CreateRibbon(name: string, options: {
  49347. pathArray: Vector3[][];
  49348. closeArray?: boolean;
  49349. closePath?: boolean;
  49350. offset?: number;
  49351. updatable?: boolean;
  49352. sideOrientation?: number;
  49353. frontUVs?: Vector4;
  49354. backUVs?: Vector4;
  49355. instance?: Mesh;
  49356. invertUV?: boolean;
  49357. uvs?: Vector2[];
  49358. colors?: Color4[];
  49359. }, scene?: Nullable<Scene>): Mesh;
  49360. }
  49361. }
  49362. declare module BABYLON {
  49363. /**
  49364. * Class containing static functions to help procedurally build meshes
  49365. */
  49366. export class ShapeBuilder {
  49367. /**
  49368. * 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.
  49369. * * 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.
  49370. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49371. * * 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.
  49372. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  49373. * * 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
  49374. * * 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
  49375. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  49376. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49377. * * 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
  49378. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  49379. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49380. * @param name defines the name of the mesh
  49381. * @param options defines the options used to create the mesh
  49382. * @param scene defines the hosting scene
  49383. * @returns the extruded shape mesh
  49384. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49385. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49386. */
  49387. static ExtrudeShape(name: string, options: {
  49388. shape: Vector3[];
  49389. path: Vector3[];
  49390. scale?: number;
  49391. rotation?: number;
  49392. cap?: number;
  49393. updatable?: boolean;
  49394. sideOrientation?: number;
  49395. frontUVs?: Vector4;
  49396. backUVs?: Vector4;
  49397. instance?: Mesh;
  49398. invertUV?: boolean;
  49399. }, scene?: Nullable<Scene>): Mesh;
  49400. /**
  49401. * Creates an custom extruded shape mesh.
  49402. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  49403. * * 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.
  49404. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49405. * * 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
  49406. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  49407. * * 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
  49408. * * It must returns a float value that will be the scale value applied to the shape on each path point
  49409. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  49410. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  49411. * * 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
  49412. * * 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
  49413. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  49414. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49415. * * 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
  49416. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49417. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49418. * @param name defines the name of the mesh
  49419. * @param options defines the options used to create the mesh
  49420. * @param scene defines the hosting scene
  49421. * @returns the custom extruded shape mesh
  49422. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  49423. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49424. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49425. */
  49426. static ExtrudeShapeCustom(name: string, options: {
  49427. shape: Vector3[];
  49428. path: Vector3[];
  49429. scaleFunction?: any;
  49430. rotationFunction?: any;
  49431. ribbonCloseArray?: boolean;
  49432. ribbonClosePath?: boolean;
  49433. cap?: number;
  49434. updatable?: boolean;
  49435. sideOrientation?: number;
  49436. frontUVs?: Vector4;
  49437. backUVs?: Vector4;
  49438. instance?: Mesh;
  49439. invertUV?: boolean;
  49440. }, scene?: Nullable<Scene>): Mesh;
  49441. private static _ExtrudeShapeGeneric;
  49442. }
  49443. }
  49444. declare module BABYLON {
  49445. /**
  49446. * AmmoJS Physics plugin
  49447. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49448. * @see https://github.com/kripken/ammo.js/
  49449. */
  49450. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  49451. private _useDeltaForWorldStep;
  49452. /**
  49453. * Reference to the Ammo library
  49454. */
  49455. bjsAMMO: any;
  49456. /**
  49457. * Created ammoJS world which physics bodies are added to
  49458. */
  49459. world: any;
  49460. /**
  49461. * Name of the plugin
  49462. */
  49463. name: string;
  49464. private _timeStep;
  49465. private _fixedTimeStep;
  49466. private _maxSteps;
  49467. private _tmpQuaternion;
  49468. private _tmpAmmoTransform;
  49469. private _tmpAmmoQuaternion;
  49470. private _tmpAmmoConcreteContactResultCallback;
  49471. private _collisionConfiguration;
  49472. private _dispatcher;
  49473. private _overlappingPairCache;
  49474. private _solver;
  49475. private _softBodySolver;
  49476. private _tmpAmmoVectorA;
  49477. private _tmpAmmoVectorB;
  49478. private _tmpAmmoVectorC;
  49479. private _tmpAmmoVectorD;
  49480. private _tmpContactCallbackResult;
  49481. private _tmpAmmoVectorRCA;
  49482. private _tmpAmmoVectorRCB;
  49483. private _raycastResult;
  49484. private static readonly DISABLE_COLLISION_FLAG;
  49485. private static readonly KINEMATIC_FLAG;
  49486. private static readonly DISABLE_DEACTIVATION_FLAG;
  49487. /**
  49488. * Initializes the ammoJS plugin
  49489. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  49490. * @param ammoInjection can be used to inject your own ammo reference
  49491. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  49492. */
  49493. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  49494. /**
  49495. * Sets the gravity of the physics world (m/(s^2))
  49496. * @param gravity Gravity to set
  49497. */
  49498. setGravity(gravity: Vector3): void;
  49499. /**
  49500. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  49501. * @param timeStep timestep to use in seconds
  49502. */
  49503. setTimeStep(timeStep: number): void;
  49504. /**
  49505. * 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)
  49506. * @param fixedTimeStep fixedTimeStep to use in seconds
  49507. */
  49508. setFixedTimeStep(fixedTimeStep: number): void;
  49509. /**
  49510. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  49511. * @param maxSteps the maximum number of steps by the physics engine per frame
  49512. */
  49513. setMaxSteps(maxSteps: number): void;
  49514. /**
  49515. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  49516. * @returns the current timestep in seconds
  49517. */
  49518. getTimeStep(): number;
  49519. private _isImpostorInContact;
  49520. private _isImpostorPairInContact;
  49521. private _stepSimulation;
  49522. /**
  49523. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  49524. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  49525. * After the step the babylon meshes are set to the position of the physics imposters
  49526. * @param delta amount of time to step forward
  49527. * @param impostors array of imposters to update before/after the step
  49528. */
  49529. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49530. /**
  49531. * Update babylon mesh to match physics world object
  49532. * @param impostor imposter to match
  49533. */
  49534. private _afterSoftStep;
  49535. /**
  49536. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  49537. * @param impostor imposter to match
  49538. */
  49539. private _ropeStep;
  49540. /**
  49541. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  49542. * @param impostor imposter to match
  49543. */
  49544. private _softbodyOrClothStep;
  49545. private _tmpVector;
  49546. private _tmpMatrix;
  49547. /**
  49548. * Applies an impulse on the imposter
  49549. * @param impostor imposter to apply impulse to
  49550. * @param force amount of force to be applied to the imposter
  49551. * @param contactPoint the location to apply the impulse on the imposter
  49552. */
  49553. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49554. /**
  49555. * Applies a force on the imposter
  49556. * @param impostor imposter to apply force
  49557. * @param force amount of force to be applied to the imposter
  49558. * @param contactPoint the location to apply the force on the imposter
  49559. */
  49560. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49561. /**
  49562. * Creates a physics body using the plugin
  49563. * @param impostor the imposter to create the physics body on
  49564. */
  49565. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49566. /**
  49567. * Removes the physics body from the imposter and disposes of the body's memory
  49568. * @param impostor imposter to remove the physics body from
  49569. */
  49570. removePhysicsBody(impostor: PhysicsImpostor): void;
  49571. /**
  49572. * Generates a joint
  49573. * @param impostorJoint the imposter joint to create the joint with
  49574. */
  49575. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49576. /**
  49577. * Removes a joint
  49578. * @param impostorJoint the imposter joint to remove the joint from
  49579. */
  49580. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49581. private _addMeshVerts;
  49582. /**
  49583. * Initialise the soft body vertices to match its object's (mesh) vertices
  49584. * Softbody vertices (nodes) are in world space and to match this
  49585. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  49586. * @param impostor to create the softbody for
  49587. */
  49588. private _softVertexData;
  49589. /**
  49590. * Create an impostor's soft body
  49591. * @param impostor to create the softbody for
  49592. */
  49593. private _createSoftbody;
  49594. /**
  49595. * Create cloth for an impostor
  49596. * @param impostor to create the softbody for
  49597. */
  49598. private _createCloth;
  49599. /**
  49600. * Create rope for an impostor
  49601. * @param impostor to create the softbody for
  49602. */
  49603. private _createRope;
  49604. private _addHullVerts;
  49605. private _createShape;
  49606. /**
  49607. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  49608. * @param impostor imposter containing the physics body and babylon object
  49609. */
  49610. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49611. /**
  49612. * Sets the babylon object's position/rotation from the physics body's position/rotation
  49613. * @param impostor imposter containing the physics body and babylon object
  49614. * @param newPosition new position
  49615. * @param newRotation new rotation
  49616. */
  49617. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49618. /**
  49619. * If this plugin is supported
  49620. * @returns true if its supported
  49621. */
  49622. isSupported(): boolean;
  49623. /**
  49624. * Sets the linear velocity of the physics body
  49625. * @param impostor imposter to set the velocity on
  49626. * @param velocity velocity to set
  49627. */
  49628. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49629. /**
  49630. * Sets the angular velocity of the physics body
  49631. * @param impostor imposter to set the velocity on
  49632. * @param velocity velocity to set
  49633. */
  49634. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49635. /**
  49636. * gets the linear velocity
  49637. * @param impostor imposter to get linear velocity from
  49638. * @returns linear velocity
  49639. */
  49640. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49641. /**
  49642. * gets the angular velocity
  49643. * @param impostor imposter to get angular velocity from
  49644. * @returns angular velocity
  49645. */
  49646. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49647. /**
  49648. * Sets the mass of physics body
  49649. * @param impostor imposter to set the mass on
  49650. * @param mass mass to set
  49651. */
  49652. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49653. /**
  49654. * Gets the mass of the physics body
  49655. * @param impostor imposter to get the mass from
  49656. * @returns mass
  49657. */
  49658. getBodyMass(impostor: PhysicsImpostor): number;
  49659. /**
  49660. * Gets friction of the impostor
  49661. * @param impostor impostor to get friction from
  49662. * @returns friction value
  49663. */
  49664. getBodyFriction(impostor: PhysicsImpostor): number;
  49665. /**
  49666. * Sets friction of the impostor
  49667. * @param impostor impostor to set friction on
  49668. * @param friction friction value
  49669. */
  49670. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49671. /**
  49672. * Gets restitution of the impostor
  49673. * @param impostor impostor to get restitution from
  49674. * @returns restitution value
  49675. */
  49676. getBodyRestitution(impostor: PhysicsImpostor): number;
  49677. /**
  49678. * Sets resitution of the impostor
  49679. * @param impostor impostor to set resitution on
  49680. * @param restitution resitution value
  49681. */
  49682. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49683. /**
  49684. * Gets pressure inside the impostor
  49685. * @param impostor impostor to get pressure from
  49686. * @returns pressure value
  49687. */
  49688. getBodyPressure(impostor: PhysicsImpostor): number;
  49689. /**
  49690. * Sets pressure inside a soft body impostor
  49691. * Cloth and rope must remain 0 pressure
  49692. * @param impostor impostor to set pressure on
  49693. * @param pressure pressure value
  49694. */
  49695. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  49696. /**
  49697. * Gets stiffness of the impostor
  49698. * @param impostor impostor to get stiffness from
  49699. * @returns pressure value
  49700. */
  49701. getBodyStiffness(impostor: PhysicsImpostor): number;
  49702. /**
  49703. * Sets stiffness of the impostor
  49704. * @param impostor impostor to set stiffness on
  49705. * @param stiffness stiffness value from 0 to 1
  49706. */
  49707. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  49708. /**
  49709. * Gets velocityIterations of the impostor
  49710. * @param impostor impostor to get velocity iterations from
  49711. * @returns velocityIterations value
  49712. */
  49713. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  49714. /**
  49715. * Sets velocityIterations of the impostor
  49716. * @param impostor impostor to set velocity iterations on
  49717. * @param velocityIterations velocityIterations value
  49718. */
  49719. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  49720. /**
  49721. * Gets positionIterations of the impostor
  49722. * @param impostor impostor to get position iterations from
  49723. * @returns positionIterations value
  49724. */
  49725. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  49726. /**
  49727. * Sets positionIterations of the impostor
  49728. * @param impostor impostor to set position on
  49729. * @param positionIterations positionIterations value
  49730. */
  49731. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  49732. /**
  49733. * Append an anchor to a cloth object
  49734. * @param impostor is the cloth impostor to add anchor to
  49735. * @param otherImpostor is the rigid impostor to anchor to
  49736. * @param width ratio across width from 0 to 1
  49737. * @param height ratio up height from 0 to 1
  49738. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  49739. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  49740. */
  49741. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  49742. /**
  49743. * Append an hook to a rope object
  49744. * @param impostor is the rope impostor to add hook to
  49745. * @param otherImpostor is the rigid impostor to hook to
  49746. * @param length ratio along the rope from 0 to 1
  49747. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  49748. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  49749. */
  49750. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  49751. /**
  49752. * Sleeps the physics body and stops it from being active
  49753. * @param impostor impostor to sleep
  49754. */
  49755. sleepBody(impostor: PhysicsImpostor): void;
  49756. /**
  49757. * Activates the physics body
  49758. * @param impostor impostor to activate
  49759. */
  49760. wakeUpBody(impostor: PhysicsImpostor): void;
  49761. /**
  49762. * Updates the distance parameters of the joint
  49763. * @param joint joint to update
  49764. * @param maxDistance maximum distance of the joint
  49765. * @param minDistance minimum distance of the joint
  49766. */
  49767. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49768. /**
  49769. * Sets a motor on the joint
  49770. * @param joint joint to set motor on
  49771. * @param speed speed of the motor
  49772. * @param maxForce maximum force of the motor
  49773. * @param motorIndex index of the motor
  49774. */
  49775. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49776. /**
  49777. * Sets the motors limit
  49778. * @param joint joint to set limit on
  49779. * @param upperLimit upper limit
  49780. * @param lowerLimit lower limit
  49781. */
  49782. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49783. /**
  49784. * Syncs the position and rotation of a mesh with the impostor
  49785. * @param mesh mesh to sync
  49786. * @param impostor impostor to update the mesh with
  49787. */
  49788. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49789. /**
  49790. * Gets the radius of the impostor
  49791. * @param impostor impostor to get radius from
  49792. * @returns the radius
  49793. */
  49794. getRadius(impostor: PhysicsImpostor): number;
  49795. /**
  49796. * Gets the box size of the impostor
  49797. * @param impostor impostor to get box size from
  49798. * @param result the resulting box size
  49799. */
  49800. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49801. /**
  49802. * Disposes of the impostor
  49803. */
  49804. dispose(): void;
  49805. /**
  49806. * Does a raycast in the physics world
  49807. * @param from when should the ray start?
  49808. * @param to when should the ray end?
  49809. * @returns PhysicsRaycastResult
  49810. */
  49811. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49812. }
  49813. }
  49814. declare module BABYLON {
  49815. interface AbstractScene {
  49816. /**
  49817. * The list of reflection probes added to the scene
  49818. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  49819. */
  49820. reflectionProbes: Array<ReflectionProbe>;
  49821. /**
  49822. * Removes the given reflection probe from this scene.
  49823. * @param toRemove The reflection probe to remove
  49824. * @returns The index of the removed reflection probe
  49825. */
  49826. removeReflectionProbe(toRemove: ReflectionProbe): number;
  49827. /**
  49828. * Adds the given reflection probe to this scene.
  49829. * @param newReflectionProbe The reflection probe to add
  49830. */
  49831. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  49832. }
  49833. /**
  49834. * Class used to generate realtime reflection / refraction cube textures
  49835. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  49836. */
  49837. export class ReflectionProbe {
  49838. /** defines the name of the probe */
  49839. name: string;
  49840. private _scene;
  49841. private _renderTargetTexture;
  49842. private _projectionMatrix;
  49843. private _viewMatrix;
  49844. private _target;
  49845. private _add;
  49846. private _attachedMesh;
  49847. private _invertYAxis;
  49848. /** Gets or sets probe position (center of the cube map) */
  49849. position: Vector3;
  49850. /**
  49851. * Creates a new reflection probe
  49852. * @param name defines the name of the probe
  49853. * @param size defines the texture resolution (for each face)
  49854. * @param scene defines the hosting scene
  49855. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  49856. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  49857. */
  49858. constructor(
  49859. /** defines the name of the probe */
  49860. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  49861. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  49862. samples: number;
  49863. /** Gets or sets the refresh rate to use (on every frame by default) */
  49864. refreshRate: number;
  49865. /**
  49866. * Gets the hosting scene
  49867. * @returns a Scene
  49868. */
  49869. getScene(): Scene;
  49870. /** Gets the internal CubeTexture used to render to */
  49871. readonly cubeTexture: RenderTargetTexture;
  49872. /** Gets the list of meshes to render */
  49873. readonly renderList: Nullable<AbstractMesh[]>;
  49874. /**
  49875. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  49876. * @param mesh defines the mesh to attach to
  49877. */
  49878. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  49879. /**
  49880. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  49881. * @param renderingGroupId The rendering group id corresponding to its index
  49882. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  49883. */
  49884. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  49885. /**
  49886. * Clean all associated resources
  49887. */
  49888. dispose(): void;
  49889. /**
  49890. * Converts the reflection probe information to a readable string for debug purpose.
  49891. * @param fullDetails Supports for multiple levels of logging within scene loading
  49892. * @returns the human readable reflection probe info
  49893. */
  49894. toString(fullDetails?: boolean): string;
  49895. /**
  49896. * Get the class name of the relfection probe.
  49897. * @returns "ReflectionProbe"
  49898. */
  49899. getClassName(): string;
  49900. /**
  49901. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  49902. * @returns The JSON representation of the texture
  49903. */
  49904. serialize(): any;
  49905. /**
  49906. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  49907. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  49908. * @param scene Define the scene the parsed reflection probe should be instantiated in
  49909. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  49910. * @returns The parsed reflection probe if successful
  49911. */
  49912. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  49913. }
  49914. }
  49915. declare module BABYLON {
  49916. /** @hidden */
  49917. export var _BabylonLoaderRegistered: boolean;
  49918. }
  49919. declare module BABYLON {
  49920. /**
  49921. * The Physically based simple base material of BJS.
  49922. *
  49923. * This enables better naming and convention enforcements on top of the pbrMaterial.
  49924. * It is used as the base class for both the specGloss and metalRough conventions.
  49925. */
  49926. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  49927. /**
  49928. * Number of Simultaneous lights allowed on the material.
  49929. */
  49930. maxSimultaneousLights: number;
  49931. /**
  49932. * If sets to true, disables all the lights affecting the material.
  49933. */
  49934. disableLighting: boolean;
  49935. /**
  49936. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  49937. */
  49938. environmentTexture: BaseTexture;
  49939. /**
  49940. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  49941. */
  49942. invertNormalMapX: boolean;
  49943. /**
  49944. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  49945. */
  49946. invertNormalMapY: boolean;
  49947. /**
  49948. * Normal map used in the model.
  49949. */
  49950. normalTexture: BaseTexture;
  49951. /**
  49952. * Emissivie color used to self-illuminate the model.
  49953. */
  49954. emissiveColor: Color3;
  49955. /**
  49956. * Emissivie texture used to self-illuminate the model.
  49957. */
  49958. emissiveTexture: BaseTexture;
  49959. /**
  49960. * Occlusion Channel Strenght.
  49961. */
  49962. occlusionStrength: number;
  49963. /**
  49964. * Occlusion Texture of the material (adding extra occlusion effects).
  49965. */
  49966. occlusionTexture: BaseTexture;
  49967. /**
  49968. * Defines the alpha limits in alpha test mode.
  49969. */
  49970. alphaCutOff: number;
  49971. /**
  49972. * Gets the current double sided mode.
  49973. */
  49974. /**
  49975. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49976. */
  49977. doubleSided: boolean;
  49978. /**
  49979. * Stores the pre-calculated light information of a mesh in a texture.
  49980. */
  49981. lightmapTexture: BaseTexture;
  49982. /**
  49983. * If true, the light map contains occlusion information instead of lighting info.
  49984. */
  49985. useLightmapAsShadowmap: boolean;
  49986. /**
  49987. * Instantiates a new PBRMaterial instance.
  49988. *
  49989. * @param name The material name
  49990. * @param scene The scene the material will be use in.
  49991. */
  49992. constructor(name: string, scene: Scene);
  49993. getClassName(): string;
  49994. }
  49995. }
  49996. declare module BABYLON {
  49997. /**
  49998. * The PBR material of BJS following the metal roughness convention.
  49999. *
  50000. * This fits to the PBR convention in the GLTF definition:
  50001. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  50002. */
  50003. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  50004. /**
  50005. * The base color has two different interpretations depending on the value of metalness.
  50006. * When the material is a metal, the base color is the specific measured reflectance value
  50007. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  50008. * of the material.
  50009. */
  50010. baseColor: Color3;
  50011. /**
  50012. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  50013. * well as opacity information in the alpha channel.
  50014. */
  50015. baseTexture: BaseTexture;
  50016. /**
  50017. * Specifies the metallic scalar value of the material.
  50018. * Can also be used to scale the metalness values of the metallic texture.
  50019. */
  50020. metallic: number;
  50021. /**
  50022. * Specifies the roughness scalar value of the material.
  50023. * Can also be used to scale the roughness values of the metallic texture.
  50024. */
  50025. roughness: number;
  50026. /**
  50027. * Texture containing both the metallic value in the B channel and the
  50028. * roughness value in the G channel to keep better precision.
  50029. */
  50030. metallicRoughnessTexture: BaseTexture;
  50031. /**
  50032. * Instantiates a new PBRMetalRoughnessMaterial instance.
  50033. *
  50034. * @param name The material name
  50035. * @param scene The scene the material will be use in.
  50036. */
  50037. constructor(name: string, scene: Scene);
  50038. /**
  50039. * Return the currrent class name of the material.
  50040. */
  50041. getClassName(): string;
  50042. /**
  50043. * Makes a duplicate of the current material.
  50044. * @param name - name to use for the new material.
  50045. */
  50046. clone(name: string): PBRMetallicRoughnessMaterial;
  50047. /**
  50048. * Serialize the material to a parsable JSON object.
  50049. */
  50050. serialize(): any;
  50051. /**
  50052. * Parses a JSON object correponding to the serialize function.
  50053. */
  50054. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  50055. }
  50056. }
  50057. declare module BABYLON {
  50058. /**
  50059. * The PBR material of BJS following the specular glossiness convention.
  50060. *
  50061. * This fits to the PBR convention in the GLTF definition:
  50062. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  50063. */
  50064. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  50065. /**
  50066. * Specifies the diffuse color of the material.
  50067. */
  50068. diffuseColor: Color3;
  50069. /**
  50070. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  50071. * channel.
  50072. */
  50073. diffuseTexture: BaseTexture;
  50074. /**
  50075. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  50076. */
  50077. specularColor: Color3;
  50078. /**
  50079. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  50080. */
  50081. glossiness: number;
  50082. /**
  50083. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  50084. */
  50085. specularGlossinessTexture: BaseTexture;
  50086. /**
  50087. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  50088. *
  50089. * @param name The material name
  50090. * @param scene The scene the material will be use in.
  50091. */
  50092. constructor(name: string, scene: Scene);
  50093. /**
  50094. * Return the currrent class name of the material.
  50095. */
  50096. getClassName(): string;
  50097. /**
  50098. * Makes a duplicate of the current material.
  50099. * @param name - name to use for the new material.
  50100. */
  50101. clone(name: string): PBRSpecularGlossinessMaterial;
  50102. /**
  50103. * Serialize the material to a parsable JSON object.
  50104. */
  50105. serialize(): any;
  50106. /**
  50107. * Parses a JSON object correponding to the serialize function.
  50108. */
  50109. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  50110. }
  50111. }
  50112. declare module BABYLON {
  50113. /**
  50114. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  50115. * It can help converting any input color in a desired output one. This can then be used to create effects
  50116. * from sepia, black and white to sixties or futuristic rendering...
  50117. *
  50118. * The only supported format is currently 3dl.
  50119. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  50120. */
  50121. export class ColorGradingTexture extends BaseTexture {
  50122. /**
  50123. * The current texture matrix. (will always be identity in color grading texture)
  50124. */
  50125. private _textureMatrix;
  50126. /**
  50127. * The texture URL.
  50128. */
  50129. url: string;
  50130. /**
  50131. * Empty line regex stored for GC.
  50132. */
  50133. private static _noneEmptyLineRegex;
  50134. private _engine;
  50135. /**
  50136. * Instantiates a ColorGradingTexture from the following parameters.
  50137. *
  50138. * @param url The location of the color gradind data (currently only supporting 3dl)
  50139. * @param scene The scene the texture will be used in
  50140. */
  50141. constructor(url: string, scene: Scene);
  50142. /**
  50143. * Returns the texture matrix used in most of the material.
  50144. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  50145. */
  50146. getTextureMatrix(): Matrix;
  50147. /**
  50148. * Occurs when the file being loaded is a .3dl LUT file.
  50149. */
  50150. private load3dlTexture;
  50151. /**
  50152. * Starts the loading process of the texture.
  50153. */
  50154. private loadTexture;
  50155. /**
  50156. * Clones the color gradind texture.
  50157. */
  50158. clone(): ColorGradingTexture;
  50159. /**
  50160. * Called during delayed load for textures.
  50161. */
  50162. delayLoad(): void;
  50163. /**
  50164. * Parses a color grading texture serialized by Babylon.
  50165. * @param parsedTexture The texture information being parsedTexture
  50166. * @param scene The scene to load the texture in
  50167. * @param rootUrl The root url of the data assets to load
  50168. * @return A color gradind texture
  50169. */
  50170. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  50171. /**
  50172. * Serializes the LUT texture to json format.
  50173. */
  50174. serialize(): any;
  50175. }
  50176. }
  50177. declare module BABYLON {
  50178. /**
  50179. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  50180. */
  50181. export class EquiRectangularCubeTexture extends BaseTexture {
  50182. /** The six faces of the cube. */
  50183. private static _FacesMapping;
  50184. private _noMipmap;
  50185. private _onLoad;
  50186. private _onError;
  50187. /** The size of the cubemap. */
  50188. private _size;
  50189. /** The buffer of the image. */
  50190. private _buffer;
  50191. /** The width of the input image. */
  50192. private _width;
  50193. /** The height of the input image. */
  50194. private _height;
  50195. /** The URL to the image. */
  50196. url: string;
  50197. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  50198. coordinatesMode: number;
  50199. /**
  50200. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  50201. * @param url The location of the image
  50202. * @param scene The scene the texture will be used in
  50203. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50204. * @param noMipmap Forces to not generate the mipmap if true
  50205. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  50206. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  50207. * @param onLoad — defines a callback called when texture is loaded
  50208. * @param onError — defines a callback called if there is an error
  50209. */
  50210. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  50211. /**
  50212. * Load the image data, by putting the image on a canvas and extracting its buffer.
  50213. */
  50214. private loadImage;
  50215. /**
  50216. * Convert the image buffer into a cubemap and create a CubeTexture.
  50217. */
  50218. private loadTexture;
  50219. /**
  50220. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  50221. * @param buffer The ArrayBuffer that should be converted.
  50222. * @returns The buffer as Float32Array.
  50223. */
  50224. private getFloat32ArrayFromArrayBuffer;
  50225. /**
  50226. * Get the current class name of the texture useful for serialization or dynamic coding.
  50227. * @returns "EquiRectangularCubeTexture"
  50228. */
  50229. getClassName(): string;
  50230. /**
  50231. * Create a clone of the current EquiRectangularCubeTexture and return it.
  50232. * @returns A clone of the current EquiRectangularCubeTexture.
  50233. */
  50234. clone(): EquiRectangularCubeTexture;
  50235. }
  50236. }
  50237. declare module BABYLON {
  50238. /**
  50239. * Based on jsTGALoader - Javascript loader for TGA file
  50240. * By Vincent Thibault
  50241. * @see http://blog.robrowser.com/javascript-tga-loader.html
  50242. */
  50243. export class TGATools {
  50244. private static _TYPE_INDEXED;
  50245. private static _TYPE_RGB;
  50246. private static _TYPE_GREY;
  50247. private static _TYPE_RLE_INDEXED;
  50248. private static _TYPE_RLE_RGB;
  50249. private static _TYPE_RLE_GREY;
  50250. private static _ORIGIN_MASK;
  50251. private static _ORIGIN_SHIFT;
  50252. private static _ORIGIN_BL;
  50253. private static _ORIGIN_BR;
  50254. private static _ORIGIN_UL;
  50255. private static _ORIGIN_UR;
  50256. /**
  50257. * Gets the header of a TGA file
  50258. * @param data defines the TGA data
  50259. * @returns the header
  50260. */
  50261. static GetTGAHeader(data: Uint8Array): any;
  50262. /**
  50263. * Uploads TGA content to a Babylon Texture
  50264. * @hidden
  50265. */
  50266. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  50267. /** @hidden */
  50268. 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;
  50269. /** @hidden */
  50270. 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;
  50271. /** @hidden */
  50272. 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;
  50273. /** @hidden */
  50274. 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;
  50275. /** @hidden */
  50276. 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;
  50277. /** @hidden */
  50278. 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;
  50279. }
  50280. }
  50281. declare module BABYLON {
  50282. /**
  50283. * Implementation of the TGA Texture Loader.
  50284. * @hidden
  50285. */
  50286. export class _TGATextureLoader implements IInternalTextureLoader {
  50287. /**
  50288. * Defines wether the loader supports cascade loading the different faces.
  50289. */
  50290. readonly supportCascades: boolean;
  50291. /**
  50292. * This returns if the loader support the current file information.
  50293. * @param extension defines the file extension of the file being loaded
  50294. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50295. * @param fallback defines the fallback internal texture if any
  50296. * @param isBase64 defines whether the texture is encoded as a base64
  50297. * @param isBuffer defines whether the texture data are stored as a buffer
  50298. * @returns true if the loader can load the specified file
  50299. */
  50300. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50301. /**
  50302. * Transform the url before loading if required.
  50303. * @param rootUrl the url of the texture
  50304. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50305. * @returns the transformed texture
  50306. */
  50307. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50308. /**
  50309. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50310. * @param rootUrl the url of the texture
  50311. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50312. * @returns the fallback texture
  50313. */
  50314. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50315. /**
  50316. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50317. * @param data contains the texture data
  50318. * @param texture defines the BabylonJS internal texture
  50319. * @param createPolynomials will be true if polynomials have been requested
  50320. * @param onLoad defines the callback to trigger once the texture is ready
  50321. * @param onError defines the callback to trigger in case of error
  50322. */
  50323. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50324. /**
  50325. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50326. * @param data contains the texture data
  50327. * @param texture defines the BabylonJS internal texture
  50328. * @param callback defines the method to call once ready to upload
  50329. */
  50330. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50331. }
  50332. }
  50333. declare module BABYLON {
  50334. /**
  50335. * Info about the .basis files
  50336. */
  50337. class BasisFileInfo {
  50338. /**
  50339. * If the file has alpha
  50340. */
  50341. hasAlpha: boolean;
  50342. /**
  50343. * Info about each image of the basis file
  50344. */
  50345. images: Array<{
  50346. levels: Array<{
  50347. width: number;
  50348. height: number;
  50349. transcodedPixels: ArrayBufferView;
  50350. }>;
  50351. }>;
  50352. }
  50353. /**
  50354. * Result of transcoding a basis file
  50355. */
  50356. class TranscodeResult {
  50357. /**
  50358. * Info about the .basis file
  50359. */
  50360. fileInfo: BasisFileInfo;
  50361. /**
  50362. * Format to use when loading the file
  50363. */
  50364. format: number;
  50365. }
  50366. /**
  50367. * Configuration options for the Basis transcoder
  50368. */
  50369. export class BasisTranscodeConfiguration {
  50370. /**
  50371. * Supported compression formats used to determine the supported output format of the transcoder
  50372. */
  50373. supportedCompressionFormats?: {
  50374. /**
  50375. * etc1 compression format
  50376. */
  50377. etc1?: boolean;
  50378. /**
  50379. * s3tc compression format
  50380. */
  50381. s3tc?: boolean;
  50382. /**
  50383. * pvrtc compression format
  50384. */
  50385. pvrtc?: boolean;
  50386. /**
  50387. * etc2 compression format
  50388. */
  50389. etc2?: boolean;
  50390. };
  50391. /**
  50392. * If mipmap levels should be loaded for transcoded images (Default: true)
  50393. */
  50394. loadMipmapLevels?: boolean;
  50395. /**
  50396. * Index of a single image to load (Default: all images)
  50397. */
  50398. loadSingleImage?: number;
  50399. }
  50400. /**
  50401. * Used to load .Basis files
  50402. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  50403. */
  50404. export class BasisTools {
  50405. private static _IgnoreSupportedFormats;
  50406. /**
  50407. * URL to use when loading the basis transcoder
  50408. */
  50409. static JSModuleURL: string;
  50410. /**
  50411. * URL to use when loading the wasm module for the transcoder
  50412. */
  50413. static WasmModuleURL: string;
  50414. /**
  50415. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  50416. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  50417. * @returns internal format corresponding to the Basis format
  50418. */
  50419. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  50420. private static _WorkerPromise;
  50421. private static _Worker;
  50422. private static _actionId;
  50423. private static _CreateWorkerAsync;
  50424. /**
  50425. * Transcodes a loaded image file to compressed pixel data
  50426. * @param imageData image data to transcode
  50427. * @param config configuration options for the transcoding
  50428. * @returns a promise resulting in the transcoded image
  50429. */
  50430. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  50431. /**
  50432. * Loads a texture from the transcode result
  50433. * @param texture texture load to
  50434. * @param transcodeResult the result of transcoding the basis file to load from
  50435. */
  50436. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  50437. }
  50438. }
  50439. declare module BABYLON {
  50440. /**
  50441. * Loader for .basis file format
  50442. */
  50443. export class _BasisTextureLoader implements IInternalTextureLoader {
  50444. /**
  50445. * Defines whether the loader supports cascade loading the different faces.
  50446. */
  50447. readonly supportCascades: boolean;
  50448. /**
  50449. * This returns if the loader support the current file information.
  50450. * @param extension defines the file extension of the file being loaded
  50451. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50452. * @param fallback defines the fallback internal texture if any
  50453. * @param isBase64 defines whether the texture is encoded as a base64
  50454. * @param isBuffer defines whether the texture data are stored as a buffer
  50455. * @returns true if the loader can load the specified file
  50456. */
  50457. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50458. /**
  50459. * Transform the url before loading if required.
  50460. * @param rootUrl the url of the texture
  50461. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50462. * @returns the transformed texture
  50463. */
  50464. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50465. /**
  50466. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50467. * @param rootUrl the url of the texture
  50468. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50469. * @returns the fallback texture
  50470. */
  50471. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50472. /**
  50473. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  50474. * @param data contains the texture data
  50475. * @param texture defines the BabylonJS internal texture
  50476. * @param createPolynomials will be true if polynomials have been requested
  50477. * @param onLoad defines the callback to trigger once the texture is ready
  50478. * @param onError defines the callback to trigger in case of error
  50479. */
  50480. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50481. /**
  50482. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50483. * @param data contains the texture data
  50484. * @param texture defines the BabylonJS internal texture
  50485. * @param callback defines the method to call once ready to upload
  50486. */
  50487. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50488. }
  50489. }
  50490. declare module BABYLON {
  50491. /**
  50492. * 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.
  50493. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  50494. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  50495. */
  50496. export class CustomProceduralTexture extends ProceduralTexture {
  50497. private _animate;
  50498. private _time;
  50499. private _config;
  50500. private _texturePath;
  50501. /**
  50502. * Instantiates a new Custom Procedural Texture.
  50503. * 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.
  50504. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  50505. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  50506. * @param name Define the name of the texture
  50507. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  50508. * @param size Define the size of the texture to create
  50509. * @param scene Define the scene the texture belongs to
  50510. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  50511. * @param generateMipMaps Define if the texture should creates mip maps or not
  50512. */
  50513. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  50514. private _loadJson;
  50515. /**
  50516. * Is the texture ready to be used ? (rendered at least once)
  50517. * @returns true if ready, otherwise, false.
  50518. */
  50519. isReady(): boolean;
  50520. /**
  50521. * Render the texture to its associated render target.
  50522. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  50523. */
  50524. render(useCameraPostProcess?: boolean): void;
  50525. /**
  50526. * Update the list of dependant textures samplers in the shader.
  50527. */
  50528. updateTextures(): void;
  50529. /**
  50530. * Update the uniform values of the procedural texture in the shader.
  50531. */
  50532. updateShaderUniforms(): void;
  50533. /**
  50534. * Define if the texture animates or not.
  50535. */
  50536. animate: boolean;
  50537. }
  50538. }
  50539. declare module BABYLON {
  50540. /** @hidden */
  50541. export var noisePixelShader: {
  50542. name: string;
  50543. shader: string;
  50544. };
  50545. }
  50546. declare module BABYLON {
  50547. /**
  50548. * Class used to generate noise procedural textures
  50549. */
  50550. export class NoiseProceduralTexture extends ProceduralTexture {
  50551. private _time;
  50552. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  50553. brightness: number;
  50554. /** Defines the number of octaves to process */
  50555. octaves: number;
  50556. /** Defines the level of persistence (0.8 by default) */
  50557. persistence: number;
  50558. /** Gets or sets animation speed factor (default is 1) */
  50559. animationSpeedFactor: number;
  50560. /**
  50561. * Creates a new NoiseProceduralTexture
  50562. * @param name defines the name fo the texture
  50563. * @param size defines the size of the texture (default is 256)
  50564. * @param scene defines the hosting scene
  50565. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  50566. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  50567. */
  50568. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  50569. private _updateShaderUniforms;
  50570. protected _getDefines(): string;
  50571. /** Generate the current state of the procedural texture */
  50572. render(useCameraPostProcess?: boolean): void;
  50573. /**
  50574. * Serializes this noise procedural texture
  50575. * @returns a serialized noise procedural texture object
  50576. */
  50577. serialize(): any;
  50578. /**
  50579. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  50580. * @param parsedTexture defines parsed texture data
  50581. * @param scene defines the current scene
  50582. * @param rootUrl defines the root URL containing noise procedural texture information
  50583. * @returns a parsed NoiseProceduralTexture
  50584. */
  50585. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  50586. }
  50587. }
  50588. declare module BABYLON {
  50589. /**
  50590. * Raw cube texture where the raw buffers are passed in
  50591. */
  50592. export class RawCubeTexture extends CubeTexture {
  50593. /**
  50594. * Creates a cube texture where the raw buffers are passed in.
  50595. * @param scene defines the scene the texture is attached to
  50596. * @param data defines the array of data to use to create each face
  50597. * @param size defines the size of the textures
  50598. * @param format defines the format of the data
  50599. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  50600. * @param generateMipMaps defines if the engine should generate the mip levels
  50601. * @param invertY defines if data must be stored with Y axis inverted
  50602. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  50603. * @param compression defines the compression used (null by default)
  50604. */
  50605. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  50606. /**
  50607. * Updates the raw cube texture.
  50608. * @param data defines the data to store
  50609. * @param format defines the data format
  50610. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  50611. * @param invertY defines if data must be stored with Y axis inverted
  50612. * @param compression defines the compression used (null by default)
  50613. * @param level defines which level of the texture to update
  50614. */
  50615. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  50616. /**
  50617. * Updates a raw cube texture with RGBD encoded data.
  50618. * @param data defines the array of data [mipmap][face] to use to create each face
  50619. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  50620. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  50621. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  50622. * @returns a promsie that resolves when the operation is complete
  50623. */
  50624. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  50625. /**
  50626. * Clones the raw cube texture.
  50627. * @return a new cube texture
  50628. */
  50629. clone(): CubeTexture;
  50630. /** @hidden */
  50631. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  50632. }
  50633. }
  50634. declare module BABYLON {
  50635. /**
  50636. * Class used to store 3D textures containing user data
  50637. */
  50638. export class RawTexture3D extends Texture {
  50639. /** Gets or sets the texture format to use */
  50640. format: number;
  50641. private _engine;
  50642. /**
  50643. * Create a new RawTexture3D
  50644. * @param data defines the data of the texture
  50645. * @param width defines the width of the texture
  50646. * @param height defines the height of the texture
  50647. * @param depth defines the depth of the texture
  50648. * @param format defines the texture format to use
  50649. * @param scene defines the hosting scene
  50650. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  50651. * @param invertY defines if texture must be stored with Y axis inverted
  50652. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  50653. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  50654. */
  50655. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  50656. /** Gets or sets the texture format to use */
  50657. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  50658. /**
  50659. * Update the texture with new data
  50660. * @param data defines the data to store in the texture
  50661. */
  50662. update(data: ArrayBufferView): void;
  50663. }
  50664. }
  50665. declare module BABYLON {
  50666. /**
  50667. * Creates a refraction texture used by refraction channel of the standard material.
  50668. * It is like a mirror but to see through a material.
  50669. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  50670. */
  50671. export class RefractionTexture extends RenderTargetTexture {
  50672. /**
  50673. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  50674. * 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.
  50675. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  50676. */
  50677. refractionPlane: Plane;
  50678. /**
  50679. * Define how deep under the surface we should see.
  50680. */
  50681. depth: number;
  50682. /**
  50683. * Creates a refraction texture used by refraction channel of the standard material.
  50684. * It is like a mirror but to see through a material.
  50685. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  50686. * @param name Define the texture name
  50687. * @param size Define the size of the underlying texture
  50688. * @param scene Define the scene the refraction belongs to
  50689. * @param generateMipMaps Define if we need to generate mips level for the refraction
  50690. */
  50691. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  50692. /**
  50693. * Clone the refraction texture.
  50694. * @returns the cloned texture
  50695. */
  50696. clone(): RefractionTexture;
  50697. /**
  50698. * Serialize the texture to a JSON representation you could use in Parse later on
  50699. * @returns the serialized JSON representation
  50700. */
  50701. serialize(): any;
  50702. }
  50703. }
  50704. declare module BABYLON {
  50705. /**
  50706. * Defines the options related to the creation of an HtmlElementTexture
  50707. */
  50708. export interface IHtmlElementTextureOptions {
  50709. /**
  50710. * Defines wether mip maps should be created or not.
  50711. */
  50712. generateMipMaps?: boolean;
  50713. /**
  50714. * Defines the sampling mode of the texture.
  50715. */
  50716. samplingMode?: number;
  50717. /**
  50718. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  50719. */
  50720. engine: Nullable<Engine>;
  50721. /**
  50722. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  50723. */
  50724. scene: Nullable<Scene>;
  50725. }
  50726. /**
  50727. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  50728. * To be as efficient as possible depending on your constraints nothing aside the first upload
  50729. * is automatically managed.
  50730. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  50731. * in your application.
  50732. *
  50733. * As the update is not automatic, you need to call them manually.
  50734. */
  50735. export class HtmlElementTexture extends BaseTexture {
  50736. /**
  50737. * The texture URL.
  50738. */
  50739. element: HTMLVideoElement | HTMLCanvasElement;
  50740. private static readonly DefaultOptions;
  50741. private _textureMatrix;
  50742. private _engine;
  50743. private _isVideo;
  50744. private _generateMipMaps;
  50745. private _samplingMode;
  50746. /**
  50747. * Instantiates a HtmlElementTexture from the following parameters.
  50748. *
  50749. * @param name Defines the name of the texture
  50750. * @param element Defines the video or canvas the texture is filled with
  50751. * @param options Defines the other none mandatory texture creation options
  50752. */
  50753. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  50754. private _createInternalTexture;
  50755. /**
  50756. * Returns the texture matrix used in most of the material.
  50757. */
  50758. getTextureMatrix(): Matrix;
  50759. /**
  50760. * Updates the content of the texture.
  50761. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  50762. */
  50763. update(invertY?: Nullable<boolean>): void;
  50764. }
  50765. }
  50766. declare module BABYLON {
  50767. /**
  50768. * Enum used to define the target of a block
  50769. */
  50770. export enum NodeMaterialBlockTargets {
  50771. /** Vertex shader */
  50772. Vertex = 1,
  50773. /** Fragment shader */
  50774. Fragment = 2,
  50775. /** Vertex and Fragment */
  50776. VertexAndFragment = 3
  50777. }
  50778. }
  50779. declare module BABYLON {
  50780. /**
  50781. * Defines the kind of connection point for node based material
  50782. */
  50783. export enum NodeMaterialBlockConnectionPointTypes {
  50784. /** Float */
  50785. Float = 1,
  50786. /** Int */
  50787. Int = 2,
  50788. /** Vector2 */
  50789. Vector2 = 4,
  50790. /** Vector3 */
  50791. Vector3 = 8,
  50792. /** Vector4 */
  50793. Vector4 = 16,
  50794. /** Color3 */
  50795. Color3 = 32,
  50796. /** Color4 */
  50797. Color4 = 64,
  50798. /** Matrix */
  50799. Matrix = 128,
  50800. /** Vector3 or Color3 */
  50801. Vector3OrColor3 = 40,
  50802. /** Vector3 or Vector4 */
  50803. Vector3OrVector4 = 24,
  50804. /** Vector4 or Color4 */
  50805. Vector4OrColor4 = 80,
  50806. /** Color3 or Color4 */
  50807. Color3OrColor4 = 96,
  50808. /** Vector2 or Color3 or Color4 */
  50809. Vector2OrColor3OrColor4 = 100,
  50810. /** Vector3 or Color3 or Color4 or Vector4 */
  50811. Vector3OrColor3OrVector4OrColor4 = 120,
  50812. /** Vector2 or Vector3 or Color3 or Color4 or Vector4 */
  50813. Vector2OrVector3OrColor3OrVector4OrColor4 = 124,
  50814. /** Detect type based on connection */
  50815. AutoDetect = 1024,
  50816. /** Output type that will be defined by input type */
  50817. BasedOnInput = 2048
  50818. }
  50819. }
  50820. declare module BABYLON {
  50821. /**
  50822. * Root class for all node material optimizers
  50823. */
  50824. export class NodeMaterialOptimizer {
  50825. /**
  50826. * Function used to optimize a NodeMaterial graph
  50827. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  50828. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  50829. */
  50830. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  50831. }
  50832. }
  50833. declare module BABYLON {
  50834. /**
  50835. * Block used to transform a vector4 with a matrix
  50836. */
  50837. export class Vector4TransformBlock extends NodeMaterialBlock {
  50838. /**
  50839. * Defines the value to use to complement Vector3 to transform it to a Vector4
  50840. */
  50841. complementW: number;
  50842. /**
  50843. * Creates a new Vector4TransformBlock
  50844. * @param name defines the block name
  50845. */
  50846. constructor(name: string);
  50847. /**
  50848. * Gets the current class name
  50849. * @returns the class name
  50850. */
  50851. getClassName(): string;
  50852. /**
  50853. * Gets the vector input
  50854. */
  50855. readonly vector: NodeMaterialConnectionPoint;
  50856. /**
  50857. * Gets the output component
  50858. */
  50859. readonly output: NodeMaterialConnectionPoint;
  50860. /**
  50861. * Gets the matrix transform input
  50862. */
  50863. readonly transform: NodeMaterialConnectionPoint;
  50864. protected _buildBlock(state: NodeMaterialBuildState): this;
  50865. }
  50866. }
  50867. declare module BABYLON {
  50868. /**
  50869. * Block used to output the vertex position
  50870. */
  50871. export class VertexOutputBlock extends NodeMaterialBlock {
  50872. /**
  50873. * Creates a new VertexOutputBlock
  50874. * @param name defines the block name
  50875. */
  50876. constructor(name: string);
  50877. /**
  50878. * Gets the current class name
  50879. * @returns the class name
  50880. */
  50881. getClassName(): string;
  50882. /**
  50883. * Gets the vector input component
  50884. */
  50885. readonly vector: NodeMaterialConnectionPoint;
  50886. protected _buildBlock(state: NodeMaterialBuildState): this;
  50887. }
  50888. }
  50889. declare module BABYLON {
  50890. /**
  50891. * Block used to output the final color
  50892. */
  50893. export class FragmentOutputBlock extends NodeMaterialBlock {
  50894. /**
  50895. * Gets or sets a boolean indicating if this block will output an alpha value
  50896. */
  50897. alphaBlendingEnabled: boolean;
  50898. /**
  50899. * Create a new FragmentOutputBlock
  50900. * @param name defines the block name
  50901. */
  50902. constructor(name: string);
  50903. /**
  50904. * Gets the current class name
  50905. * @returns the class name
  50906. */
  50907. getClassName(): string;
  50908. /**
  50909. * Gets the color input component
  50910. */
  50911. readonly color: NodeMaterialConnectionPoint;
  50912. protected _buildBlock(state: NodeMaterialBuildState): this;
  50913. }
  50914. }
  50915. declare module BABYLON {
  50916. /**
  50917. * Interface used to configure the node material editor
  50918. */
  50919. export interface INodeMaterialEditorOptions {
  50920. /** Define the URl to load node editor script */
  50921. editorURL?: string;
  50922. }
  50923. /** @hidden */
  50924. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  50925. /** BONES */
  50926. NUM_BONE_INFLUENCERS: number;
  50927. BonesPerMesh: number;
  50928. BONETEXTURE: boolean;
  50929. /** MORPH TARGETS */
  50930. MORPHTARGETS: boolean;
  50931. MORPHTARGETS_NORMAL: boolean;
  50932. MORPHTARGETS_TANGENT: boolean;
  50933. MORPHTARGETS_UV: boolean;
  50934. NUM_MORPH_INFLUENCERS: number;
  50935. /** IMAGE PROCESSING */
  50936. IMAGEPROCESSING: boolean;
  50937. VIGNETTE: boolean;
  50938. VIGNETTEBLENDMODEMULTIPLY: boolean;
  50939. VIGNETTEBLENDMODEOPAQUE: boolean;
  50940. TONEMAPPING: boolean;
  50941. TONEMAPPING_ACES: boolean;
  50942. CONTRAST: boolean;
  50943. EXPOSURE: boolean;
  50944. COLORCURVES: boolean;
  50945. COLORGRADING: boolean;
  50946. COLORGRADING3D: boolean;
  50947. SAMPLER3DGREENDEPTH: boolean;
  50948. SAMPLER3DBGRMAP: boolean;
  50949. IMAGEPROCESSINGPOSTPROCESS: boolean;
  50950. constructor();
  50951. setValue(name: string, value: boolean): void;
  50952. }
  50953. /**
  50954. * Class used to configure NodeMaterial
  50955. */
  50956. export interface INodeMaterialOptions {
  50957. /**
  50958. * Defines if blocks should emit comments
  50959. */
  50960. emitComments: boolean;
  50961. }
  50962. /**
  50963. * Class used to create a node based material built by assembling shader blocks
  50964. */
  50965. export class NodeMaterial extends PushMaterial {
  50966. private _options;
  50967. private _vertexCompilationState;
  50968. private _fragmentCompilationState;
  50969. private _sharedData;
  50970. private _buildId;
  50971. private _buildWasSuccessful;
  50972. private _cachedWorldViewMatrix;
  50973. private _cachedWorldViewProjectionMatrix;
  50974. private _optimizers;
  50975. /** Define the URl to load node editor script */
  50976. static EditorURL: string;
  50977. private BJSNODEMATERIALEDITOR;
  50978. /** Get the inspector from bundle or global */
  50979. private _getGlobalNodeMaterialEditor;
  50980. /**
  50981. * Defines the maximum number of lights that can be used in the material
  50982. */
  50983. maxSimultaneousLights: number;
  50984. /**
  50985. * Observable raised when the material is built
  50986. */
  50987. onBuildObservable: Observable<NodeMaterial>;
  50988. /**
  50989. * Gets or sets the root nodes of the material vertex shader
  50990. */
  50991. _vertexOutputNodes: NodeMaterialBlock[];
  50992. /**
  50993. * Gets or sets the root nodes of the material fragment (pixel) shader
  50994. */
  50995. _fragmentOutputNodes: NodeMaterialBlock[];
  50996. /** Gets or sets options to control the node material overall behavior */
  50997. options: INodeMaterialOptions;
  50998. /**
  50999. * Default configuration related to image processing available in the standard Material.
  51000. */
  51001. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51002. /**
  51003. * Gets the image processing configuration used either in this material.
  51004. */
  51005. /**
  51006. * Sets the Default image processing configuration used either in the this material.
  51007. *
  51008. * If sets to null, the scene one is in use.
  51009. */
  51010. imageProcessingConfiguration: ImageProcessingConfiguration;
  51011. /**
  51012. * Create a new node based material
  51013. * @param name defines the material name
  51014. * @param scene defines the hosting scene
  51015. * @param options defines creation option
  51016. */
  51017. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  51018. /**
  51019. * Gets the current class name of the material e.g. "NodeMaterial"
  51020. * @returns the class name
  51021. */
  51022. getClassName(): string;
  51023. /**
  51024. * Keep track of the image processing observer to allow dispose and replace.
  51025. */
  51026. private _imageProcessingObserver;
  51027. /**
  51028. * Attaches a new image processing configuration to the Standard Material.
  51029. * @param configuration
  51030. */
  51031. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51032. /**
  51033. * Adds a new optimizer to the list of optimizers
  51034. * @param optimizer defines the optimizers to add
  51035. * @returns the current material
  51036. */
  51037. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  51038. /**
  51039. * Remove an optimizer from the list of optimizers
  51040. * @param optimizer defines the optimizers to remove
  51041. * @returns the current material
  51042. */
  51043. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  51044. /**
  51045. * Add a new block to the list of output nodes
  51046. * @param node defines the node to add
  51047. * @returns the current material
  51048. */
  51049. addOutputNode(node: NodeMaterialBlock): this;
  51050. /**
  51051. * Remove a block from the list of root nodes
  51052. * @param node defines the node to remove
  51053. * @returns the current material
  51054. */
  51055. removeOutputNode(node: NodeMaterialBlock): this;
  51056. private _addVertexOutputNode;
  51057. private _removeVertexOutputNode;
  51058. private _addFragmentOutputNode;
  51059. private _removeFragmentOutputNode;
  51060. /**
  51061. * Specifies if the material will require alpha blending
  51062. * @returns a boolean specifying if alpha blending is needed
  51063. */
  51064. needAlphaBlending(): boolean;
  51065. /**
  51066. * Specifies if this material should be rendered in alpha test mode
  51067. * @returns a boolean specifying if an alpha test is needed.
  51068. */
  51069. needAlphaTesting(): boolean;
  51070. private _initializeBlock;
  51071. private _resetDualBlocks;
  51072. /**
  51073. * Build the material and generates the inner effect
  51074. * @param verbose defines if the build should log activity
  51075. */
  51076. build(verbose?: boolean): void;
  51077. /**
  51078. * Runs an otpimization phase to try to improve the shader code
  51079. */
  51080. optimize(): void;
  51081. private _prepareDefinesForAttributes;
  51082. /**
  51083. * Get if the submesh is ready to be used and all its information available.
  51084. * Child classes can use it to update shaders
  51085. * @param mesh defines the mesh to check
  51086. * @param subMesh defines which submesh to check
  51087. * @param useInstances specifies that instances should be used
  51088. * @returns a boolean indicating that the submesh is ready or not
  51089. */
  51090. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51091. /**
  51092. * Binds the world matrix to the material
  51093. * @param world defines the world transformation matrix
  51094. */
  51095. bindOnlyWorldMatrix(world: Matrix): void;
  51096. /**
  51097. * Binds the submesh to this material by preparing the effect and shader to draw
  51098. * @param world defines the world transformation matrix
  51099. * @param mesh defines the mesh containing the submesh
  51100. * @param subMesh defines the submesh to bind the material to
  51101. */
  51102. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51103. /**
  51104. * Gets the active textures from the material
  51105. * @returns an array of textures
  51106. */
  51107. getActiveTextures(): BaseTexture[];
  51108. /**
  51109. * Specifies if the material uses a texture
  51110. * @param texture defines the texture to check against the material
  51111. * @returns a boolean specifying if the material uses the texture
  51112. */
  51113. hasTexture(texture: BaseTexture): boolean;
  51114. /**
  51115. * Disposes the material
  51116. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  51117. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  51118. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  51119. */
  51120. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  51121. /** Creates the node editor window. */
  51122. private _createNodeEditor;
  51123. /**
  51124. * Launch the node material editor
  51125. * @param config Define the configuration of the editor
  51126. * @return a promise fulfilled when the node editor is visible
  51127. */
  51128. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  51129. /**
  51130. * Clear the current material
  51131. */
  51132. clear(): void;
  51133. /**
  51134. * Clear the current material and set it to a default state
  51135. */
  51136. setToDefault(): void;
  51137. }
  51138. }
  51139. declare module BABYLON {
  51140. /**
  51141. * Block used to read a texture from a sampler
  51142. */
  51143. export class TextureBlock extends NodeMaterialBlock {
  51144. private _defineName;
  51145. private _samplerName;
  51146. private _transformedUVName;
  51147. private _textureTransformName;
  51148. private _textureInfoName;
  51149. private _mainUVName;
  51150. private _mainUVDefineName;
  51151. /**
  51152. * Gets or sets the texture associated with the node
  51153. */
  51154. texture: Nullable<BaseTexture>;
  51155. /**
  51156. * Create a new TextureBlock
  51157. * @param name defines the block name
  51158. */
  51159. constructor(name: string);
  51160. /**
  51161. * Gets the current class name
  51162. * @returns the class name
  51163. */
  51164. getClassName(): string;
  51165. /**
  51166. * Gets the uv input component
  51167. */
  51168. readonly uv: NodeMaterialConnectionPoint;
  51169. /**
  51170. * Gets the output component
  51171. */
  51172. readonly output: NodeMaterialConnectionPoint;
  51173. autoConfigure(): void;
  51174. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  51175. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51176. isReady(): boolean;
  51177. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51178. private _injectVertexCode;
  51179. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  51180. }
  51181. }
  51182. declare module BABYLON {
  51183. /**
  51184. * Class used to store shared data between 2 NodeMaterialBuildState
  51185. */
  51186. export class NodeMaterialBuildStateSharedData {
  51187. /**
  51188. * Gets the list of emitted varyings
  51189. */
  51190. varyings: string[];
  51191. /**
  51192. * Gets the varying declaration string
  51193. */
  51194. varyingDeclaration: string;
  51195. /**
  51196. * Input blocks
  51197. */
  51198. inputBlocks: InputBlock[];
  51199. /**
  51200. * Input blocks
  51201. */
  51202. textureBlocks: TextureBlock[];
  51203. /**
  51204. * Bindable blocks (Blocks that need to set data to the effect)
  51205. */
  51206. bindableBlocks: NodeMaterialBlock[];
  51207. /**
  51208. * List of blocks that can provide a compilation fallback
  51209. */
  51210. blocksWithFallbacks: NodeMaterialBlock[];
  51211. /**
  51212. * List of blocks that can provide a define update
  51213. */
  51214. blocksWithDefines: NodeMaterialBlock[];
  51215. /**
  51216. * List of blocks that can provide a repeatable content
  51217. */
  51218. repeatableContentBlocks: NodeMaterialBlock[];
  51219. /**
  51220. * List of blocks that can provide a dynamic list of uniforms
  51221. */
  51222. dynamicUniformBlocks: NodeMaterialBlock[];
  51223. /**
  51224. * List of blocks that can block the isReady function for the material
  51225. */
  51226. blockingBlocks: NodeMaterialBlock[];
  51227. /**
  51228. * Build Id used to avoid multiple recompilations
  51229. */
  51230. buildId: number;
  51231. /** List of emitted variables */
  51232. variableNames: {
  51233. [key: string]: number;
  51234. };
  51235. /** List of emitted defines */
  51236. defineNames: {
  51237. [key: string]: number;
  51238. };
  51239. /** Should emit comments? */
  51240. emitComments: boolean;
  51241. /** Emit build activity */
  51242. verbose: boolean;
  51243. /**
  51244. * Gets the compilation hints emitted at compilation time
  51245. */
  51246. hints: {
  51247. needWorldViewMatrix: boolean;
  51248. needWorldViewProjectionMatrix: boolean;
  51249. needAlphaBlending: boolean;
  51250. needAlphaTesting: boolean;
  51251. };
  51252. /**
  51253. * List of compilation checks
  51254. */
  51255. checks: {
  51256. emitVertex: boolean;
  51257. emitFragment: boolean;
  51258. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  51259. };
  51260. /** Creates a new shared data */
  51261. constructor();
  51262. /**
  51263. * Emits console errors and exceptions if there is a failing check
  51264. */
  51265. emitErrors(): void;
  51266. }
  51267. }
  51268. declare module BABYLON {
  51269. /**
  51270. * Class used to store node based material build state
  51271. */
  51272. export class NodeMaterialBuildState {
  51273. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  51274. supportUniformBuffers: boolean;
  51275. /**
  51276. * Gets the list of emitted attributes
  51277. */
  51278. attributes: string[];
  51279. /**
  51280. * Gets the list of emitted uniforms
  51281. */
  51282. uniforms: string[];
  51283. /**
  51284. * Gets the list of emitted uniform buffers
  51285. */
  51286. uniformBuffers: string[];
  51287. /**
  51288. * Gets the list of emitted samplers
  51289. */
  51290. samplers: string[];
  51291. /**
  51292. * Gets the list of emitted functions
  51293. */
  51294. functions: {
  51295. [key: string]: string;
  51296. };
  51297. /**
  51298. * Gets the target of the compilation state
  51299. */
  51300. target: NodeMaterialBlockTargets;
  51301. /**
  51302. * Gets the list of emitted counters
  51303. */
  51304. counters: {
  51305. [key: string]: number;
  51306. };
  51307. /**
  51308. * Shared data between multiple NodeMaterialBuildState instances
  51309. */
  51310. sharedData: NodeMaterialBuildStateSharedData;
  51311. /** @hidden */
  51312. _vertexState: NodeMaterialBuildState;
  51313. /** @hidden */
  51314. _attributeDeclaration: string;
  51315. /** @hidden */
  51316. _uniformDeclaration: string;
  51317. /** @hidden */
  51318. _samplerDeclaration: string;
  51319. /** @hidden */
  51320. _varyingTransfer: string;
  51321. private _repeatableContentAnchorIndex;
  51322. /** @hidden */
  51323. _builtCompilationString: string;
  51324. /**
  51325. * Gets the emitted compilation strings
  51326. */
  51327. compilationString: string;
  51328. /**
  51329. * Finalize the compilation strings
  51330. * @param state defines the current compilation state
  51331. */
  51332. finalize(state: NodeMaterialBuildState): void;
  51333. /** @hidden */
  51334. readonly _repeatableContentAnchor: string;
  51335. /** @hidden */
  51336. _getFreeVariableName(prefix: string): string;
  51337. /** @hidden */
  51338. _getFreeDefineName(prefix: string): string;
  51339. /** @hidden */
  51340. _excludeVariableName(name: string): void;
  51341. /** @hidden */
  51342. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  51343. /** @hidden */
  51344. _emitFunction(name: string, code: string, comments: string): void;
  51345. /** @hidden */
  51346. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  51347. replaceStrings?: {
  51348. search: RegExp;
  51349. replace: string;
  51350. }[];
  51351. repeatKey?: string;
  51352. }): string;
  51353. /** @hidden */
  51354. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  51355. repeatKey?: string;
  51356. removeAttributes?: boolean;
  51357. removeUniforms?: boolean;
  51358. removeVaryings?: boolean;
  51359. removeIfDef?: boolean;
  51360. replaceStrings?: {
  51361. search: RegExp;
  51362. replace: string;
  51363. }[];
  51364. }, storeKey?: string): void;
  51365. /** @hidden */
  51366. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  51367. /** @hidden */
  51368. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  51369. }
  51370. }
  51371. declare module BABYLON {
  51372. /**
  51373. * Defines a block that can be used inside a node based material
  51374. */
  51375. export class NodeMaterialBlock {
  51376. private _buildId;
  51377. private _buildTarget;
  51378. private _target;
  51379. private _isFinalMerger;
  51380. private _isInput;
  51381. /** @hidden */
  51382. _inputs: NodeMaterialConnectionPoint[];
  51383. /** @hidden */
  51384. _outputs: NodeMaterialConnectionPoint[];
  51385. /**
  51386. * Gets or sets the name of the block
  51387. */
  51388. name: string;
  51389. /**
  51390. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  51391. */
  51392. readonly isFinalMerger: boolean;
  51393. /**
  51394. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  51395. */
  51396. readonly isInput: boolean;
  51397. /**
  51398. * Gets or sets the build Id
  51399. */
  51400. buildId: number;
  51401. /**
  51402. * Gets or sets the target of the block
  51403. */
  51404. target: NodeMaterialBlockTargets;
  51405. /**
  51406. * Gets the list of input points
  51407. */
  51408. readonly inputs: NodeMaterialConnectionPoint[];
  51409. /** Gets the list of output points */
  51410. readonly outputs: NodeMaterialConnectionPoint[];
  51411. /**
  51412. * Find an input by its name
  51413. * @param name defines the name of the input to look for
  51414. * @returns the input or null if not found
  51415. */
  51416. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  51417. /**
  51418. * Find an output by its name
  51419. * @param name defines the name of the outputto look for
  51420. * @returns the output or null if not found
  51421. */
  51422. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  51423. /**
  51424. * Creates a new NodeMaterialBlock
  51425. * @param name defines the block name
  51426. * @param target defines the target of that block (Vertex by default)
  51427. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  51428. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  51429. */
  51430. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  51431. /**
  51432. * Initialize the block and prepare the context for build
  51433. * @param state defines the state that will be used for the build
  51434. */
  51435. initialize(state: NodeMaterialBuildState): void;
  51436. /**
  51437. * Bind data to effect. Will only be called for blocks with isBindable === true
  51438. * @param effect defines the effect to bind data to
  51439. * @param nodeMaterial defines the hosting NodeMaterial
  51440. * @param mesh defines the mesh that will be rendered
  51441. */
  51442. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51443. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  51444. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  51445. protected _writeFloat(value: number): string;
  51446. /**
  51447. * Gets the current class name e.g. "NodeMaterialBlock"
  51448. * @returns the class name
  51449. */
  51450. getClassName(): string;
  51451. /**
  51452. * Register a new input. Must be called inside a block constructor
  51453. * @param name defines the connection point name
  51454. * @param type defines the connection point type
  51455. * @param isOptional defines a boolean indicating that this input can be omitted
  51456. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  51457. * @returns the current block
  51458. */
  51459. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  51460. /**
  51461. * Register a new output. Must be called inside a block constructor
  51462. * @param name defines the connection point name
  51463. * @param type defines the connection point type
  51464. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  51465. * @returns the current block
  51466. */
  51467. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  51468. /**
  51469. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  51470. * @param forOutput defines an optional connection point to check compatibility with
  51471. * @returns the first available input or null
  51472. */
  51473. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  51474. /**
  51475. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  51476. * @param forBlock defines an optional block to check compatibility with
  51477. * @returns the first available input or null
  51478. */
  51479. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  51480. /**
  51481. * Connect current block with another block
  51482. * @param other defines the block to connect with
  51483. * @param options define the various options to help pick the right connections
  51484. * @returns the current block
  51485. */
  51486. connectTo(other: NodeMaterialBlock, options?: {
  51487. input?: string;
  51488. output?: string;
  51489. outputSwizzle?: string;
  51490. }): this | undefined;
  51491. protected _buildBlock(state: NodeMaterialBuildState): void;
  51492. /**
  51493. * Add uniforms, samplers and uniform buffers at compilation time
  51494. * @param state defines the state to update
  51495. * @param nodeMaterial defines the node material requesting the update
  51496. * @param defines defines the material defines to update
  51497. */
  51498. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51499. /**
  51500. * Add potential fallbacks if shader compilation fails
  51501. * @param mesh defines the mesh to be rendered
  51502. * @param fallbacks defines the current prioritized list of fallbacks
  51503. */
  51504. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  51505. /**
  51506. * Update defines for shader compilation
  51507. * @param mesh defines the mesh to be rendered
  51508. * @param nodeMaterial defines the node material requesting the update
  51509. * @param defines defines the material defines to update
  51510. * @param useInstances specifies that instances should be used
  51511. */
  51512. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  51513. /**
  51514. * Initialize defines for shader compilation
  51515. * @param mesh defines the mesh to be rendered
  51516. * @param nodeMaterial defines the node material requesting the update
  51517. * @param defines defines the material defines to be prepared
  51518. * @param useInstances specifies that instances should be used
  51519. */
  51520. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  51521. /**
  51522. * Lets the block try to connect some inputs automatically
  51523. */
  51524. autoConfigure(): void;
  51525. /**
  51526. * Function called when a block is declared as repeatable content generator
  51527. * @param vertexShaderState defines the current compilation state for the vertex shader
  51528. * @param fragmentShaderState defines the current compilation state for the fragment shader
  51529. * @param mesh defines the mesh to be rendered
  51530. * @param defines defines the material defines to update
  51531. */
  51532. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  51533. /**
  51534. * Checks if the block is ready
  51535. * @param mesh defines the mesh to be rendered
  51536. * @param nodeMaterial defines the node material requesting the update
  51537. * @param defines defines the material defines to update
  51538. * @param useInstances specifies that instances should be used
  51539. * @returns true if the block is ready
  51540. */
  51541. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  51542. private _processBuild;
  51543. /**
  51544. * Compile the current node and generate the shader code
  51545. * @param state defines the current compilation state (uniforms, samplers, current string)
  51546. * @param contextSwitched indicates that the previous block was built for a different context (vertex vs. fragment)
  51547. * @returns true if already built
  51548. */
  51549. build(state: NodeMaterialBuildState, contextSwitched?: boolean): boolean;
  51550. }
  51551. }
  51552. declare module BABYLON {
  51553. /**
  51554. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  51555. */
  51556. export enum NodeMaterialBlockConnectionPointMode {
  51557. /** Value is an uniform */
  51558. Uniform = 0,
  51559. /** Value is a mesh attribute */
  51560. Attribute = 1,
  51561. /** Value is a varying between vertex and fragment shaders */
  51562. Varying = 2,
  51563. /** Mode is undefined */
  51564. Undefined = 3
  51565. }
  51566. }
  51567. declare module BABYLON {
  51568. /**
  51569. * Enum used to define well known values e.g. values automatically provided by the system
  51570. */
  51571. export enum NodeMaterialWellKnownValues {
  51572. /** World */
  51573. World = 1,
  51574. /** View */
  51575. View = 2,
  51576. /** Projection */
  51577. Projection = 3,
  51578. /** ViewProjection */
  51579. ViewProjection = 4,
  51580. /** WorldView */
  51581. WorldView = 5,
  51582. /** WorldViewProjection */
  51583. WorldViewProjection = 6,
  51584. /** CameraPosition */
  51585. CameraPosition = 7,
  51586. /** Fog Color */
  51587. FogColor = 8
  51588. }
  51589. }
  51590. declare module BABYLON {
  51591. /**
  51592. * Block used to expose an input value
  51593. */
  51594. export class InputBlock extends NodeMaterialBlock {
  51595. private _mode;
  51596. private _associatedVariableName;
  51597. private _storedValue;
  51598. private _valueCallback;
  51599. private _type;
  51600. /** @hidden */
  51601. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  51602. /**
  51603. * Gets or sets the connection point type (default is float)
  51604. */
  51605. readonly type: NodeMaterialBlockConnectionPointTypes;
  51606. /**
  51607. * Creates a new InputBlock
  51608. * @param name defines the block name
  51609. * @param target defines the target of that block (Vertex by default)
  51610. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  51611. */
  51612. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  51613. /**
  51614. * Gets the output component
  51615. */
  51616. readonly output: NodeMaterialConnectionPoint;
  51617. /**
  51618. * Set the source of this connection point to a vertex attribute
  51619. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  51620. * @returns the current connection point
  51621. */
  51622. setAsAttribute(attributeName?: string): InputBlock;
  51623. /**
  51624. * Set the source of this connection point to a well known value
  51625. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  51626. * @returns the current connection point
  51627. */
  51628. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): InputBlock;
  51629. /**
  51630. * Gets or sets the value of that point.
  51631. * Please note that this value will be ignored if valueCallback is defined
  51632. */
  51633. value: any;
  51634. /**
  51635. * Gets or sets a callback used to get the value of that point.
  51636. * Please note that setting this value will force the connection point to ignore the value property
  51637. */
  51638. valueCallback: () => any;
  51639. /**
  51640. * Gets or sets the associated variable name in the shader
  51641. */
  51642. associatedVariableName: string;
  51643. /**
  51644. * Gets a boolean indicating that this connection point not defined yet
  51645. */
  51646. readonly isUndefined: boolean;
  51647. /**
  51648. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  51649. * In this case the connection point name must be the name of the uniform to use.
  51650. * Can only be set on inputs
  51651. */
  51652. isUniform: boolean;
  51653. /**
  51654. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  51655. * In this case the connection point name must be the name of the attribute to use
  51656. * Can only be set on inputs
  51657. */
  51658. isAttribute: boolean;
  51659. /**
  51660. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  51661. * Can only be set on exit points
  51662. */
  51663. isVarying: boolean;
  51664. /**
  51665. * Gets a boolean indicating that the current connection point is a well known value
  51666. */
  51667. readonly isWellKnownValue: boolean;
  51668. /**
  51669. * Gets or sets the current well known value or null if not defined as well know value
  51670. */
  51671. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  51672. /**
  51673. * Gets the current class name
  51674. * @returns the class name
  51675. */
  51676. getClassName(): string;
  51677. private _emitDefine;
  51678. /**
  51679. * Set the input block to its default value (based on its type)
  51680. */
  51681. setDefaultValue(): void;
  51682. private _emit;
  51683. /** @hidden */
  51684. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  51685. /** @hidden */
  51686. _transmit(effect: Effect, scene: Scene): void;
  51687. protected _buildBlock(state: NodeMaterialBuildState): void;
  51688. }
  51689. }
  51690. declare module BABYLON {
  51691. /**
  51692. * Defines a connection point for a block
  51693. */
  51694. export class NodeMaterialConnectionPoint {
  51695. /** @hidden */
  51696. _ownerBlock: NodeMaterialBlock;
  51697. /** @hidden */
  51698. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  51699. private _endpoints;
  51700. private _associatedVariableName;
  51701. /** @hidden */
  51702. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  51703. private _type;
  51704. /** @hidden */
  51705. _enforceAssociatedVariableName: boolean;
  51706. /**
  51707. * Gets or sets the associated variable name in the shader
  51708. */
  51709. associatedVariableName: string;
  51710. /**
  51711. * Gets or sets the connection point type (default is float)
  51712. */
  51713. type: NodeMaterialBlockConnectionPointTypes;
  51714. /**
  51715. * Gets or sets the connection point name
  51716. */
  51717. name: string;
  51718. /**
  51719. * Gets or sets the swizzle to apply to this connection point when reading or writing
  51720. */
  51721. swizzle: string;
  51722. /**
  51723. * Gets or sets a boolean indicating that this connection point can be omitted
  51724. */
  51725. isOptional: boolean;
  51726. /**
  51727. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  51728. */
  51729. define: string;
  51730. /** Gets or sets the target of that connection point */
  51731. target: NodeMaterialBlockTargets;
  51732. /**
  51733. * Gets a boolean indicating that the current point is connected
  51734. */
  51735. readonly isConnected: boolean;
  51736. /**
  51737. * Gets a boolean indicating that the current point is connected to an input block
  51738. */
  51739. readonly isConnectedToInput: boolean;
  51740. /**
  51741. * Gets a the connected input block (if any)
  51742. */
  51743. readonly connectInputBlock: Nullable<InputBlock>;
  51744. /** Get the other side of the connection (if any) */
  51745. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  51746. /** Get the block that owns this connection point */
  51747. readonly ownerBlock: NodeMaterialBlock;
  51748. /** Get the block connected on the other side of this connection (if any) */
  51749. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  51750. /** Get the block connected on the endpoints of this connection (if any) */
  51751. readonly connectedBlocks: Array<NodeMaterialBlock>;
  51752. /** Gets the list of connected endpoints */
  51753. readonly endpoints: NodeMaterialConnectionPoint[];
  51754. /**
  51755. * Creates a new connection point
  51756. * @param name defines the connection point name
  51757. * @param ownerBlock defines the block hosting this connection point
  51758. */
  51759. constructor(name: string, ownerBlock: NodeMaterialBlock);
  51760. /**
  51761. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  51762. * @returns the class name
  51763. */
  51764. getClassName(): string;
  51765. private _getTypeLength;
  51766. /**
  51767. * Gets an boolean indicating if the current point can be connected to another point
  51768. * @param connectionPoint defines the other connection point
  51769. * @returns true if the connection is possible
  51770. */
  51771. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  51772. /**
  51773. * Connect this point to another connection point
  51774. * @param connectionPoint defines the other connection point
  51775. * @returns the current connection point
  51776. */
  51777. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  51778. /**
  51779. * Disconnect this point from one of his endpoint
  51780. * @param endpoint defines the other connection point
  51781. * @returns the current connection point
  51782. */
  51783. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  51784. }
  51785. }
  51786. declare module BABYLON {
  51787. /**
  51788. * Block used to add support for vertex skinning (bones)
  51789. */
  51790. export class BonesBlock extends NodeMaterialBlock {
  51791. /**
  51792. * Creates a new BonesBlock
  51793. * @param name defines the block name
  51794. */
  51795. constructor(name: string);
  51796. /**
  51797. * Initialize the block and prepare the context for build
  51798. * @param state defines the state that will be used for the build
  51799. */
  51800. initialize(state: NodeMaterialBuildState): void;
  51801. /**
  51802. * Gets the current class name
  51803. * @returns the class name
  51804. */
  51805. getClassName(): string;
  51806. /**
  51807. * Gets the matrix indices input component
  51808. */
  51809. readonly matricesIndices: NodeMaterialConnectionPoint;
  51810. /**
  51811. * Gets the matrix weights input component
  51812. */
  51813. readonly matricesWeights: NodeMaterialConnectionPoint;
  51814. /**
  51815. * Gets the extra matrix indices input component
  51816. */
  51817. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  51818. /**
  51819. * Gets the extra matrix weights input component
  51820. */
  51821. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  51822. /**
  51823. * Gets the world input component
  51824. */
  51825. readonly world: NodeMaterialConnectionPoint;
  51826. /**
  51827. * Gets the output component
  51828. */
  51829. readonly output: NodeMaterialConnectionPoint;
  51830. autoConfigure(): void;
  51831. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  51832. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51833. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51834. protected _buildBlock(state: NodeMaterialBuildState): this;
  51835. }
  51836. }
  51837. declare module BABYLON {
  51838. /**
  51839. * Block used to add support for instances
  51840. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  51841. */
  51842. export class InstancesBlock extends NodeMaterialBlock {
  51843. /**
  51844. * Creates a new InstancesBlock
  51845. * @param name defines the block name
  51846. */
  51847. constructor(name: string);
  51848. /**
  51849. * Gets the current class name
  51850. * @returns the class name
  51851. */
  51852. getClassName(): string;
  51853. /**
  51854. * Gets the first world row input component
  51855. */
  51856. readonly world0: NodeMaterialConnectionPoint;
  51857. /**
  51858. * Gets the second world row input component
  51859. */
  51860. readonly world1: NodeMaterialConnectionPoint;
  51861. /**
  51862. * Gets the third world row input component
  51863. */
  51864. readonly world2: NodeMaterialConnectionPoint;
  51865. /**
  51866. * Gets the forth world row input component
  51867. */
  51868. readonly world3: NodeMaterialConnectionPoint;
  51869. /**
  51870. * Gets the world input component
  51871. */
  51872. readonly world: NodeMaterialConnectionPoint;
  51873. /**
  51874. * Gets the output component
  51875. */
  51876. readonly output: NodeMaterialConnectionPoint;
  51877. autoConfigure(): void;
  51878. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  51879. protected _buildBlock(state: NodeMaterialBuildState): this;
  51880. }
  51881. }
  51882. declare module BABYLON {
  51883. /**
  51884. * Block used to add morph targets support to vertex shader
  51885. */
  51886. export class MorphTargetsBlock extends NodeMaterialBlock {
  51887. private _repeatableContentAnchor;
  51888. private _repeatebleContentGenerated;
  51889. /**
  51890. * Create a new MorphTargetsBlock
  51891. * @param name defines the block name
  51892. */
  51893. constructor(name: string);
  51894. /**
  51895. * Gets the current class name
  51896. * @returns the class name
  51897. */
  51898. getClassName(): string;
  51899. /**
  51900. * Gets the position input component
  51901. */
  51902. readonly position: NodeMaterialConnectionPoint;
  51903. /**
  51904. * Gets the normal input component
  51905. */
  51906. readonly normal: NodeMaterialConnectionPoint;
  51907. /**
  51908. * Gets the tangent input component
  51909. */
  51910. readonly tangent: NodeMaterialConnectionPoint;
  51911. /**
  51912. * Gets the tangent input component
  51913. */
  51914. readonly uv: NodeMaterialConnectionPoint;
  51915. /**
  51916. * Gets the position output component
  51917. */
  51918. readonly positionOutput: NodeMaterialConnectionPoint;
  51919. /**
  51920. * Gets the normal output component
  51921. */
  51922. readonly normalOutput: NodeMaterialConnectionPoint;
  51923. /**
  51924. * Gets the tangent output component
  51925. */
  51926. readonly tangentOutput: NodeMaterialConnectionPoint;
  51927. /**
  51928. * Gets the tangent output component
  51929. */
  51930. readonly uvOutput: NodeMaterialConnectionPoint;
  51931. initialize(state: NodeMaterialBuildState): void;
  51932. autoConfigure(): void;
  51933. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51934. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51935. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  51936. protected _buildBlock(state: NodeMaterialBuildState): this;
  51937. }
  51938. }
  51939. declare module BABYLON {
  51940. /**
  51941. * Block used to add an alpha test in the fragment shader
  51942. */
  51943. export class AlphaTestBlock extends NodeMaterialBlock {
  51944. /**
  51945. * Gets or sets the alpha value where alpha testing happens
  51946. */
  51947. alphaCutOff: number;
  51948. /**
  51949. * Create a new AlphaTestBlock
  51950. * @param name defines the block name
  51951. */
  51952. constructor(name: string);
  51953. /**
  51954. * Gets the current class name
  51955. * @returns the class name
  51956. */
  51957. getClassName(): string;
  51958. /**
  51959. * Gets the color input component
  51960. */
  51961. readonly color: NodeMaterialConnectionPoint;
  51962. protected _buildBlock(state: NodeMaterialBuildState): this;
  51963. }
  51964. }
  51965. declare module BABYLON {
  51966. /**
  51967. * Block used to create a Color4 out of 4 inputs (one for each component)
  51968. */
  51969. export class RGBAMergerBlock extends NodeMaterialBlock {
  51970. /**
  51971. * Create a new RGBAMergerBlock
  51972. * @param name defines the block name
  51973. */
  51974. constructor(name: string);
  51975. /**
  51976. * Gets the current class name
  51977. * @returns the class name
  51978. */
  51979. getClassName(): string;
  51980. /**
  51981. * Gets the R input component
  51982. */
  51983. readonly r: NodeMaterialConnectionPoint;
  51984. /**
  51985. * Gets the G input component
  51986. */
  51987. readonly g: NodeMaterialConnectionPoint;
  51988. /**
  51989. * Gets the B input component
  51990. */
  51991. readonly b: NodeMaterialConnectionPoint;
  51992. /**
  51993. * Gets the RGB input component
  51994. */
  51995. readonly rgb: NodeMaterialConnectionPoint;
  51996. /**
  51997. * Gets the R input component
  51998. */
  51999. readonly a: NodeMaterialConnectionPoint;
  52000. /**
  52001. * Gets the output component
  52002. */
  52003. readonly output: NodeMaterialConnectionPoint;
  52004. protected _buildBlock(state: NodeMaterialBuildState): this;
  52005. }
  52006. }
  52007. declare module BABYLON {
  52008. /**
  52009. * Block used to create a Color3 out of 3 inputs (one for each component)
  52010. */
  52011. export class RGBMergerBlock extends NodeMaterialBlock {
  52012. /**
  52013. * Create a new RGBMergerBlock
  52014. * @param name defines the block name
  52015. */
  52016. constructor(name: string);
  52017. /**
  52018. * Gets the current class name
  52019. * @returns the class name
  52020. */
  52021. getClassName(): string;
  52022. /**
  52023. * Gets the R component input
  52024. */
  52025. readonly r: NodeMaterialConnectionPoint;
  52026. /**
  52027. * Gets the G component input
  52028. */
  52029. readonly g: NodeMaterialConnectionPoint;
  52030. /**
  52031. * Gets the B component input
  52032. */
  52033. readonly b: NodeMaterialConnectionPoint;
  52034. /**
  52035. * Gets the output component
  52036. */
  52037. readonly output: NodeMaterialConnectionPoint;
  52038. protected _buildBlock(state: NodeMaterialBuildState): this;
  52039. }
  52040. }
  52041. declare module BABYLON {
  52042. /**
  52043. * Block used to expand a Color4 or a Vector4 into 4 outputs (one for each component)
  52044. */
  52045. export class RGBASplitterBlock extends NodeMaterialBlock {
  52046. /**
  52047. * Create a new RGBASplitterBlock
  52048. * @param name defines the block name
  52049. */
  52050. constructor(name: string);
  52051. /**
  52052. * Gets the current class name
  52053. * @returns the class name
  52054. */
  52055. getClassName(): string;
  52056. /**
  52057. * Gets the input component
  52058. */
  52059. readonly input: NodeMaterialConnectionPoint;
  52060. protected _buildBlock(state: NodeMaterialBuildState): this;
  52061. }
  52062. }
  52063. declare module BABYLON {
  52064. /**
  52065. * Block used to expand a Color3 or a Vector3 into 3 outputs (one for each component)
  52066. */
  52067. export class RGBSplitterBlock extends NodeMaterialBlock {
  52068. /**
  52069. * Create a new RGBSplitterBlock
  52070. * @param name defines the block name
  52071. */
  52072. constructor(name: string);
  52073. /**
  52074. * Gets the current class name
  52075. * @returns the class name
  52076. */
  52077. getClassName(): string;
  52078. /**
  52079. * Gets the input component
  52080. */
  52081. readonly input: NodeMaterialConnectionPoint;
  52082. protected _buildBlock(state: NodeMaterialBuildState): this;
  52083. }
  52084. }
  52085. declare module BABYLON {
  52086. /**
  52087. * Block used to add image processing support to fragment shader
  52088. */
  52089. export class ImageProcessingBlock extends NodeMaterialBlock {
  52090. /**
  52091. * Create a new ImageProcessingBlock
  52092. * @param name defines the block name
  52093. */
  52094. constructor(name: string);
  52095. /**
  52096. * Gets the current class name
  52097. * @returns the class name
  52098. */
  52099. getClassName(): string;
  52100. /**
  52101. * Gets the color input component
  52102. */
  52103. readonly color: NodeMaterialConnectionPoint;
  52104. /**
  52105. * Gets the output component
  52106. */
  52107. readonly output: NodeMaterialConnectionPoint;
  52108. /**
  52109. * Initialize the block and prepare the context for build
  52110. * @param state defines the state that will be used for the build
  52111. */
  52112. initialize(state: NodeMaterialBuildState): void;
  52113. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  52114. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52115. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52116. protected _buildBlock(state: NodeMaterialBuildState): this;
  52117. }
  52118. }
  52119. declare module BABYLON {
  52120. /**
  52121. * Block used to add support for scene fog
  52122. */
  52123. export class FogBlock extends NodeMaterialBlock {
  52124. private _fogDistanceName;
  52125. private _fogParameters;
  52126. /**
  52127. * Create a new FogBlock
  52128. * @param name defines the block name
  52129. */
  52130. constructor(name: string);
  52131. /**
  52132. * Gets the current class name
  52133. * @returns the class name
  52134. */
  52135. getClassName(): string;
  52136. /**
  52137. * Gets the world position input component
  52138. */
  52139. readonly worldPosition: NodeMaterialConnectionPoint;
  52140. /**
  52141. * Gets the view input component
  52142. */
  52143. readonly view: NodeMaterialConnectionPoint;
  52144. /**
  52145. * Gets the color input component
  52146. */
  52147. readonly color: NodeMaterialConnectionPoint;
  52148. /**
  52149. * Gets the fog color input component
  52150. */
  52151. readonly fogColor: NodeMaterialConnectionPoint;
  52152. /**
  52153. * Gets the output component
  52154. */
  52155. readonly output: NodeMaterialConnectionPoint;
  52156. autoConfigure(): void;
  52157. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52158. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52159. protected _buildBlock(state: NodeMaterialBuildState): this;
  52160. }
  52161. }
  52162. declare module BABYLON {
  52163. /**
  52164. * Block used to add light in the fragment shader
  52165. */
  52166. export class LightBlock extends NodeMaterialBlock {
  52167. private _lightId;
  52168. /**
  52169. * Gets or sets the light associated with this block
  52170. */
  52171. light: Nullable<Light>;
  52172. /**
  52173. * Create a new LightBlock
  52174. * @param name defines the block name
  52175. */
  52176. constructor(name: string);
  52177. /**
  52178. * Gets the current class name
  52179. * @returns the class name
  52180. */
  52181. getClassName(): string;
  52182. /**
  52183. * Gets the world position input component
  52184. */
  52185. readonly worldPosition: NodeMaterialConnectionPoint;
  52186. /**
  52187. * Gets the world normal input component
  52188. */
  52189. readonly worldNormal: NodeMaterialConnectionPoint;
  52190. /**
  52191. * Gets the camera (or eye) position component
  52192. */
  52193. readonly cameraPosition: NodeMaterialConnectionPoint;
  52194. /**
  52195. * Gets the diffuse output component
  52196. */
  52197. readonly diffuseOutput: NodeMaterialConnectionPoint;
  52198. /**
  52199. * Gets the specular output component
  52200. */
  52201. readonly specularOutput: NodeMaterialConnectionPoint;
  52202. autoConfigure(): void;
  52203. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52204. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52205. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52206. private _injectVertexCode;
  52207. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  52208. }
  52209. }
  52210. declare module BABYLON {
  52211. /**
  52212. * Block used to multiply 2 values
  52213. */
  52214. export class MultiplyBlock extends NodeMaterialBlock {
  52215. /**
  52216. * Creates a new MultiplyBlock
  52217. * @param name defines the block name
  52218. */
  52219. constructor(name: string);
  52220. /**
  52221. * Gets the current class name
  52222. * @returns the class name
  52223. */
  52224. getClassName(): string;
  52225. /**
  52226. * Gets the left operand input component
  52227. */
  52228. readonly left: NodeMaterialConnectionPoint;
  52229. /**
  52230. * Gets the right operand input component
  52231. */
  52232. readonly right: NodeMaterialConnectionPoint;
  52233. /**
  52234. * Gets the output component
  52235. */
  52236. readonly output: NodeMaterialConnectionPoint;
  52237. protected _buildBlock(state: NodeMaterialBuildState): this;
  52238. }
  52239. }
  52240. declare module BABYLON {
  52241. /**
  52242. * Block used to add 2 vector4
  52243. */
  52244. export class AddBlock extends NodeMaterialBlock {
  52245. /**
  52246. * Creates a new AddBlock
  52247. * @param name defines the block name
  52248. */
  52249. constructor(name: string);
  52250. /**
  52251. * Gets the current class name
  52252. * @returns the class name
  52253. */
  52254. getClassName(): string;
  52255. /**
  52256. * Gets the left operand input component
  52257. */
  52258. readonly left: NodeMaterialConnectionPoint;
  52259. /**
  52260. * Gets the right operand input component
  52261. */
  52262. readonly right: NodeMaterialConnectionPoint;
  52263. /**
  52264. * Gets the output component
  52265. */
  52266. readonly output: NodeMaterialConnectionPoint;
  52267. protected _buildBlock(state: NodeMaterialBuildState): this;
  52268. }
  52269. }
  52270. declare module BABYLON {
  52271. /**
  52272. * Block used to clamp a float
  52273. */
  52274. export class ClampBlock extends NodeMaterialBlock {
  52275. /** Gets or sets the minimum range */
  52276. minimum: number;
  52277. /** Gets or sets the maximum range */
  52278. maximum: number;
  52279. /**
  52280. * Creates a new ClampBlock
  52281. * @param name defines the block name
  52282. */
  52283. constructor(name: string);
  52284. /**
  52285. * Gets the current class name
  52286. * @returns the class name
  52287. */
  52288. getClassName(): string;
  52289. /**
  52290. * Gets the value input component
  52291. */
  52292. readonly value: NodeMaterialConnectionPoint;
  52293. /**
  52294. * Gets the output component
  52295. */
  52296. readonly output: NodeMaterialConnectionPoint;
  52297. protected _buildBlock(state: NodeMaterialBuildState): this;
  52298. }
  52299. }
  52300. declare module BABYLON {
  52301. /**
  52302. * Block used to transform a vector2 with a matrix
  52303. */
  52304. export class Vector2TransformBlock extends NodeMaterialBlock {
  52305. /**
  52306. * Defines the value to use to complement Vector2 to transform it to a Vector4
  52307. */
  52308. complementZ: number;
  52309. /**
  52310. * Defines the value to use to complement Vector2 to transform it to a Vector4
  52311. */
  52312. complementW: number;
  52313. /**
  52314. * Creates a new Vector2TransformBlock
  52315. * @param name defines the block name
  52316. */
  52317. constructor(name: string);
  52318. /**
  52319. * Gets the vector input
  52320. */
  52321. readonly vector: NodeMaterialConnectionPoint;
  52322. /**
  52323. * Gets the matrix transform input
  52324. */
  52325. readonly transform: NodeMaterialConnectionPoint;
  52326. /**
  52327. * Gets the output component
  52328. */
  52329. readonly output: NodeMaterialConnectionPoint;
  52330. /**
  52331. * Gets the current class name
  52332. * @returns the class name
  52333. */
  52334. getClassName(): string;
  52335. protected _buildBlock(state: NodeMaterialBuildState): this;
  52336. }
  52337. }
  52338. declare module BABYLON {
  52339. /**
  52340. * Block used to transform a vector3 with a matrix
  52341. */
  52342. export class Vector3TransformBlock extends NodeMaterialBlock {
  52343. /**
  52344. * Defines the value to use to complement Vector3 to transform it to a Vector4
  52345. */
  52346. complement: number;
  52347. /**
  52348. * Creates a new Vector3TransformBlock
  52349. * @param name defines the block name
  52350. */
  52351. constructor(name: string);
  52352. /**
  52353. * Gets the vector input
  52354. */
  52355. readonly vector: NodeMaterialConnectionPoint;
  52356. /**
  52357. * Gets the matrix transform input
  52358. */
  52359. readonly transform: NodeMaterialConnectionPoint;
  52360. /**
  52361. * Gets the output component
  52362. */
  52363. readonly output: NodeMaterialConnectionPoint;
  52364. /**
  52365. * Gets the current class name
  52366. * @returns the class name
  52367. */
  52368. getClassName(): string;
  52369. protected _buildBlock(state: NodeMaterialBuildState): this;
  52370. }
  52371. }
  52372. declare module BABYLON {
  52373. /**
  52374. * Helper class to render one or more effects
  52375. */
  52376. export class EffectRenderer {
  52377. private engine;
  52378. private static _Vertices;
  52379. private static _Indices;
  52380. private _vertexBuffers;
  52381. private _indexBuffer;
  52382. private _ringBufferIndex;
  52383. private _ringScreenBuffer;
  52384. private _getNextFrameBuffer;
  52385. /**
  52386. * Creates an effect renderer
  52387. * @param engine the engine to use for rendering
  52388. */
  52389. constructor(engine: Engine);
  52390. /**
  52391. * renders one or more effects to a specified texture
  52392. * @param effectWrappers list of effects to renderer
  52393. * @param outputTexture texture to draw to, if null it will render to the screen
  52394. */
  52395. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  52396. /**
  52397. * Disposes of the effect renderer
  52398. */
  52399. dispose(): void;
  52400. }
  52401. /**
  52402. * Options to create an EffectWrapper
  52403. */
  52404. interface EffectWrapperCreationOptions {
  52405. /**
  52406. * Engine to use to create the effect
  52407. */
  52408. engine: Engine;
  52409. /**
  52410. * Fragment shader for the effect
  52411. */
  52412. fragmentShader: string;
  52413. /**
  52414. * Attributes to use in the shader
  52415. */
  52416. attributeNames: Array<string>;
  52417. /**
  52418. * Uniforms to use in the shader
  52419. */
  52420. uniformNames: Array<string>;
  52421. /**
  52422. * Texture sampler names to use in the shader
  52423. */
  52424. samplerNames: Array<string>;
  52425. }
  52426. /**
  52427. * Wraps an effect to be used for rendering
  52428. */
  52429. export class EffectWrapper {
  52430. /**
  52431. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  52432. */
  52433. onApplyObservable: Observable<{}>;
  52434. /**
  52435. * The underlying effect
  52436. */
  52437. effect: Effect;
  52438. /**
  52439. * Creates an effect to be renderer
  52440. * @param creationOptions options to create the effect
  52441. */
  52442. constructor(creationOptions: EffectWrapperCreationOptions);
  52443. /**
  52444. * Disposes of the effect wrapper
  52445. */
  52446. dispose(): void;
  52447. }
  52448. }
  52449. declare module BABYLON {
  52450. /**
  52451. * Helper class to push actions to a pool of workers.
  52452. */
  52453. export class WorkerPool implements IDisposable {
  52454. private _workerInfos;
  52455. private _pendingActions;
  52456. /**
  52457. * Constructor
  52458. * @param workers Array of workers to use for actions
  52459. */
  52460. constructor(workers: Array<Worker>);
  52461. /**
  52462. * Terminates all workers and clears any pending actions.
  52463. */
  52464. dispose(): void;
  52465. /**
  52466. * Pushes an action to the worker pool. If all the workers are active, the action will be
  52467. * pended until a worker has completed its action.
  52468. * @param action The action to perform. Call onComplete when the action is complete.
  52469. */
  52470. push(action: (worker: Worker, onComplete: () => void) => void): void;
  52471. private _execute;
  52472. }
  52473. }
  52474. declare module BABYLON {
  52475. /**
  52476. * Configuration for Draco compression
  52477. */
  52478. export interface IDracoCompressionConfiguration {
  52479. /**
  52480. * Configuration for the decoder.
  52481. */
  52482. decoder: {
  52483. /**
  52484. * The url to the WebAssembly module.
  52485. */
  52486. wasmUrl?: string;
  52487. /**
  52488. * The url to the WebAssembly binary.
  52489. */
  52490. wasmBinaryUrl?: string;
  52491. /**
  52492. * The url to the fallback JavaScript module.
  52493. */
  52494. fallbackUrl?: string;
  52495. };
  52496. }
  52497. /**
  52498. * Draco compression (https://google.github.io/draco/)
  52499. *
  52500. * This class wraps the Draco module.
  52501. *
  52502. * **Encoder**
  52503. *
  52504. * The encoder is not currently implemented.
  52505. *
  52506. * **Decoder**
  52507. *
  52508. * 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.
  52509. *
  52510. * To update the configuration, use the following code:
  52511. * ```javascript
  52512. * DracoCompression.Configuration = {
  52513. * decoder: {
  52514. * wasmUrl: "<url to the WebAssembly library>",
  52515. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  52516. * fallbackUrl: "<url to the fallback JavaScript library>",
  52517. * }
  52518. * };
  52519. * ```
  52520. *
  52521. * 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.
  52522. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  52523. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  52524. *
  52525. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  52526. * ```javascript
  52527. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  52528. * ```
  52529. *
  52530. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  52531. */
  52532. export class DracoCompression implements IDisposable {
  52533. private _workerPoolPromise?;
  52534. private _decoderModulePromise?;
  52535. /**
  52536. * The configuration. Defaults to the following urls:
  52537. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  52538. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  52539. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  52540. */
  52541. static Configuration: IDracoCompressionConfiguration;
  52542. /**
  52543. * Returns true if the decoder configuration is available.
  52544. */
  52545. static readonly DecoderAvailable: boolean;
  52546. /**
  52547. * Default number of workers to create when creating the draco compression object.
  52548. */
  52549. static DefaultNumWorkers: number;
  52550. private static GetDefaultNumWorkers;
  52551. private static _Default;
  52552. /**
  52553. * Default instance for the draco compression object.
  52554. */
  52555. static readonly Default: DracoCompression;
  52556. /**
  52557. * Constructor
  52558. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  52559. */
  52560. constructor(numWorkers?: number);
  52561. /**
  52562. * Stop all async operations and release resources.
  52563. */
  52564. dispose(): void;
  52565. /**
  52566. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  52567. * @returns a promise that resolves when ready
  52568. */
  52569. whenReadyAsync(): Promise<void>;
  52570. /**
  52571. * Decode Draco compressed mesh data to vertex data.
  52572. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  52573. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  52574. * @returns A promise that resolves with the decoded vertex data
  52575. */
  52576. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  52577. [kind: string]: number;
  52578. }): Promise<VertexData>;
  52579. }
  52580. }
  52581. declare module BABYLON {
  52582. /**
  52583. * Class for building Constructive Solid Geometry
  52584. */
  52585. export class CSG {
  52586. private polygons;
  52587. /**
  52588. * The world matrix
  52589. */
  52590. matrix: Matrix;
  52591. /**
  52592. * Stores the position
  52593. */
  52594. position: Vector3;
  52595. /**
  52596. * Stores the rotation
  52597. */
  52598. rotation: Vector3;
  52599. /**
  52600. * Stores the rotation quaternion
  52601. */
  52602. rotationQuaternion: Nullable<Quaternion>;
  52603. /**
  52604. * Stores the scaling vector
  52605. */
  52606. scaling: Vector3;
  52607. /**
  52608. * Convert the Mesh to CSG
  52609. * @param mesh The Mesh to convert to CSG
  52610. * @returns A new CSG from the Mesh
  52611. */
  52612. static FromMesh(mesh: Mesh): CSG;
  52613. /**
  52614. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  52615. * @param polygons Polygons used to construct a CSG solid
  52616. */
  52617. private static FromPolygons;
  52618. /**
  52619. * Clones, or makes a deep copy, of the CSG
  52620. * @returns A new CSG
  52621. */
  52622. clone(): CSG;
  52623. /**
  52624. * Unions this CSG with another CSG
  52625. * @param csg The CSG to union against this CSG
  52626. * @returns The unioned CSG
  52627. */
  52628. union(csg: CSG): CSG;
  52629. /**
  52630. * Unions this CSG with another CSG in place
  52631. * @param csg The CSG to union against this CSG
  52632. */
  52633. unionInPlace(csg: CSG): void;
  52634. /**
  52635. * Subtracts this CSG with another CSG
  52636. * @param csg The CSG to subtract against this CSG
  52637. * @returns A new CSG
  52638. */
  52639. subtract(csg: CSG): CSG;
  52640. /**
  52641. * Subtracts this CSG with another CSG in place
  52642. * @param csg The CSG to subtact against this CSG
  52643. */
  52644. subtractInPlace(csg: CSG): void;
  52645. /**
  52646. * Intersect this CSG with another CSG
  52647. * @param csg The CSG to intersect against this CSG
  52648. * @returns A new CSG
  52649. */
  52650. intersect(csg: CSG): CSG;
  52651. /**
  52652. * Intersects this CSG with another CSG in place
  52653. * @param csg The CSG to intersect against this CSG
  52654. */
  52655. intersectInPlace(csg: CSG): void;
  52656. /**
  52657. * Return a new CSG solid with solid and empty space switched. This solid is
  52658. * not modified.
  52659. * @returns A new CSG solid with solid and empty space switched
  52660. */
  52661. inverse(): CSG;
  52662. /**
  52663. * Inverses the CSG in place
  52664. */
  52665. inverseInPlace(): void;
  52666. /**
  52667. * This is used to keep meshes transformations so they can be restored
  52668. * when we build back a Babylon Mesh
  52669. * NB : All CSG operations are performed in world coordinates
  52670. * @param csg The CSG to copy the transform attributes from
  52671. * @returns This CSG
  52672. */
  52673. copyTransformAttributes(csg: CSG): CSG;
  52674. /**
  52675. * Build Raw mesh from CSG
  52676. * Coordinates here are in world space
  52677. * @param name The name of the mesh geometry
  52678. * @param scene The Scene
  52679. * @param keepSubMeshes Specifies if the submeshes should be kept
  52680. * @returns A new Mesh
  52681. */
  52682. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  52683. /**
  52684. * Build Mesh from CSG taking material and transforms into account
  52685. * @param name The name of the Mesh
  52686. * @param material The material of the Mesh
  52687. * @param scene The Scene
  52688. * @param keepSubMeshes Specifies if submeshes should be kept
  52689. * @returns The new Mesh
  52690. */
  52691. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  52692. }
  52693. }
  52694. declare module BABYLON {
  52695. /**
  52696. * Class used to create a trail following a mesh
  52697. */
  52698. export class TrailMesh extends Mesh {
  52699. private _generator;
  52700. private _autoStart;
  52701. private _running;
  52702. private _diameter;
  52703. private _length;
  52704. private _sectionPolygonPointsCount;
  52705. private _sectionVectors;
  52706. private _sectionNormalVectors;
  52707. private _beforeRenderObserver;
  52708. /**
  52709. * @constructor
  52710. * @param name The value used by scene.getMeshByName() to do a lookup.
  52711. * @param generator The mesh to generate a trail.
  52712. * @param scene The scene to add this mesh to.
  52713. * @param diameter Diameter of trailing mesh. Default is 1.
  52714. * @param length Length of trailing mesh. Default is 60.
  52715. * @param autoStart Automatically start trailing mesh. Default true.
  52716. */
  52717. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  52718. /**
  52719. * "TrailMesh"
  52720. * @returns "TrailMesh"
  52721. */
  52722. getClassName(): string;
  52723. private _createMesh;
  52724. /**
  52725. * Start trailing mesh.
  52726. */
  52727. start(): void;
  52728. /**
  52729. * Stop trailing mesh.
  52730. */
  52731. stop(): void;
  52732. /**
  52733. * Update trailing mesh geometry.
  52734. */
  52735. update(): void;
  52736. /**
  52737. * Returns a new TrailMesh object.
  52738. * @param name is a string, the name given to the new mesh
  52739. * @param newGenerator use new generator object for cloned trail mesh
  52740. * @returns a new mesh
  52741. */
  52742. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  52743. /**
  52744. * Serializes this trail mesh
  52745. * @param serializationObject object to write serialization to
  52746. */
  52747. serialize(serializationObject: any): void;
  52748. /**
  52749. * Parses a serialized trail mesh
  52750. * @param parsedMesh the serialized mesh
  52751. * @param scene the scene to create the trail mesh in
  52752. * @returns the created trail mesh
  52753. */
  52754. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  52755. }
  52756. }
  52757. declare module BABYLON {
  52758. /**
  52759. * Class containing static functions to help procedurally build meshes
  52760. */
  52761. export class TiledBoxBuilder {
  52762. /**
  52763. * Creates a box mesh
  52764. * 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)
  52765. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52766. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52767. * * 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
  52768. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52769. * @param name defines the name of the mesh
  52770. * @param options defines the options used to create the mesh
  52771. * @param scene defines the hosting scene
  52772. * @returns the box mesh
  52773. */
  52774. static CreateTiledBox(name: string, options: {
  52775. pattern?: number;
  52776. width?: number;
  52777. height?: number;
  52778. depth?: number;
  52779. tileSize?: number;
  52780. tileWidth?: number;
  52781. tileHeight?: number;
  52782. alignHorizontal?: number;
  52783. alignVertical?: number;
  52784. faceUV?: Vector4[];
  52785. faceColors?: Color4[];
  52786. sideOrientation?: number;
  52787. updatable?: boolean;
  52788. }, scene?: Nullable<Scene>): Mesh;
  52789. }
  52790. }
  52791. declare module BABYLON {
  52792. /**
  52793. * Class containing static functions to help procedurally build meshes
  52794. */
  52795. export class TorusKnotBuilder {
  52796. /**
  52797. * Creates a torus knot mesh
  52798. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  52799. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  52800. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  52801. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  52802. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52803. * * 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
  52804. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52805. * @param name defines the name of the mesh
  52806. * @param options defines the options used to create the mesh
  52807. * @param scene defines the hosting scene
  52808. * @returns the torus knot mesh
  52809. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  52810. */
  52811. static CreateTorusKnot(name: string, options: {
  52812. radius?: number;
  52813. tube?: number;
  52814. radialSegments?: number;
  52815. tubularSegments?: number;
  52816. p?: number;
  52817. q?: number;
  52818. updatable?: boolean;
  52819. sideOrientation?: number;
  52820. frontUVs?: Vector4;
  52821. backUVs?: Vector4;
  52822. }, scene: any): Mesh;
  52823. }
  52824. }
  52825. declare module BABYLON {
  52826. /**
  52827. * Polygon
  52828. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  52829. */
  52830. export class Polygon {
  52831. /**
  52832. * Creates a rectangle
  52833. * @param xmin bottom X coord
  52834. * @param ymin bottom Y coord
  52835. * @param xmax top X coord
  52836. * @param ymax top Y coord
  52837. * @returns points that make the resulting rectation
  52838. */
  52839. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  52840. /**
  52841. * Creates a circle
  52842. * @param radius radius of circle
  52843. * @param cx scale in x
  52844. * @param cy scale in y
  52845. * @param numberOfSides number of sides that make up the circle
  52846. * @returns points that make the resulting circle
  52847. */
  52848. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  52849. /**
  52850. * Creates a polygon from input string
  52851. * @param input Input polygon data
  52852. * @returns the parsed points
  52853. */
  52854. static Parse(input: string): Vector2[];
  52855. /**
  52856. * Starts building a polygon from x and y coordinates
  52857. * @param x x coordinate
  52858. * @param y y coordinate
  52859. * @returns the started path2
  52860. */
  52861. static StartingAt(x: number, y: number): Path2;
  52862. }
  52863. /**
  52864. * Builds a polygon
  52865. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  52866. */
  52867. export class PolygonMeshBuilder {
  52868. private _points;
  52869. private _outlinepoints;
  52870. private _holes;
  52871. private _name;
  52872. private _scene;
  52873. private _epoints;
  52874. private _eholes;
  52875. private _addToepoint;
  52876. /**
  52877. * Babylon reference to the earcut plugin.
  52878. */
  52879. bjsEarcut: any;
  52880. /**
  52881. * Creates a PolygonMeshBuilder
  52882. * @param name name of the builder
  52883. * @param contours Path of the polygon
  52884. * @param scene scene to add to when creating the mesh
  52885. * @param earcutInjection can be used to inject your own earcut reference
  52886. */
  52887. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  52888. /**
  52889. * Adds a whole within the polygon
  52890. * @param hole Array of points defining the hole
  52891. * @returns this
  52892. */
  52893. addHole(hole: Vector2[]): PolygonMeshBuilder;
  52894. /**
  52895. * Creates the polygon
  52896. * @param updatable If the mesh should be updatable
  52897. * @param depth The depth of the mesh created
  52898. * @returns the created mesh
  52899. */
  52900. build(updatable?: boolean, depth?: number): Mesh;
  52901. /**
  52902. * Creates the polygon
  52903. * @param depth The depth of the mesh created
  52904. * @returns the created VertexData
  52905. */
  52906. buildVertexData(depth?: number): VertexData;
  52907. /**
  52908. * Adds a side to the polygon
  52909. * @param positions points that make the polygon
  52910. * @param normals normals of the polygon
  52911. * @param uvs uvs of the polygon
  52912. * @param indices indices of the polygon
  52913. * @param bounds bounds of the polygon
  52914. * @param points points of the polygon
  52915. * @param depth depth of the polygon
  52916. * @param flip flip of the polygon
  52917. */
  52918. private addSide;
  52919. }
  52920. }
  52921. declare module BABYLON {
  52922. /**
  52923. * Class containing static functions to help procedurally build meshes
  52924. */
  52925. export class PolygonBuilder {
  52926. /**
  52927. * Creates a polygon mesh
  52928. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  52929. * * 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
  52930. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  52931. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52932. * * 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)
  52933. * * Remember you can only change the shape positions, not their number when updating a polygon
  52934. * @param name defines the name of the mesh
  52935. * @param options defines the options used to create the mesh
  52936. * @param scene defines the hosting scene
  52937. * @param earcutInjection can be used to inject your own earcut reference
  52938. * @returns the polygon mesh
  52939. */
  52940. static CreatePolygon(name: string, options: {
  52941. shape: Vector3[];
  52942. holes?: Vector3[][];
  52943. depth?: number;
  52944. faceUV?: Vector4[];
  52945. faceColors?: Color4[];
  52946. updatable?: boolean;
  52947. sideOrientation?: number;
  52948. frontUVs?: Vector4;
  52949. backUVs?: Vector4;
  52950. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52951. /**
  52952. * Creates an extruded polygon mesh, with depth in the Y direction.
  52953. * * 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)
  52954. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52955. * @param name defines the name of the mesh
  52956. * @param options defines the options used to create the mesh
  52957. * @param scene defines the hosting scene
  52958. * @param earcutInjection can be used to inject your own earcut reference
  52959. * @returns the polygon mesh
  52960. */
  52961. static ExtrudePolygon(name: string, options: {
  52962. shape: Vector3[];
  52963. holes?: Vector3[][];
  52964. depth?: number;
  52965. faceUV?: Vector4[];
  52966. faceColors?: Color4[];
  52967. updatable?: boolean;
  52968. sideOrientation?: number;
  52969. frontUVs?: Vector4;
  52970. backUVs?: Vector4;
  52971. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52972. }
  52973. }
  52974. declare module BABYLON {
  52975. /**
  52976. * Class containing static functions to help procedurally build meshes
  52977. */
  52978. export class LatheBuilder {
  52979. /**
  52980. * Creates lathe mesh.
  52981. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  52982. * * 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
  52983. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  52984. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  52985. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  52986. * * 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
  52987. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  52988. * * 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
  52989. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52990. * * 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
  52991. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52992. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52993. * @param name defines the name of the mesh
  52994. * @param options defines the options used to create the mesh
  52995. * @param scene defines the hosting scene
  52996. * @returns the lathe mesh
  52997. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  52998. */
  52999. static CreateLathe(name: string, options: {
  53000. shape: Vector3[];
  53001. radius?: number;
  53002. tessellation?: number;
  53003. clip?: number;
  53004. arc?: number;
  53005. closed?: boolean;
  53006. updatable?: boolean;
  53007. sideOrientation?: number;
  53008. frontUVs?: Vector4;
  53009. backUVs?: Vector4;
  53010. cap?: number;
  53011. invertUV?: boolean;
  53012. }, scene?: Nullable<Scene>): Mesh;
  53013. }
  53014. }
  53015. declare module BABYLON {
  53016. /**
  53017. * Class containing static functions to help procedurally build meshes
  53018. */
  53019. export class TiledPlaneBuilder {
  53020. /**
  53021. * Creates a tiled plane mesh
  53022. * * The parameter `pattern` will, depending on value, do nothing or
  53023. * * * flip (reflect about central vertical) alternate tiles across and up
  53024. * * * flip every tile on alternate rows
  53025. * * * rotate (180 degs) alternate tiles across and up
  53026. * * * rotate every tile on alternate rows
  53027. * * * flip and rotate alternate tiles across and up
  53028. * * * flip and rotate every tile on alternate rows
  53029. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  53030. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  53031. * * 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
  53032. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  53033. * * 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)
  53034. * * 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)
  53035. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  53036. * @param name defines the name of the mesh
  53037. * @param options defines the options used to create the mesh
  53038. * @param scene defines the hosting scene
  53039. * @returns the box mesh
  53040. */
  53041. static CreateTiledPlane(name: string, options: {
  53042. pattern?: number;
  53043. tileSize?: number;
  53044. tileWidth?: number;
  53045. tileHeight?: number;
  53046. size?: number;
  53047. width?: number;
  53048. height?: number;
  53049. alignHorizontal?: number;
  53050. alignVertical?: number;
  53051. sideOrientation?: number;
  53052. frontUVs?: Vector4;
  53053. backUVs?: Vector4;
  53054. updatable?: boolean;
  53055. }, scene?: Nullable<Scene>): Mesh;
  53056. }
  53057. }
  53058. declare module BABYLON {
  53059. /**
  53060. * Class containing static functions to help procedurally build meshes
  53061. */
  53062. export class TubeBuilder {
  53063. /**
  53064. * Creates a tube mesh.
  53065. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53066. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  53067. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  53068. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  53069. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  53070. * * 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)
  53071. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  53072. * * 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
  53073. * * 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
  53074. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53075. * * 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
  53076. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53077. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53078. * @param name defines the name of the mesh
  53079. * @param options defines the options used to create the mesh
  53080. * @param scene defines the hosting scene
  53081. * @returns the tube mesh
  53082. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53083. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  53084. */
  53085. static CreateTube(name: string, options: {
  53086. path: Vector3[];
  53087. radius?: number;
  53088. tessellation?: number;
  53089. radiusFunction?: {
  53090. (i: number, distance: number): number;
  53091. };
  53092. cap?: number;
  53093. arc?: number;
  53094. updatable?: boolean;
  53095. sideOrientation?: number;
  53096. frontUVs?: Vector4;
  53097. backUVs?: Vector4;
  53098. instance?: Mesh;
  53099. invertUV?: boolean;
  53100. }, scene?: Nullable<Scene>): Mesh;
  53101. }
  53102. }
  53103. declare module BABYLON {
  53104. /**
  53105. * Class containing static functions to help procedurally build meshes
  53106. */
  53107. export class IcoSphereBuilder {
  53108. /**
  53109. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  53110. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  53111. * * 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`)
  53112. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  53113. * * 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
  53114. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53115. * * 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
  53116. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53117. * @param name defines the name of the mesh
  53118. * @param options defines the options used to create the mesh
  53119. * @param scene defines the hosting scene
  53120. * @returns the icosahedron mesh
  53121. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  53122. */
  53123. static CreateIcoSphere(name: string, options: {
  53124. radius?: number;
  53125. radiusX?: number;
  53126. radiusY?: number;
  53127. radiusZ?: number;
  53128. flat?: boolean;
  53129. subdivisions?: number;
  53130. sideOrientation?: number;
  53131. frontUVs?: Vector4;
  53132. backUVs?: Vector4;
  53133. updatable?: boolean;
  53134. }, scene?: Nullable<Scene>): Mesh;
  53135. }
  53136. }
  53137. declare module BABYLON {
  53138. /**
  53139. * Class containing static functions to help procedurally build meshes
  53140. */
  53141. export class DecalBuilder {
  53142. /**
  53143. * Creates a decal mesh.
  53144. * 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
  53145. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  53146. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  53147. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  53148. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  53149. * @param name defines the name of the mesh
  53150. * @param sourceMesh defines the mesh where the decal must be applied
  53151. * @param options defines the options used to create the mesh
  53152. * @param scene defines the hosting scene
  53153. * @returns the decal mesh
  53154. * @see https://doc.babylonjs.com/how_to/decals
  53155. */
  53156. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  53157. position?: Vector3;
  53158. normal?: Vector3;
  53159. size?: Vector3;
  53160. angle?: number;
  53161. }): Mesh;
  53162. }
  53163. }
  53164. declare module BABYLON {
  53165. /**
  53166. * Class containing static functions to help procedurally build meshes
  53167. */
  53168. export class MeshBuilder {
  53169. /**
  53170. * Creates a box mesh
  53171. * * The parameter `size` sets the size (float) of each box side (default 1)
  53172. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  53173. * * 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)
  53174. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  53175. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53176. * * 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
  53177. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53178. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  53179. * @param name defines the name of the mesh
  53180. * @param options defines the options used to create the mesh
  53181. * @param scene defines the hosting scene
  53182. * @returns the box mesh
  53183. */
  53184. static CreateBox(name: string, options: {
  53185. size?: number;
  53186. width?: number;
  53187. height?: number;
  53188. depth?: number;
  53189. faceUV?: Vector4[];
  53190. faceColors?: Color4[];
  53191. sideOrientation?: number;
  53192. frontUVs?: Vector4;
  53193. backUVs?: Vector4;
  53194. updatable?: boolean;
  53195. }, scene?: Nullable<Scene>): Mesh;
  53196. /**
  53197. * Creates a tiled box mesh
  53198. * * faceTiles sets the pattern, tile size and number of tiles for a face
  53199. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53200. * @param name defines the name of the mesh
  53201. * @param options defines the options used to create the mesh
  53202. * @param scene defines the hosting scene
  53203. * @returns the tiled box mesh
  53204. */
  53205. static CreateTiledBox(name: string, options: {
  53206. pattern?: number;
  53207. size?: number;
  53208. width?: number;
  53209. height?: number;
  53210. depth: number;
  53211. tileSize?: number;
  53212. tileWidth?: number;
  53213. tileHeight?: number;
  53214. faceUV?: Vector4[];
  53215. faceColors?: Color4[];
  53216. alignHorizontal?: number;
  53217. alignVertical?: number;
  53218. sideOrientation?: number;
  53219. updatable?: boolean;
  53220. }, scene?: Nullable<Scene>): Mesh;
  53221. /**
  53222. * Creates a sphere mesh
  53223. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  53224. * * 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`)
  53225. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  53226. * * 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
  53227. * * 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)
  53228. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53229. * * 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
  53230. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53231. * @param name defines the name of the mesh
  53232. * @param options defines the options used to create the mesh
  53233. * @param scene defines the hosting scene
  53234. * @returns the sphere mesh
  53235. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  53236. */
  53237. static CreateSphere(name: string, options: {
  53238. segments?: number;
  53239. diameter?: number;
  53240. diameterX?: number;
  53241. diameterY?: number;
  53242. diameterZ?: number;
  53243. arc?: number;
  53244. slice?: number;
  53245. sideOrientation?: number;
  53246. frontUVs?: Vector4;
  53247. backUVs?: Vector4;
  53248. updatable?: boolean;
  53249. }, scene?: Nullable<Scene>): Mesh;
  53250. /**
  53251. * Creates a plane polygonal mesh. By default, this is a disc
  53252. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  53253. * * 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
  53254. * * 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
  53255. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53256. * * 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
  53257. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53258. * @param name defines the name of the mesh
  53259. * @param options defines the options used to create the mesh
  53260. * @param scene defines the hosting scene
  53261. * @returns the plane polygonal mesh
  53262. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  53263. */
  53264. static CreateDisc(name: string, options: {
  53265. radius?: number;
  53266. tessellation?: number;
  53267. arc?: number;
  53268. updatable?: boolean;
  53269. sideOrientation?: number;
  53270. frontUVs?: Vector4;
  53271. backUVs?: Vector4;
  53272. }, scene?: Nullable<Scene>): Mesh;
  53273. /**
  53274. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  53275. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  53276. * * 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`)
  53277. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  53278. * * 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
  53279. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53280. * * 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
  53281. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53282. * @param name defines the name of the mesh
  53283. * @param options defines the options used to create the mesh
  53284. * @param scene defines the hosting scene
  53285. * @returns the icosahedron mesh
  53286. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  53287. */
  53288. static CreateIcoSphere(name: string, options: {
  53289. radius?: number;
  53290. radiusX?: number;
  53291. radiusY?: number;
  53292. radiusZ?: number;
  53293. flat?: boolean;
  53294. subdivisions?: number;
  53295. sideOrientation?: number;
  53296. frontUVs?: Vector4;
  53297. backUVs?: Vector4;
  53298. updatable?: boolean;
  53299. }, scene?: Nullable<Scene>): Mesh;
  53300. /**
  53301. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53302. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  53303. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  53304. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  53305. * * 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
  53306. * * 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
  53307. * * 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
  53308. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53309. * * 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
  53310. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53311. * * 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
  53312. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  53313. * * 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
  53314. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  53315. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53316. * @param name defines the name of the mesh
  53317. * @param options defines the options used to create the mesh
  53318. * @param scene defines the hosting scene
  53319. * @returns the ribbon mesh
  53320. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  53321. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53322. */
  53323. static CreateRibbon(name: string, options: {
  53324. pathArray: Vector3[][];
  53325. closeArray?: boolean;
  53326. closePath?: boolean;
  53327. offset?: number;
  53328. updatable?: boolean;
  53329. sideOrientation?: number;
  53330. frontUVs?: Vector4;
  53331. backUVs?: Vector4;
  53332. instance?: Mesh;
  53333. invertUV?: boolean;
  53334. uvs?: Vector2[];
  53335. colors?: Color4[];
  53336. }, scene?: Nullable<Scene>): Mesh;
  53337. /**
  53338. * Creates a cylinder or a cone mesh
  53339. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  53340. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  53341. * * 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.
  53342. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  53343. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  53344. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  53345. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  53346. * * 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).
  53347. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  53348. * * 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).
  53349. * * 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
  53350. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  53351. * * 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
  53352. * * 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.
  53353. * * If `enclose` is false, a ring surface is one element.
  53354. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  53355. * * 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
  53356. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53357. * * 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
  53358. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53359. * @param name defines the name of the mesh
  53360. * @param options defines the options used to create the mesh
  53361. * @param scene defines the hosting scene
  53362. * @returns the cylinder mesh
  53363. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  53364. */
  53365. static CreateCylinder(name: string, options: {
  53366. height?: number;
  53367. diameterTop?: number;
  53368. diameterBottom?: number;
  53369. diameter?: number;
  53370. tessellation?: number;
  53371. subdivisions?: number;
  53372. arc?: number;
  53373. faceColors?: Color4[];
  53374. faceUV?: Vector4[];
  53375. updatable?: boolean;
  53376. hasRings?: boolean;
  53377. enclose?: boolean;
  53378. cap?: number;
  53379. sideOrientation?: number;
  53380. frontUVs?: Vector4;
  53381. backUVs?: Vector4;
  53382. }, scene?: Nullable<Scene>): Mesh;
  53383. /**
  53384. * Creates a torus mesh
  53385. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  53386. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  53387. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  53388. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53389. * * 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
  53390. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53391. * @param name defines the name of the mesh
  53392. * @param options defines the options used to create the mesh
  53393. * @param scene defines the hosting scene
  53394. * @returns the torus mesh
  53395. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  53396. */
  53397. static CreateTorus(name: string, options: {
  53398. diameter?: number;
  53399. thickness?: number;
  53400. tessellation?: number;
  53401. updatable?: boolean;
  53402. sideOrientation?: number;
  53403. frontUVs?: Vector4;
  53404. backUVs?: Vector4;
  53405. }, scene?: Nullable<Scene>): Mesh;
  53406. /**
  53407. * Creates a torus knot mesh
  53408. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  53409. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  53410. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  53411. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  53412. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53413. * * 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
  53414. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53415. * @param name defines the name of the mesh
  53416. * @param options defines the options used to create the mesh
  53417. * @param scene defines the hosting scene
  53418. * @returns the torus knot mesh
  53419. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  53420. */
  53421. static CreateTorusKnot(name: string, options: {
  53422. radius?: number;
  53423. tube?: number;
  53424. radialSegments?: number;
  53425. tubularSegments?: number;
  53426. p?: number;
  53427. q?: number;
  53428. updatable?: boolean;
  53429. sideOrientation?: number;
  53430. frontUVs?: Vector4;
  53431. backUVs?: Vector4;
  53432. }, scene?: Nullable<Scene>): Mesh;
  53433. /**
  53434. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  53435. * * 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
  53436. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  53437. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  53438. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  53439. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  53440. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  53441. * * 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
  53442. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  53443. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53444. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  53445. * @param name defines the name of the new line system
  53446. * @param options defines the options used to create the line system
  53447. * @param scene defines the hosting scene
  53448. * @returns a new line system mesh
  53449. */
  53450. static CreateLineSystem(name: string, options: {
  53451. lines: Vector3[][];
  53452. updatable?: boolean;
  53453. instance?: Nullable<LinesMesh>;
  53454. colors?: Nullable<Color4[][]>;
  53455. useVertexAlpha?: boolean;
  53456. }, scene: Nullable<Scene>): LinesMesh;
  53457. /**
  53458. * Creates a line mesh
  53459. * 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
  53460. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  53461. * * The parameter `points` is an array successive Vector3
  53462. * * 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
  53463. * * The optional parameter `colors` is an array of successive Color4, one per line point
  53464. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  53465. * * When updating an instance, remember that only point positions can change, not the number of points
  53466. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53467. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  53468. * @param name defines the name of the new line system
  53469. * @param options defines the options used to create the line system
  53470. * @param scene defines the hosting scene
  53471. * @returns a new line mesh
  53472. */
  53473. static CreateLines(name: string, options: {
  53474. points: Vector3[];
  53475. updatable?: boolean;
  53476. instance?: Nullable<LinesMesh>;
  53477. colors?: Color4[];
  53478. useVertexAlpha?: boolean;
  53479. }, scene?: Nullable<Scene>): LinesMesh;
  53480. /**
  53481. * Creates a dashed line mesh
  53482. * * 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
  53483. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  53484. * * The parameter `points` is an array successive Vector3
  53485. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  53486. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  53487. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  53488. * * 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
  53489. * * When updating an instance, remember that only point positions can change, not the number of points
  53490. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53491. * @param name defines the name of the mesh
  53492. * @param options defines the options used to create the mesh
  53493. * @param scene defines the hosting scene
  53494. * @returns the dashed line mesh
  53495. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  53496. */
  53497. static CreateDashedLines(name: string, options: {
  53498. points: Vector3[];
  53499. dashSize?: number;
  53500. gapSize?: number;
  53501. dashNb?: number;
  53502. updatable?: boolean;
  53503. instance?: LinesMesh;
  53504. }, scene?: Nullable<Scene>): LinesMesh;
  53505. /**
  53506. * 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.
  53507. * * 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.
  53508. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53509. * * 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.
  53510. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  53511. * * 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
  53512. * * 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
  53513. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  53514. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53515. * * 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
  53516. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  53517. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53518. * @param name defines the name of the mesh
  53519. * @param options defines the options used to create the mesh
  53520. * @param scene defines the hosting scene
  53521. * @returns the extruded shape mesh
  53522. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53523. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53524. */
  53525. static ExtrudeShape(name: string, options: {
  53526. shape: Vector3[];
  53527. path: Vector3[];
  53528. scale?: number;
  53529. rotation?: number;
  53530. cap?: number;
  53531. updatable?: boolean;
  53532. sideOrientation?: number;
  53533. frontUVs?: Vector4;
  53534. backUVs?: Vector4;
  53535. instance?: Mesh;
  53536. invertUV?: boolean;
  53537. }, scene?: Nullable<Scene>): Mesh;
  53538. /**
  53539. * Creates an custom extruded shape mesh.
  53540. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  53541. * * 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.
  53542. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53543. * * 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
  53544. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  53545. * * 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
  53546. * * It must returns a float value that will be the scale value applied to the shape on each path point
  53547. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  53548. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  53549. * * 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
  53550. * * 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
  53551. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  53552. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53553. * * 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
  53554. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53555. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53556. * @param name defines the name of the mesh
  53557. * @param options defines the options used to create the mesh
  53558. * @param scene defines the hosting scene
  53559. * @returns the custom extruded shape mesh
  53560. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  53561. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53562. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53563. */
  53564. static ExtrudeShapeCustom(name: string, options: {
  53565. shape: Vector3[];
  53566. path: Vector3[];
  53567. scaleFunction?: any;
  53568. rotationFunction?: any;
  53569. ribbonCloseArray?: boolean;
  53570. ribbonClosePath?: boolean;
  53571. cap?: number;
  53572. updatable?: boolean;
  53573. sideOrientation?: number;
  53574. frontUVs?: Vector4;
  53575. backUVs?: Vector4;
  53576. instance?: Mesh;
  53577. invertUV?: boolean;
  53578. }, scene?: Nullable<Scene>): Mesh;
  53579. /**
  53580. * Creates lathe mesh.
  53581. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  53582. * * 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
  53583. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  53584. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  53585. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  53586. * * 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
  53587. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  53588. * * 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
  53589. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53590. * * 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
  53591. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53592. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53593. * @param name defines the name of the mesh
  53594. * @param options defines the options used to create the mesh
  53595. * @param scene defines the hosting scene
  53596. * @returns the lathe mesh
  53597. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  53598. */
  53599. static CreateLathe(name: string, options: {
  53600. shape: Vector3[];
  53601. radius?: number;
  53602. tessellation?: number;
  53603. clip?: number;
  53604. arc?: number;
  53605. closed?: boolean;
  53606. updatable?: boolean;
  53607. sideOrientation?: number;
  53608. frontUVs?: Vector4;
  53609. backUVs?: Vector4;
  53610. cap?: number;
  53611. invertUV?: boolean;
  53612. }, scene?: Nullable<Scene>): Mesh;
  53613. /**
  53614. * Creates a tiled plane mesh
  53615. * * You can set a limited pattern arrangement with the tiles
  53616. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53617. * * 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
  53618. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53619. * @param name defines the name of the mesh
  53620. * @param options defines the options used to create the mesh
  53621. * @param scene defines the hosting scene
  53622. * @returns the plane mesh
  53623. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  53624. */
  53625. static CreateTiledPlane(name: string, options: {
  53626. pattern?: number;
  53627. tileSize?: number;
  53628. tileWidth?: number;
  53629. tileHeight?: number;
  53630. size?: number;
  53631. width?: number;
  53632. height?: number;
  53633. alignHorizontal?: number;
  53634. alignVertical?: number;
  53635. sideOrientation?: number;
  53636. frontUVs?: Vector4;
  53637. backUVs?: Vector4;
  53638. updatable?: boolean;
  53639. }, scene?: Nullable<Scene>): Mesh;
  53640. /**
  53641. * Creates a plane mesh
  53642. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  53643. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  53644. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  53645. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53646. * * 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
  53647. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53648. * @param name defines the name of the mesh
  53649. * @param options defines the options used to create the mesh
  53650. * @param scene defines the hosting scene
  53651. * @returns the plane mesh
  53652. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  53653. */
  53654. static CreatePlane(name: string, options: {
  53655. size?: number;
  53656. width?: number;
  53657. height?: number;
  53658. sideOrientation?: number;
  53659. frontUVs?: Vector4;
  53660. backUVs?: Vector4;
  53661. updatable?: boolean;
  53662. sourcePlane?: Plane;
  53663. }, scene?: Nullable<Scene>): Mesh;
  53664. /**
  53665. * Creates a ground mesh
  53666. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  53667. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  53668. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53669. * @param name defines the name of the mesh
  53670. * @param options defines the options used to create the mesh
  53671. * @param scene defines the hosting scene
  53672. * @returns the ground mesh
  53673. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  53674. */
  53675. static CreateGround(name: string, options: {
  53676. width?: number;
  53677. height?: number;
  53678. subdivisions?: number;
  53679. subdivisionsX?: number;
  53680. subdivisionsY?: number;
  53681. updatable?: boolean;
  53682. }, scene?: Nullable<Scene>): Mesh;
  53683. /**
  53684. * Creates a tiled ground mesh
  53685. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  53686. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  53687. * * 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
  53688. * * 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
  53689. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53690. * @param name defines the name of the mesh
  53691. * @param options defines the options used to create the mesh
  53692. * @param scene defines the hosting scene
  53693. * @returns the tiled ground mesh
  53694. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  53695. */
  53696. static CreateTiledGround(name: string, options: {
  53697. xmin: number;
  53698. zmin: number;
  53699. xmax: number;
  53700. zmax: number;
  53701. subdivisions?: {
  53702. w: number;
  53703. h: number;
  53704. };
  53705. precision?: {
  53706. w: number;
  53707. h: number;
  53708. };
  53709. updatable?: boolean;
  53710. }, scene?: Nullable<Scene>): Mesh;
  53711. /**
  53712. * Creates a ground mesh from a height map
  53713. * * The parameter `url` sets the URL of the height map image resource.
  53714. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  53715. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  53716. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  53717. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  53718. * * 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.
  53719. * * 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).
  53720. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  53721. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53722. * @param name defines the name of the mesh
  53723. * @param url defines the url to the height map
  53724. * @param options defines the options used to create the mesh
  53725. * @param scene defines the hosting scene
  53726. * @returns the ground mesh
  53727. * @see https://doc.babylonjs.com/babylon101/height_map
  53728. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  53729. */
  53730. static CreateGroundFromHeightMap(name: string, url: string, options: {
  53731. width?: number;
  53732. height?: number;
  53733. subdivisions?: number;
  53734. minHeight?: number;
  53735. maxHeight?: number;
  53736. colorFilter?: Color3;
  53737. alphaFilter?: number;
  53738. updatable?: boolean;
  53739. onReady?: (mesh: GroundMesh) => void;
  53740. }, scene?: Nullable<Scene>): GroundMesh;
  53741. /**
  53742. * Creates a polygon mesh
  53743. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  53744. * * 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
  53745. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  53746. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53747. * * 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)
  53748. * * Remember you can only change the shape positions, not their number when updating a polygon
  53749. * @param name defines the name of the mesh
  53750. * @param options defines the options used to create the mesh
  53751. * @param scene defines the hosting scene
  53752. * @param earcutInjection can be used to inject your own earcut reference
  53753. * @returns the polygon mesh
  53754. */
  53755. static CreatePolygon(name: string, options: {
  53756. shape: Vector3[];
  53757. holes?: Vector3[][];
  53758. depth?: number;
  53759. faceUV?: Vector4[];
  53760. faceColors?: Color4[];
  53761. updatable?: boolean;
  53762. sideOrientation?: number;
  53763. frontUVs?: Vector4;
  53764. backUVs?: Vector4;
  53765. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  53766. /**
  53767. * Creates an extruded polygon mesh, with depth in the Y direction.
  53768. * * 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)
  53769. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  53770. * @param name defines the name of the mesh
  53771. * @param options defines the options used to create the mesh
  53772. * @param scene defines the hosting scene
  53773. * @param earcutInjection can be used to inject your own earcut reference
  53774. * @returns the polygon mesh
  53775. */
  53776. static ExtrudePolygon(name: string, options: {
  53777. shape: Vector3[];
  53778. holes?: Vector3[][];
  53779. depth?: number;
  53780. faceUV?: Vector4[];
  53781. faceColors?: Color4[];
  53782. updatable?: boolean;
  53783. sideOrientation?: number;
  53784. frontUVs?: Vector4;
  53785. backUVs?: Vector4;
  53786. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  53787. /**
  53788. * Creates a tube mesh.
  53789. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53790. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  53791. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  53792. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  53793. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  53794. * * 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)
  53795. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  53796. * * 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
  53797. * * 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
  53798. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53799. * * 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
  53800. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53801. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53802. * @param name defines the name of the mesh
  53803. * @param options defines the options used to create the mesh
  53804. * @param scene defines the hosting scene
  53805. * @returns the tube mesh
  53806. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53807. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  53808. */
  53809. static CreateTube(name: string, options: {
  53810. path: Vector3[];
  53811. radius?: number;
  53812. tessellation?: number;
  53813. radiusFunction?: {
  53814. (i: number, distance: number): number;
  53815. };
  53816. cap?: number;
  53817. arc?: number;
  53818. updatable?: boolean;
  53819. sideOrientation?: number;
  53820. frontUVs?: Vector4;
  53821. backUVs?: Vector4;
  53822. instance?: Mesh;
  53823. invertUV?: boolean;
  53824. }, scene?: Nullable<Scene>): Mesh;
  53825. /**
  53826. * Creates a polyhedron mesh
  53827. * * 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
  53828. * * The parameter `size` (positive float, default 1) sets the polygon size
  53829. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  53830. * * 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`
  53831. * * 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
  53832. * * 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)`)
  53833. * * 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
  53834. * * 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
  53835. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53836. * * 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
  53837. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53838. * @param name defines the name of the mesh
  53839. * @param options defines the options used to create the mesh
  53840. * @param scene defines the hosting scene
  53841. * @returns the polyhedron mesh
  53842. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  53843. */
  53844. static CreatePolyhedron(name: string, options: {
  53845. type?: number;
  53846. size?: number;
  53847. sizeX?: number;
  53848. sizeY?: number;
  53849. sizeZ?: number;
  53850. custom?: any;
  53851. faceUV?: Vector4[];
  53852. faceColors?: Color4[];
  53853. flat?: boolean;
  53854. updatable?: boolean;
  53855. sideOrientation?: number;
  53856. frontUVs?: Vector4;
  53857. backUVs?: Vector4;
  53858. }, scene?: Nullable<Scene>): Mesh;
  53859. /**
  53860. * Creates a decal mesh.
  53861. * 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
  53862. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  53863. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  53864. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  53865. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  53866. * @param name defines the name of the mesh
  53867. * @param sourceMesh defines the mesh where the decal must be applied
  53868. * @param options defines the options used to create the mesh
  53869. * @param scene defines the hosting scene
  53870. * @returns the decal mesh
  53871. * @see https://doc.babylonjs.com/how_to/decals
  53872. */
  53873. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  53874. position?: Vector3;
  53875. normal?: Vector3;
  53876. size?: Vector3;
  53877. angle?: number;
  53878. }): Mesh;
  53879. }
  53880. }
  53881. declare module BABYLON {
  53882. /**
  53883. * A simplifier interface for future simplification implementations
  53884. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53885. */
  53886. export interface ISimplifier {
  53887. /**
  53888. * Simplification of a given mesh according to the given settings.
  53889. * Since this requires computation, it is assumed that the function runs async.
  53890. * @param settings The settings of the simplification, including quality and distance
  53891. * @param successCallback A callback that will be called after the mesh was simplified.
  53892. * @param errorCallback in case of an error, this callback will be called. optional.
  53893. */
  53894. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  53895. }
  53896. /**
  53897. * Expected simplification settings.
  53898. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  53899. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53900. */
  53901. export interface ISimplificationSettings {
  53902. /**
  53903. * Gets or sets the expected quality
  53904. */
  53905. quality: number;
  53906. /**
  53907. * Gets or sets the distance when this optimized version should be used
  53908. */
  53909. distance: number;
  53910. /**
  53911. * Gets an already optimized mesh
  53912. */
  53913. optimizeMesh?: boolean;
  53914. }
  53915. /**
  53916. * Class used to specify simplification options
  53917. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53918. */
  53919. export class SimplificationSettings implements ISimplificationSettings {
  53920. /** expected quality */
  53921. quality: number;
  53922. /** distance when this optimized version should be used */
  53923. distance: number;
  53924. /** already optimized mesh */
  53925. optimizeMesh?: boolean | undefined;
  53926. /**
  53927. * Creates a SimplificationSettings
  53928. * @param quality expected quality
  53929. * @param distance distance when this optimized version should be used
  53930. * @param optimizeMesh already optimized mesh
  53931. */
  53932. constructor(
  53933. /** expected quality */
  53934. quality: number,
  53935. /** distance when this optimized version should be used */
  53936. distance: number,
  53937. /** already optimized mesh */
  53938. optimizeMesh?: boolean | undefined);
  53939. }
  53940. /**
  53941. * Interface used to define a simplification task
  53942. */
  53943. export interface ISimplificationTask {
  53944. /**
  53945. * Array of settings
  53946. */
  53947. settings: Array<ISimplificationSettings>;
  53948. /**
  53949. * Simplification type
  53950. */
  53951. simplificationType: SimplificationType;
  53952. /**
  53953. * Mesh to simplify
  53954. */
  53955. mesh: Mesh;
  53956. /**
  53957. * Callback called on success
  53958. */
  53959. successCallback?: () => void;
  53960. /**
  53961. * Defines if parallel processing can be used
  53962. */
  53963. parallelProcessing: boolean;
  53964. }
  53965. /**
  53966. * Queue used to order the simplification tasks
  53967. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53968. */
  53969. export class SimplificationQueue {
  53970. private _simplificationArray;
  53971. /**
  53972. * Gets a boolean indicating that the process is still running
  53973. */
  53974. running: boolean;
  53975. /**
  53976. * Creates a new queue
  53977. */
  53978. constructor();
  53979. /**
  53980. * Adds a new simplification task
  53981. * @param task defines a task to add
  53982. */
  53983. addTask(task: ISimplificationTask): void;
  53984. /**
  53985. * Execute next task
  53986. */
  53987. executeNext(): void;
  53988. /**
  53989. * Execute a simplification task
  53990. * @param task defines the task to run
  53991. */
  53992. runSimplification(task: ISimplificationTask): void;
  53993. private getSimplifier;
  53994. }
  53995. /**
  53996. * The implemented types of simplification
  53997. * At the moment only Quadratic Error Decimation is implemented
  53998. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53999. */
  54000. export enum SimplificationType {
  54001. /** Quadratic error decimation */
  54002. QUADRATIC = 0
  54003. }
  54004. }
  54005. declare module BABYLON {
  54006. interface Scene {
  54007. /** @hidden (Backing field) */
  54008. _simplificationQueue: SimplificationQueue;
  54009. /**
  54010. * Gets or sets the simplification queue attached to the scene
  54011. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  54012. */
  54013. simplificationQueue: SimplificationQueue;
  54014. }
  54015. interface Mesh {
  54016. /**
  54017. * Simplify the mesh according to the given array of settings.
  54018. * Function will return immediately and will simplify async
  54019. * @param settings a collection of simplification settings
  54020. * @param parallelProcessing should all levels calculate parallel or one after the other
  54021. * @param simplificationType the type of simplification to run
  54022. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  54023. * @returns the current mesh
  54024. */
  54025. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  54026. }
  54027. /**
  54028. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  54029. * created in a scene
  54030. */
  54031. export class SimplicationQueueSceneComponent implements ISceneComponent {
  54032. /**
  54033. * The component name helpfull to identify the component in the list of scene components.
  54034. */
  54035. readonly name: string;
  54036. /**
  54037. * The scene the component belongs to.
  54038. */
  54039. scene: Scene;
  54040. /**
  54041. * Creates a new instance of the component for the given scene
  54042. * @param scene Defines the scene to register the component in
  54043. */
  54044. constructor(scene: Scene);
  54045. /**
  54046. * Registers the component in a given scene
  54047. */
  54048. register(): void;
  54049. /**
  54050. * Rebuilds the elements related to this component in case of
  54051. * context lost for instance.
  54052. */
  54053. rebuild(): void;
  54054. /**
  54055. * Disposes the component and the associated ressources
  54056. */
  54057. dispose(): void;
  54058. private _beforeCameraUpdate;
  54059. }
  54060. }
  54061. declare module BABYLON {
  54062. /**
  54063. * Class used to enable access to IndexedDB
  54064. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  54065. */
  54066. export class Database implements IOfflineProvider {
  54067. private _callbackManifestChecked;
  54068. private _currentSceneUrl;
  54069. private _db;
  54070. private _enableSceneOffline;
  54071. private _enableTexturesOffline;
  54072. private _manifestVersionFound;
  54073. private _mustUpdateRessources;
  54074. private _hasReachedQuota;
  54075. private _isSupported;
  54076. private _idbFactory;
  54077. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  54078. private static IsUASupportingBlobStorage;
  54079. /**
  54080. * Gets a boolean indicating if Database storate is enabled (off by default)
  54081. */
  54082. static IDBStorageEnabled: boolean;
  54083. /**
  54084. * Gets a boolean indicating if scene must be saved in the database
  54085. */
  54086. readonly enableSceneOffline: boolean;
  54087. /**
  54088. * Gets a boolean indicating if textures must be saved in the database
  54089. */
  54090. readonly enableTexturesOffline: boolean;
  54091. /**
  54092. * Creates a new Database
  54093. * @param urlToScene defines the url to load the scene
  54094. * @param callbackManifestChecked defines the callback to use when manifest is checked
  54095. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  54096. */
  54097. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  54098. private static _ParseURL;
  54099. private static _ReturnFullUrlLocation;
  54100. private _checkManifestFile;
  54101. /**
  54102. * Open the database and make it available
  54103. * @param successCallback defines the callback to call on success
  54104. * @param errorCallback defines the callback to call on error
  54105. */
  54106. open(successCallback: () => void, errorCallback: () => void): void;
  54107. /**
  54108. * Loads an image from the database
  54109. * @param url defines the url to load from
  54110. * @param image defines the target DOM image
  54111. */
  54112. loadImage(url: string, image: HTMLImageElement): void;
  54113. private _loadImageFromDBAsync;
  54114. private _saveImageIntoDBAsync;
  54115. private _checkVersionFromDB;
  54116. private _loadVersionFromDBAsync;
  54117. private _saveVersionIntoDBAsync;
  54118. /**
  54119. * Loads a file from database
  54120. * @param url defines the URL to load from
  54121. * @param sceneLoaded defines a callback to call on success
  54122. * @param progressCallBack defines a callback to call when progress changed
  54123. * @param errorCallback defines a callback to call on error
  54124. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  54125. */
  54126. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  54127. private _loadFileAsync;
  54128. private _saveFileAsync;
  54129. /**
  54130. * Validates if xhr data is correct
  54131. * @param xhr defines the request to validate
  54132. * @param dataType defines the expected data type
  54133. * @returns true if data is correct
  54134. */
  54135. private static _ValidateXHRData;
  54136. }
  54137. }
  54138. declare module BABYLON {
  54139. /** @hidden */
  54140. export var gpuUpdateParticlesPixelShader: {
  54141. name: string;
  54142. shader: string;
  54143. };
  54144. }
  54145. declare module BABYLON {
  54146. /** @hidden */
  54147. export var gpuUpdateParticlesVertexShader: {
  54148. name: string;
  54149. shader: string;
  54150. };
  54151. }
  54152. declare module BABYLON {
  54153. /** @hidden */
  54154. export var clipPlaneFragmentDeclaration2: {
  54155. name: string;
  54156. shader: string;
  54157. };
  54158. }
  54159. declare module BABYLON {
  54160. /** @hidden */
  54161. export var gpuRenderParticlesPixelShader: {
  54162. name: string;
  54163. shader: string;
  54164. };
  54165. }
  54166. declare module BABYLON {
  54167. /** @hidden */
  54168. export var clipPlaneVertexDeclaration2: {
  54169. name: string;
  54170. shader: string;
  54171. };
  54172. }
  54173. declare module BABYLON {
  54174. /** @hidden */
  54175. export var gpuRenderParticlesVertexShader: {
  54176. name: string;
  54177. shader: string;
  54178. };
  54179. }
  54180. declare module BABYLON {
  54181. /**
  54182. * This represents a GPU particle system in Babylon
  54183. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  54184. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  54185. */
  54186. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  54187. /**
  54188. * The layer mask we are rendering the particles through.
  54189. */
  54190. layerMask: number;
  54191. private _capacity;
  54192. private _activeCount;
  54193. private _currentActiveCount;
  54194. private _accumulatedCount;
  54195. private _renderEffect;
  54196. private _updateEffect;
  54197. private _buffer0;
  54198. private _buffer1;
  54199. private _spriteBuffer;
  54200. private _updateVAO;
  54201. private _renderVAO;
  54202. private _targetIndex;
  54203. private _sourceBuffer;
  54204. private _targetBuffer;
  54205. private _engine;
  54206. private _currentRenderId;
  54207. private _started;
  54208. private _stopped;
  54209. private _timeDelta;
  54210. private _randomTexture;
  54211. private _randomTexture2;
  54212. private _attributesStrideSize;
  54213. private _updateEffectOptions;
  54214. private _randomTextureSize;
  54215. private _actualFrame;
  54216. private readonly _rawTextureWidth;
  54217. /**
  54218. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  54219. */
  54220. static readonly IsSupported: boolean;
  54221. /**
  54222. * An event triggered when the system is disposed.
  54223. */
  54224. onDisposeObservable: Observable<GPUParticleSystem>;
  54225. /**
  54226. * Gets the maximum number of particles active at the same time.
  54227. * @returns The max number of active particles.
  54228. */
  54229. getCapacity(): number;
  54230. /**
  54231. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  54232. * to override the particles.
  54233. */
  54234. forceDepthWrite: boolean;
  54235. /**
  54236. * Gets or set the number of active particles
  54237. */
  54238. activeParticleCount: number;
  54239. private _preWarmDone;
  54240. /**
  54241. * Is this system ready to be used/rendered
  54242. * @return true if the system is ready
  54243. */
  54244. isReady(): boolean;
  54245. /**
  54246. * Gets if the system has been started. (Note: this will still be true after stop is called)
  54247. * @returns True if it has been started, otherwise false.
  54248. */
  54249. isStarted(): boolean;
  54250. /**
  54251. * Starts the particle system and begins to emit
  54252. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  54253. */
  54254. start(delay?: number): void;
  54255. /**
  54256. * Stops the particle system.
  54257. */
  54258. stop(): void;
  54259. /**
  54260. * Remove all active particles
  54261. */
  54262. reset(): void;
  54263. /**
  54264. * Returns the string "GPUParticleSystem"
  54265. * @returns a string containing the class name
  54266. */
  54267. getClassName(): string;
  54268. private _colorGradientsTexture;
  54269. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  54270. /**
  54271. * Adds a new color gradient
  54272. * @param gradient defines the gradient to use (between 0 and 1)
  54273. * @param color1 defines the color to affect to the specified gradient
  54274. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  54275. * @returns the current particle system
  54276. */
  54277. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  54278. /**
  54279. * Remove a specific color gradient
  54280. * @param gradient defines the gradient to remove
  54281. * @returns the current particle system
  54282. */
  54283. removeColorGradient(gradient: number): GPUParticleSystem;
  54284. private _angularSpeedGradientsTexture;
  54285. private _sizeGradientsTexture;
  54286. private _velocityGradientsTexture;
  54287. private _limitVelocityGradientsTexture;
  54288. private _dragGradientsTexture;
  54289. private _addFactorGradient;
  54290. /**
  54291. * Adds a new size gradient
  54292. * @param gradient defines the gradient to use (between 0 and 1)
  54293. * @param factor defines the size factor to affect to the specified gradient
  54294. * @returns the current particle system
  54295. */
  54296. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  54297. /**
  54298. * Remove a specific size gradient
  54299. * @param gradient defines the gradient to remove
  54300. * @returns the current particle system
  54301. */
  54302. removeSizeGradient(gradient: number): GPUParticleSystem;
  54303. /**
  54304. * Adds a new angular speed gradient
  54305. * @param gradient defines the gradient to use (between 0 and 1)
  54306. * @param factor defines the angular speed to affect to the specified gradient
  54307. * @returns the current particle system
  54308. */
  54309. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  54310. /**
  54311. * Remove a specific angular speed gradient
  54312. * @param gradient defines the gradient to remove
  54313. * @returns the current particle system
  54314. */
  54315. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  54316. /**
  54317. * Adds a new velocity gradient
  54318. * @param gradient defines the gradient to use (between 0 and 1)
  54319. * @param factor defines the velocity to affect to the specified gradient
  54320. * @returns the current particle system
  54321. */
  54322. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  54323. /**
  54324. * Remove a specific velocity gradient
  54325. * @param gradient defines the gradient to remove
  54326. * @returns the current particle system
  54327. */
  54328. removeVelocityGradient(gradient: number): GPUParticleSystem;
  54329. /**
  54330. * Adds a new limit velocity gradient
  54331. * @param gradient defines the gradient to use (between 0 and 1)
  54332. * @param factor defines the limit velocity value to affect to the specified gradient
  54333. * @returns the current particle system
  54334. */
  54335. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  54336. /**
  54337. * Remove a specific limit velocity gradient
  54338. * @param gradient defines the gradient to remove
  54339. * @returns the current particle system
  54340. */
  54341. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  54342. /**
  54343. * Adds a new drag gradient
  54344. * @param gradient defines the gradient to use (between 0 and 1)
  54345. * @param factor defines the drag value to affect to the specified gradient
  54346. * @returns the current particle system
  54347. */
  54348. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  54349. /**
  54350. * Remove a specific drag gradient
  54351. * @param gradient defines the gradient to remove
  54352. * @returns the current particle system
  54353. */
  54354. removeDragGradient(gradient: number): GPUParticleSystem;
  54355. /**
  54356. * Not supported by GPUParticleSystem
  54357. * @param gradient defines the gradient to use (between 0 and 1)
  54358. * @param factor defines the emit rate value to affect to the specified gradient
  54359. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  54360. * @returns the current particle system
  54361. */
  54362. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  54363. /**
  54364. * Not supported by GPUParticleSystem
  54365. * @param gradient defines the gradient to remove
  54366. * @returns the current particle system
  54367. */
  54368. removeEmitRateGradient(gradient: number): IParticleSystem;
  54369. /**
  54370. * Not supported by GPUParticleSystem
  54371. * @param gradient defines the gradient to use (between 0 and 1)
  54372. * @param factor defines the start size value to affect to the specified gradient
  54373. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  54374. * @returns the current particle system
  54375. */
  54376. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  54377. /**
  54378. * Not supported by GPUParticleSystem
  54379. * @param gradient defines the gradient to remove
  54380. * @returns the current particle system
  54381. */
  54382. removeStartSizeGradient(gradient: number): IParticleSystem;
  54383. /**
  54384. * Not supported by GPUParticleSystem
  54385. * @param gradient defines the gradient to use (between 0 and 1)
  54386. * @param min defines the color remap minimal range
  54387. * @param max defines the color remap maximal range
  54388. * @returns the current particle system
  54389. */
  54390. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  54391. /**
  54392. * Not supported by GPUParticleSystem
  54393. * @param gradient defines the gradient to remove
  54394. * @returns the current particle system
  54395. */
  54396. removeColorRemapGradient(): IParticleSystem;
  54397. /**
  54398. * Not supported by GPUParticleSystem
  54399. * @param gradient defines the gradient to use (between 0 and 1)
  54400. * @param min defines the alpha remap minimal range
  54401. * @param max defines the alpha remap maximal range
  54402. * @returns the current particle system
  54403. */
  54404. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  54405. /**
  54406. * Not supported by GPUParticleSystem
  54407. * @param gradient defines the gradient to remove
  54408. * @returns the current particle system
  54409. */
  54410. removeAlphaRemapGradient(): IParticleSystem;
  54411. /**
  54412. * Not supported by GPUParticleSystem
  54413. * @param gradient defines the gradient to use (between 0 and 1)
  54414. * @param color defines the color to affect to the specified gradient
  54415. * @returns the current particle system
  54416. */
  54417. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  54418. /**
  54419. * Not supported by GPUParticleSystem
  54420. * @param gradient defines the gradient to remove
  54421. * @returns the current particle system
  54422. */
  54423. removeRampGradient(): IParticleSystem;
  54424. /**
  54425. * Not supported by GPUParticleSystem
  54426. * @returns the list of ramp gradients
  54427. */
  54428. getRampGradients(): Nullable<Array<Color3Gradient>>;
  54429. /**
  54430. * Not supported by GPUParticleSystem
  54431. * Gets or sets a boolean indicating that ramp gradients must be used
  54432. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  54433. */
  54434. useRampGradients: boolean;
  54435. /**
  54436. * Not supported by GPUParticleSystem
  54437. * @param gradient defines the gradient to use (between 0 and 1)
  54438. * @param factor defines the life time factor to affect to the specified gradient
  54439. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  54440. * @returns the current particle system
  54441. */
  54442. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  54443. /**
  54444. * Not supported by GPUParticleSystem
  54445. * @param gradient defines the gradient to remove
  54446. * @returns the current particle system
  54447. */
  54448. removeLifeTimeGradient(gradient: number): IParticleSystem;
  54449. /**
  54450. * Instantiates a GPU particle system.
  54451. * 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.
  54452. * @param name The name of the particle system
  54453. * @param options The options used to create the system
  54454. * @param scene The scene the particle system belongs to
  54455. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  54456. */
  54457. constructor(name: string, options: Partial<{
  54458. capacity: number;
  54459. randomTextureSize: number;
  54460. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  54461. protected _reset(): void;
  54462. private _createUpdateVAO;
  54463. private _createRenderVAO;
  54464. private _initialize;
  54465. /** @hidden */
  54466. _recreateUpdateEffect(): void;
  54467. /** @hidden */
  54468. _recreateRenderEffect(): void;
  54469. /**
  54470. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  54471. * @param preWarm defines if we are in the pre-warmimg phase
  54472. */
  54473. animate(preWarm?: boolean): void;
  54474. private _createFactorGradientTexture;
  54475. private _createSizeGradientTexture;
  54476. private _createAngularSpeedGradientTexture;
  54477. private _createVelocityGradientTexture;
  54478. private _createLimitVelocityGradientTexture;
  54479. private _createDragGradientTexture;
  54480. private _createColorGradientTexture;
  54481. /**
  54482. * Renders the particle system in its current state
  54483. * @param preWarm defines if the system should only update the particles but not render them
  54484. * @returns the current number of particles
  54485. */
  54486. render(preWarm?: boolean): number;
  54487. /**
  54488. * Rebuilds the particle system
  54489. */
  54490. rebuild(): void;
  54491. private _releaseBuffers;
  54492. private _releaseVAOs;
  54493. /**
  54494. * Disposes the particle system and free the associated resources
  54495. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  54496. */
  54497. dispose(disposeTexture?: boolean): void;
  54498. /**
  54499. * Clones the particle system.
  54500. * @param name The name of the cloned object
  54501. * @param newEmitter The new emitter to use
  54502. * @returns the cloned particle system
  54503. */
  54504. clone(name: string, newEmitter: any): GPUParticleSystem;
  54505. /**
  54506. * Serializes the particle system to a JSON object.
  54507. * @returns the JSON object
  54508. */
  54509. serialize(): any;
  54510. /**
  54511. * Parses a JSON object to create a GPU particle system.
  54512. * @param parsedParticleSystem The JSON object to parse
  54513. * @param scene The scene to create the particle system in
  54514. * @param rootUrl The root url to use to load external dependencies like texture
  54515. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  54516. * @returns the parsed GPU particle system
  54517. */
  54518. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  54519. }
  54520. }
  54521. declare module BABYLON {
  54522. /**
  54523. * Represents a set of particle systems working together to create a specific effect
  54524. */
  54525. export class ParticleSystemSet implements IDisposable {
  54526. private _emitterCreationOptions;
  54527. private _emitterNode;
  54528. /**
  54529. * Gets the particle system list
  54530. */
  54531. systems: IParticleSystem[];
  54532. /**
  54533. * Gets the emitter node used with this set
  54534. */
  54535. readonly emitterNode: Nullable<TransformNode>;
  54536. /**
  54537. * Creates a new emitter mesh as a sphere
  54538. * @param options defines the options used to create the sphere
  54539. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  54540. * @param scene defines the hosting scene
  54541. */
  54542. setEmitterAsSphere(options: {
  54543. diameter: number;
  54544. segments: number;
  54545. color: Color3;
  54546. }, renderingGroupId: number, scene: Scene): void;
  54547. /**
  54548. * Starts all particle systems of the set
  54549. * @param emitter defines an optional mesh to use as emitter for the particle systems
  54550. */
  54551. start(emitter?: AbstractMesh): void;
  54552. /**
  54553. * Release all associated resources
  54554. */
  54555. dispose(): void;
  54556. /**
  54557. * Serialize the set into a JSON compatible object
  54558. * @returns a JSON compatible representation of the set
  54559. */
  54560. serialize(): any;
  54561. /**
  54562. * Parse a new ParticleSystemSet from a serialized source
  54563. * @param data defines a JSON compatible representation of the set
  54564. * @param scene defines the hosting scene
  54565. * @param gpu defines if we want GPU particles or CPU particles
  54566. * @returns a new ParticleSystemSet
  54567. */
  54568. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  54569. }
  54570. }
  54571. declare module BABYLON {
  54572. /**
  54573. * This class is made for on one-liner static method to help creating particle system set.
  54574. */
  54575. export class ParticleHelper {
  54576. /**
  54577. * Gets or sets base Assets URL
  54578. */
  54579. static BaseAssetsUrl: string;
  54580. /**
  54581. * Create a default particle system that you can tweak
  54582. * @param emitter defines the emitter to use
  54583. * @param capacity defines the system capacity (default is 500 particles)
  54584. * @param scene defines the hosting scene
  54585. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  54586. * @returns the new Particle system
  54587. */
  54588. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  54589. /**
  54590. * This is the main static method (one-liner) of this helper to create different particle systems
  54591. * @param type This string represents the type to the particle system to create
  54592. * @param scene The scene where the particle system should live
  54593. * @param gpu If the system will use gpu
  54594. * @returns the ParticleSystemSet created
  54595. */
  54596. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  54597. /**
  54598. * Static function used to export a particle system to a ParticleSystemSet variable.
  54599. * Please note that the emitter shape is not exported
  54600. * @param systems defines the particle systems to export
  54601. * @returns the created particle system set
  54602. */
  54603. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  54604. }
  54605. }
  54606. declare module BABYLON {
  54607. interface Engine {
  54608. /**
  54609. * Create an effect to use with particle systems.
  54610. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  54611. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  54612. * @param uniformsNames defines a list of attribute names
  54613. * @param samplers defines an array of string used to represent textures
  54614. * @param defines defines the string containing the defines to use to compile the shaders
  54615. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  54616. * @param onCompiled defines a function to call when the effect creation is successful
  54617. * @param onError defines a function to call when the effect creation has failed
  54618. * @returns the new Effect
  54619. */
  54620. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  54621. }
  54622. interface Mesh {
  54623. /**
  54624. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  54625. * @returns an array of IParticleSystem
  54626. */
  54627. getEmittedParticleSystems(): IParticleSystem[];
  54628. /**
  54629. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  54630. * @returns an array of IParticleSystem
  54631. */
  54632. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  54633. }
  54634. /**
  54635. * @hidden
  54636. */
  54637. export var _IDoNeedToBeInTheBuild: number;
  54638. }
  54639. declare module BABYLON {
  54640. interface Scene {
  54641. /** @hidden (Backing field) */
  54642. _physicsEngine: Nullable<IPhysicsEngine>;
  54643. /**
  54644. * Gets the current physics engine
  54645. * @returns a IPhysicsEngine or null if none attached
  54646. */
  54647. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  54648. /**
  54649. * Enables physics to the current scene
  54650. * @param gravity defines the scene's gravity for the physics engine
  54651. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  54652. * @return a boolean indicating if the physics engine was initialized
  54653. */
  54654. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  54655. /**
  54656. * Disables and disposes the physics engine associated with the scene
  54657. */
  54658. disablePhysicsEngine(): void;
  54659. /**
  54660. * Gets a boolean indicating if there is an active physics engine
  54661. * @returns a boolean indicating if there is an active physics engine
  54662. */
  54663. isPhysicsEnabled(): boolean;
  54664. /**
  54665. * Deletes a physics compound impostor
  54666. * @param compound defines the compound to delete
  54667. */
  54668. deleteCompoundImpostor(compound: any): void;
  54669. /**
  54670. * An event triggered when physic simulation is about to be run
  54671. */
  54672. onBeforePhysicsObservable: Observable<Scene>;
  54673. /**
  54674. * An event triggered when physic simulation has been done
  54675. */
  54676. onAfterPhysicsObservable: Observable<Scene>;
  54677. }
  54678. interface AbstractMesh {
  54679. /** @hidden */
  54680. _physicsImpostor: Nullable<PhysicsImpostor>;
  54681. /**
  54682. * Gets or sets impostor used for physic simulation
  54683. * @see http://doc.babylonjs.com/features/physics_engine
  54684. */
  54685. physicsImpostor: Nullable<PhysicsImpostor>;
  54686. /**
  54687. * Gets the current physics impostor
  54688. * @see http://doc.babylonjs.com/features/physics_engine
  54689. * @returns a physics impostor or null
  54690. */
  54691. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  54692. /** Apply a physic impulse to the mesh
  54693. * @param force defines the force to apply
  54694. * @param contactPoint defines where to apply the force
  54695. * @returns the current mesh
  54696. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  54697. */
  54698. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  54699. /**
  54700. * Creates a physic joint between two meshes
  54701. * @param otherMesh defines the other mesh to use
  54702. * @param pivot1 defines the pivot to use on this mesh
  54703. * @param pivot2 defines the pivot to use on the other mesh
  54704. * @param options defines additional options (can be plugin dependent)
  54705. * @returns the current mesh
  54706. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  54707. */
  54708. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  54709. /** @hidden */
  54710. _disposePhysicsObserver: Nullable<Observer<Node>>;
  54711. }
  54712. /**
  54713. * Defines the physics engine scene component responsible to manage a physics engine
  54714. */
  54715. export class PhysicsEngineSceneComponent implements ISceneComponent {
  54716. /**
  54717. * The component name helpful to identify the component in the list of scene components.
  54718. */
  54719. readonly name: string;
  54720. /**
  54721. * The scene the component belongs to.
  54722. */
  54723. scene: Scene;
  54724. /**
  54725. * Creates a new instance of the component for the given scene
  54726. * @param scene Defines the scene to register the component in
  54727. */
  54728. constructor(scene: Scene);
  54729. /**
  54730. * Registers the component in a given scene
  54731. */
  54732. register(): void;
  54733. /**
  54734. * Rebuilds the elements related to this component in case of
  54735. * context lost for instance.
  54736. */
  54737. rebuild(): void;
  54738. /**
  54739. * Disposes the component and the associated ressources
  54740. */
  54741. dispose(): void;
  54742. }
  54743. }
  54744. declare module BABYLON {
  54745. /**
  54746. * A helper for physics simulations
  54747. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54748. */
  54749. export class PhysicsHelper {
  54750. private _scene;
  54751. private _physicsEngine;
  54752. /**
  54753. * Initializes the Physics helper
  54754. * @param scene Babylon.js scene
  54755. */
  54756. constructor(scene: Scene);
  54757. /**
  54758. * Applies a radial explosion impulse
  54759. * @param origin the origin of the explosion
  54760. * @param radiusOrEventOptions the radius or the options of radial explosion
  54761. * @param strength the explosion strength
  54762. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54763. * @returns A physics radial explosion event, or null
  54764. */
  54765. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  54766. /**
  54767. * Applies a radial explosion force
  54768. * @param origin the origin of the explosion
  54769. * @param radiusOrEventOptions the radius or the options of radial explosion
  54770. * @param strength the explosion strength
  54771. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54772. * @returns A physics radial explosion event, or null
  54773. */
  54774. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  54775. /**
  54776. * Creates a gravitational field
  54777. * @param origin the origin of the explosion
  54778. * @param radiusOrEventOptions the radius or the options of radial explosion
  54779. * @param strength the explosion strength
  54780. * @param falloff possible options: Constant & Linear. Defaults to Constant
  54781. * @returns A physics gravitational field event, or null
  54782. */
  54783. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  54784. /**
  54785. * Creates a physics updraft event
  54786. * @param origin the origin of the updraft
  54787. * @param radiusOrEventOptions the radius or the options of the updraft
  54788. * @param strength the strength of the updraft
  54789. * @param height the height of the updraft
  54790. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  54791. * @returns A physics updraft event, or null
  54792. */
  54793. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  54794. /**
  54795. * Creates a physics vortex event
  54796. * @param origin the of the vortex
  54797. * @param radiusOrEventOptions the radius or the options of the vortex
  54798. * @param strength the strength of the vortex
  54799. * @param height the height of the vortex
  54800. * @returns a Physics vortex event, or null
  54801. * A physics vortex event or null
  54802. */
  54803. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  54804. }
  54805. /**
  54806. * Represents a physics radial explosion event
  54807. */
  54808. class PhysicsRadialExplosionEvent {
  54809. private _scene;
  54810. private _options;
  54811. private _sphere;
  54812. private _dataFetched;
  54813. /**
  54814. * Initializes a radial explosioin event
  54815. * @param _scene BabylonJS scene
  54816. * @param _options The options for the vortex event
  54817. */
  54818. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  54819. /**
  54820. * Returns the data related to the radial explosion event (sphere).
  54821. * @returns The radial explosion event data
  54822. */
  54823. getData(): PhysicsRadialExplosionEventData;
  54824. /**
  54825. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  54826. * @param impostor A physics imposter
  54827. * @param origin the origin of the explosion
  54828. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  54829. */
  54830. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  54831. /**
  54832. * Triggers affecterd impostors callbacks
  54833. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  54834. */
  54835. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  54836. /**
  54837. * Disposes the sphere.
  54838. * @param force Specifies if the sphere should be disposed by force
  54839. */
  54840. dispose(force?: boolean): void;
  54841. /*** Helpers ***/
  54842. private _prepareSphere;
  54843. private _intersectsWithSphere;
  54844. }
  54845. /**
  54846. * Represents a gravitational field event
  54847. */
  54848. class PhysicsGravitationalFieldEvent {
  54849. private _physicsHelper;
  54850. private _scene;
  54851. private _origin;
  54852. private _options;
  54853. private _tickCallback;
  54854. private _sphere;
  54855. private _dataFetched;
  54856. /**
  54857. * Initializes the physics gravitational field event
  54858. * @param _physicsHelper A physics helper
  54859. * @param _scene BabylonJS scene
  54860. * @param _origin The origin position of the gravitational field event
  54861. * @param _options The options for the vortex event
  54862. */
  54863. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  54864. /**
  54865. * Returns the data related to the gravitational field event (sphere).
  54866. * @returns A gravitational field event
  54867. */
  54868. getData(): PhysicsGravitationalFieldEventData;
  54869. /**
  54870. * Enables the gravitational field.
  54871. */
  54872. enable(): void;
  54873. /**
  54874. * Disables the gravitational field.
  54875. */
  54876. disable(): void;
  54877. /**
  54878. * Disposes the sphere.
  54879. * @param force The force to dispose from the gravitational field event
  54880. */
  54881. dispose(force?: boolean): void;
  54882. private _tick;
  54883. }
  54884. /**
  54885. * Represents a physics updraft event
  54886. */
  54887. class PhysicsUpdraftEvent {
  54888. private _scene;
  54889. private _origin;
  54890. private _options;
  54891. private _physicsEngine;
  54892. private _originTop;
  54893. private _originDirection;
  54894. private _tickCallback;
  54895. private _cylinder;
  54896. private _cylinderPosition;
  54897. private _dataFetched;
  54898. /**
  54899. * Initializes the physics updraft event
  54900. * @param _scene BabylonJS scene
  54901. * @param _origin The origin position of the updraft
  54902. * @param _options The options for the updraft event
  54903. */
  54904. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  54905. /**
  54906. * Returns the data related to the updraft event (cylinder).
  54907. * @returns A physics updraft event
  54908. */
  54909. getData(): PhysicsUpdraftEventData;
  54910. /**
  54911. * Enables the updraft.
  54912. */
  54913. enable(): void;
  54914. /**
  54915. * Disables the updraft.
  54916. */
  54917. disable(): void;
  54918. /**
  54919. * Disposes the cylinder.
  54920. * @param force Specifies if the updraft should be disposed by force
  54921. */
  54922. dispose(force?: boolean): void;
  54923. private getImpostorHitData;
  54924. private _tick;
  54925. /*** Helpers ***/
  54926. private _prepareCylinder;
  54927. private _intersectsWithCylinder;
  54928. }
  54929. /**
  54930. * Represents a physics vortex event
  54931. */
  54932. class PhysicsVortexEvent {
  54933. private _scene;
  54934. private _origin;
  54935. private _options;
  54936. private _physicsEngine;
  54937. private _originTop;
  54938. private _tickCallback;
  54939. private _cylinder;
  54940. private _cylinderPosition;
  54941. private _dataFetched;
  54942. /**
  54943. * Initializes the physics vortex event
  54944. * @param _scene The BabylonJS scene
  54945. * @param _origin The origin position of the vortex
  54946. * @param _options The options for the vortex event
  54947. */
  54948. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  54949. /**
  54950. * Returns the data related to the vortex event (cylinder).
  54951. * @returns The physics vortex event data
  54952. */
  54953. getData(): PhysicsVortexEventData;
  54954. /**
  54955. * Enables the vortex.
  54956. */
  54957. enable(): void;
  54958. /**
  54959. * Disables the cortex.
  54960. */
  54961. disable(): void;
  54962. /**
  54963. * Disposes the sphere.
  54964. * @param force
  54965. */
  54966. dispose(force?: boolean): void;
  54967. private getImpostorHitData;
  54968. private _tick;
  54969. /*** Helpers ***/
  54970. private _prepareCylinder;
  54971. private _intersectsWithCylinder;
  54972. }
  54973. /**
  54974. * Options fot the radial explosion event
  54975. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54976. */
  54977. export class PhysicsRadialExplosionEventOptions {
  54978. /**
  54979. * The radius of the sphere for the radial explosion.
  54980. */
  54981. radius: number;
  54982. /**
  54983. * The strenth of the explosion.
  54984. */
  54985. strength: number;
  54986. /**
  54987. * The strenght of the force in correspondence to the distance of the affected object
  54988. */
  54989. falloff: PhysicsRadialImpulseFalloff;
  54990. /**
  54991. * Sphere options for the radial explosion.
  54992. */
  54993. sphere: {
  54994. segments: number;
  54995. diameter: number;
  54996. };
  54997. /**
  54998. * Sphere options for the radial explosion.
  54999. */
  55000. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  55001. }
  55002. /**
  55003. * Options fot the updraft event
  55004. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55005. */
  55006. export class PhysicsUpdraftEventOptions {
  55007. /**
  55008. * The radius of the cylinder for the vortex
  55009. */
  55010. radius: number;
  55011. /**
  55012. * The strenth of the updraft.
  55013. */
  55014. strength: number;
  55015. /**
  55016. * The height of the cylinder for the updraft.
  55017. */
  55018. height: number;
  55019. /**
  55020. * The mode for the the updraft.
  55021. */
  55022. updraftMode: PhysicsUpdraftMode;
  55023. }
  55024. /**
  55025. * Options fot the vortex event
  55026. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55027. */
  55028. export class PhysicsVortexEventOptions {
  55029. /**
  55030. * The radius of the cylinder for the vortex
  55031. */
  55032. radius: number;
  55033. /**
  55034. * The strenth of the vortex.
  55035. */
  55036. strength: number;
  55037. /**
  55038. * The height of the cylinder for the vortex.
  55039. */
  55040. height: number;
  55041. /**
  55042. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  55043. */
  55044. centripetalForceThreshold: number;
  55045. /**
  55046. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  55047. */
  55048. centripetalForceMultiplier: number;
  55049. /**
  55050. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  55051. */
  55052. centrifugalForceMultiplier: number;
  55053. /**
  55054. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  55055. */
  55056. updraftForceMultiplier: number;
  55057. }
  55058. /**
  55059. * The strenght of the force in correspondence to the distance of the affected object
  55060. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55061. */
  55062. export enum PhysicsRadialImpulseFalloff {
  55063. /** Defines that impulse is constant in strength across it's whole radius */
  55064. Constant = 0,
  55065. /** Defines that impulse gets weaker if it's further from the origin */
  55066. Linear = 1
  55067. }
  55068. /**
  55069. * The strength of the force in correspondence to the distance of the affected object
  55070. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55071. */
  55072. export enum PhysicsUpdraftMode {
  55073. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  55074. Center = 0,
  55075. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  55076. Perpendicular = 1
  55077. }
  55078. /**
  55079. * Interface for a physics hit data
  55080. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55081. */
  55082. export interface PhysicsHitData {
  55083. /**
  55084. * The force applied at the contact point
  55085. */
  55086. force: Vector3;
  55087. /**
  55088. * The contact point
  55089. */
  55090. contactPoint: Vector3;
  55091. /**
  55092. * The distance from the origin to the contact point
  55093. */
  55094. distanceFromOrigin: number;
  55095. }
  55096. /**
  55097. * Interface for radial explosion event data
  55098. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55099. */
  55100. export interface PhysicsRadialExplosionEventData {
  55101. /**
  55102. * A sphere used for the radial explosion event
  55103. */
  55104. sphere: Mesh;
  55105. }
  55106. /**
  55107. * Interface for gravitational field event data
  55108. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55109. */
  55110. export interface PhysicsGravitationalFieldEventData {
  55111. /**
  55112. * A sphere mesh used for the gravitational field event
  55113. */
  55114. sphere: Mesh;
  55115. }
  55116. /**
  55117. * Interface for updraft event data
  55118. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55119. */
  55120. export interface PhysicsUpdraftEventData {
  55121. /**
  55122. * A cylinder used for the updraft event
  55123. */
  55124. cylinder: Mesh;
  55125. }
  55126. /**
  55127. * Interface for vortex event data
  55128. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55129. */
  55130. export interface PhysicsVortexEventData {
  55131. /**
  55132. * A cylinder used for the vortex event
  55133. */
  55134. cylinder: Mesh;
  55135. }
  55136. /**
  55137. * Interface for an affected physics impostor
  55138. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55139. */
  55140. export interface PhysicsAffectedImpostorWithData {
  55141. /**
  55142. * The impostor affected by the effect
  55143. */
  55144. impostor: PhysicsImpostor;
  55145. /**
  55146. * The data about the hit/horce from the explosion
  55147. */
  55148. hitData: PhysicsHitData;
  55149. }
  55150. }
  55151. declare module BABYLON {
  55152. /** @hidden */
  55153. export var blackAndWhitePixelShader: {
  55154. name: string;
  55155. shader: string;
  55156. };
  55157. }
  55158. declare module BABYLON {
  55159. /**
  55160. * Post process used to render in black and white
  55161. */
  55162. export class BlackAndWhitePostProcess extends PostProcess {
  55163. /**
  55164. * Linear about to convert he result to black and white (default: 1)
  55165. */
  55166. degree: number;
  55167. /**
  55168. * Creates a black and white post process
  55169. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  55170. * @param name The name of the effect.
  55171. * @param options The required width/height ratio to downsize to before computing the render pass.
  55172. * @param camera The camera to apply the render pass to.
  55173. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55174. * @param engine The engine which the post process will be applied. (default: current engine)
  55175. * @param reusable If the post process can be reused on the same frame. (default: false)
  55176. */
  55177. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55178. }
  55179. }
  55180. declare module BABYLON {
  55181. /**
  55182. * This represents a set of one or more post processes in Babylon.
  55183. * A post process can be used to apply a shader to a texture after it is rendered.
  55184. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55185. */
  55186. export class PostProcessRenderEffect {
  55187. private _postProcesses;
  55188. private _getPostProcesses;
  55189. private _singleInstance;
  55190. private _cameras;
  55191. private _indicesForCamera;
  55192. /**
  55193. * Name of the effect
  55194. * @hidden
  55195. */
  55196. _name: string;
  55197. /**
  55198. * Instantiates a post process render effect.
  55199. * A post process can be used to apply a shader to a texture after it is rendered.
  55200. * @param engine The engine the effect is tied to
  55201. * @param name The name of the effect
  55202. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  55203. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  55204. */
  55205. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  55206. /**
  55207. * Checks if all the post processes in the effect are supported.
  55208. */
  55209. readonly isSupported: boolean;
  55210. /**
  55211. * Updates the current state of the effect
  55212. * @hidden
  55213. */
  55214. _update(): void;
  55215. /**
  55216. * Attaches the effect on cameras
  55217. * @param cameras The camera to attach to.
  55218. * @hidden
  55219. */
  55220. _attachCameras(cameras: Camera): void;
  55221. /**
  55222. * Attaches the effect on cameras
  55223. * @param cameras The camera to attach to.
  55224. * @hidden
  55225. */
  55226. _attachCameras(cameras: Camera[]): void;
  55227. /**
  55228. * Detaches the effect on cameras
  55229. * @param cameras The camera to detatch from.
  55230. * @hidden
  55231. */
  55232. _detachCameras(cameras: Camera): void;
  55233. /**
  55234. * Detatches the effect on cameras
  55235. * @param cameras The camera to detatch from.
  55236. * @hidden
  55237. */
  55238. _detachCameras(cameras: Camera[]): void;
  55239. /**
  55240. * Enables the effect on given cameras
  55241. * @param cameras The camera to enable.
  55242. * @hidden
  55243. */
  55244. _enable(cameras: Camera): void;
  55245. /**
  55246. * Enables the effect on given cameras
  55247. * @param cameras The camera to enable.
  55248. * @hidden
  55249. */
  55250. _enable(cameras: Nullable<Camera[]>): void;
  55251. /**
  55252. * Disables the effect on the given cameras
  55253. * @param cameras The camera to disable.
  55254. * @hidden
  55255. */
  55256. _disable(cameras: Camera): void;
  55257. /**
  55258. * Disables the effect on the given cameras
  55259. * @param cameras The camera to disable.
  55260. * @hidden
  55261. */
  55262. _disable(cameras: Nullable<Camera[]>): void;
  55263. /**
  55264. * Gets a list of the post processes contained in the effect.
  55265. * @param camera The camera to get the post processes on.
  55266. * @returns The list of the post processes in the effect.
  55267. */
  55268. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  55269. }
  55270. }
  55271. declare module BABYLON {
  55272. /** @hidden */
  55273. export var extractHighlightsPixelShader: {
  55274. name: string;
  55275. shader: string;
  55276. };
  55277. }
  55278. declare module BABYLON {
  55279. /**
  55280. * 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.
  55281. */
  55282. export class ExtractHighlightsPostProcess extends PostProcess {
  55283. /**
  55284. * The luminance threshold, pixels below this value will be set to black.
  55285. */
  55286. threshold: number;
  55287. /** @hidden */
  55288. _exposure: number;
  55289. /**
  55290. * Post process which has the input texture to be used when performing highlight extraction
  55291. * @hidden
  55292. */
  55293. _inputPostProcess: Nullable<PostProcess>;
  55294. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55295. }
  55296. }
  55297. declare module BABYLON {
  55298. /** @hidden */
  55299. export var bloomMergePixelShader: {
  55300. name: string;
  55301. shader: string;
  55302. };
  55303. }
  55304. declare module BABYLON {
  55305. /**
  55306. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  55307. */
  55308. export class BloomMergePostProcess extends PostProcess {
  55309. /** Weight of the bloom to be added to the original input. */
  55310. weight: number;
  55311. /**
  55312. * Creates a new instance of @see BloomMergePostProcess
  55313. * @param name The name of the effect.
  55314. * @param originalFromInput Post process which's input will be used for the merge.
  55315. * @param blurred Blurred highlights post process which's output will be used.
  55316. * @param weight Weight of the bloom to be added to the original input.
  55317. * @param options The required width/height ratio to downsize to before computing the render pass.
  55318. * @param camera The camera to apply the render pass to.
  55319. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55320. * @param engine The engine which the post process will be applied. (default: current engine)
  55321. * @param reusable If the post process can be reused on the same frame. (default: false)
  55322. * @param textureType Type of textures used when performing the post process. (default: 0)
  55323. * @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)
  55324. */
  55325. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  55326. /** Weight of the bloom to be added to the original input. */
  55327. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55328. }
  55329. }
  55330. declare module BABYLON {
  55331. /**
  55332. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  55333. */
  55334. export class BloomEffect extends PostProcessRenderEffect {
  55335. private bloomScale;
  55336. /**
  55337. * @hidden Internal
  55338. */
  55339. _effects: Array<PostProcess>;
  55340. /**
  55341. * @hidden Internal
  55342. */
  55343. _downscale: ExtractHighlightsPostProcess;
  55344. private _blurX;
  55345. private _blurY;
  55346. private _merge;
  55347. /**
  55348. * The luminance threshold to find bright areas of the image to bloom.
  55349. */
  55350. threshold: number;
  55351. /**
  55352. * The strength of the bloom.
  55353. */
  55354. weight: number;
  55355. /**
  55356. * Specifies the size of the bloom blur kernel, relative to the final output size
  55357. */
  55358. kernel: number;
  55359. /**
  55360. * Creates a new instance of @see BloomEffect
  55361. * @param scene The scene the effect belongs to.
  55362. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  55363. * @param bloomKernel The size of the kernel to be used when applying the blur.
  55364. * @param bloomWeight The the strength of bloom.
  55365. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  55366. * @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)
  55367. */
  55368. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  55369. /**
  55370. * Disposes each of the internal effects for a given camera.
  55371. * @param camera The camera to dispose the effect on.
  55372. */
  55373. disposeEffects(camera: Camera): void;
  55374. /**
  55375. * @hidden Internal
  55376. */
  55377. _updateEffects(): void;
  55378. /**
  55379. * Internal
  55380. * @returns if all the contained post processes are ready.
  55381. * @hidden
  55382. */
  55383. _isReady(): boolean;
  55384. }
  55385. }
  55386. declare module BABYLON {
  55387. /** @hidden */
  55388. export var chromaticAberrationPixelShader: {
  55389. name: string;
  55390. shader: string;
  55391. };
  55392. }
  55393. declare module BABYLON {
  55394. /**
  55395. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  55396. */
  55397. export class ChromaticAberrationPostProcess extends PostProcess {
  55398. /**
  55399. * The amount of seperation of rgb channels (default: 30)
  55400. */
  55401. aberrationAmount: number;
  55402. /**
  55403. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  55404. */
  55405. radialIntensity: number;
  55406. /**
  55407. * 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))
  55408. */
  55409. direction: Vector2;
  55410. /**
  55411. * 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))
  55412. */
  55413. centerPosition: Vector2;
  55414. /**
  55415. * Creates a new instance ChromaticAberrationPostProcess
  55416. * @param name The name of the effect.
  55417. * @param screenWidth The width of the screen to apply the effect on.
  55418. * @param screenHeight The height of the screen to apply the effect on.
  55419. * @param options The required width/height ratio to downsize to before computing the render pass.
  55420. * @param camera The camera to apply the render pass to.
  55421. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55422. * @param engine The engine which the post process will be applied. (default: current engine)
  55423. * @param reusable If the post process can be reused on the same frame. (default: false)
  55424. * @param textureType Type of textures used when performing the post process. (default: 0)
  55425. * @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)
  55426. */
  55427. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55428. }
  55429. }
  55430. declare module BABYLON {
  55431. /** @hidden */
  55432. export var circleOfConfusionPixelShader: {
  55433. name: string;
  55434. shader: string;
  55435. };
  55436. }
  55437. declare module BABYLON {
  55438. /**
  55439. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  55440. */
  55441. export class CircleOfConfusionPostProcess extends PostProcess {
  55442. /**
  55443. * 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.
  55444. */
  55445. lensSize: number;
  55446. /**
  55447. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  55448. */
  55449. fStop: number;
  55450. /**
  55451. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  55452. */
  55453. focusDistance: number;
  55454. /**
  55455. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  55456. */
  55457. focalLength: number;
  55458. private _depthTexture;
  55459. /**
  55460. * Creates a new instance CircleOfConfusionPostProcess
  55461. * @param name The name of the effect.
  55462. * @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.
  55463. * @param options The required width/height ratio to downsize to before computing the render pass.
  55464. * @param camera The camera to apply the render pass to.
  55465. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55466. * @param engine The engine which the post process will be applied. (default: current engine)
  55467. * @param reusable If the post process can be reused on the same frame. (default: false)
  55468. * @param textureType Type of textures used when performing the post process. (default: 0)
  55469. * @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)
  55470. */
  55471. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55472. /**
  55473. * 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.
  55474. */
  55475. depthTexture: RenderTargetTexture;
  55476. }
  55477. }
  55478. declare module BABYLON {
  55479. /** @hidden */
  55480. export var colorCorrectionPixelShader: {
  55481. name: string;
  55482. shader: string;
  55483. };
  55484. }
  55485. declare module BABYLON {
  55486. /**
  55487. *
  55488. * This post-process allows the modification of rendered colors by using
  55489. * a 'look-up table' (LUT). This effect is also called Color Grading.
  55490. *
  55491. * The object needs to be provided an url to a texture containing the color
  55492. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  55493. * Use an image editing software to tweak the LUT to match your needs.
  55494. *
  55495. * For an example of a color LUT, see here:
  55496. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  55497. * For explanations on color grading, see here:
  55498. * @see http://udn.epicgames.com/Three/ColorGrading.html
  55499. *
  55500. */
  55501. export class ColorCorrectionPostProcess extends PostProcess {
  55502. private _colorTableTexture;
  55503. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55504. }
  55505. }
  55506. declare module BABYLON {
  55507. /** @hidden */
  55508. export var convolutionPixelShader: {
  55509. name: string;
  55510. shader: string;
  55511. };
  55512. }
  55513. declare module BABYLON {
  55514. /**
  55515. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  55516. * input texture to perform effects such as edge detection or sharpening
  55517. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  55518. */
  55519. export class ConvolutionPostProcess extends PostProcess {
  55520. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  55521. kernel: number[];
  55522. /**
  55523. * Creates a new instance ConvolutionPostProcess
  55524. * @param name The name of the effect.
  55525. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  55526. * @param options The required width/height ratio to downsize to before computing the render pass.
  55527. * @param camera The camera to apply the render pass to.
  55528. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55529. * @param engine The engine which the post process will be applied. (default: current engine)
  55530. * @param reusable If the post process can be reused on the same frame. (default: false)
  55531. * @param textureType Type of textures used when performing the post process. (default: 0)
  55532. */
  55533. constructor(name: string,
  55534. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  55535. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55536. /**
  55537. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55538. */
  55539. static EdgeDetect0Kernel: number[];
  55540. /**
  55541. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55542. */
  55543. static EdgeDetect1Kernel: number[];
  55544. /**
  55545. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55546. */
  55547. static EdgeDetect2Kernel: number[];
  55548. /**
  55549. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55550. */
  55551. static SharpenKernel: number[];
  55552. /**
  55553. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55554. */
  55555. static EmbossKernel: number[];
  55556. /**
  55557. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  55558. */
  55559. static GaussianKernel: number[];
  55560. }
  55561. }
  55562. declare module BABYLON {
  55563. /**
  55564. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  55565. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  55566. * based on samples that have a large difference in distance than the center pixel.
  55567. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  55568. */
  55569. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  55570. direction: Vector2;
  55571. /**
  55572. * Creates a new instance CircleOfConfusionPostProcess
  55573. * @param name The name of the effect.
  55574. * @param scene The scene the effect belongs to.
  55575. * @param direction The direction the blur should be applied.
  55576. * @param kernel The size of the kernel used to blur.
  55577. * @param options The required width/height ratio to downsize to before computing the render pass.
  55578. * @param camera The camera to apply the render pass to.
  55579. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  55580. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  55581. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55582. * @param engine The engine which the post process will be applied. (default: current engine)
  55583. * @param reusable If the post process can be reused on the same frame. (default: false)
  55584. * @param textureType Type of textures used when performing the post process. (default: 0)
  55585. * @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)
  55586. */
  55587. 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);
  55588. }
  55589. }
  55590. declare module BABYLON {
  55591. /** @hidden */
  55592. export var depthOfFieldMergePixelShader: {
  55593. name: string;
  55594. shader: string;
  55595. };
  55596. }
  55597. declare module BABYLON {
  55598. /**
  55599. * Options to be set when merging outputs from the default pipeline.
  55600. */
  55601. export class DepthOfFieldMergePostProcessOptions {
  55602. /**
  55603. * The original image to merge on top of
  55604. */
  55605. originalFromInput: PostProcess;
  55606. /**
  55607. * Parameters to perform the merge of the depth of field effect
  55608. */
  55609. depthOfField?: {
  55610. circleOfConfusion: PostProcess;
  55611. blurSteps: Array<PostProcess>;
  55612. };
  55613. /**
  55614. * Parameters to perform the merge of bloom effect
  55615. */
  55616. bloom?: {
  55617. blurred: PostProcess;
  55618. weight: number;
  55619. };
  55620. }
  55621. /**
  55622. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  55623. */
  55624. export class DepthOfFieldMergePostProcess extends PostProcess {
  55625. private blurSteps;
  55626. /**
  55627. * Creates a new instance of DepthOfFieldMergePostProcess
  55628. * @param name The name of the effect.
  55629. * @param originalFromInput Post process which's input will be used for the merge.
  55630. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  55631. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  55632. * @param options The required width/height ratio to downsize to before computing the render pass.
  55633. * @param camera The camera to apply the render pass to.
  55634. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55635. * @param engine The engine which the post process will be applied. (default: current engine)
  55636. * @param reusable If the post process can be reused on the same frame. (default: false)
  55637. * @param textureType Type of textures used when performing the post process. (default: 0)
  55638. * @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)
  55639. */
  55640. 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);
  55641. /**
  55642. * Updates the effect with the current post process compile time values and recompiles the shader.
  55643. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  55644. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  55645. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  55646. * @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
  55647. * @param onCompiled Called when the shader has been compiled.
  55648. * @param onError Called if there is an error when compiling a shader.
  55649. */
  55650. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  55651. }
  55652. }
  55653. declare module BABYLON {
  55654. /**
  55655. * Specifies the level of max blur that should be applied when using the depth of field effect
  55656. */
  55657. export enum DepthOfFieldEffectBlurLevel {
  55658. /**
  55659. * Subtle blur
  55660. */
  55661. Low = 0,
  55662. /**
  55663. * Medium blur
  55664. */
  55665. Medium = 1,
  55666. /**
  55667. * Large blur
  55668. */
  55669. High = 2
  55670. }
  55671. /**
  55672. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  55673. */
  55674. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  55675. private _circleOfConfusion;
  55676. /**
  55677. * @hidden Internal, blurs from high to low
  55678. */
  55679. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  55680. private _depthOfFieldBlurY;
  55681. private _dofMerge;
  55682. /**
  55683. * @hidden Internal post processes in depth of field effect
  55684. */
  55685. _effects: Array<PostProcess>;
  55686. /**
  55687. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  55688. */
  55689. focalLength: number;
  55690. /**
  55691. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  55692. */
  55693. fStop: number;
  55694. /**
  55695. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  55696. */
  55697. focusDistance: number;
  55698. /**
  55699. * 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.
  55700. */
  55701. lensSize: number;
  55702. /**
  55703. * Creates a new instance DepthOfFieldEffect
  55704. * @param scene The scene the effect belongs to.
  55705. * @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.
  55706. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  55707. * @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)
  55708. */
  55709. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  55710. /**
  55711. * Get the current class name of the current effet
  55712. * @returns "DepthOfFieldEffect"
  55713. */
  55714. getClassName(): string;
  55715. /**
  55716. * 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.
  55717. */
  55718. depthTexture: RenderTargetTexture;
  55719. /**
  55720. * Disposes each of the internal effects for a given camera.
  55721. * @param camera The camera to dispose the effect on.
  55722. */
  55723. disposeEffects(camera: Camera): void;
  55724. /**
  55725. * @hidden Internal
  55726. */
  55727. _updateEffects(): void;
  55728. /**
  55729. * Internal
  55730. * @returns if all the contained post processes are ready.
  55731. * @hidden
  55732. */
  55733. _isReady(): boolean;
  55734. }
  55735. }
  55736. declare module BABYLON {
  55737. /** @hidden */
  55738. export var displayPassPixelShader: {
  55739. name: string;
  55740. shader: string;
  55741. };
  55742. }
  55743. declare module BABYLON {
  55744. /**
  55745. * DisplayPassPostProcess which produces an output the same as it's input
  55746. */
  55747. export class DisplayPassPostProcess extends PostProcess {
  55748. /**
  55749. * Creates the DisplayPassPostProcess
  55750. * @param name The name of the effect.
  55751. * @param options The required width/height ratio to downsize to before computing the render pass.
  55752. * @param camera The camera to apply the render pass to.
  55753. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55754. * @param engine The engine which the post process will be applied. (default: current engine)
  55755. * @param reusable If the post process can be reused on the same frame. (default: false)
  55756. */
  55757. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55758. }
  55759. }
  55760. declare module BABYLON {
  55761. /** @hidden */
  55762. export var filterPixelShader: {
  55763. name: string;
  55764. shader: string;
  55765. };
  55766. }
  55767. declare module BABYLON {
  55768. /**
  55769. * Applies a kernel filter to the image
  55770. */
  55771. export class FilterPostProcess extends PostProcess {
  55772. /** The matrix to be applied to the image */
  55773. kernelMatrix: Matrix;
  55774. /**
  55775. *
  55776. * @param name The name of the effect.
  55777. * @param kernelMatrix The matrix to be applied to the image
  55778. * @param options The required width/height ratio to downsize to before computing the render pass.
  55779. * @param camera The camera to apply the render pass to.
  55780. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55781. * @param engine The engine which the post process will be applied. (default: current engine)
  55782. * @param reusable If the post process can be reused on the same frame. (default: false)
  55783. */
  55784. constructor(name: string,
  55785. /** The matrix to be applied to the image */
  55786. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55787. }
  55788. }
  55789. declare module BABYLON {
  55790. /** @hidden */
  55791. export var fxaaPixelShader: {
  55792. name: string;
  55793. shader: string;
  55794. };
  55795. }
  55796. declare module BABYLON {
  55797. /** @hidden */
  55798. export var fxaaVertexShader: {
  55799. name: string;
  55800. shader: string;
  55801. };
  55802. }
  55803. declare module BABYLON {
  55804. /**
  55805. * Fxaa post process
  55806. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  55807. */
  55808. export class FxaaPostProcess extends PostProcess {
  55809. /** @hidden */
  55810. texelWidth: number;
  55811. /** @hidden */
  55812. texelHeight: number;
  55813. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55814. private _getDefines;
  55815. }
  55816. }
  55817. declare module BABYLON {
  55818. /** @hidden */
  55819. export var grainPixelShader: {
  55820. name: string;
  55821. shader: string;
  55822. };
  55823. }
  55824. declare module BABYLON {
  55825. /**
  55826. * The GrainPostProcess adds noise to the image at mid luminance levels
  55827. */
  55828. export class GrainPostProcess extends PostProcess {
  55829. /**
  55830. * The intensity of the grain added (default: 30)
  55831. */
  55832. intensity: number;
  55833. /**
  55834. * If the grain should be randomized on every frame
  55835. */
  55836. animated: boolean;
  55837. /**
  55838. * Creates a new instance of @see GrainPostProcess
  55839. * @param name The name of the effect.
  55840. * @param options The required width/height ratio to downsize to before computing the render pass.
  55841. * @param camera The camera to apply the render pass to.
  55842. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55843. * @param engine The engine which the post process will be applied. (default: current engine)
  55844. * @param reusable If the post process can be reused on the same frame. (default: false)
  55845. * @param textureType Type of textures used when performing the post process. (default: 0)
  55846. * @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)
  55847. */
  55848. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55849. }
  55850. }
  55851. declare module BABYLON {
  55852. /** @hidden */
  55853. export var highlightsPixelShader: {
  55854. name: string;
  55855. shader: string;
  55856. };
  55857. }
  55858. declare module BABYLON {
  55859. /**
  55860. * Extracts highlights from the image
  55861. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  55862. */
  55863. export class HighlightsPostProcess extends PostProcess {
  55864. /**
  55865. * Extracts highlights from the image
  55866. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  55867. * @param name The name of the effect.
  55868. * @param options The required width/height ratio to downsize to before computing the render pass.
  55869. * @param camera The camera to apply the render pass to.
  55870. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55871. * @param engine The engine which the post process will be applied. (default: current engine)
  55872. * @param reusable If the post process can be reused on the same frame. (default: false)
  55873. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  55874. */
  55875. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55876. }
  55877. }
  55878. declare module BABYLON {
  55879. /** @hidden */
  55880. export var mrtFragmentDeclaration: {
  55881. name: string;
  55882. shader: string;
  55883. };
  55884. }
  55885. declare module BABYLON {
  55886. /** @hidden */
  55887. export var geometryPixelShader: {
  55888. name: string;
  55889. shader: string;
  55890. };
  55891. }
  55892. declare module BABYLON {
  55893. /** @hidden */
  55894. export var geometryVertexShader: {
  55895. name: string;
  55896. shader: string;
  55897. };
  55898. }
  55899. declare module BABYLON {
  55900. /** @hidden */
  55901. interface ISavedTransformationMatrix {
  55902. world: Matrix;
  55903. viewProjection: Matrix;
  55904. }
  55905. /**
  55906. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  55907. */
  55908. export class GeometryBufferRenderer {
  55909. /**
  55910. * Constant used to retrieve the position texture index in the G-Buffer textures array
  55911. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  55912. */
  55913. static readonly POSITION_TEXTURE_TYPE: number;
  55914. /**
  55915. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  55916. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  55917. */
  55918. static readonly VELOCITY_TEXTURE_TYPE: number;
  55919. /**
  55920. * Dictionary used to store the previous transformation matrices of each rendered mesh
  55921. * in order to compute objects velocities when enableVelocity is set to "true"
  55922. * @hidden
  55923. */
  55924. _previousTransformationMatrices: {
  55925. [index: number]: ISavedTransformationMatrix;
  55926. };
  55927. /**
  55928. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  55929. * in order to compute objects velocities when enableVelocity is set to "true"
  55930. * @hidden
  55931. */
  55932. _previousBonesTransformationMatrices: {
  55933. [index: number]: Float32Array;
  55934. };
  55935. /**
  55936. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  55937. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  55938. */
  55939. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  55940. private _scene;
  55941. private _multiRenderTarget;
  55942. private _ratio;
  55943. private _enablePosition;
  55944. private _enableVelocity;
  55945. private _positionIndex;
  55946. private _velocityIndex;
  55947. protected _effect: Effect;
  55948. protected _cachedDefines: string;
  55949. /**
  55950. * Set the render list (meshes to be rendered) used in the G buffer.
  55951. */
  55952. renderList: Mesh[];
  55953. /**
  55954. * Gets wether or not G buffer are supported by the running hardware.
  55955. * This requires draw buffer supports
  55956. */
  55957. readonly isSupported: boolean;
  55958. /**
  55959. * Returns the index of the given texture type in the G-Buffer textures array
  55960. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  55961. * @returns the index of the given texture type in the G-Buffer textures array
  55962. */
  55963. getTextureIndex(textureType: number): number;
  55964. /**
  55965. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  55966. */
  55967. /**
  55968. * Sets whether or not objects positions are enabled for the G buffer.
  55969. */
  55970. enablePosition: boolean;
  55971. /**
  55972. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  55973. */
  55974. /**
  55975. * Sets wether or not objects velocities are enabled for the G buffer.
  55976. */
  55977. enableVelocity: boolean;
  55978. /**
  55979. * Gets the scene associated with the buffer.
  55980. */
  55981. readonly scene: Scene;
  55982. /**
  55983. * Gets the ratio used by the buffer during its creation.
  55984. * How big is the buffer related to the main canvas.
  55985. */
  55986. readonly ratio: number;
  55987. /** @hidden */
  55988. static _SceneComponentInitialization: (scene: Scene) => void;
  55989. /**
  55990. * Creates a new G Buffer for the scene
  55991. * @param scene The scene the buffer belongs to
  55992. * @param ratio How big is the buffer related to the main canvas.
  55993. */
  55994. constructor(scene: Scene, ratio?: number);
  55995. /**
  55996. * Checks wether everything is ready to render a submesh to the G buffer.
  55997. * @param subMesh the submesh to check readiness for
  55998. * @param useInstances is the mesh drawn using instance or not
  55999. * @returns true if ready otherwise false
  56000. */
  56001. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56002. /**
  56003. * Gets the current underlying G Buffer.
  56004. * @returns the buffer
  56005. */
  56006. getGBuffer(): MultiRenderTarget;
  56007. /**
  56008. * Gets the number of samples used to render the buffer (anti aliasing).
  56009. */
  56010. /**
  56011. * Sets the number of samples used to render the buffer (anti aliasing).
  56012. */
  56013. samples: number;
  56014. /**
  56015. * Disposes the renderer and frees up associated resources.
  56016. */
  56017. dispose(): void;
  56018. protected _createRenderTargets(): void;
  56019. private _copyBonesTransformationMatrices;
  56020. }
  56021. }
  56022. declare module BABYLON {
  56023. interface Scene {
  56024. /** @hidden (Backing field) */
  56025. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  56026. /**
  56027. * Gets or Sets the current geometry buffer associated to the scene.
  56028. */
  56029. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  56030. /**
  56031. * Enables a GeometryBufferRender and associates it with the scene
  56032. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  56033. * @returns the GeometryBufferRenderer
  56034. */
  56035. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  56036. /**
  56037. * Disables the GeometryBufferRender associated with the scene
  56038. */
  56039. disableGeometryBufferRenderer(): void;
  56040. }
  56041. /**
  56042. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  56043. * in several rendering techniques.
  56044. */
  56045. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  56046. /**
  56047. * The component name helpful to identify the component in the list of scene components.
  56048. */
  56049. readonly name: string;
  56050. /**
  56051. * The scene the component belongs to.
  56052. */
  56053. scene: Scene;
  56054. /**
  56055. * Creates a new instance of the component for the given scene
  56056. * @param scene Defines the scene to register the component in
  56057. */
  56058. constructor(scene: Scene);
  56059. /**
  56060. * Registers the component in a given scene
  56061. */
  56062. register(): void;
  56063. /**
  56064. * Rebuilds the elements related to this component in case of
  56065. * context lost for instance.
  56066. */
  56067. rebuild(): void;
  56068. /**
  56069. * Disposes the component and the associated ressources
  56070. */
  56071. dispose(): void;
  56072. private _gatherRenderTargets;
  56073. }
  56074. }
  56075. declare module BABYLON {
  56076. /** @hidden */
  56077. export var motionBlurPixelShader: {
  56078. name: string;
  56079. shader: string;
  56080. };
  56081. }
  56082. declare module BABYLON {
  56083. /**
  56084. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  56085. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  56086. * As an example, all you have to do is to create the post-process:
  56087. * var mb = new BABYLON.MotionBlurPostProcess(
  56088. * 'mb', // The name of the effect.
  56089. * scene, // The scene containing the objects to blur according to their velocity.
  56090. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  56091. * camera // The camera to apply the render pass to.
  56092. * );
  56093. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  56094. */
  56095. export class MotionBlurPostProcess extends PostProcess {
  56096. /**
  56097. * Defines how much the image is blurred by the movement. Default value is equal to 1
  56098. */
  56099. motionStrength: number;
  56100. /**
  56101. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  56102. */
  56103. /**
  56104. * Sets the number of iterations to be used for motion blur quality
  56105. */
  56106. motionBlurSamples: number;
  56107. private _motionBlurSamples;
  56108. private _geometryBufferRenderer;
  56109. /**
  56110. * Creates a new instance MotionBlurPostProcess
  56111. * @param name The name of the effect.
  56112. * @param scene The scene containing the objects to blur according to their velocity.
  56113. * @param options The required width/height ratio to downsize to before computing the render pass.
  56114. * @param camera The camera to apply the render pass to.
  56115. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56116. * @param engine The engine which the post process will be applied. (default: current engine)
  56117. * @param reusable If the post process can be reused on the same frame. (default: false)
  56118. * @param textureType Type of textures used when performing the post process. (default: 0)
  56119. * @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)
  56120. */
  56121. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  56122. /**
  56123. * Excludes the given skinned mesh from computing bones velocities.
  56124. * 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.
  56125. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  56126. */
  56127. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  56128. /**
  56129. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  56130. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  56131. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  56132. */
  56133. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  56134. /**
  56135. * Disposes the post process.
  56136. * @param camera The camera to dispose the post process on.
  56137. */
  56138. dispose(camera?: Camera): void;
  56139. }
  56140. }
  56141. declare module BABYLON {
  56142. /** @hidden */
  56143. export var refractionPixelShader: {
  56144. name: string;
  56145. shader: string;
  56146. };
  56147. }
  56148. declare module BABYLON {
  56149. /**
  56150. * Post process which applies a refractin texture
  56151. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  56152. */
  56153. export class RefractionPostProcess extends PostProcess {
  56154. /** the base color of the refraction (used to taint the rendering) */
  56155. color: Color3;
  56156. /** simulated refraction depth */
  56157. depth: number;
  56158. /** the coefficient of the base color (0 to remove base color tainting) */
  56159. colorLevel: number;
  56160. private _refTexture;
  56161. private _ownRefractionTexture;
  56162. /**
  56163. * Gets or sets the refraction texture
  56164. * Please note that you are responsible for disposing the texture if you set it manually
  56165. */
  56166. refractionTexture: Texture;
  56167. /**
  56168. * Initializes the RefractionPostProcess
  56169. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  56170. * @param name The name of the effect.
  56171. * @param refractionTextureUrl Url of the refraction texture to use
  56172. * @param color the base color of the refraction (used to taint the rendering)
  56173. * @param depth simulated refraction depth
  56174. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  56175. * @param camera The camera to apply the render pass to.
  56176. * @param options The required width/height ratio to downsize to before computing the render pass.
  56177. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56178. * @param engine The engine which the post process will be applied. (default: current engine)
  56179. * @param reusable If the post process can be reused on the same frame. (default: false)
  56180. */
  56181. constructor(name: string, refractionTextureUrl: string,
  56182. /** the base color of the refraction (used to taint the rendering) */
  56183. color: Color3,
  56184. /** simulated refraction depth */
  56185. depth: number,
  56186. /** the coefficient of the base color (0 to remove base color tainting) */
  56187. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  56188. /**
  56189. * Disposes of the post process
  56190. * @param camera Camera to dispose post process on
  56191. */
  56192. dispose(camera: Camera): void;
  56193. }
  56194. }
  56195. declare module BABYLON {
  56196. /** @hidden */
  56197. export var sharpenPixelShader: {
  56198. name: string;
  56199. shader: string;
  56200. };
  56201. }
  56202. declare module BABYLON {
  56203. /**
  56204. * The SharpenPostProcess applies a sharpen kernel to every pixel
  56205. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  56206. */
  56207. export class SharpenPostProcess extends PostProcess {
  56208. /**
  56209. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  56210. */
  56211. colorAmount: number;
  56212. /**
  56213. * How much sharpness should be applied (default: 0.3)
  56214. */
  56215. edgeAmount: number;
  56216. /**
  56217. * Creates a new instance ConvolutionPostProcess
  56218. * @param name The name of the effect.
  56219. * @param options The required width/height ratio to downsize to before computing the render pass.
  56220. * @param camera The camera to apply the render pass to.
  56221. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56222. * @param engine The engine which the post process will be applied. (default: current engine)
  56223. * @param reusable If the post process can be reused on the same frame. (default: false)
  56224. * @param textureType Type of textures used when performing the post process. (default: 0)
  56225. * @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)
  56226. */
  56227. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  56228. }
  56229. }
  56230. declare module BABYLON {
  56231. /**
  56232. * PostProcessRenderPipeline
  56233. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  56234. */
  56235. export class PostProcessRenderPipeline {
  56236. private engine;
  56237. private _renderEffects;
  56238. private _renderEffectsForIsolatedPass;
  56239. /**
  56240. * List of inspectable custom properties (used by the Inspector)
  56241. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  56242. */
  56243. inspectableCustomProperties: IInspectable[];
  56244. /**
  56245. * @hidden
  56246. */
  56247. protected _cameras: Camera[];
  56248. /** @hidden */
  56249. _name: string;
  56250. /**
  56251. * Gets pipeline name
  56252. */
  56253. readonly name: string;
  56254. /**
  56255. * Initializes a PostProcessRenderPipeline
  56256. * @param engine engine to add the pipeline to
  56257. * @param name name of the pipeline
  56258. */
  56259. constructor(engine: Engine, name: string);
  56260. /**
  56261. * Gets the class name
  56262. * @returns "PostProcessRenderPipeline"
  56263. */
  56264. getClassName(): string;
  56265. /**
  56266. * If all the render effects in the pipeline are supported
  56267. */
  56268. readonly isSupported: boolean;
  56269. /**
  56270. * Adds an effect to the pipeline
  56271. * @param renderEffect the effect to add
  56272. */
  56273. addEffect(renderEffect: PostProcessRenderEffect): void;
  56274. /** @hidden */
  56275. _rebuild(): void;
  56276. /** @hidden */
  56277. _enableEffect(renderEffectName: string, cameras: Camera): void;
  56278. /** @hidden */
  56279. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  56280. /** @hidden */
  56281. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  56282. /** @hidden */
  56283. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  56284. /** @hidden */
  56285. _attachCameras(cameras: Camera, unique: boolean): void;
  56286. /** @hidden */
  56287. _attachCameras(cameras: Camera[], unique: boolean): void;
  56288. /** @hidden */
  56289. _detachCameras(cameras: Camera): void;
  56290. /** @hidden */
  56291. _detachCameras(cameras: Nullable<Camera[]>): void;
  56292. /** @hidden */
  56293. _update(): void;
  56294. /** @hidden */
  56295. _reset(): void;
  56296. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  56297. /**
  56298. * Disposes of the pipeline
  56299. */
  56300. dispose(): void;
  56301. }
  56302. }
  56303. declare module BABYLON {
  56304. /**
  56305. * PostProcessRenderPipelineManager class
  56306. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  56307. */
  56308. export class PostProcessRenderPipelineManager {
  56309. private _renderPipelines;
  56310. /**
  56311. * Initializes a PostProcessRenderPipelineManager
  56312. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  56313. */
  56314. constructor();
  56315. /**
  56316. * Gets the list of supported render pipelines
  56317. */
  56318. readonly supportedPipelines: PostProcessRenderPipeline[];
  56319. /**
  56320. * Adds a pipeline to the manager
  56321. * @param renderPipeline The pipeline to add
  56322. */
  56323. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  56324. /**
  56325. * Attaches a camera to the pipeline
  56326. * @param renderPipelineName The name of the pipeline to attach to
  56327. * @param cameras the camera to attach
  56328. * @param unique if the camera can be attached multiple times to the pipeline
  56329. */
  56330. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  56331. /**
  56332. * Detaches a camera from the pipeline
  56333. * @param renderPipelineName The name of the pipeline to detach from
  56334. * @param cameras the camera to detach
  56335. */
  56336. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  56337. /**
  56338. * Enables an effect by name on a pipeline
  56339. * @param renderPipelineName the name of the pipeline to enable the effect in
  56340. * @param renderEffectName the name of the effect to enable
  56341. * @param cameras the cameras that the effect should be enabled on
  56342. */
  56343. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  56344. /**
  56345. * Disables an effect by name on a pipeline
  56346. * @param renderPipelineName the name of the pipeline to disable the effect in
  56347. * @param renderEffectName the name of the effect to disable
  56348. * @param cameras the cameras that the effect should be disabled on
  56349. */
  56350. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  56351. /**
  56352. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  56353. */
  56354. update(): void;
  56355. /** @hidden */
  56356. _rebuild(): void;
  56357. /**
  56358. * Disposes of the manager and pipelines
  56359. */
  56360. dispose(): void;
  56361. }
  56362. }
  56363. declare module BABYLON {
  56364. interface Scene {
  56365. /** @hidden (Backing field) */
  56366. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  56367. /**
  56368. * Gets the postprocess render pipeline manager
  56369. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  56370. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  56371. */
  56372. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  56373. }
  56374. /**
  56375. * Defines the Render Pipeline scene component responsible to rendering pipelines
  56376. */
  56377. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  56378. /**
  56379. * The component name helpfull to identify the component in the list of scene components.
  56380. */
  56381. readonly name: string;
  56382. /**
  56383. * The scene the component belongs to.
  56384. */
  56385. scene: Scene;
  56386. /**
  56387. * Creates a new instance of the component for the given scene
  56388. * @param scene Defines the scene to register the component in
  56389. */
  56390. constructor(scene: Scene);
  56391. /**
  56392. * Registers the component in a given scene
  56393. */
  56394. register(): void;
  56395. /**
  56396. * Rebuilds the elements related to this component in case of
  56397. * context lost for instance.
  56398. */
  56399. rebuild(): void;
  56400. /**
  56401. * Disposes the component and the associated ressources
  56402. */
  56403. dispose(): void;
  56404. private _gatherRenderTargets;
  56405. }
  56406. }
  56407. declare module BABYLON {
  56408. /**
  56409. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  56410. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  56411. */
  56412. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  56413. private _scene;
  56414. private _camerasToBeAttached;
  56415. /**
  56416. * ID of the sharpen post process,
  56417. */
  56418. private readonly SharpenPostProcessId;
  56419. /**
  56420. * @ignore
  56421. * ID of the image processing post process;
  56422. */
  56423. readonly ImageProcessingPostProcessId: string;
  56424. /**
  56425. * @ignore
  56426. * ID of the Fast Approximate Anti-Aliasing post process;
  56427. */
  56428. readonly FxaaPostProcessId: string;
  56429. /**
  56430. * ID of the chromatic aberration post process,
  56431. */
  56432. private readonly ChromaticAberrationPostProcessId;
  56433. /**
  56434. * ID of the grain post process
  56435. */
  56436. private readonly GrainPostProcessId;
  56437. /**
  56438. * Sharpen post process which will apply a sharpen convolution to enhance edges
  56439. */
  56440. sharpen: SharpenPostProcess;
  56441. private _sharpenEffect;
  56442. private bloom;
  56443. /**
  56444. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  56445. */
  56446. depthOfField: DepthOfFieldEffect;
  56447. /**
  56448. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  56449. */
  56450. fxaa: FxaaPostProcess;
  56451. /**
  56452. * Image post processing pass used to perform operations such as tone mapping or color grading.
  56453. */
  56454. imageProcessing: ImageProcessingPostProcess;
  56455. /**
  56456. * Chromatic aberration post process which will shift rgb colors in the image
  56457. */
  56458. chromaticAberration: ChromaticAberrationPostProcess;
  56459. private _chromaticAberrationEffect;
  56460. /**
  56461. * Grain post process which add noise to the image
  56462. */
  56463. grain: GrainPostProcess;
  56464. private _grainEffect;
  56465. /**
  56466. * Glow post process which adds a glow to emissive areas of the image
  56467. */
  56468. private _glowLayer;
  56469. /**
  56470. * Animations which can be used to tweak settings over a period of time
  56471. */
  56472. animations: Animation[];
  56473. private _imageProcessingConfigurationObserver;
  56474. private _sharpenEnabled;
  56475. private _bloomEnabled;
  56476. private _depthOfFieldEnabled;
  56477. private _depthOfFieldBlurLevel;
  56478. private _fxaaEnabled;
  56479. private _imageProcessingEnabled;
  56480. private _defaultPipelineTextureType;
  56481. private _bloomScale;
  56482. private _chromaticAberrationEnabled;
  56483. private _grainEnabled;
  56484. private _buildAllowed;
  56485. /**
  56486. * Gets active scene
  56487. */
  56488. readonly scene: Scene;
  56489. /**
  56490. * Enable or disable the sharpen process from the pipeline
  56491. */
  56492. sharpenEnabled: boolean;
  56493. private _resizeObserver;
  56494. private _hardwareScaleLevel;
  56495. private _bloomKernel;
  56496. /**
  56497. * Specifies the size of the bloom blur kernel, relative to the final output size
  56498. */
  56499. bloomKernel: number;
  56500. /**
  56501. * Specifies the weight of the bloom in the final rendering
  56502. */
  56503. private _bloomWeight;
  56504. /**
  56505. * Specifies the luma threshold for the area that will be blurred by the bloom
  56506. */
  56507. private _bloomThreshold;
  56508. private _hdr;
  56509. /**
  56510. * The strength of the bloom.
  56511. */
  56512. bloomWeight: number;
  56513. /**
  56514. * The strength of the bloom.
  56515. */
  56516. bloomThreshold: number;
  56517. /**
  56518. * The scale of the bloom, lower value will provide better performance.
  56519. */
  56520. bloomScale: number;
  56521. /**
  56522. * Enable or disable the bloom from the pipeline
  56523. */
  56524. bloomEnabled: boolean;
  56525. private _rebuildBloom;
  56526. /**
  56527. * If the depth of field is enabled.
  56528. */
  56529. depthOfFieldEnabled: boolean;
  56530. /**
  56531. * Blur level of the depth of field effect. (Higher blur will effect performance)
  56532. */
  56533. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  56534. /**
  56535. * If the anti aliasing is enabled.
  56536. */
  56537. fxaaEnabled: boolean;
  56538. private _samples;
  56539. /**
  56540. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  56541. */
  56542. samples: number;
  56543. /**
  56544. * If image processing is enabled.
  56545. */
  56546. imageProcessingEnabled: boolean;
  56547. /**
  56548. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  56549. */
  56550. glowLayerEnabled: boolean;
  56551. /**
  56552. * Gets the glow layer (or null if not defined)
  56553. */
  56554. readonly glowLayer: Nullable<GlowLayer>;
  56555. /**
  56556. * Enable or disable the chromaticAberration process from the pipeline
  56557. */
  56558. chromaticAberrationEnabled: boolean;
  56559. /**
  56560. * Enable or disable the grain process from the pipeline
  56561. */
  56562. grainEnabled: boolean;
  56563. /**
  56564. * @constructor
  56565. * @param name - The rendering pipeline name (default: "")
  56566. * @param hdr - If high dynamic range textures should be used (default: true)
  56567. * @param scene - The scene linked to this pipeline (default: the last created scene)
  56568. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  56569. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  56570. */
  56571. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  56572. /**
  56573. * Get the class name
  56574. * @returns "DefaultRenderingPipeline"
  56575. */
  56576. getClassName(): string;
  56577. /**
  56578. * Force the compilation of the entire pipeline.
  56579. */
  56580. prepare(): void;
  56581. private _hasCleared;
  56582. private _prevPostProcess;
  56583. private _prevPrevPostProcess;
  56584. private _setAutoClearAndTextureSharing;
  56585. private _depthOfFieldSceneObserver;
  56586. private _buildPipeline;
  56587. private _disposePostProcesses;
  56588. /**
  56589. * Adds a camera to the pipeline
  56590. * @param camera the camera to be added
  56591. */
  56592. addCamera(camera: Camera): void;
  56593. /**
  56594. * Removes a camera from the pipeline
  56595. * @param camera the camera to remove
  56596. */
  56597. removeCamera(camera: Camera): void;
  56598. /**
  56599. * Dispose of the pipeline and stop all post processes
  56600. */
  56601. dispose(): void;
  56602. /**
  56603. * Serialize the rendering pipeline (Used when exporting)
  56604. * @returns the serialized object
  56605. */
  56606. serialize(): any;
  56607. /**
  56608. * Parse the serialized pipeline
  56609. * @param source Source pipeline.
  56610. * @param scene The scene to load the pipeline to.
  56611. * @param rootUrl The URL of the serialized pipeline.
  56612. * @returns An instantiated pipeline from the serialized object.
  56613. */
  56614. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  56615. }
  56616. }
  56617. declare module BABYLON {
  56618. /** @hidden */
  56619. export var lensHighlightsPixelShader: {
  56620. name: string;
  56621. shader: string;
  56622. };
  56623. }
  56624. declare module BABYLON {
  56625. /** @hidden */
  56626. export var depthOfFieldPixelShader: {
  56627. name: string;
  56628. shader: string;
  56629. };
  56630. }
  56631. declare module BABYLON {
  56632. /**
  56633. * BABYLON.JS Chromatic Aberration GLSL Shader
  56634. * Author: Olivier Guyot
  56635. * Separates very slightly R, G and B colors on the edges of the screen
  56636. * Inspired by Francois Tarlier & Martins Upitis
  56637. */
  56638. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  56639. /**
  56640. * @ignore
  56641. * The chromatic aberration PostProcess id in the pipeline
  56642. */
  56643. LensChromaticAberrationEffect: string;
  56644. /**
  56645. * @ignore
  56646. * The highlights enhancing PostProcess id in the pipeline
  56647. */
  56648. HighlightsEnhancingEffect: string;
  56649. /**
  56650. * @ignore
  56651. * The depth-of-field PostProcess id in the pipeline
  56652. */
  56653. LensDepthOfFieldEffect: string;
  56654. private _scene;
  56655. private _depthTexture;
  56656. private _grainTexture;
  56657. private _chromaticAberrationPostProcess;
  56658. private _highlightsPostProcess;
  56659. private _depthOfFieldPostProcess;
  56660. private _edgeBlur;
  56661. private _grainAmount;
  56662. private _chromaticAberration;
  56663. private _distortion;
  56664. private _highlightsGain;
  56665. private _highlightsThreshold;
  56666. private _dofDistance;
  56667. private _dofAperture;
  56668. private _dofDarken;
  56669. private _dofPentagon;
  56670. private _blurNoise;
  56671. /**
  56672. * @constructor
  56673. *
  56674. * Effect parameters are as follow:
  56675. * {
  56676. * chromatic_aberration: number; // from 0 to x (1 for realism)
  56677. * edge_blur: number; // from 0 to x (1 for realism)
  56678. * distortion: number; // from 0 to x (1 for realism)
  56679. * grain_amount: number; // from 0 to 1
  56680. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  56681. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  56682. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  56683. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  56684. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  56685. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  56686. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  56687. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  56688. * }
  56689. * Note: if an effect parameter is unset, effect is disabled
  56690. *
  56691. * @param name The rendering pipeline name
  56692. * @param parameters - An object containing all parameters (see above)
  56693. * @param scene The scene linked to this pipeline
  56694. * @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)
  56695. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56696. */
  56697. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  56698. /**
  56699. * Get the class name
  56700. * @returns "LensRenderingPipeline"
  56701. */
  56702. getClassName(): string;
  56703. /**
  56704. * Gets associated scene
  56705. */
  56706. readonly scene: Scene;
  56707. /**
  56708. * Gets or sets the edge blur
  56709. */
  56710. edgeBlur: number;
  56711. /**
  56712. * Gets or sets the grain amount
  56713. */
  56714. grainAmount: number;
  56715. /**
  56716. * Gets or sets the chromatic aberration amount
  56717. */
  56718. chromaticAberration: number;
  56719. /**
  56720. * Gets or sets the depth of field aperture
  56721. */
  56722. dofAperture: number;
  56723. /**
  56724. * Gets or sets the edge distortion
  56725. */
  56726. edgeDistortion: number;
  56727. /**
  56728. * Gets or sets the depth of field distortion
  56729. */
  56730. dofDistortion: number;
  56731. /**
  56732. * Gets or sets the darken out of focus amount
  56733. */
  56734. darkenOutOfFocus: number;
  56735. /**
  56736. * Gets or sets a boolean indicating if blur noise is enabled
  56737. */
  56738. blurNoise: boolean;
  56739. /**
  56740. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  56741. */
  56742. pentagonBokeh: boolean;
  56743. /**
  56744. * Gets or sets the highlight grain amount
  56745. */
  56746. highlightsGain: number;
  56747. /**
  56748. * Gets or sets the highlight threshold
  56749. */
  56750. highlightsThreshold: number;
  56751. /**
  56752. * Sets the amount of blur at the edges
  56753. * @param amount blur amount
  56754. */
  56755. setEdgeBlur(amount: number): void;
  56756. /**
  56757. * Sets edge blur to 0
  56758. */
  56759. disableEdgeBlur(): void;
  56760. /**
  56761. * Sets the amout of grain
  56762. * @param amount Amount of grain
  56763. */
  56764. setGrainAmount(amount: number): void;
  56765. /**
  56766. * Set grain amount to 0
  56767. */
  56768. disableGrain(): void;
  56769. /**
  56770. * Sets the chromatic aberration amount
  56771. * @param amount amount of chromatic aberration
  56772. */
  56773. setChromaticAberration(amount: number): void;
  56774. /**
  56775. * Sets chromatic aberration amount to 0
  56776. */
  56777. disableChromaticAberration(): void;
  56778. /**
  56779. * Sets the EdgeDistortion amount
  56780. * @param amount amount of EdgeDistortion
  56781. */
  56782. setEdgeDistortion(amount: number): void;
  56783. /**
  56784. * Sets edge distortion to 0
  56785. */
  56786. disableEdgeDistortion(): void;
  56787. /**
  56788. * Sets the FocusDistance amount
  56789. * @param amount amount of FocusDistance
  56790. */
  56791. setFocusDistance(amount: number): void;
  56792. /**
  56793. * Disables depth of field
  56794. */
  56795. disableDepthOfField(): void;
  56796. /**
  56797. * Sets the Aperture amount
  56798. * @param amount amount of Aperture
  56799. */
  56800. setAperture(amount: number): void;
  56801. /**
  56802. * Sets the DarkenOutOfFocus amount
  56803. * @param amount amount of DarkenOutOfFocus
  56804. */
  56805. setDarkenOutOfFocus(amount: number): void;
  56806. private _pentagonBokehIsEnabled;
  56807. /**
  56808. * Creates a pentagon bokeh effect
  56809. */
  56810. enablePentagonBokeh(): void;
  56811. /**
  56812. * Disables the pentagon bokeh effect
  56813. */
  56814. disablePentagonBokeh(): void;
  56815. /**
  56816. * Enables noise blur
  56817. */
  56818. enableNoiseBlur(): void;
  56819. /**
  56820. * Disables noise blur
  56821. */
  56822. disableNoiseBlur(): void;
  56823. /**
  56824. * Sets the HighlightsGain amount
  56825. * @param amount amount of HighlightsGain
  56826. */
  56827. setHighlightsGain(amount: number): void;
  56828. /**
  56829. * Sets the HighlightsThreshold amount
  56830. * @param amount amount of HighlightsThreshold
  56831. */
  56832. setHighlightsThreshold(amount: number): void;
  56833. /**
  56834. * Disables highlights
  56835. */
  56836. disableHighlights(): void;
  56837. /**
  56838. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  56839. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  56840. */
  56841. dispose(disableDepthRender?: boolean): void;
  56842. private _createChromaticAberrationPostProcess;
  56843. private _createHighlightsPostProcess;
  56844. private _createDepthOfFieldPostProcess;
  56845. private _createGrainTexture;
  56846. }
  56847. }
  56848. declare module BABYLON {
  56849. /** @hidden */
  56850. export var ssao2PixelShader: {
  56851. name: string;
  56852. shader: string;
  56853. };
  56854. }
  56855. declare module BABYLON {
  56856. /** @hidden */
  56857. export var ssaoCombinePixelShader: {
  56858. name: string;
  56859. shader: string;
  56860. };
  56861. }
  56862. declare module BABYLON {
  56863. /**
  56864. * Render pipeline to produce ssao effect
  56865. */
  56866. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  56867. /**
  56868. * @ignore
  56869. * The PassPostProcess id in the pipeline that contains the original scene color
  56870. */
  56871. SSAOOriginalSceneColorEffect: string;
  56872. /**
  56873. * @ignore
  56874. * The SSAO PostProcess id in the pipeline
  56875. */
  56876. SSAORenderEffect: string;
  56877. /**
  56878. * @ignore
  56879. * The horizontal blur PostProcess id in the pipeline
  56880. */
  56881. SSAOBlurHRenderEffect: string;
  56882. /**
  56883. * @ignore
  56884. * The vertical blur PostProcess id in the pipeline
  56885. */
  56886. SSAOBlurVRenderEffect: string;
  56887. /**
  56888. * @ignore
  56889. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  56890. */
  56891. SSAOCombineRenderEffect: string;
  56892. /**
  56893. * The output strength of the SSAO post-process. Default value is 1.0.
  56894. */
  56895. totalStrength: number;
  56896. /**
  56897. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  56898. */
  56899. maxZ: number;
  56900. /**
  56901. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  56902. */
  56903. minZAspect: number;
  56904. private _samples;
  56905. /**
  56906. * Number of samples used for the SSAO calculations. Default value is 8
  56907. */
  56908. samples: number;
  56909. private _textureSamples;
  56910. /**
  56911. * Number of samples to use for antialiasing
  56912. */
  56913. textureSamples: number;
  56914. /**
  56915. * Ratio object used for SSAO ratio and blur ratio
  56916. */
  56917. private _ratio;
  56918. /**
  56919. * Dynamically generated sphere sampler.
  56920. */
  56921. private _sampleSphere;
  56922. /**
  56923. * Blur filter offsets
  56924. */
  56925. private _samplerOffsets;
  56926. private _expensiveBlur;
  56927. /**
  56928. * If bilateral blur should be used
  56929. */
  56930. expensiveBlur: boolean;
  56931. /**
  56932. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  56933. */
  56934. radius: number;
  56935. /**
  56936. * The base color of the SSAO post-process
  56937. * The final result is "base + ssao" between [0, 1]
  56938. */
  56939. base: number;
  56940. /**
  56941. * Support test.
  56942. */
  56943. static readonly IsSupported: boolean;
  56944. private _scene;
  56945. private _depthTexture;
  56946. private _normalTexture;
  56947. private _randomTexture;
  56948. private _originalColorPostProcess;
  56949. private _ssaoPostProcess;
  56950. private _blurHPostProcess;
  56951. private _blurVPostProcess;
  56952. private _ssaoCombinePostProcess;
  56953. private _firstUpdate;
  56954. /**
  56955. * Gets active scene
  56956. */
  56957. readonly scene: Scene;
  56958. /**
  56959. * @constructor
  56960. * @param name The rendering pipeline name
  56961. * @param scene The scene linked to this pipeline
  56962. * @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 }
  56963. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56964. */
  56965. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  56966. /**
  56967. * Get the class name
  56968. * @returns "SSAO2RenderingPipeline"
  56969. */
  56970. getClassName(): string;
  56971. /**
  56972. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  56973. */
  56974. dispose(disableGeometryBufferRenderer?: boolean): void;
  56975. private _createBlurPostProcess;
  56976. /** @hidden */
  56977. _rebuild(): void;
  56978. private _bits;
  56979. private _radicalInverse_VdC;
  56980. private _hammersley;
  56981. private _hemisphereSample_uniform;
  56982. private _generateHemisphere;
  56983. private _createSSAOPostProcess;
  56984. private _createSSAOCombinePostProcess;
  56985. private _createRandomTexture;
  56986. /**
  56987. * Serialize the rendering pipeline (Used when exporting)
  56988. * @returns the serialized object
  56989. */
  56990. serialize(): any;
  56991. /**
  56992. * Parse the serialized pipeline
  56993. * @param source Source pipeline.
  56994. * @param scene The scene to load the pipeline to.
  56995. * @param rootUrl The URL of the serialized pipeline.
  56996. * @returns An instantiated pipeline from the serialized object.
  56997. */
  56998. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  56999. }
  57000. }
  57001. declare module BABYLON {
  57002. /** @hidden */
  57003. export var ssaoPixelShader: {
  57004. name: string;
  57005. shader: string;
  57006. };
  57007. }
  57008. declare module BABYLON {
  57009. /**
  57010. * Render pipeline to produce ssao effect
  57011. */
  57012. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  57013. /**
  57014. * @ignore
  57015. * The PassPostProcess id in the pipeline that contains the original scene color
  57016. */
  57017. SSAOOriginalSceneColorEffect: string;
  57018. /**
  57019. * @ignore
  57020. * The SSAO PostProcess id in the pipeline
  57021. */
  57022. SSAORenderEffect: string;
  57023. /**
  57024. * @ignore
  57025. * The horizontal blur PostProcess id in the pipeline
  57026. */
  57027. SSAOBlurHRenderEffect: string;
  57028. /**
  57029. * @ignore
  57030. * The vertical blur PostProcess id in the pipeline
  57031. */
  57032. SSAOBlurVRenderEffect: string;
  57033. /**
  57034. * @ignore
  57035. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  57036. */
  57037. SSAOCombineRenderEffect: string;
  57038. /**
  57039. * The output strength of the SSAO post-process. Default value is 1.0.
  57040. */
  57041. totalStrength: number;
  57042. /**
  57043. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  57044. */
  57045. radius: number;
  57046. /**
  57047. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  57048. * Must not be equal to fallOff and superior to fallOff.
  57049. * Default value is 0.0075
  57050. */
  57051. area: number;
  57052. /**
  57053. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  57054. * Must not be equal to area and inferior to area.
  57055. * Default value is 0.000001
  57056. */
  57057. fallOff: number;
  57058. /**
  57059. * The base color of the SSAO post-process
  57060. * The final result is "base + ssao" between [0, 1]
  57061. */
  57062. base: number;
  57063. private _scene;
  57064. private _depthTexture;
  57065. private _randomTexture;
  57066. private _originalColorPostProcess;
  57067. private _ssaoPostProcess;
  57068. private _blurHPostProcess;
  57069. private _blurVPostProcess;
  57070. private _ssaoCombinePostProcess;
  57071. private _firstUpdate;
  57072. /**
  57073. * Gets active scene
  57074. */
  57075. readonly scene: Scene;
  57076. /**
  57077. * @constructor
  57078. * @param name - The rendering pipeline name
  57079. * @param scene - The scene linked to this pipeline
  57080. * @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 }
  57081. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  57082. */
  57083. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  57084. /**
  57085. * Get the class name
  57086. * @returns "SSAORenderingPipeline"
  57087. */
  57088. getClassName(): string;
  57089. /**
  57090. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  57091. */
  57092. dispose(disableDepthRender?: boolean): void;
  57093. private _createBlurPostProcess;
  57094. /** @hidden */
  57095. _rebuild(): void;
  57096. private _createSSAOPostProcess;
  57097. private _createSSAOCombinePostProcess;
  57098. private _createRandomTexture;
  57099. }
  57100. }
  57101. declare module BABYLON {
  57102. /** @hidden */
  57103. export var standardPixelShader: {
  57104. name: string;
  57105. shader: string;
  57106. };
  57107. }
  57108. declare module BABYLON {
  57109. /**
  57110. * Standard rendering pipeline
  57111. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  57112. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  57113. */
  57114. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  57115. /**
  57116. * Public members
  57117. */
  57118. /**
  57119. * Post-process which contains the original scene color before the pipeline applies all the effects
  57120. */
  57121. originalPostProcess: Nullable<PostProcess>;
  57122. /**
  57123. * Post-process used to down scale an image x4
  57124. */
  57125. downSampleX4PostProcess: Nullable<PostProcess>;
  57126. /**
  57127. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  57128. */
  57129. brightPassPostProcess: Nullable<PostProcess>;
  57130. /**
  57131. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  57132. */
  57133. blurHPostProcesses: PostProcess[];
  57134. /**
  57135. * Post-process array storing all the vertical blur post-processes used by the pipeline
  57136. */
  57137. blurVPostProcesses: PostProcess[];
  57138. /**
  57139. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  57140. */
  57141. textureAdderPostProcess: Nullable<PostProcess>;
  57142. /**
  57143. * Post-process used to create volumetric lighting effect
  57144. */
  57145. volumetricLightPostProcess: Nullable<PostProcess>;
  57146. /**
  57147. * Post-process used to smooth the previous volumetric light post-process on the X axis
  57148. */
  57149. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  57150. /**
  57151. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  57152. */
  57153. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  57154. /**
  57155. * Post-process used to merge the volumetric light effect and the real scene color
  57156. */
  57157. volumetricLightMergePostProces: Nullable<PostProcess>;
  57158. /**
  57159. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  57160. */
  57161. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  57162. /**
  57163. * Base post-process used to calculate the average luminance of the final image for HDR
  57164. */
  57165. luminancePostProcess: Nullable<PostProcess>;
  57166. /**
  57167. * Post-processes used to create down sample post-processes in order to get
  57168. * the average luminance of the final image for HDR
  57169. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  57170. */
  57171. luminanceDownSamplePostProcesses: PostProcess[];
  57172. /**
  57173. * Post-process used to create a HDR effect (light adaptation)
  57174. */
  57175. hdrPostProcess: Nullable<PostProcess>;
  57176. /**
  57177. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  57178. */
  57179. textureAdderFinalPostProcess: Nullable<PostProcess>;
  57180. /**
  57181. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  57182. */
  57183. lensFlareFinalPostProcess: Nullable<PostProcess>;
  57184. /**
  57185. * Post-process used to merge the final HDR post-process and the real scene color
  57186. */
  57187. hdrFinalPostProcess: Nullable<PostProcess>;
  57188. /**
  57189. * Post-process used to create a lens flare effect
  57190. */
  57191. lensFlarePostProcess: Nullable<PostProcess>;
  57192. /**
  57193. * Post-process that merges the result of the lens flare post-process and the real scene color
  57194. */
  57195. lensFlareComposePostProcess: Nullable<PostProcess>;
  57196. /**
  57197. * Post-process used to create a motion blur effect
  57198. */
  57199. motionBlurPostProcess: Nullable<PostProcess>;
  57200. /**
  57201. * Post-process used to create a depth of field effect
  57202. */
  57203. depthOfFieldPostProcess: Nullable<PostProcess>;
  57204. /**
  57205. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  57206. */
  57207. fxaaPostProcess: Nullable<FxaaPostProcess>;
  57208. /**
  57209. * Represents the brightness threshold in order to configure the illuminated surfaces
  57210. */
  57211. brightThreshold: number;
  57212. /**
  57213. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  57214. */
  57215. blurWidth: number;
  57216. /**
  57217. * Sets if the blur for highlighted surfaces must be only horizontal
  57218. */
  57219. horizontalBlur: boolean;
  57220. /**
  57221. * Gets the overall exposure used by the pipeline
  57222. */
  57223. /**
  57224. * Sets the overall exposure used by the pipeline
  57225. */
  57226. exposure: number;
  57227. /**
  57228. * Texture used typically to simulate "dirty" on camera lens
  57229. */
  57230. lensTexture: Nullable<Texture>;
  57231. /**
  57232. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  57233. */
  57234. volumetricLightCoefficient: number;
  57235. /**
  57236. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  57237. */
  57238. volumetricLightPower: number;
  57239. /**
  57240. * Used the set the blur intensity to smooth the volumetric lights
  57241. */
  57242. volumetricLightBlurScale: number;
  57243. /**
  57244. * Light (spot or directional) used to generate the volumetric lights rays
  57245. * The source light must have a shadow generate so the pipeline can get its
  57246. * depth map
  57247. */
  57248. sourceLight: Nullable<SpotLight | DirectionalLight>;
  57249. /**
  57250. * For eye adaptation, represents the minimum luminance the eye can see
  57251. */
  57252. hdrMinimumLuminance: number;
  57253. /**
  57254. * For eye adaptation, represents the decrease luminance speed
  57255. */
  57256. hdrDecreaseRate: number;
  57257. /**
  57258. * For eye adaptation, represents the increase luminance speed
  57259. */
  57260. hdrIncreaseRate: number;
  57261. /**
  57262. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  57263. */
  57264. /**
  57265. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  57266. */
  57267. hdrAutoExposure: boolean;
  57268. /**
  57269. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  57270. */
  57271. lensColorTexture: Nullable<Texture>;
  57272. /**
  57273. * The overall strengh for the lens flare effect
  57274. */
  57275. lensFlareStrength: number;
  57276. /**
  57277. * Dispersion coefficient for lens flare ghosts
  57278. */
  57279. lensFlareGhostDispersal: number;
  57280. /**
  57281. * Main lens flare halo width
  57282. */
  57283. lensFlareHaloWidth: number;
  57284. /**
  57285. * Based on the lens distortion effect, defines how much the lens flare result
  57286. * is distorted
  57287. */
  57288. lensFlareDistortionStrength: number;
  57289. /**
  57290. * Lens star texture must be used to simulate rays on the flares and is available
  57291. * in the documentation
  57292. */
  57293. lensStarTexture: Nullable<Texture>;
  57294. /**
  57295. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  57296. * flare effect by taking account of the dirt texture
  57297. */
  57298. lensFlareDirtTexture: Nullable<Texture>;
  57299. /**
  57300. * Represents the focal length for the depth of field effect
  57301. */
  57302. depthOfFieldDistance: number;
  57303. /**
  57304. * Represents the blur intensity for the blurred part of the depth of field effect
  57305. */
  57306. depthOfFieldBlurWidth: number;
  57307. /**
  57308. * Gets how much the image is blurred by the movement while using the motion blur post-process
  57309. */
  57310. /**
  57311. * Sets how much the image is blurred by the movement while using the motion blur post-process
  57312. */
  57313. motionStrength: number;
  57314. /**
  57315. * Gets wether or not the motion blur post-process is object based or screen based.
  57316. */
  57317. /**
  57318. * Sets wether or not the motion blur post-process should be object based or screen based
  57319. */
  57320. objectBasedMotionBlur: boolean;
  57321. /**
  57322. * List of animations for the pipeline (IAnimatable implementation)
  57323. */
  57324. animations: Animation[];
  57325. /**
  57326. * Private members
  57327. */
  57328. private _scene;
  57329. private _currentDepthOfFieldSource;
  57330. private _basePostProcess;
  57331. private _fixedExposure;
  57332. private _currentExposure;
  57333. private _hdrAutoExposure;
  57334. private _hdrCurrentLuminance;
  57335. private _motionStrength;
  57336. private _isObjectBasedMotionBlur;
  57337. private _floatTextureType;
  57338. private _ratio;
  57339. private _bloomEnabled;
  57340. private _depthOfFieldEnabled;
  57341. private _vlsEnabled;
  57342. private _lensFlareEnabled;
  57343. private _hdrEnabled;
  57344. private _motionBlurEnabled;
  57345. private _fxaaEnabled;
  57346. private _motionBlurSamples;
  57347. private _volumetricLightStepsCount;
  57348. private _samples;
  57349. /**
  57350. * @ignore
  57351. * Specifies if the bloom pipeline is enabled
  57352. */
  57353. BloomEnabled: boolean;
  57354. /**
  57355. * @ignore
  57356. * Specifies if the depth of field pipeline is enabed
  57357. */
  57358. DepthOfFieldEnabled: boolean;
  57359. /**
  57360. * @ignore
  57361. * Specifies if the lens flare pipeline is enabed
  57362. */
  57363. LensFlareEnabled: boolean;
  57364. /**
  57365. * @ignore
  57366. * Specifies if the HDR pipeline is enabled
  57367. */
  57368. HDREnabled: boolean;
  57369. /**
  57370. * @ignore
  57371. * Specifies if the volumetric lights scattering effect is enabled
  57372. */
  57373. VLSEnabled: boolean;
  57374. /**
  57375. * @ignore
  57376. * Specifies if the motion blur effect is enabled
  57377. */
  57378. MotionBlurEnabled: boolean;
  57379. /**
  57380. * Specifies if anti-aliasing is enabled
  57381. */
  57382. fxaaEnabled: boolean;
  57383. /**
  57384. * Specifies the number of steps used to calculate the volumetric lights
  57385. * Typically in interval [50, 200]
  57386. */
  57387. volumetricLightStepsCount: number;
  57388. /**
  57389. * Specifies the number of samples used for the motion blur effect
  57390. * Typically in interval [16, 64]
  57391. */
  57392. motionBlurSamples: number;
  57393. /**
  57394. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  57395. */
  57396. samples: number;
  57397. /**
  57398. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  57399. * @constructor
  57400. * @param name The rendering pipeline name
  57401. * @param scene The scene linked to this pipeline
  57402. * @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)
  57403. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  57404. * @param cameras The array of cameras that the rendering pipeline will be attached to
  57405. */
  57406. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  57407. private _buildPipeline;
  57408. private _createDownSampleX4PostProcess;
  57409. private _createBrightPassPostProcess;
  57410. private _createBlurPostProcesses;
  57411. private _createTextureAdderPostProcess;
  57412. private _createVolumetricLightPostProcess;
  57413. private _createLuminancePostProcesses;
  57414. private _createHdrPostProcess;
  57415. private _createLensFlarePostProcess;
  57416. private _createDepthOfFieldPostProcess;
  57417. private _createMotionBlurPostProcess;
  57418. private _getDepthTexture;
  57419. private _disposePostProcesses;
  57420. /**
  57421. * Dispose of the pipeline and stop all post processes
  57422. */
  57423. dispose(): void;
  57424. /**
  57425. * Serialize the rendering pipeline (Used when exporting)
  57426. * @returns the serialized object
  57427. */
  57428. serialize(): any;
  57429. /**
  57430. * Parse the serialized pipeline
  57431. * @param source Source pipeline.
  57432. * @param scene The scene to load the pipeline to.
  57433. * @param rootUrl The URL of the serialized pipeline.
  57434. * @returns An instantiated pipeline from the serialized object.
  57435. */
  57436. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  57437. /**
  57438. * Luminance steps
  57439. */
  57440. static LuminanceSteps: number;
  57441. }
  57442. }
  57443. declare module BABYLON {
  57444. /** @hidden */
  57445. export var tonemapPixelShader: {
  57446. name: string;
  57447. shader: string;
  57448. };
  57449. }
  57450. declare module BABYLON {
  57451. /** Defines operator used for tonemapping */
  57452. export enum TonemappingOperator {
  57453. /** Hable */
  57454. Hable = 0,
  57455. /** Reinhard */
  57456. Reinhard = 1,
  57457. /** HejiDawson */
  57458. HejiDawson = 2,
  57459. /** Photographic */
  57460. Photographic = 3
  57461. }
  57462. /**
  57463. * Defines a post process to apply tone mapping
  57464. */
  57465. export class TonemapPostProcess extends PostProcess {
  57466. private _operator;
  57467. /** Defines the required exposure adjustement */
  57468. exposureAdjustment: number;
  57469. /**
  57470. * Creates a new TonemapPostProcess
  57471. * @param name defines the name of the postprocess
  57472. * @param _operator defines the operator to use
  57473. * @param exposureAdjustment defines the required exposure adjustement
  57474. * @param camera defines the camera to use (can be null)
  57475. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  57476. * @param engine defines the hosting engine (can be ignore if camera is set)
  57477. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  57478. */
  57479. constructor(name: string, _operator: TonemappingOperator,
  57480. /** Defines the required exposure adjustement */
  57481. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  57482. }
  57483. }
  57484. declare module BABYLON {
  57485. /** @hidden */
  57486. export var depthVertexShader: {
  57487. name: string;
  57488. shader: string;
  57489. };
  57490. }
  57491. declare module BABYLON {
  57492. /** @hidden */
  57493. export var volumetricLightScatteringPixelShader: {
  57494. name: string;
  57495. shader: string;
  57496. };
  57497. }
  57498. declare module BABYLON {
  57499. /** @hidden */
  57500. export var volumetricLightScatteringPassPixelShader: {
  57501. name: string;
  57502. shader: string;
  57503. };
  57504. }
  57505. declare module BABYLON {
  57506. /**
  57507. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  57508. */
  57509. export class VolumetricLightScatteringPostProcess extends PostProcess {
  57510. private _volumetricLightScatteringPass;
  57511. private _volumetricLightScatteringRTT;
  57512. private _viewPort;
  57513. private _screenCoordinates;
  57514. private _cachedDefines;
  57515. /**
  57516. * If not undefined, the mesh position is computed from the attached node position
  57517. */
  57518. attachedNode: {
  57519. position: Vector3;
  57520. };
  57521. /**
  57522. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  57523. */
  57524. customMeshPosition: Vector3;
  57525. /**
  57526. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  57527. */
  57528. useCustomMeshPosition: boolean;
  57529. /**
  57530. * If the post-process should inverse the light scattering direction
  57531. */
  57532. invert: boolean;
  57533. /**
  57534. * The internal mesh used by the post-process
  57535. */
  57536. mesh: Mesh;
  57537. /**
  57538. * @hidden
  57539. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  57540. */
  57541. useDiffuseColor: boolean;
  57542. /**
  57543. * Array containing the excluded meshes not rendered in the internal pass
  57544. */
  57545. excludedMeshes: AbstractMesh[];
  57546. /**
  57547. * Controls the overall intensity of the post-process
  57548. */
  57549. exposure: number;
  57550. /**
  57551. * Dissipates each sample's contribution in range [0, 1]
  57552. */
  57553. decay: number;
  57554. /**
  57555. * Controls the overall intensity of each sample
  57556. */
  57557. weight: number;
  57558. /**
  57559. * Controls the density of each sample
  57560. */
  57561. density: number;
  57562. /**
  57563. * @constructor
  57564. * @param name The post-process name
  57565. * @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)
  57566. * @param camera The camera that the post-process will be attached to
  57567. * @param mesh The mesh used to create the light scattering
  57568. * @param samples The post-process quality, default 100
  57569. * @param samplingModeThe post-process filtering mode
  57570. * @param engine The babylon engine
  57571. * @param reusable If the post-process is reusable
  57572. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  57573. */
  57574. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  57575. /**
  57576. * Returns the string "VolumetricLightScatteringPostProcess"
  57577. * @returns "VolumetricLightScatteringPostProcess"
  57578. */
  57579. getClassName(): string;
  57580. private _isReady;
  57581. /**
  57582. * Sets the new light position for light scattering effect
  57583. * @param position The new custom light position
  57584. */
  57585. setCustomMeshPosition(position: Vector3): void;
  57586. /**
  57587. * Returns the light position for light scattering effect
  57588. * @return Vector3 The custom light position
  57589. */
  57590. getCustomMeshPosition(): Vector3;
  57591. /**
  57592. * Disposes the internal assets and detaches the post-process from the camera
  57593. */
  57594. dispose(camera: Camera): void;
  57595. /**
  57596. * Returns the render target texture used by the post-process
  57597. * @return the render target texture used by the post-process
  57598. */
  57599. getPass(): RenderTargetTexture;
  57600. private _meshExcluded;
  57601. private _createPass;
  57602. private _updateMeshScreenCoordinates;
  57603. /**
  57604. * Creates a default mesh for the Volumeric Light Scattering post-process
  57605. * @param name The mesh name
  57606. * @param scene The scene where to create the mesh
  57607. * @return the default mesh
  57608. */
  57609. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  57610. }
  57611. }
  57612. declare module BABYLON {
  57613. interface Scene {
  57614. /** @hidden (Backing field) */
  57615. _boundingBoxRenderer: BoundingBoxRenderer;
  57616. /** @hidden (Backing field) */
  57617. _forceShowBoundingBoxes: boolean;
  57618. /**
  57619. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  57620. */
  57621. forceShowBoundingBoxes: boolean;
  57622. /**
  57623. * Gets the bounding box renderer associated with the scene
  57624. * @returns a BoundingBoxRenderer
  57625. */
  57626. getBoundingBoxRenderer(): BoundingBoxRenderer;
  57627. }
  57628. interface AbstractMesh {
  57629. /** @hidden (Backing field) */
  57630. _showBoundingBox: boolean;
  57631. /**
  57632. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  57633. */
  57634. showBoundingBox: boolean;
  57635. }
  57636. /**
  57637. * Component responsible of rendering the bounding box of the meshes in a scene.
  57638. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  57639. */
  57640. export class BoundingBoxRenderer implements ISceneComponent {
  57641. /**
  57642. * The component name helpfull to identify the component in the list of scene components.
  57643. */
  57644. readonly name: string;
  57645. /**
  57646. * The scene the component belongs to.
  57647. */
  57648. scene: Scene;
  57649. /**
  57650. * Color of the bounding box lines placed in front of an object
  57651. */
  57652. frontColor: Color3;
  57653. /**
  57654. * Color of the bounding box lines placed behind an object
  57655. */
  57656. backColor: Color3;
  57657. /**
  57658. * Defines if the renderer should show the back lines or not
  57659. */
  57660. showBackLines: boolean;
  57661. /**
  57662. * @hidden
  57663. */
  57664. renderList: SmartArray<BoundingBox>;
  57665. private _colorShader;
  57666. private _vertexBuffers;
  57667. private _indexBuffer;
  57668. private _fillIndexBuffer;
  57669. private _fillIndexData;
  57670. /**
  57671. * Instantiates a new bounding box renderer in a scene.
  57672. * @param scene the scene the renderer renders in
  57673. */
  57674. constructor(scene: Scene);
  57675. /**
  57676. * Registers the component in a given scene
  57677. */
  57678. register(): void;
  57679. private _evaluateSubMesh;
  57680. private _activeMesh;
  57681. private _prepareRessources;
  57682. private _createIndexBuffer;
  57683. /**
  57684. * Rebuilds the elements related to this component in case of
  57685. * context lost for instance.
  57686. */
  57687. rebuild(): void;
  57688. /**
  57689. * @hidden
  57690. */
  57691. reset(): void;
  57692. /**
  57693. * Render the bounding boxes of a specific rendering group
  57694. * @param renderingGroupId defines the rendering group to render
  57695. */
  57696. render(renderingGroupId: number): void;
  57697. /**
  57698. * In case of occlusion queries, we can render the occlusion bounding box through this method
  57699. * @param mesh Define the mesh to render the occlusion bounding box for
  57700. */
  57701. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  57702. /**
  57703. * Dispose and release the resources attached to this renderer.
  57704. */
  57705. dispose(): void;
  57706. }
  57707. }
  57708. declare module BABYLON {
  57709. /** @hidden */
  57710. export var depthPixelShader: {
  57711. name: string;
  57712. shader: string;
  57713. };
  57714. }
  57715. declare module BABYLON {
  57716. /**
  57717. * This represents a depth renderer in Babylon.
  57718. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  57719. */
  57720. export class DepthRenderer {
  57721. private _scene;
  57722. private _depthMap;
  57723. private _effect;
  57724. private readonly _storeNonLinearDepth;
  57725. private readonly _clearColor;
  57726. /** Get if the depth renderer is using packed depth or not */
  57727. readonly isPacked: boolean;
  57728. private _cachedDefines;
  57729. private _camera;
  57730. /**
  57731. * Specifiess that the depth renderer will only be used within
  57732. * the camera it is created for.
  57733. * This can help forcing its rendering during the camera processing.
  57734. */
  57735. useOnlyInActiveCamera: boolean;
  57736. /** @hidden */
  57737. static _SceneComponentInitialization: (scene: Scene) => void;
  57738. /**
  57739. * Instantiates a depth renderer
  57740. * @param scene The scene the renderer belongs to
  57741. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  57742. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  57743. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  57744. */
  57745. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  57746. /**
  57747. * Creates the depth rendering effect and checks if the effect is ready.
  57748. * @param subMesh The submesh to be used to render the depth map of
  57749. * @param useInstances If multiple world instances should be used
  57750. * @returns if the depth renderer is ready to render the depth map
  57751. */
  57752. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57753. /**
  57754. * Gets the texture which the depth map will be written to.
  57755. * @returns The depth map texture
  57756. */
  57757. getDepthMap(): RenderTargetTexture;
  57758. /**
  57759. * Disposes of the depth renderer.
  57760. */
  57761. dispose(): void;
  57762. }
  57763. }
  57764. declare module BABYLON {
  57765. interface Scene {
  57766. /** @hidden (Backing field) */
  57767. _depthRenderer: {
  57768. [id: string]: DepthRenderer;
  57769. };
  57770. /**
  57771. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  57772. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  57773. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  57774. * @returns the created depth renderer
  57775. */
  57776. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  57777. /**
  57778. * Disables a depth renderer for a given camera
  57779. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  57780. */
  57781. disableDepthRenderer(camera?: Nullable<Camera>): void;
  57782. }
  57783. /**
  57784. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  57785. * in several rendering techniques.
  57786. */
  57787. export class DepthRendererSceneComponent implements ISceneComponent {
  57788. /**
  57789. * The component name helpfull to identify the component in the list of scene components.
  57790. */
  57791. readonly name: string;
  57792. /**
  57793. * The scene the component belongs to.
  57794. */
  57795. scene: Scene;
  57796. /**
  57797. * Creates a new instance of the component for the given scene
  57798. * @param scene Defines the scene to register the component in
  57799. */
  57800. constructor(scene: Scene);
  57801. /**
  57802. * Registers the component in a given scene
  57803. */
  57804. register(): void;
  57805. /**
  57806. * Rebuilds the elements related to this component in case of
  57807. * context lost for instance.
  57808. */
  57809. rebuild(): void;
  57810. /**
  57811. * Disposes the component and the associated ressources
  57812. */
  57813. dispose(): void;
  57814. private _gatherRenderTargets;
  57815. private _gatherActiveCameraRenderTargets;
  57816. }
  57817. }
  57818. declare module BABYLON {
  57819. /** @hidden */
  57820. export var outlinePixelShader: {
  57821. name: string;
  57822. shader: string;
  57823. };
  57824. }
  57825. declare module BABYLON {
  57826. /** @hidden */
  57827. export var outlineVertexShader: {
  57828. name: string;
  57829. shader: string;
  57830. };
  57831. }
  57832. declare module BABYLON {
  57833. interface Scene {
  57834. /** @hidden */
  57835. _outlineRenderer: OutlineRenderer;
  57836. /**
  57837. * Gets the outline renderer associated with the scene
  57838. * @returns a OutlineRenderer
  57839. */
  57840. getOutlineRenderer(): OutlineRenderer;
  57841. }
  57842. interface AbstractMesh {
  57843. /** @hidden (Backing field) */
  57844. _renderOutline: boolean;
  57845. /**
  57846. * Gets or sets a boolean indicating if the outline must be rendered as well
  57847. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  57848. */
  57849. renderOutline: boolean;
  57850. /** @hidden (Backing field) */
  57851. _renderOverlay: boolean;
  57852. /**
  57853. * Gets or sets a boolean indicating if the overlay must be rendered as well
  57854. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  57855. */
  57856. renderOverlay: boolean;
  57857. }
  57858. /**
  57859. * This class is responsible to draw bothe outline/overlay of meshes.
  57860. * It should not be used directly but through the available method on mesh.
  57861. */
  57862. export class OutlineRenderer implements ISceneComponent {
  57863. /**
  57864. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  57865. */
  57866. private static _StencilReference;
  57867. /**
  57868. * The name of the component. Each component must have a unique name.
  57869. */
  57870. name: string;
  57871. /**
  57872. * The scene the component belongs to.
  57873. */
  57874. scene: Scene;
  57875. /**
  57876. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  57877. */
  57878. zOffset: number;
  57879. private _engine;
  57880. private _effect;
  57881. private _cachedDefines;
  57882. private _savedDepthWrite;
  57883. /**
  57884. * Instantiates a new outline renderer. (There could be only one per scene).
  57885. * @param scene Defines the scene it belongs to
  57886. */
  57887. constructor(scene: Scene);
  57888. /**
  57889. * Register the component to one instance of a scene.
  57890. */
  57891. register(): void;
  57892. /**
  57893. * Rebuilds the elements related to this component in case of
  57894. * context lost for instance.
  57895. */
  57896. rebuild(): void;
  57897. /**
  57898. * Disposes the component and the associated ressources.
  57899. */
  57900. dispose(): void;
  57901. /**
  57902. * Renders the outline in the canvas.
  57903. * @param subMesh Defines the sumesh to render
  57904. * @param batch Defines the batch of meshes in case of instances
  57905. * @param useOverlay Defines if the rendering is for the overlay or the outline
  57906. */
  57907. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  57908. /**
  57909. * Returns whether or not the outline renderer is ready for a given submesh.
  57910. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  57911. * @param subMesh Defines the submesh to check readyness for
  57912. * @param useInstances Defines wheter wee are trying to render instances or not
  57913. * @returns true if ready otherwise false
  57914. */
  57915. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57916. private _beforeRenderingMesh;
  57917. private _afterRenderingMesh;
  57918. }
  57919. }
  57920. declare module BABYLON {
  57921. /**
  57922. * Defines the list of states available for a task inside a AssetsManager
  57923. */
  57924. export enum AssetTaskState {
  57925. /**
  57926. * Initialization
  57927. */
  57928. INIT = 0,
  57929. /**
  57930. * Running
  57931. */
  57932. RUNNING = 1,
  57933. /**
  57934. * Done
  57935. */
  57936. DONE = 2,
  57937. /**
  57938. * Error
  57939. */
  57940. ERROR = 3
  57941. }
  57942. /**
  57943. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  57944. */
  57945. export abstract class AbstractAssetTask {
  57946. /**
  57947. * Task name
  57948. */ name: string;
  57949. /**
  57950. * Callback called when the task is successful
  57951. */
  57952. onSuccess: (task: any) => void;
  57953. /**
  57954. * Callback called when the task is not successful
  57955. */
  57956. onError: (task: any, message?: string, exception?: any) => void;
  57957. /**
  57958. * Creates a new AssetsManager
  57959. * @param name defines the name of the task
  57960. */
  57961. constructor(
  57962. /**
  57963. * Task name
  57964. */ name: string);
  57965. private _isCompleted;
  57966. private _taskState;
  57967. private _errorObject;
  57968. /**
  57969. * Get if the task is completed
  57970. */
  57971. readonly isCompleted: boolean;
  57972. /**
  57973. * Gets the current state of the task
  57974. */
  57975. readonly taskState: AssetTaskState;
  57976. /**
  57977. * Gets the current error object (if task is in error)
  57978. */
  57979. readonly errorObject: {
  57980. message?: string;
  57981. exception?: any;
  57982. };
  57983. /**
  57984. * Internal only
  57985. * @hidden
  57986. */
  57987. _setErrorObject(message?: string, exception?: any): void;
  57988. /**
  57989. * Execute the current task
  57990. * @param scene defines the scene where you want your assets to be loaded
  57991. * @param onSuccess is a callback called when the task is successfully executed
  57992. * @param onError is a callback called if an error occurs
  57993. */
  57994. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57995. /**
  57996. * Execute the current task
  57997. * @param scene defines the scene where you want your assets to be loaded
  57998. * @param onSuccess is a callback called when the task is successfully executed
  57999. * @param onError is a callback called if an error occurs
  58000. */
  58001. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58002. /**
  58003. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  58004. * This can be used with failed tasks that have the reason for failure fixed.
  58005. */
  58006. reset(): void;
  58007. private onErrorCallback;
  58008. private onDoneCallback;
  58009. }
  58010. /**
  58011. * Define the interface used by progress events raised during assets loading
  58012. */
  58013. export interface IAssetsProgressEvent {
  58014. /**
  58015. * Defines the number of remaining tasks to process
  58016. */
  58017. remainingCount: number;
  58018. /**
  58019. * Defines the total number of tasks
  58020. */
  58021. totalCount: number;
  58022. /**
  58023. * Defines the task that was just processed
  58024. */
  58025. task: AbstractAssetTask;
  58026. }
  58027. /**
  58028. * Class used to share progress information about assets loading
  58029. */
  58030. export class AssetsProgressEvent implements IAssetsProgressEvent {
  58031. /**
  58032. * Defines the number of remaining tasks to process
  58033. */
  58034. remainingCount: number;
  58035. /**
  58036. * Defines the total number of tasks
  58037. */
  58038. totalCount: number;
  58039. /**
  58040. * Defines the task that was just processed
  58041. */
  58042. task: AbstractAssetTask;
  58043. /**
  58044. * Creates a AssetsProgressEvent
  58045. * @param remainingCount defines the number of remaining tasks to process
  58046. * @param totalCount defines the total number of tasks
  58047. * @param task defines the task that was just processed
  58048. */
  58049. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  58050. }
  58051. /**
  58052. * Define a task used by AssetsManager to load meshes
  58053. */
  58054. export class MeshAssetTask extends AbstractAssetTask {
  58055. /**
  58056. * Defines the name of the task
  58057. */
  58058. name: string;
  58059. /**
  58060. * Defines the list of mesh's names you want to load
  58061. */
  58062. meshesNames: any;
  58063. /**
  58064. * Defines the root url to use as a base to load your meshes and associated resources
  58065. */
  58066. rootUrl: string;
  58067. /**
  58068. * Defines the filename of the scene to load from
  58069. */
  58070. sceneFilename: string;
  58071. /**
  58072. * Gets the list of loaded meshes
  58073. */
  58074. loadedMeshes: Array<AbstractMesh>;
  58075. /**
  58076. * Gets the list of loaded particle systems
  58077. */
  58078. loadedParticleSystems: Array<IParticleSystem>;
  58079. /**
  58080. * Gets the list of loaded skeletons
  58081. */
  58082. loadedSkeletons: Array<Skeleton>;
  58083. /**
  58084. * Gets the list of loaded animation groups
  58085. */
  58086. loadedAnimationGroups: Array<AnimationGroup>;
  58087. /**
  58088. * Callback called when the task is successful
  58089. */
  58090. onSuccess: (task: MeshAssetTask) => void;
  58091. /**
  58092. * Callback called when the task is successful
  58093. */
  58094. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  58095. /**
  58096. * Creates a new MeshAssetTask
  58097. * @param name defines the name of the task
  58098. * @param meshesNames defines the list of mesh's names you want to load
  58099. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  58100. * @param sceneFilename defines the filename of the scene to load from
  58101. */
  58102. constructor(
  58103. /**
  58104. * Defines the name of the task
  58105. */
  58106. name: string,
  58107. /**
  58108. * Defines the list of mesh's names you want to load
  58109. */
  58110. meshesNames: any,
  58111. /**
  58112. * Defines the root url to use as a base to load your meshes and associated resources
  58113. */
  58114. rootUrl: string,
  58115. /**
  58116. * Defines the filename of the scene to load from
  58117. */
  58118. sceneFilename: string);
  58119. /**
  58120. * Execute the current task
  58121. * @param scene defines the scene where you want your assets to be loaded
  58122. * @param onSuccess is a callback called when the task is successfully executed
  58123. * @param onError is a callback called if an error occurs
  58124. */
  58125. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58126. }
  58127. /**
  58128. * Define a task used by AssetsManager to load text content
  58129. */
  58130. export class TextFileAssetTask extends AbstractAssetTask {
  58131. /**
  58132. * Defines the name of the task
  58133. */
  58134. name: string;
  58135. /**
  58136. * Defines the location of the file to load
  58137. */
  58138. url: string;
  58139. /**
  58140. * Gets the loaded text string
  58141. */
  58142. text: string;
  58143. /**
  58144. * Callback called when the task is successful
  58145. */
  58146. onSuccess: (task: TextFileAssetTask) => void;
  58147. /**
  58148. * Callback called when the task is successful
  58149. */
  58150. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  58151. /**
  58152. * Creates a new TextFileAssetTask object
  58153. * @param name defines the name of the task
  58154. * @param url defines the location of the file to load
  58155. */
  58156. constructor(
  58157. /**
  58158. * Defines the name of the task
  58159. */
  58160. name: string,
  58161. /**
  58162. * Defines the location of the file to load
  58163. */
  58164. url: string);
  58165. /**
  58166. * Execute the current task
  58167. * @param scene defines the scene where you want your assets to be loaded
  58168. * @param onSuccess is a callback called when the task is successfully executed
  58169. * @param onError is a callback called if an error occurs
  58170. */
  58171. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58172. }
  58173. /**
  58174. * Define a task used by AssetsManager to load binary data
  58175. */
  58176. export class BinaryFileAssetTask extends AbstractAssetTask {
  58177. /**
  58178. * Defines the name of the task
  58179. */
  58180. name: string;
  58181. /**
  58182. * Defines the location of the file to load
  58183. */
  58184. url: string;
  58185. /**
  58186. * Gets the lodaded data (as an array buffer)
  58187. */
  58188. data: ArrayBuffer;
  58189. /**
  58190. * Callback called when the task is successful
  58191. */
  58192. onSuccess: (task: BinaryFileAssetTask) => void;
  58193. /**
  58194. * Callback called when the task is successful
  58195. */
  58196. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  58197. /**
  58198. * Creates a new BinaryFileAssetTask object
  58199. * @param name defines the name of the new task
  58200. * @param url defines the location of the file to load
  58201. */
  58202. constructor(
  58203. /**
  58204. * Defines the name of the task
  58205. */
  58206. name: string,
  58207. /**
  58208. * Defines the location of the file to load
  58209. */
  58210. url: string);
  58211. /**
  58212. * Execute the current task
  58213. * @param scene defines the scene where you want your assets to be loaded
  58214. * @param onSuccess is a callback called when the task is successfully executed
  58215. * @param onError is a callback called if an error occurs
  58216. */
  58217. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58218. }
  58219. /**
  58220. * Define a task used by AssetsManager to load images
  58221. */
  58222. export class ImageAssetTask extends AbstractAssetTask {
  58223. /**
  58224. * Defines the name of the task
  58225. */
  58226. name: string;
  58227. /**
  58228. * Defines the location of the image to load
  58229. */
  58230. url: string;
  58231. /**
  58232. * Gets the loaded images
  58233. */
  58234. image: HTMLImageElement;
  58235. /**
  58236. * Callback called when the task is successful
  58237. */
  58238. onSuccess: (task: ImageAssetTask) => void;
  58239. /**
  58240. * Callback called when the task is successful
  58241. */
  58242. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  58243. /**
  58244. * Creates a new ImageAssetTask
  58245. * @param name defines the name of the task
  58246. * @param url defines the location of the image to load
  58247. */
  58248. constructor(
  58249. /**
  58250. * Defines the name of the task
  58251. */
  58252. name: string,
  58253. /**
  58254. * Defines the location of the image to load
  58255. */
  58256. url: string);
  58257. /**
  58258. * Execute the current task
  58259. * @param scene defines the scene where you want your assets to be loaded
  58260. * @param onSuccess is a callback called when the task is successfully executed
  58261. * @param onError is a callback called if an error occurs
  58262. */
  58263. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58264. }
  58265. /**
  58266. * Defines the interface used by texture loading tasks
  58267. */
  58268. export interface ITextureAssetTask<TEX extends BaseTexture> {
  58269. /**
  58270. * Gets the loaded texture
  58271. */
  58272. texture: TEX;
  58273. }
  58274. /**
  58275. * Define a task used by AssetsManager to load 2D textures
  58276. */
  58277. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  58278. /**
  58279. * Defines the name of the task
  58280. */
  58281. name: string;
  58282. /**
  58283. * Defines the location of the file to load
  58284. */
  58285. url: string;
  58286. /**
  58287. * Defines if mipmap should not be generated (default is false)
  58288. */
  58289. noMipmap?: boolean | undefined;
  58290. /**
  58291. * Defines if texture must be inverted on Y axis (default is false)
  58292. */
  58293. invertY?: boolean | undefined;
  58294. /**
  58295. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  58296. */
  58297. samplingMode: number;
  58298. /**
  58299. * Gets the loaded texture
  58300. */
  58301. texture: Texture;
  58302. /**
  58303. * Callback called when the task is successful
  58304. */
  58305. onSuccess: (task: TextureAssetTask) => void;
  58306. /**
  58307. * Callback called when the task is successful
  58308. */
  58309. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  58310. /**
  58311. * Creates a new TextureAssetTask object
  58312. * @param name defines the name of the task
  58313. * @param url defines the location of the file to load
  58314. * @param noMipmap defines if mipmap should not be generated (default is false)
  58315. * @param invertY defines if texture must be inverted on Y axis (default is false)
  58316. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  58317. */
  58318. constructor(
  58319. /**
  58320. * Defines the name of the task
  58321. */
  58322. name: string,
  58323. /**
  58324. * Defines the location of the file to load
  58325. */
  58326. url: string,
  58327. /**
  58328. * Defines if mipmap should not be generated (default is false)
  58329. */
  58330. noMipmap?: boolean | undefined,
  58331. /**
  58332. * Defines if texture must be inverted on Y axis (default is false)
  58333. */
  58334. invertY?: boolean | undefined,
  58335. /**
  58336. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  58337. */
  58338. samplingMode?: number);
  58339. /**
  58340. * Execute the current task
  58341. * @param scene defines the scene where you want your assets to be loaded
  58342. * @param onSuccess is a callback called when the task is successfully executed
  58343. * @param onError is a callback called if an error occurs
  58344. */
  58345. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58346. }
  58347. /**
  58348. * Define a task used by AssetsManager to load cube textures
  58349. */
  58350. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  58351. /**
  58352. * Defines the name of the task
  58353. */
  58354. name: string;
  58355. /**
  58356. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  58357. */
  58358. url: string;
  58359. /**
  58360. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  58361. */
  58362. extensions?: string[] | undefined;
  58363. /**
  58364. * Defines if mipmaps should not be generated (default is false)
  58365. */
  58366. noMipmap?: boolean | undefined;
  58367. /**
  58368. * Defines the explicit list of files (undefined by default)
  58369. */
  58370. files?: string[] | undefined;
  58371. /**
  58372. * Gets the loaded texture
  58373. */
  58374. texture: CubeTexture;
  58375. /**
  58376. * Callback called when the task is successful
  58377. */
  58378. onSuccess: (task: CubeTextureAssetTask) => void;
  58379. /**
  58380. * Callback called when the task is successful
  58381. */
  58382. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  58383. /**
  58384. * Creates a new CubeTextureAssetTask
  58385. * @param name defines the name of the task
  58386. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  58387. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  58388. * @param noMipmap defines if mipmaps should not be generated (default is false)
  58389. * @param files defines the explicit list of files (undefined by default)
  58390. */
  58391. constructor(
  58392. /**
  58393. * Defines the name of the task
  58394. */
  58395. name: string,
  58396. /**
  58397. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  58398. */
  58399. url: string,
  58400. /**
  58401. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  58402. */
  58403. extensions?: string[] | undefined,
  58404. /**
  58405. * Defines if mipmaps should not be generated (default is false)
  58406. */
  58407. noMipmap?: boolean | undefined,
  58408. /**
  58409. * Defines the explicit list of files (undefined by default)
  58410. */
  58411. files?: string[] | undefined);
  58412. /**
  58413. * Execute the current task
  58414. * @param scene defines the scene where you want your assets to be loaded
  58415. * @param onSuccess is a callback called when the task is successfully executed
  58416. * @param onError is a callback called if an error occurs
  58417. */
  58418. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58419. }
  58420. /**
  58421. * Define a task used by AssetsManager to load HDR cube textures
  58422. */
  58423. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  58424. /**
  58425. * Defines the name of the task
  58426. */
  58427. name: string;
  58428. /**
  58429. * Defines the location of the file to load
  58430. */
  58431. url: string;
  58432. /**
  58433. * Defines the desired size (the more it increases the longer the generation will be)
  58434. */
  58435. size: number;
  58436. /**
  58437. * Defines if mipmaps should not be generated (default is false)
  58438. */
  58439. noMipmap: boolean;
  58440. /**
  58441. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  58442. */
  58443. generateHarmonics: boolean;
  58444. /**
  58445. * 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)
  58446. */
  58447. gammaSpace: boolean;
  58448. /**
  58449. * Internal Use Only
  58450. */
  58451. reserved: boolean;
  58452. /**
  58453. * Gets the loaded texture
  58454. */
  58455. texture: HDRCubeTexture;
  58456. /**
  58457. * Callback called when the task is successful
  58458. */
  58459. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  58460. /**
  58461. * Callback called when the task is successful
  58462. */
  58463. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  58464. /**
  58465. * Creates a new HDRCubeTextureAssetTask object
  58466. * @param name defines the name of the task
  58467. * @param url defines the location of the file to load
  58468. * @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.
  58469. * @param noMipmap defines if mipmaps should not be generated (default is false)
  58470. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  58471. * @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)
  58472. * @param reserved Internal use only
  58473. */
  58474. constructor(
  58475. /**
  58476. * Defines the name of the task
  58477. */
  58478. name: string,
  58479. /**
  58480. * Defines the location of the file to load
  58481. */
  58482. url: string,
  58483. /**
  58484. * Defines the desired size (the more it increases the longer the generation will be)
  58485. */
  58486. size: number,
  58487. /**
  58488. * Defines if mipmaps should not be generated (default is false)
  58489. */
  58490. noMipmap?: boolean,
  58491. /**
  58492. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  58493. */
  58494. generateHarmonics?: boolean,
  58495. /**
  58496. * 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)
  58497. */
  58498. gammaSpace?: boolean,
  58499. /**
  58500. * Internal Use Only
  58501. */
  58502. reserved?: boolean);
  58503. /**
  58504. * Execute the current task
  58505. * @param scene defines the scene where you want your assets to be loaded
  58506. * @param onSuccess is a callback called when the task is successfully executed
  58507. * @param onError is a callback called if an error occurs
  58508. */
  58509. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58510. }
  58511. /**
  58512. * Define a task used by AssetsManager to load Equirectangular cube textures
  58513. */
  58514. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  58515. /**
  58516. * Defines the name of the task
  58517. */
  58518. name: string;
  58519. /**
  58520. * Defines the location of the file to load
  58521. */
  58522. url: string;
  58523. /**
  58524. * Defines the desired size (the more it increases the longer the generation will be)
  58525. */
  58526. size: number;
  58527. /**
  58528. * Defines if mipmaps should not be generated (default is false)
  58529. */
  58530. noMipmap: boolean;
  58531. /**
  58532. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  58533. * but the standard material would require them in Gamma space) (default is true)
  58534. */
  58535. gammaSpace: boolean;
  58536. /**
  58537. * Gets the loaded texture
  58538. */
  58539. texture: EquiRectangularCubeTexture;
  58540. /**
  58541. * Callback called when the task is successful
  58542. */
  58543. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  58544. /**
  58545. * Callback called when the task is successful
  58546. */
  58547. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  58548. /**
  58549. * Creates a new EquiRectangularCubeTextureAssetTask object
  58550. * @param name defines the name of the task
  58551. * @param url defines the location of the file to load
  58552. * @param size defines the desired size (the more it increases the longer the generation will be)
  58553. * If the size is omitted this implies you are using a preprocessed cubemap.
  58554. * @param noMipmap defines if mipmaps should not be generated (default is false)
  58555. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  58556. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  58557. * (default is true)
  58558. */
  58559. constructor(
  58560. /**
  58561. * Defines the name of the task
  58562. */
  58563. name: string,
  58564. /**
  58565. * Defines the location of the file to load
  58566. */
  58567. url: string,
  58568. /**
  58569. * Defines the desired size (the more it increases the longer the generation will be)
  58570. */
  58571. size: number,
  58572. /**
  58573. * Defines if mipmaps should not be generated (default is false)
  58574. */
  58575. noMipmap?: boolean,
  58576. /**
  58577. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  58578. * but the standard material would require them in Gamma space) (default is true)
  58579. */
  58580. gammaSpace?: boolean);
  58581. /**
  58582. * Execute the current task
  58583. * @param scene defines the scene where you want your assets to be loaded
  58584. * @param onSuccess is a callback called when the task is successfully executed
  58585. * @param onError is a callback called if an error occurs
  58586. */
  58587. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58588. }
  58589. /**
  58590. * This class can be used to easily import assets into a scene
  58591. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  58592. */
  58593. export class AssetsManager {
  58594. private _scene;
  58595. private _isLoading;
  58596. protected _tasks: AbstractAssetTask[];
  58597. protected _waitingTasksCount: number;
  58598. protected _totalTasksCount: number;
  58599. /**
  58600. * Callback called when all tasks are processed
  58601. */
  58602. onFinish: (tasks: AbstractAssetTask[]) => void;
  58603. /**
  58604. * Callback called when a task is successful
  58605. */
  58606. onTaskSuccess: (task: AbstractAssetTask) => void;
  58607. /**
  58608. * Callback called when a task had an error
  58609. */
  58610. onTaskError: (task: AbstractAssetTask) => void;
  58611. /**
  58612. * Callback called when a task is done (whatever the result is)
  58613. */
  58614. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  58615. /**
  58616. * Observable called when all tasks are processed
  58617. */
  58618. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  58619. /**
  58620. * Observable called when a task had an error
  58621. */
  58622. onTaskErrorObservable: Observable<AbstractAssetTask>;
  58623. /**
  58624. * Observable called when all tasks were executed
  58625. */
  58626. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  58627. /**
  58628. * Observable called when a task is done (whatever the result is)
  58629. */
  58630. onProgressObservable: Observable<IAssetsProgressEvent>;
  58631. /**
  58632. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  58633. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  58634. */
  58635. useDefaultLoadingScreen: boolean;
  58636. /**
  58637. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  58638. * when all assets have been downloaded.
  58639. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  58640. */
  58641. autoHideLoadingUI: boolean;
  58642. /**
  58643. * Creates a new AssetsManager
  58644. * @param scene defines the scene to work on
  58645. */
  58646. constructor(scene: Scene);
  58647. /**
  58648. * Add a MeshAssetTask to the list of active tasks
  58649. * @param taskName defines the name of the new task
  58650. * @param meshesNames defines the name of meshes to load
  58651. * @param rootUrl defines the root url to use to locate files
  58652. * @param sceneFilename defines the filename of the scene file
  58653. * @returns a new MeshAssetTask object
  58654. */
  58655. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  58656. /**
  58657. * Add a TextFileAssetTask to the list of active tasks
  58658. * @param taskName defines the name of the new task
  58659. * @param url defines the url of the file to load
  58660. * @returns a new TextFileAssetTask object
  58661. */
  58662. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  58663. /**
  58664. * Add a BinaryFileAssetTask to the list of active tasks
  58665. * @param taskName defines the name of the new task
  58666. * @param url defines the url of the file to load
  58667. * @returns a new BinaryFileAssetTask object
  58668. */
  58669. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  58670. /**
  58671. * Add a ImageAssetTask to the list of active tasks
  58672. * @param taskName defines the name of the new task
  58673. * @param url defines the url of the file to load
  58674. * @returns a new ImageAssetTask object
  58675. */
  58676. addImageTask(taskName: string, url: string): ImageAssetTask;
  58677. /**
  58678. * Add a TextureAssetTask to the list of active tasks
  58679. * @param taskName defines the name of the new task
  58680. * @param url defines the url of the file to load
  58681. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58682. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  58683. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58684. * @returns a new TextureAssetTask object
  58685. */
  58686. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  58687. /**
  58688. * Add a CubeTextureAssetTask to the list of active tasks
  58689. * @param taskName defines the name of the new task
  58690. * @param url defines the url of the file to load
  58691. * @param extensions defines the extension to use to load the cube map (can be null)
  58692. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58693. * @param files defines the list of files to load (can be null)
  58694. * @returns a new CubeTextureAssetTask object
  58695. */
  58696. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  58697. /**
  58698. *
  58699. * Add a HDRCubeTextureAssetTask to the list of active tasks
  58700. * @param taskName defines the name of the new task
  58701. * @param url defines the url of the file to load
  58702. * @param size defines the size you want for the cubemap (can be null)
  58703. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58704. * @param generateHarmonics defines if you want to automatically generate (true by default)
  58705. * @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)
  58706. * @param reserved Internal use only
  58707. * @returns a new HDRCubeTextureAssetTask object
  58708. */
  58709. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  58710. /**
  58711. *
  58712. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  58713. * @param taskName defines the name of the new task
  58714. * @param url defines the url of the file to load
  58715. * @param size defines the size you want for the cubemap (can be null)
  58716. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58717. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  58718. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  58719. * @returns a new EquiRectangularCubeTextureAssetTask object
  58720. */
  58721. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  58722. /**
  58723. * Remove a task from the assets manager.
  58724. * @param task the task to remove
  58725. */
  58726. removeTask(task: AbstractAssetTask): void;
  58727. private _decreaseWaitingTasksCount;
  58728. private _runTask;
  58729. /**
  58730. * Reset the AssetsManager and remove all tasks
  58731. * @return the current instance of the AssetsManager
  58732. */
  58733. reset(): AssetsManager;
  58734. /**
  58735. * Start the loading process
  58736. * @return the current instance of the AssetsManager
  58737. */
  58738. load(): AssetsManager;
  58739. /**
  58740. * Start the loading process as an async operation
  58741. * @return a promise returning the list of failed tasks
  58742. */
  58743. loadAsync(): Promise<void>;
  58744. }
  58745. }
  58746. declare module BABYLON {
  58747. /**
  58748. * Wrapper class for promise with external resolve and reject.
  58749. */
  58750. export class Deferred<T> {
  58751. /**
  58752. * The promise associated with this deferred object.
  58753. */
  58754. readonly promise: Promise<T>;
  58755. private _resolve;
  58756. private _reject;
  58757. /**
  58758. * The resolve method of the promise associated with this deferred object.
  58759. */
  58760. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  58761. /**
  58762. * The reject method of the promise associated with this deferred object.
  58763. */
  58764. readonly reject: (reason?: any) => void;
  58765. /**
  58766. * Constructor for this deferred object.
  58767. */
  58768. constructor();
  58769. }
  58770. }
  58771. declare module BABYLON {
  58772. /**
  58773. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  58774. */
  58775. export class MeshExploder {
  58776. private _centerMesh;
  58777. private _meshes;
  58778. private _meshesOrigins;
  58779. private _toCenterVectors;
  58780. private _scaledDirection;
  58781. private _newPosition;
  58782. private _centerPosition;
  58783. /**
  58784. * Explodes meshes from a center mesh.
  58785. * @param meshes The meshes to explode.
  58786. * @param centerMesh The mesh to be center of explosion.
  58787. */
  58788. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  58789. private _setCenterMesh;
  58790. /**
  58791. * Get class name
  58792. * @returns "MeshExploder"
  58793. */
  58794. getClassName(): string;
  58795. /**
  58796. * "Exploded meshes"
  58797. * @returns Array of meshes with the centerMesh at index 0.
  58798. */
  58799. getMeshes(): Array<Mesh>;
  58800. /**
  58801. * Explodes meshes giving a specific direction
  58802. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  58803. */
  58804. explode(direction?: number): void;
  58805. }
  58806. }
  58807. declare module BABYLON {
  58808. /**
  58809. * Class used to help managing file picking and drag'n'drop
  58810. */
  58811. export class FilesInput {
  58812. /**
  58813. * List of files ready to be loaded
  58814. */
  58815. static readonly FilesToLoad: {
  58816. [key: string]: File;
  58817. };
  58818. /**
  58819. * Callback called when a file is processed
  58820. */
  58821. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  58822. private _engine;
  58823. private _currentScene;
  58824. private _sceneLoadedCallback;
  58825. private _progressCallback;
  58826. private _additionalRenderLoopLogicCallback;
  58827. private _textureLoadingCallback;
  58828. private _startingProcessingFilesCallback;
  58829. private _onReloadCallback;
  58830. private _errorCallback;
  58831. private _elementToMonitor;
  58832. private _sceneFileToLoad;
  58833. private _filesToLoad;
  58834. /**
  58835. * Creates a new FilesInput
  58836. * @param engine defines the rendering engine
  58837. * @param scene defines the hosting scene
  58838. * @param sceneLoadedCallback callback called when scene is loaded
  58839. * @param progressCallback callback called to track progress
  58840. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  58841. * @param textureLoadingCallback callback called when a texture is loading
  58842. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  58843. * @param onReloadCallback callback called when a reload is requested
  58844. * @param errorCallback callback call if an error occurs
  58845. */
  58846. 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);
  58847. private _dragEnterHandler;
  58848. private _dragOverHandler;
  58849. private _dropHandler;
  58850. /**
  58851. * Calls this function to listen to drag'n'drop events on a specific DOM element
  58852. * @param elementToMonitor defines the DOM element to track
  58853. */
  58854. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  58855. /**
  58856. * Release all associated resources
  58857. */
  58858. dispose(): void;
  58859. private renderFunction;
  58860. private drag;
  58861. private drop;
  58862. private _traverseFolder;
  58863. private _processFiles;
  58864. /**
  58865. * Load files from a drop event
  58866. * @param event defines the drop event to use as source
  58867. */
  58868. loadFiles(event: any): void;
  58869. private _processReload;
  58870. /**
  58871. * Reload the current scene from the loaded files
  58872. */
  58873. reload(): void;
  58874. }
  58875. }
  58876. declare module BABYLON {
  58877. /**
  58878. * Defines the root class used to create scene optimization to use with SceneOptimizer
  58879. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58880. */
  58881. export class SceneOptimization {
  58882. /**
  58883. * Defines the priority of this optimization (0 by default which means first in the list)
  58884. */
  58885. priority: number;
  58886. /**
  58887. * Gets a string describing the action executed by the current optimization
  58888. * @returns description string
  58889. */
  58890. getDescription(): string;
  58891. /**
  58892. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58893. * @param scene defines the current scene where to apply this optimization
  58894. * @param optimizer defines the current optimizer
  58895. * @returns true if everything that can be done was applied
  58896. */
  58897. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58898. /**
  58899. * Creates the SceneOptimization object
  58900. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58901. * @param desc defines the description associated with the optimization
  58902. */
  58903. constructor(
  58904. /**
  58905. * Defines the priority of this optimization (0 by default which means first in the list)
  58906. */
  58907. priority?: number);
  58908. }
  58909. /**
  58910. * Defines an optimization used to reduce the size of render target textures
  58911. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58912. */
  58913. export class TextureOptimization extends SceneOptimization {
  58914. /**
  58915. * Defines the priority of this optimization (0 by default which means first in the list)
  58916. */
  58917. priority: number;
  58918. /**
  58919. * 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
  58920. */
  58921. maximumSize: number;
  58922. /**
  58923. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58924. */
  58925. step: number;
  58926. /**
  58927. * Gets a string describing the action executed by the current optimization
  58928. * @returns description string
  58929. */
  58930. getDescription(): string;
  58931. /**
  58932. * Creates the TextureOptimization object
  58933. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58934. * @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
  58935. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58936. */
  58937. constructor(
  58938. /**
  58939. * Defines the priority of this optimization (0 by default which means first in the list)
  58940. */
  58941. priority?: number,
  58942. /**
  58943. * 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
  58944. */
  58945. maximumSize?: number,
  58946. /**
  58947. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58948. */
  58949. step?: number);
  58950. /**
  58951. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58952. * @param scene defines the current scene where to apply this optimization
  58953. * @param optimizer defines the current optimizer
  58954. * @returns true if everything that can be done was applied
  58955. */
  58956. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58957. }
  58958. /**
  58959. * Defines an optimization used to increase or decrease the rendering resolution
  58960. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58961. */
  58962. export class HardwareScalingOptimization extends SceneOptimization {
  58963. /**
  58964. * Defines the priority of this optimization (0 by default which means first in the list)
  58965. */
  58966. priority: number;
  58967. /**
  58968. * Defines the maximum scale to use (2 by default)
  58969. */
  58970. maximumScale: number;
  58971. /**
  58972. * Defines the step to use between two passes (0.5 by default)
  58973. */
  58974. step: number;
  58975. private _currentScale;
  58976. private _directionOffset;
  58977. /**
  58978. * Gets a string describing the action executed by the current optimization
  58979. * @return description string
  58980. */
  58981. getDescription(): string;
  58982. /**
  58983. * Creates the HardwareScalingOptimization object
  58984. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58985. * @param maximumScale defines the maximum scale to use (2 by default)
  58986. * @param step defines the step to use between two passes (0.5 by default)
  58987. */
  58988. constructor(
  58989. /**
  58990. * Defines the priority of this optimization (0 by default which means first in the list)
  58991. */
  58992. priority?: number,
  58993. /**
  58994. * Defines the maximum scale to use (2 by default)
  58995. */
  58996. maximumScale?: number,
  58997. /**
  58998. * Defines the step to use between two passes (0.5 by default)
  58999. */
  59000. step?: number);
  59001. /**
  59002. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59003. * @param scene defines the current scene where to apply this optimization
  59004. * @param optimizer defines the current optimizer
  59005. * @returns true if everything that can be done was applied
  59006. */
  59007. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59008. }
  59009. /**
  59010. * Defines an optimization used to remove shadows
  59011. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59012. */
  59013. export class ShadowsOptimization extends SceneOptimization {
  59014. /**
  59015. * Gets a string describing the action executed by the current optimization
  59016. * @return description string
  59017. */
  59018. getDescription(): string;
  59019. /**
  59020. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59021. * @param scene defines the current scene where to apply this optimization
  59022. * @param optimizer defines the current optimizer
  59023. * @returns true if everything that can be done was applied
  59024. */
  59025. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59026. }
  59027. /**
  59028. * Defines an optimization used to turn post-processes off
  59029. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59030. */
  59031. export class PostProcessesOptimization extends SceneOptimization {
  59032. /**
  59033. * Gets a string describing the action executed by the current optimization
  59034. * @return description string
  59035. */
  59036. getDescription(): string;
  59037. /**
  59038. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59039. * @param scene defines the current scene where to apply this optimization
  59040. * @param optimizer defines the current optimizer
  59041. * @returns true if everything that can be done was applied
  59042. */
  59043. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59044. }
  59045. /**
  59046. * Defines an optimization used to turn lens flares off
  59047. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59048. */
  59049. export class LensFlaresOptimization extends SceneOptimization {
  59050. /**
  59051. * Gets a string describing the action executed by the current optimization
  59052. * @return description string
  59053. */
  59054. getDescription(): string;
  59055. /**
  59056. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59057. * @param scene defines the current scene where to apply this optimization
  59058. * @param optimizer defines the current optimizer
  59059. * @returns true if everything that can be done was applied
  59060. */
  59061. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59062. }
  59063. /**
  59064. * Defines an optimization based on user defined callback.
  59065. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59066. */
  59067. export class CustomOptimization extends SceneOptimization {
  59068. /**
  59069. * Callback called to apply the custom optimization.
  59070. */
  59071. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  59072. /**
  59073. * Callback called to get custom description
  59074. */
  59075. onGetDescription: () => string;
  59076. /**
  59077. * Gets a string describing the action executed by the current optimization
  59078. * @returns description string
  59079. */
  59080. getDescription(): string;
  59081. /**
  59082. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59083. * @param scene defines the current scene where to apply this optimization
  59084. * @param optimizer defines the current optimizer
  59085. * @returns true if everything that can be done was applied
  59086. */
  59087. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59088. }
  59089. /**
  59090. * Defines an optimization used to turn particles off
  59091. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59092. */
  59093. export class ParticlesOptimization extends SceneOptimization {
  59094. /**
  59095. * Gets a string describing the action executed by the current optimization
  59096. * @return description string
  59097. */
  59098. getDescription(): string;
  59099. /**
  59100. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59101. * @param scene defines the current scene where to apply this optimization
  59102. * @param optimizer defines the current optimizer
  59103. * @returns true if everything that can be done was applied
  59104. */
  59105. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59106. }
  59107. /**
  59108. * Defines an optimization used to turn render targets off
  59109. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59110. */
  59111. export class RenderTargetsOptimization extends SceneOptimization {
  59112. /**
  59113. * Gets a string describing the action executed by the current optimization
  59114. * @return description string
  59115. */
  59116. getDescription(): string;
  59117. /**
  59118. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59119. * @param scene defines the current scene where to apply this optimization
  59120. * @param optimizer defines the current optimizer
  59121. * @returns true if everything that can be done was applied
  59122. */
  59123. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59124. }
  59125. /**
  59126. * Defines an optimization used to merge meshes with compatible materials
  59127. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59128. */
  59129. export class MergeMeshesOptimization extends SceneOptimization {
  59130. private static _UpdateSelectionTree;
  59131. /**
  59132. * Gets or sets a boolean which defines if optimization octree has to be updated
  59133. */
  59134. /**
  59135. * Gets or sets a boolean which defines if optimization octree has to be updated
  59136. */
  59137. static UpdateSelectionTree: boolean;
  59138. /**
  59139. * Gets a string describing the action executed by the current optimization
  59140. * @return description string
  59141. */
  59142. getDescription(): string;
  59143. private _canBeMerged;
  59144. /**
  59145. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59146. * @param scene defines the current scene where to apply this optimization
  59147. * @param optimizer defines the current optimizer
  59148. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  59149. * @returns true if everything that can be done was applied
  59150. */
  59151. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  59152. }
  59153. /**
  59154. * Defines a list of options used by SceneOptimizer
  59155. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59156. */
  59157. export class SceneOptimizerOptions {
  59158. /**
  59159. * Defines the target frame rate to reach (60 by default)
  59160. */
  59161. targetFrameRate: number;
  59162. /**
  59163. * Defines the interval between two checkes (2000ms by default)
  59164. */
  59165. trackerDuration: number;
  59166. /**
  59167. * Gets the list of optimizations to apply
  59168. */
  59169. optimizations: SceneOptimization[];
  59170. /**
  59171. * Creates a new list of options used by SceneOptimizer
  59172. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  59173. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  59174. */
  59175. constructor(
  59176. /**
  59177. * Defines the target frame rate to reach (60 by default)
  59178. */
  59179. targetFrameRate?: number,
  59180. /**
  59181. * Defines the interval between two checkes (2000ms by default)
  59182. */
  59183. trackerDuration?: number);
  59184. /**
  59185. * Add a new optimization
  59186. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  59187. * @returns the current SceneOptimizerOptions
  59188. */
  59189. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  59190. /**
  59191. * Add a new custom optimization
  59192. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  59193. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  59194. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  59195. * @returns the current SceneOptimizerOptions
  59196. */
  59197. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  59198. /**
  59199. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  59200. * @param targetFrameRate defines the target frame rate (60 by default)
  59201. * @returns a SceneOptimizerOptions object
  59202. */
  59203. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  59204. /**
  59205. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  59206. * @param targetFrameRate defines the target frame rate (60 by default)
  59207. * @returns a SceneOptimizerOptions object
  59208. */
  59209. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  59210. /**
  59211. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  59212. * @param targetFrameRate defines the target frame rate (60 by default)
  59213. * @returns a SceneOptimizerOptions object
  59214. */
  59215. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  59216. }
  59217. /**
  59218. * Class used to run optimizations in order to reach a target frame rate
  59219. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59220. */
  59221. export class SceneOptimizer implements IDisposable {
  59222. private _isRunning;
  59223. private _options;
  59224. private _scene;
  59225. private _currentPriorityLevel;
  59226. private _targetFrameRate;
  59227. private _trackerDuration;
  59228. private _currentFrameRate;
  59229. private _sceneDisposeObserver;
  59230. private _improvementMode;
  59231. /**
  59232. * Defines an observable called when the optimizer reaches the target frame rate
  59233. */
  59234. onSuccessObservable: Observable<SceneOptimizer>;
  59235. /**
  59236. * Defines an observable called when the optimizer enables an optimization
  59237. */
  59238. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  59239. /**
  59240. * Defines an observable called when the optimizer is not able to reach the target frame rate
  59241. */
  59242. onFailureObservable: Observable<SceneOptimizer>;
  59243. /**
  59244. * Gets a boolean indicating if the optimizer is in improvement mode
  59245. */
  59246. readonly isInImprovementMode: boolean;
  59247. /**
  59248. * Gets the current priority level (0 at start)
  59249. */
  59250. readonly currentPriorityLevel: number;
  59251. /**
  59252. * Gets the current frame rate checked by the SceneOptimizer
  59253. */
  59254. readonly currentFrameRate: number;
  59255. /**
  59256. * Gets or sets the current target frame rate (60 by default)
  59257. */
  59258. /**
  59259. * Gets or sets the current target frame rate (60 by default)
  59260. */
  59261. targetFrameRate: number;
  59262. /**
  59263. * Gets or sets the current interval between two checks (every 2000ms by default)
  59264. */
  59265. /**
  59266. * Gets or sets the current interval between two checks (every 2000ms by default)
  59267. */
  59268. trackerDuration: number;
  59269. /**
  59270. * Gets the list of active optimizations
  59271. */
  59272. readonly optimizations: SceneOptimization[];
  59273. /**
  59274. * Creates a new SceneOptimizer
  59275. * @param scene defines the scene to work on
  59276. * @param options defines the options to use with the SceneOptimizer
  59277. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  59278. * @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)
  59279. */
  59280. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  59281. /**
  59282. * Stops the current optimizer
  59283. */
  59284. stop(): void;
  59285. /**
  59286. * Reset the optimizer to initial step (current priority level = 0)
  59287. */
  59288. reset(): void;
  59289. /**
  59290. * Start the optimizer. By default it will try to reach a specific framerate
  59291. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  59292. */
  59293. start(): void;
  59294. private _checkCurrentState;
  59295. /**
  59296. * Release all resources
  59297. */
  59298. dispose(): void;
  59299. /**
  59300. * Helper function to create a SceneOptimizer with one single line of code
  59301. * @param scene defines the scene to work on
  59302. * @param options defines the options to use with the SceneOptimizer
  59303. * @param onSuccess defines a callback to call on success
  59304. * @param onFailure defines a callback to call on failure
  59305. * @returns the new SceneOptimizer object
  59306. */
  59307. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  59308. }
  59309. }
  59310. declare module BABYLON {
  59311. /**
  59312. * Class used to serialize a scene into a string
  59313. */
  59314. export class SceneSerializer {
  59315. /**
  59316. * Clear cache used by a previous serialization
  59317. */
  59318. static ClearCache(): void;
  59319. /**
  59320. * Serialize a scene into a JSON compatible object
  59321. * @param scene defines the scene to serialize
  59322. * @returns a JSON compatible object
  59323. */
  59324. static Serialize(scene: Scene): any;
  59325. /**
  59326. * Serialize a mesh into a JSON compatible object
  59327. * @param toSerialize defines the mesh to serialize
  59328. * @param withParents defines if parents must be serialized as well
  59329. * @param withChildren defines if children must be serialized as well
  59330. * @returns a JSON compatible object
  59331. */
  59332. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  59333. }
  59334. }
  59335. declare module BABYLON {
  59336. /**
  59337. * Class used to host texture specific utilities
  59338. */
  59339. export class TextureTools {
  59340. /**
  59341. * Uses the GPU to create a copy texture rescaled at a given size
  59342. * @param texture Texture to copy from
  59343. * @param width defines the desired width
  59344. * @param height defines the desired height
  59345. * @param useBilinearMode defines if bilinear mode has to be used
  59346. * @return the generated texture
  59347. */
  59348. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  59349. }
  59350. }
  59351. declare module BABYLON {
  59352. /**
  59353. * This represents the different options available for the video capture.
  59354. */
  59355. export interface VideoRecorderOptions {
  59356. /** Defines the mime type of the video. */
  59357. mimeType: string;
  59358. /** Defines the FPS the video should be recorded at. */
  59359. fps: number;
  59360. /** Defines the chunk size for the recording data. */
  59361. recordChunckSize: number;
  59362. /** The audio tracks to attach to the recording. */
  59363. audioTracks?: MediaStreamTrack[];
  59364. }
  59365. /**
  59366. * This can help with recording videos from BabylonJS.
  59367. * This is based on the available WebRTC functionalities of the browser.
  59368. *
  59369. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  59370. */
  59371. export class VideoRecorder {
  59372. private static readonly _defaultOptions;
  59373. /**
  59374. * Returns whether or not the VideoRecorder is available in your browser.
  59375. * @param engine Defines the Babylon Engine.
  59376. * @returns true if supported otherwise false.
  59377. */
  59378. static IsSupported(engine: Engine): boolean;
  59379. private readonly _options;
  59380. private _canvas;
  59381. private _mediaRecorder;
  59382. private _recordedChunks;
  59383. private _fileName;
  59384. private _resolve;
  59385. private _reject;
  59386. /**
  59387. * True when a recording is already in progress.
  59388. */
  59389. readonly isRecording: boolean;
  59390. /**
  59391. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  59392. * @param engine Defines the BabylonJS Engine you wish to record.
  59393. * @param options Defines options that can be used to customize the capture.
  59394. */
  59395. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  59396. /**
  59397. * Stops the current recording before the default capture timeout passed in the startRecording function.
  59398. */
  59399. stopRecording(): void;
  59400. /**
  59401. * Starts recording the canvas for a max duration specified in parameters.
  59402. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  59403. * If null no automatic download will start and you can rely on the promise to get the data back.
  59404. * @param maxDuration Defines the maximum recording time in seconds.
  59405. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  59406. * @return A promise callback at the end of the recording with the video data in Blob.
  59407. */
  59408. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  59409. /**
  59410. * Releases internal resources used during the recording.
  59411. */
  59412. dispose(): void;
  59413. private _handleDataAvailable;
  59414. private _handleError;
  59415. private _handleStop;
  59416. }
  59417. }
  59418. declare module BABYLON {
  59419. /**
  59420. * Class containing a set of static utilities functions for screenshots
  59421. */
  59422. export class ScreenshotTools {
  59423. /**
  59424. * Captures a screenshot of the current rendering
  59425. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  59426. * @param engine defines the rendering engine
  59427. * @param camera defines the source camera
  59428. * @param size This parameter can be set to a single number or to an object with the
  59429. * following (optional) properties: precision, width, height. If a single number is passed,
  59430. * it will be used for both width and height. If an object is passed, the screenshot size
  59431. * will be derived from the parameters. The precision property is a multiplier allowing
  59432. * rendering at a higher or lower resolution
  59433. * @param successCallback defines the callback receives a single parameter which contains the
  59434. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  59435. * src parameter of an <img> to display it
  59436. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  59437. * Check your browser for supported MIME types
  59438. */
  59439. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  59440. /**
  59441. * Generates an image screenshot from the specified camera.
  59442. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  59443. * @param engine The engine to use for rendering
  59444. * @param camera The camera to use for rendering
  59445. * @param size This parameter can be set to a single number or to an object with the
  59446. * following (optional) properties: precision, width, height. If a single number is passed,
  59447. * it will be used for both width and height. If an object is passed, the screenshot size
  59448. * will be derived from the parameters. The precision property is a multiplier allowing
  59449. * rendering at a higher or lower resolution
  59450. * @param successCallback The callback receives a single parameter which contains the
  59451. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  59452. * src parameter of an <img> to display it
  59453. * @param mimeType The MIME type of the screenshot image (default: image/png).
  59454. * Check your browser for supported MIME types
  59455. * @param samples Texture samples (default: 1)
  59456. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  59457. * @param fileName A name for for the downloaded file.
  59458. */
  59459. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  59460. }
  59461. }
  59462. declare module BABYLON {
  59463. /**
  59464. * A cursor which tracks a point on a path
  59465. */
  59466. export class PathCursor {
  59467. private path;
  59468. /**
  59469. * Stores path cursor callbacks for when an onchange event is triggered
  59470. */
  59471. private _onchange;
  59472. /**
  59473. * The value of the path cursor
  59474. */
  59475. value: number;
  59476. /**
  59477. * The animation array of the path cursor
  59478. */
  59479. animations: Animation[];
  59480. /**
  59481. * Initializes the path cursor
  59482. * @param path The path to track
  59483. */
  59484. constructor(path: Path2);
  59485. /**
  59486. * Gets the cursor point on the path
  59487. * @returns A point on the path cursor at the cursor location
  59488. */
  59489. getPoint(): Vector3;
  59490. /**
  59491. * Moves the cursor ahead by the step amount
  59492. * @param step The amount to move the cursor forward
  59493. * @returns This path cursor
  59494. */
  59495. moveAhead(step?: number): PathCursor;
  59496. /**
  59497. * Moves the cursor behind by the step amount
  59498. * @param step The amount to move the cursor back
  59499. * @returns This path cursor
  59500. */
  59501. moveBack(step?: number): PathCursor;
  59502. /**
  59503. * Moves the cursor by the step amount
  59504. * If the step amount is greater than one, an exception is thrown
  59505. * @param step The amount to move the cursor
  59506. * @returns This path cursor
  59507. */
  59508. move(step: number): PathCursor;
  59509. /**
  59510. * Ensures that the value is limited between zero and one
  59511. * @returns This path cursor
  59512. */
  59513. private ensureLimits;
  59514. /**
  59515. * Runs onchange callbacks on change (used by the animation engine)
  59516. * @returns This path cursor
  59517. */
  59518. private raiseOnChange;
  59519. /**
  59520. * Executes a function on change
  59521. * @param f A path cursor onchange callback
  59522. * @returns This path cursor
  59523. */
  59524. onchange(f: (cursor: PathCursor) => void): PathCursor;
  59525. }
  59526. }
  59527. declare module BABYLON {
  59528. /** @hidden */
  59529. export var blurPixelShader: {
  59530. name: string;
  59531. shader: string;
  59532. };
  59533. }
  59534. declare module BABYLON {
  59535. /** @hidden */
  59536. export var pointCloudVertexDeclaration: {
  59537. name: string;
  59538. shader: string;
  59539. };
  59540. }
  59541. // Mixins
  59542. interface Window {
  59543. mozIndexedDB: IDBFactory;
  59544. webkitIndexedDB: IDBFactory;
  59545. msIndexedDB: IDBFactory;
  59546. webkitURL: typeof URL;
  59547. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  59548. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  59549. WebGLRenderingContext: WebGLRenderingContext;
  59550. MSGesture: MSGesture;
  59551. CANNON: any;
  59552. AudioContext: AudioContext;
  59553. webkitAudioContext: AudioContext;
  59554. PointerEvent: any;
  59555. Math: Math;
  59556. Uint8Array: Uint8ArrayConstructor;
  59557. Float32Array: Float32ArrayConstructor;
  59558. mozURL: typeof URL;
  59559. msURL: typeof URL;
  59560. VRFrameData: any; // WebVR, from specs 1.1
  59561. DracoDecoderModule: any;
  59562. setImmediate(handler: (...args: any[]) => void): number;
  59563. }
  59564. interface HTMLCanvasElement {
  59565. requestPointerLock(): void;
  59566. msRequestPointerLock?(): void;
  59567. mozRequestPointerLock?(): void;
  59568. webkitRequestPointerLock?(): void;
  59569. /** Track wether a record is in progress */
  59570. isRecording: boolean;
  59571. /** Capture Stream method defined by some browsers */
  59572. captureStream(fps?: number): MediaStream;
  59573. }
  59574. interface CanvasRenderingContext2D {
  59575. msImageSmoothingEnabled: boolean;
  59576. }
  59577. interface MouseEvent {
  59578. mozMovementX: number;
  59579. mozMovementY: number;
  59580. webkitMovementX: number;
  59581. webkitMovementY: number;
  59582. msMovementX: number;
  59583. msMovementY: number;
  59584. }
  59585. interface Navigator {
  59586. mozGetVRDevices: (any: any) => any;
  59587. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59588. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59589. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59590. webkitGetGamepads(): Gamepad[];
  59591. msGetGamepads(): Gamepad[];
  59592. webkitGamepads(): Gamepad[];
  59593. }
  59594. interface HTMLVideoElement {
  59595. mozSrcObject: any;
  59596. }
  59597. interface Math {
  59598. fround(x: number): number;
  59599. imul(a: number, b: number): number;
  59600. }
  59601. interface WebGLRenderingContext {
  59602. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  59603. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  59604. vertexAttribDivisor(index: number, divisor: number): void;
  59605. createVertexArray(): any;
  59606. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  59607. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  59608. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  59609. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  59610. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  59611. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  59612. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  59613. // Queries
  59614. createQuery(): WebGLQuery;
  59615. deleteQuery(query: WebGLQuery): void;
  59616. beginQuery(target: number, query: WebGLQuery): void;
  59617. endQuery(target: number): void;
  59618. getQueryParameter(query: WebGLQuery, pname: number): any;
  59619. getQuery(target: number, pname: number): any;
  59620. MAX_SAMPLES: number;
  59621. RGBA8: number;
  59622. READ_FRAMEBUFFER: number;
  59623. DRAW_FRAMEBUFFER: number;
  59624. UNIFORM_BUFFER: number;
  59625. HALF_FLOAT_OES: number;
  59626. RGBA16F: number;
  59627. RGBA32F: number;
  59628. R32F: number;
  59629. RG32F: number;
  59630. RGB32F: number;
  59631. R16F: number;
  59632. RG16F: number;
  59633. RGB16F: number;
  59634. RED: number;
  59635. RG: number;
  59636. R8: number;
  59637. RG8: number;
  59638. UNSIGNED_INT_24_8: number;
  59639. DEPTH24_STENCIL8: number;
  59640. /* Multiple Render Targets */
  59641. drawBuffers(buffers: number[]): void;
  59642. readBuffer(src: number): void;
  59643. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  59644. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  59645. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  59646. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  59647. // Occlusion Query
  59648. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  59649. ANY_SAMPLES_PASSED: number;
  59650. QUERY_RESULT_AVAILABLE: number;
  59651. QUERY_RESULT: number;
  59652. }
  59653. interface WebGLProgram {
  59654. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  59655. }
  59656. interface EXT_disjoint_timer_query {
  59657. QUERY_COUNTER_BITS_EXT: number;
  59658. TIME_ELAPSED_EXT: number;
  59659. TIMESTAMP_EXT: number;
  59660. GPU_DISJOINT_EXT: number;
  59661. QUERY_RESULT_EXT: number;
  59662. QUERY_RESULT_AVAILABLE_EXT: number;
  59663. queryCounterEXT(query: WebGLQuery, target: number): void;
  59664. createQueryEXT(): WebGLQuery;
  59665. beginQueryEXT(target: number, query: WebGLQuery): void;
  59666. endQueryEXT(target: number): void;
  59667. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  59668. deleteQueryEXT(query: WebGLQuery): void;
  59669. }
  59670. interface WebGLUniformLocation {
  59671. _currentState: any;
  59672. }
  59673. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  59674. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  59675. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  59676. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  59677. interface WebGLRenderingContext {
  59678. readonly RASTERIZER_DISCARD: number;
  59679. readonly DEPTH_COMPONENT24: number;
  59680. readonly TEXTURE_3D: number;
  59681. readonly TEXTURE_2D_ARRAY: number;
  59682. readonly TEXTURE_COMPARE_FUNC: number;
  59683. readonly TEXTURE_COMPARE_MODE: number;
  59684. readonly COMPARE_REF_TO_TEXTURE: number;
  59685. readonly TEXTURE_WRAP_R: number;
  59686. readonly HALF_FLOAT: number;
  59687. readonly RGB8: number;
  59688. readonly RED_INTEGER: number;
  59689. readonly RG_INTEGER: number;
  59690. readonly RGB_INTEGER: number;
  59691. readonly RGBA_INTEGER: number;
  59692. readonly R8_SNORM: number;
  59693. readonly RG8_SNORM: number;
  59694. readonly RGB8_SNORM: number;
  59695. readonly RGBA8_SNORM: number;
  59696. readonly R8I: number;
  59697. readonly RG8I: number;
  59698. readonly RGB8I: number;
  59699. readonly RGBA8I: number;
  59700. readonly R8UI: number;
  59701. readonly RG8UI: number;
  59702. readonly RGB8UI: number;
  59703. readonly RGBA8UI: number;
  59704. readonly R16I: number;
  59705. readonly RG16I: number;
  59706. readonly RGB16I: number;
  59707. readonly RGBA16I: number;
  59708. readonly R16UI: number;
  59709. readonly RG16UI: number;
  59710. readonly RGB16UI: number;
  59711. readonly RGBA16UI: number;
  59712. readonly R32I: number;
  59713. readonly RG32I: number;
  59714. readonly RGB32I: number;
  59715. readonly RGBA32I: number;
  59716. readonly R32UI: number;
  59717. readonly RG32UI: number;
  59718. readonly RGB32UI: number;
  59719. readonly RGBA32UI: number;
  59720. readonly RGB10_A2UI: number;
  59721. readonly R11F_G11F_B10F: number;
  59722. readonly RGB9_E5: number;
  59723. readonly RGB10_A2: number;
  59724. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  59725. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  59726. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  59727. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  59728. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  59729. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  59730. 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;
  59731. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  59732. readonly TRANSFORM_FEEDBACK: number;
  59733. readonly INTERLEAVED_ATTRIBS: number;
  59734. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  59735. createTransformFeedback(): WebGLTransformFeedback;
  59736. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  59737. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  59738. beginTransformFeedback(primitiveMode: number): void;
  59739. endTransformFeedback(): void;
  59740. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  59741. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59742. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59743. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59744. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  59745. }
  59746. interface ImageBitmap {
  59747. readonly width: number;
  59748. readonly height: number;
  59749. close(): void;
  59750. }
  59751. interface WebGLQuery extends WebGLObject {
  59752. }
  59753. declare var WebGLQuery: {
  59754. prototype: WebGLQuery;
  59755. new(): WebGLQuery;
  59756. };
  59757. interface WebGLSampler extends WebGLObject {
  59758. }
  59759. declare var WebGLSampler: {
  59760. prototype: WebGLSampler;
  59761. new(): WebGLSampler;
  59762. };
  59763. interface WebGLSync extends WebGLObject {
  59764. }
  59765. declare var WebGLSync: {
  59766. prototype: WebGLSync;
  59767. new(): WebGLSync;
  59768. };
  59769. interface WebGLTransformFeedback extends WebGLObject {
  59770. }
  59771. declare var WebGLTransformFeedback: {
  59772. prototype: WebGLTransformFeedback;
  59773. new(): WebGLTransformFeedback;
  59774. };
  59775. interface WebGLVertexArrayObject extends WebGLObject {
  59776. }
  59777. declare var WebGLVertexArrayObject: {
  59778. prototype: WebGLVertexArrayObject;
  59779. new(): WebGLVertexArrayObject;
  59780. };
  59781. // Type definitions for WebVR API
  59782. // Project: https://w3c.github.io/webvr/
  59783. // Definitions by: six a <https://github.com/lostfictions>
  59784. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  59785. interface VRDisplay extends EventTarget {
  59786. /**
  59787. * Dictionary of capabilities describing the VRDisplay.
  59788. */
  59789. readonly capabilities: VRDisplayCapabilities;
  59790. /**
  59791. * z-depth defining the far plane of the eye view frustum
  59792. * enables mapping of values in the render target depth
  59793. * attachment to scene coordinates. Initially set to 10000.0.
  59794. */
  59795. depthFar: number;
  59796. /**
  59797. * z-depth defining the near plane of the eye view frustum
  59798. * enables mapping of values in the render target depth
  59799. * attachment to scene coordinates. Initially set to 0.01.
  59800. */
  59801. depthNear: number;
  59802. /**
  59803. * An identifier for this distinct VRDisplay. Used as an
  59804. * association point in the Gamepad API.
  59805. */
  59806. readonly displayId: number;
  59807. /**
  59808. * A display name, a user-readable name identifying it.
  59809. */
  59810. readonly displayName: string;
  59811. readonly isConnected: boolean;
  59812. readonly isPresenting: boolean;
  59813. /**
  59814. * If this VRDisplay supports room-scale experiences, the optional
  59815. * stage attribute contains details on the room-scale parameters.
  59816. */
  59817. readonly stageParameters: VRStageParameters | null;
  59818. /**
  59819. * Passing the value returned by `requestAnimationFrame` to
  59820. * `cancelAnimationFrame` will unregister the callback.
  59821. * @param handle Define the hanle of the request to cancel
  59822. */
  59823. cancelAnimationFrame(handle: number): void;
  59824. /**
  59825. * Stops presenting to the VRDisplay.
  59826. * @returns a promise to know when it stopped
  59827. */
  59828. exitPresent(): Promise<void>;
  59829. /**
  59830. * Return the current VREyeParameters for the given eye.
  59831. * @param whichEye Define the eye we want the parameter for
  59832. * @returns the eye parameters
  59833. */
  59834. getEyeParameters(whichEye: string): VREyeParameters;
  59835. /**
  59836. * Populates the passed VRFrameData with the information required to render
  59837. * the current frame.
  59838. * @param frameData Define the data structure to populate
  59839. * @returns true if ok otherwise false
  59840. */
  59841. getFrameData(frameData: VRFrameData): boolean;
  59842. /**
  59843. * Get the layers currently being presented.
  59844. * @returns the list of VR layers
  59845. */
  59846. getLayers(): VRLayer[];
  59847. /**
  59848. * Return a VRPose containing the future predicted pose of the VRDisplay
  59849. * when the current frame will be presented. The value returned will not
  59850. * change until JavaScript has returned control to the browser.
  59851. *
  59852. * The VRPose will contain the position, orientation, velocity,
  59853. * and acceleration of each of these properties.
  59854. * @returns the pose object
  59855. */
  59856. getPose(): VRPose;
  59857. /**
  59858. * Return the current instantaneous pose of the VRDisplay, with no
  59859. * prediction applied.
  59860. * @returns the current instantaneous pose
  59861. */
  59862. getImmediatePose(): VRPose;
  59863. /**
  59864. * The callback passed to `requestAnimationFrame` will be called
  59865. * any time a new frame should be rendered. When the VRDisplay is
  59866. * presenting the callback will be called at the native refresh
  59867. * rate of the HMD. When not presenting this function acts
  59868. * identically to how window.requestAnimationFrame acts. Content should
  59869. * make no assumptions of frame rate or vsync behavior as the HMD runs
  59870. * asynchronously from other displays and at differing refresh rates.
  59871. * @param callback Define the eaction to run next frame
  59872. * @returns the request handle it
  59873. */
  59874. requestAnimationFrame(callback: FrameRequestCallback): number;
  59875. /**
  59876. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  59877. * Repeat calls while already presenting will update the VRLayers being displayed.
  59878. * @param layers Define the list of layer to present
  59879. * @returns a promise to know when the request has been fulfilled
  59880. */
  59881. requestPresent(layers: VRLayer[]): Promise<void>;
  59882. /**
  59883. * Reset the pose for this display, treating its current position and
  59884. * orientation as the "origin/zero" values. VRPose.position,
  59885. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  59886. * updated when calling resetPose(). This should be called in only
  59887. * sitting-space experiences.
  59888. */
  59889. resetPose(): void;
  59890. /**
  59891. * The VRLayer provided to the VRDisplay will be captured and presented
  59892. * in the HMD. Calling this function has the same effect on the source
  59893. * canvas as any other operation that uses its source image, and canvases
  59894. * created without preserveDrawingBuffer set to true will be cleared.
  59895. * @param pose Define the pose to submit
  59896. */
  59897. submitFrame(pose?: VRPose): void;
  59898. }
  59899. declare var VRDisplay: {
  59900. prototype: VRDisplay;
  59901. new(): VRDisplay;
  59902. };
  59903. interface VRLayer {
  59904. leftBounds?: number[] | Float32Array | null;
  59905. rightBounds?: number[] | Float32Array | null;
  59906. source?: HTMLCanvasElement | null;
  59907. }
  59908. interface VRDisplayCapabilities {
  59909. readonly canPresent: boolean;
  59910. readonly hasExternalDisplay: boolean;
  59911. readonly hasOrientation: boolean;
  59912. readonly hasPosition: boolean;
  59913. readonly maxLayers: number;
  59914. }
  59915. interface VREyeParameters {
  59916. /** @deprecated */
  59917. readonly fieldOfView: VRFieldOfView;
  59918. readonly offset: Float32Array;
  59919. readonly renderHeight: number;
  59920. readonly renderWidth: number;
  59921. }
  59922. interface VRFieldOfView {
  59923. readonly downDegrees: number;
  59924. readonly leftDegrees: number;
  59925. readonly rightDegrees: number;
  59926. readonly upDegrees: number;
  59927. }
  59928. interface VRFrameData {
  59929. readonly leftProjectionMatrix: Float32Array;
  59930. readonly leftViewMatrix: Float32Array;
  59931. readonly pose: VRPose;
  59932. readonly rightProjectionMatrix: Float32Array;
  59933. readonly rightViewMatrix: Float32Array;
  59934. readonly timestamp: number;
  59935. }
  59936. interface VRPose {
  59937. readonly angularAcceleration: Float32Array | null;
  59938. readonly angularVelocity: Float32Array | null;
  59939. readonly linearAcceleration: Float32Array | null;
  59940. readonly linearVelocity: Float32Array | null;
  59941. readonly orientation: Float32Array | null;
  59942. readonly position: Float32Array | null;
  59943. readonly timestamp: number;
  59944. }
  59945. interface VRStageParameters {
  59946. sittingToStandingTransform?: Float32Array;
  59947. sizeX?: number;
  59948. sizeY?: number;
  59949. }
  59950. interface Navigator {
  59951. getVRDisplays(): Promise<VRDisplay[]>;
  59952. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  59953. }
  59954. interface Window {
  59955. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  59956. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  59957. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  59958. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  59959. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  59960. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  59961. }
  59962. interface Gamepad {
  59963. readonly displayId: number;
  59964. }
  59965. type XRSessionMode =
  59966. | "inline"
  59967. | "immersive-vr"
  59968. | "immersive-ar";
  59969. type XRReferenceSpaceType =
  59970. | "viewer"
  59971. | "local"
  59972. | "local-floor"
  59973. | "bounded-floor"
  59974. | "unbounded";
  59975. type XREnvironmentBlendMode =
  59976. | "opaque"
  59977. | "additive"
  59978. | "alpha-blend";
  59979. type XRVisibilityState =
  59980. | "visible"
  59981. | "visible-blurred"
  59982. | "hidden";
  59983. type XRHandedness =
  59984. | "none"
  59985. | "left"
  59986. | "right";
  59987. type XRTargetRayMode =
  59988. | "gaze"
  59989. | "tracked-pointer"
  59990. | "screen";
  59991. type XREye =
  59992. | "none"
  59993. | "left"
  59994. | "right";
  59995. interface XRSpace extends EventTarget {
  59996. }
  59997. interface XRRenderState {
  59998. depthNear: number ;
  59999. depthFar: number ;
  60000. inlineVerticalFieldOfView: number | undefined;
  60001. baseLayer: XRWebGLLayer | undefined;
  60002. }
  60003. interface XRInputSource {
  60004. handedness: XRHandedness;
  60005. targetRayMode: XRTargetRayMode;
  60006. targetRaySpace: XRSpace;
  60007. gripSpace: XRSpace | undefined;
  60008. gamepad: Gamepad | undefined;
  60009. profiles: Array<string>;
  60010. }
  60011. interface XRSession {
  60012. addEventListener: Function;
  60013. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  60014. updateRenderState(XRRenderStateInit: any): Promise<void>;
  60015. requestAnimationFrame: Function;
  60016. end(): Promise<void>;
  60017. renderState: XRRenderState;
  60018. inputSources: Array<XRInputSource>;
  60019. }
  60020. interface XRReferenceSpace extends XRSpace {
  60021. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  60022. onreset: any;
  60023. }
  60024. interface XRFrame {
  60025. session: XRSession;
  60026. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  60027. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  60028. }
  60029. interface XRViewerPose extends XRPose {
  60030. views: Array<XRView>;
  60031. }
  60032. interface XRPose {
  60033. transform: XRRigidTransform;
  60034. emulatedPosition: boolean;
  60035. }
  60036. declare var XRWebGLLayer: {
  60037. prototype: XRWebGLLayer;
  60038. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  60039. };
  60040. interface XRWebGLLayer {
  60041. framebuffer: WebGLFramebuffer;
  60042. framebufferWidth: number;
  60043. framebufferHeight: number;
  60044. getViewport: Function;
  60045. }
  60046. interface XRRigidTransform {
  60047. position: DOMPointReadOnly;
  60048. orientation: DOMPointReadOnly;
  60049. matrix: Float32Array;
  60050. inverse: XRRigidTransform;
  60051. }
  60052. interface XRView {
  60053. eye: XREye;
  60054. projectionMatrix: Float32Array;
  60055. transform: XRRigidTransform;
  60056. }
  60057. interface XRInputSourceChangeEvent {
  60058. session: XRSession;
  60059. removed: Array<XRInputSource>;
  60060. added: Array<XRInputSource>;
  60061. }
  60062. declare module BABYLON.GUI {
  60063. /**
  60064. * Class used to specific a value and its associated unit
  60065. */
  60066. export class ValueAndUnit {
  60067. /** defines the unit to store */
  60068. unit: number;
  60069. /** defines a boolean indicating if the value can be negative */
  60070. negativeValueAllowed: boolean;
  60071. private _value;
  60072. private _originalUnit;
  60073. /**
  60074. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  60075. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  60076. */
  60077. ignoreAdaptiveScaling: boolean;
  60078. /**
  60079. * Creates a new ValueAndUnit
  60080. * @param value defines the value to store
  60081. * @param unit defines the unit to store
  60082. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  60083. */
  60084. constructor(value: number,
  60085. /** defines the unit to store */
  60086. unit?: number,
  60087. /** defines a boolean indicating if the value can be negative */
  60088. negativeValueAllowed?: boolean);
  60089. /** Gets a boolean indicating if the value is a percentage */
  60090. readonly isPercentage: boolean;
  60091. /** Gets a boolean indicating if the value is store as pixel */
  60092. readonly isPixel: boolean;
  60093. /** Gets direct internal value */
  60094. readonly internalValue: number;
  60095. /**
  60096. * Gets value as pixel
  60097. * @param host defines the root host
  60098. * @param refValue defines the reference value for percentages
  60099. * @returns the value as pixel
  60100. */
  60101. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  60102. /**
  60103. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  60104. * @param value defines the value to store
  60105. * @param unit defines the unit to store
  60106. * @returns the current ValueAndUnit
  60107. */
  60108. updateInPlace(value: number, unit?: number): ValueAndUnit;
  60109. /**
  60110. * Gets the value accordingly to its unit
  60111. * @param host defines the root host
  60112. * @returns the value
  60113. */
  60114. getValue(host: AdvancedDynamicTexture): number;
  60115. /**
  60116. * Gets a string representation of the value
  60117. * @param host defines the root host
  60118. * @param decimals defines an optional number of decimals to display
  60119. * @returns a string
  60120. */
  60121. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  60122. /**
  60123. * Store a value parsed from a string
  60124. * @param source defines the source string
  60125. * @returns true if the value was successfully parsed
  60126. */
  60127. fromString(source: string | number): boolean;
  60128. private static _Regex;
  60129. private static _UNITMODE_PERCENTAGE;
  60130. private static _UNITMODE_PIXEL;
  60131. /** UNITMODE_PERCENTAGE */
  60132. static readonly UNITMODE_PERCENTAGE: number;
  60133. /** UNITMODE_PIXEL */
  60134. static readonly UNITMODE_PIXEL: number;
  60135. }
  60136. }
  60137. declare module BABYLON.GUI {
  60138. /**
  60139. * Define a style used by control to automatically setup properties based on a template.
  60140. * Only support font related properties so far
  60141. */
  60142. export class Style implements BABYLON.IDisposable {
  60143. private _fontFamily;
  60144. private _fontStyle;
  60145. private _fontWeight;
  60146. /** @hidden */
  60147. _host: AdvancedDynamicTexture;
  60148. /** @hidden */
  60149. _fontSize: ValueAndUnit;
  60150. /**
  60151. * BABYLON.Observable raised when the style values are changed
  60152. */
  60153. onChangedObservable: BABYLON.Observable<Style>;
  60154. /**
  60155. * Creates a new style object
  60156. * @param host defines the AdvancedDynamicTexture which hosts this style
  60157. */
  60158. constructor(host: AdvancedDynamicTexture);
  60159. /**
  60160. * Gets or sets the font size
  60161. */
  60162. fontSize: string | number;
  60163. /**
  60164. * Gets or sets the font family
  60165. */
  60166. fontFamily: string;
  60167. /**
  60168. * Gets or sets the font style
  60169. */
  60170. fontStyle: string;
  60171. /** Gets or sets font weight */
  60172. fontWeight: string;
  60173. /** Dispose all associated resources */
  60174. dispose(): void;
  60175. }
  60176. }
  60177. declare module BABYLON.GUI {
  60178. /**
  60179. * Class used to transport BABYLON.Vector2 information for pointer events
  60180. */
  60181. export class Vector2WithInfo extends BABYLON.Vector2 {
  60182. /** defines the current mouse button index */
  60183. buttonIndex: number;
  60184. /**
  60185. * Creates a new Vector2WithInfo
  60186. * @param source defines the vector2 data to transport
  60187. * @param buttonIndex defines the current mouse button index
  60188. */
  60189. constructor(source: BABYLON.Vector2,
  60190. /** defines the current mouse button index */
  60191. buttonIndex?: number);
  60192. }
  60193. /** Class used to provide 2D matrix features */
  60194. export class Matrix2D {
  60195. /** Gets the internal array of 6 floats used to store matrix data */
  60196. m: Float32Array;
  60197. /**
  60198. * Creates a new matrix
  60199. * @param m00 defines value for (0, 0)
  60200. * @param m01 defines value for (0, 1)
  60201. * @param m10 defines value for (1, 0)
  60202. * @param m11 defines value for (1, 1)
  60203. * @param m20 defines value for (2, 0)
  60204. * @param m21 defines value for (2, 1)
  60205. */
  60206. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  60207. /**
  60208. * Fills the matrix from direct values
  60209. * @param m00 defines value for (0, 0)
  60210. * @param m01 defines value for (0, 1)
  60211. * @param m10 defines value for (1, 0)
  60212. * @param m11 defines value for (1, 1)
  60213. * @param m20 defines value for (2, 0)
  60214. * @param m21 defines value for (2, 1)
  60215. * @returns the current modified matrix
  60216. */
  60217. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  60218. /**
  60219. * Gets matrix determinant
  60220. * @returns the determinant
  60221. */
  60222. determinant(): number;
  60223. /**
  60224. * Inverses the matrix and stores it in a target matrix
  60225. * @param result defines the target matrix
  60226. * @returns the current matrix
  60227. */
  60228. invertToRef(result: Matrix2D): Matrix2D;
  60229. /**
  60230. * Multiplies the current matrix with another one
  60231. * @param other defines the second operand
  60232. * @param result defines the target matrix
  60233. * @returns the current matrix
  60234. */
  60235. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  60236. /**
  60237. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  60238. * @param x defines the x coordinate to transform
  60239. * @param y defines the x coordinate to transform
  60240. * @param result defines the target vector2
  60241. * @returns the current matrix
  60242. */
  60243. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  60244. /**
  60245. * Creates an identity matrix
  60246. * @returns a new matrix
  60247. */
  60248. static Identity(): Matrix2D;
  60249. /**
  60250. * Creates a translation matrix and stores it in a target matrix
  60251. * @param x defines the x coordinate of the translation
  60252. * @param y defines the y coordinate of the translation
  60253. * @param result defines the target matrix
  60254. */
  60255. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  60256. /**
  60257. * Creates a scaling matrix and stores it in a target matrix
  60258. * @param x defines the x coordinate of the scaling
  60259. * @param y defines the y coordinate of the scaling
  60260. * @param result defines the target matrix
  60261. */
  60262. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  60263. /**
  60264. * Creates a rotation matrix and stores it in a target matrix
  60265. * @param angle defines the rotation angle
  60266. * @param result defines the target matrix
  60267. */
  60268. static RotationToRef(angle: number, result: Matrix2D): void;
  60269. private static _TempPreTranslationMatrix;
  60270. private static _TempPostTranslationMatrix;
  60271. private static _TempRotationMatrix;
  60272. private static _TempScalingMatrix;
  60273. private static _TempCompose0;
  60274. private static _TempCompose1;
  60275. private static _TempCompose2;
  60276. /**
  60277. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  60278. * @param tx defines the x coordinate of the translation
  60279. * @param ty defines the y coordinate of the translation
  60280. * @param angle defines the rotation angle
  60281. * @param scaleX defines the x coordinate of the scaling
  60282. * @param scaleY defines the y coordinate of the scaling
  60283. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  60284. * @param result defines the target matrix
  60285. */
  60286. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  60287. }
  60288. }
  60289. declare module BABYLON.GUI {
  60290. /**
  60291. * Class used to store 2D control sizes
  60292. */
  60293. export class Measure {
  60294. /** defines left coordinate */
  60295. left: number;
  60296. /** defines top coordinate */
  60297. top: number;
  60298. /** defines width dimension */
  60299. width: number;
  60300. /** defines height dimension */
  60301. height: number;
  60302. /**
  60303. * Creates a new measure
  60304. * @param left defines left coordinate
  60305. * @param top defines top coordinate
  60306. * @param width defines width dimension
  60307. * @param height defines height dimension
  60308. */
  60309. constructor(
  60310. /** defines left coordinate */
  60311. left: number,
  60312. /** defines top coordinate */
  60313. top: number,
  60314. /** defines width dimension */
  60315. width: number,
  60316. /** defines height dimension */
  60317. height: number);
  60318. /**
  60319. * Copy from another measure
  60320. * @param other defines the other measure to copy from
  60321. */
  60322. copyFrom(other: Measure): void;
  60323. /**
  60324. * Copy from a group of 4 floats
  60325. * @param left defines left coordinate
  60326. * @param top defines top coordinate
  60327. * @param width defines width dimension
  60328. * @param height defines height dimension
  60329. */
  60330. copyFromFloats(left: number, top: number, width: number, height: number): void;
  60331. /**
  60332. * Computes the axis aligned bounding box measure for two given measures
  60333. * @param a Input measure
  60334. * @param b Input measure
  60335. * @param result the resulting bounding measure
  60336. */
  60337. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  60338. /**
  60339. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  60340. * @param transform the matrix to transform the measure before computing the AABB
  60341. * @param result the resulting AABB
  60342. */
  60343. transformToRef(transform: Matrix2D, result: Measure): void;
  60344. /**
  60345. * Check equality between this measure and another one
  60346. * @param other defines the other measures
  60347. * @returns true if both measures are equals
  60348. */
  60349. isEqualsTo(other: Measure): boolean;
  60350. /**
  60351. * Creates an empty measure
  60352. * @returns a new measure
  60353. */
  60354. static Empty(): Measure;
  60355. }
  60356. }
  60357. declare module BABYLON.GUI {
  60358. /**
  60359. * Interface used to define a control that can receive focus
  60360. */
  60361. export interface IFocusableControl {
  60362. /**
  60363. * Function called when the control receives the focus
  60364. */
  60365. onFocus(): void;
  60366. /**
  60367. * Function called when the control loses the focus
  60368. */
  60369. onBlur(): void;
  60370. /**
  60371. * Function called to let the control handle keyboard events
  60372. * @param evt defines the current keyboard event
  60373. */
  60374. processKeyboard(evt: KeyboardEvent): void;
  60375. /**
  60376. * Function called to get the list of controls that should not steal the focus from this control
  60377. * @returns an array of controls
  60378. */
  60379. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  60380. }
  60381. /**
  60382. * Class used to create texture to support 2D GUI elements
  60383. * @see http://doc.babylonjs.com/how_to/gui
  60384. */
  60385. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  60386. private _isDirty;
  60387. private _renderObserver;
  60388. private _resizeObserver;
  60389. private _preKeyboardObserver;
  60390. private _pointerMoveObserver;
  60391. private _pointerObserver;
  60392. private _canvasPointerOutObserver;
  60393. private _background;
  60394. /** @hidden */
  60395. _rootContainer: Container;
  60396. /** @hidden */
  60397. _lastPickedControl: Control;
  60398. /** @hidden */
  60399. _lastControlOver: {
  60400. [pointerId: number]: Control;
  60401. };
  60402. /** @hidden */
  60403. _lastControlDown: {
  60404. [pointerId: number]: Control;
  60405. };
  60406. /** @hidden */
  60407. _capturingControl: {
  60408. [pointerId: number]: Control;
  60409. };
  60410. /** @hidden */
  60411. _shouldBlockPointer: boolean;
  60412. /** @hidden */
  60413. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  60414. /** @hidden */
  60415. _linkedControls: Control[];
  60416. private _isFullscreen;
  60417. private _fullscreenViewport;
  60418. private _idealWidth;
  60419. private _idealHeight;
  60420. private _useSmallestIdeal;
  60421. private _renderAtIdealSize;
  60422. private _focusedControl;
  60423. private _blockNextFocusCheck;
  60424. private _renderScale;
  60425. private _rootCanvas;
  60426. private _cursorChanged;
  60427. /**
  60428. * Define type to string to ensure compatibility across browsers
  60429. * Safari doesn't support DataTransfer constructor
  60430. */
  60431. private _clipboardData;
  60432. /**
  60433. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  60434. */
  60435. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  60436. /**
  60437. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  60438. */
  60439. onControlPickedObservable: BABYLON.Observable<Control>;
  60440. /**
  60441. * BABYLON.Observable event triggered before layout is evaluated
  60442. */
  60443. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  60444. /**
  60445. * BABYLON.Observable event triggered after the layout was evaluated
  60446. */
  60447. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  60448. /**
  60449. * BABYLON.Observable event triggered before the texture is rendered
  60450. */
  60451. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  60452. /**
  60453. * BABYLON.Observable event triggered after the texture was rendered
  60454. */
  60455. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  60456. /**
  60457. * Gets or sets a boolean defining if alpha is stored as premultiplied
  60458. */
  60459. premulAlpha: boolean;
  60460. /**
  60461. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  60462. * Useful when you want more antialiasing
  60463. */
  60464. renderScale: number;
  60465. /** Gets or sets the background color */
  60466. background: string;
  60467. /**
  60468. * Gets or sets the ideal width used to design controls.
  60469. * The GUI will then rescale everything accordingly
  60470. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  60471. */
  60472. idealWidth: number;
  60473. /**
  60474. * Gets or sets the ideal height used to design controls.
  60475. * The GUI will then rescale everything accordingly
  60476. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  60477. */
  60478. idealHeight: number;
  60479. /**
  60480. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  60481. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  60482. */
  60483. useSmallestIdeal: boolean;
  60484. /**
  60485. * Gets or sets a boolean indicating if adaptive scaling must be used
  60486. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  60487. */
  60488. renderAtIdealSize: boolean;
  60489. /**
  60490. * Gets the underlying layer used to render the texture when in fullscreen mode
  60491. */
  60492. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  60493. /**
  60494. * Gets the root container control
  60495. */
  60496. readonly rootContainer: Container;
  60497. /**
  60498. * Returns an array containing the root container.
  60499. * This is mostly used to let the Inspector introspects the ADT
  60500. * @returns an array containing the rootContainer
  60501. */
  60502. getChildren(): Array<Container>;
  60503. /**
  60504. * Will return all controls that are inside this texture
  60505. * @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
  60506. * @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
  60507. * @return all child controls
  60508. */
  60509. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  60510. /**
  60511. * Gets or sets the current focused control
  60512. */
  60513. focusedControl: BABYLON.Nullable<IFocusableControl>;
  60514. /**
  60515. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  60516. */
  60517. isForeground: boolean;
  60518. /**
  60519. * Gets or set information about clipboardData
  60520. */
  60521. clipboardData: string;
  60522. /**
  60523. * Creates a new AdvancedDynamicTexture
  60524. * @param name defines the name of the texture
  60525. * @param width defines the width of the texture
  60526. * @param height defines the height of the texture
  60527. * @param scene defines the hosting scene
  60528. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  60529. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  60530. */
  60531. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  60532. /**
  60533. * Get the current class name of the texture useful for serialization or dynamic coding.
  60534. * @returns "AdvancedDynamicTexture"
  60535. */
  60536. getClassName(): string;
  60537. /**
  60538. * Function used to execute a function on all controls
  60539. * @param func defines the function to execute
  60540. * @param container defines the container where controls belong. If null the root container will be used
  60541. */
  60542. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  60543. private _useInvalidateRectOptimization;
  60544. /**
  60545. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  60546. */
  60547. useInvalidateRectOptimization: boolean;
  60548. private _invalidatedRectangle;
  60549. /**
  60550. * Invalidates a rectangle area on the gui texture
  60551. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  60552. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  60553. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  60554. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  60555. */
  60556. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  60557. /**
  60558. * Marks the texture as dirty forcing a complete update
  60559. */
  60560. markAsDirty(): void;
  60561. /**
  60562. * Helper function used to create a new style
  60563. * @returns a new style
  60564. * @see http://doc.babylonjs.com/how_to/gui#styles
  60565. */
  60566. createStyle(): Style;
  60567. /**
  60568. * Adds a new control to the root container
  60569. * @param control defines the control to add
  60570. * @returns the current texture
  60571. */
  60572. addControl(control: Control): AdvancedDynamicTexture;
  60573. /**
  60574. * Removes a control from the root container
  60575. * @param control defines the control to remove
  60576. * @returns the current texture
  60577. */
  60578. removeControl(control: Control): AdvancedDynamicTexture;
  60579. /**
  60580. * Release all resources
  60581. */
  60582. dispose(): void;
  60583. private _onResize;
  60584. /** @hidden */
  60585. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  60586. /**
  60587. * Get screen coordinates for a vector3
  60588. * @param position defines the position to project
  60589. * @param worldMatrix defines the world matrix to use
  60590. * @returns the projected position
  60591. */
  60592. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  60593. private _checkUpdate;
  60594. private _clearMeasure;
  60595. private _render;
  60596. /** @hidden */
  60597. _changeCursor(cursor: string): void;
  60598. /** @hidden */
  60599. _registerLastControlDown(control: Control, pointerId: number): void;
  60600. private _doPicking;
  60601. /** @hidden */
  60602. _cleanControlAfterRemovalFromList(list: {
  60603. [pointerId: number]: Control;
  60604. }, control: Control): void;
  60605. /** @hidden */
  60606. _cleanControlAfterRemoval(control: Control): void;
  60607. /** Attach to all scene events required to support pointer events */
  60608. attach(): void;
  60609. /** @hidden */
  60610. private onClipboardCopy;
  60611. /** @hidden */
  60612. private onClipboardCut;
  60613. /** @hidden */
  60614. private onClipboardPaste;
  60615. /**
  60616. * Register the clipboard Events onto the canvas
  60617. */
  60618. registerClipboardEvents(): void;
  60619. /**
  60620. * Unregister the clipboard Events from the canvas
  60621. */
  60622. unRegisterClipboardEvents(): void;
  60623. /**
  60624. * Connect the texture to a hosting mesh to enable interactions
  60625. * @param mesh defines the mesh to attach to
  60626. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  60627. */
  60628. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  60629. /**
  60630. * Move the focus to a specific control
  60631. * @param control defines the control which will receive the focus
  60632. */
  60633. moveFocusToControl(control: IFocusableControl): void;
  60634. private _manageFocus;
  60635. private _attachToOnPointerOut;
  60636. /**
  60637. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  60638. * @param mesh defines the mesh which will receive the texture
  60639. * @param width defines the texture width (1024 by default)
  60640. * @param height defines the texture height (1024 by default)
  60641. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  60642. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  60643. * @returns a new AdvancedDynamicTexture
  60644. */
  60645. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  60646. /**
  60647. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  60648. * In this mode the texture will rely on a layer for its rendering.
  60649. * This allows it to be treated like any other layer.
  60650. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  60651. * LayerMask is set through advancedTexture.layer.layerMask
  60652. * @param name defines name for the texture
  60653. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  60654. * @param scene defines the hsoting scene
  60655. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  60656. * @returns a new AdvancedDynamicTexture
  60657. */
  60658. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  60659. }
  60660. }
  60661. declare module BABYLON.GUI {
  60662. /**
  60663. * Root class used for all 2D controls
  60664. * @see http://doc.babylonjs.com/how_to/gui#controls
  60665. */
  60666. export class Control {
  60667. /** defines the name of the control */
  60668. name?: string | undefined;
  60669. /**
  60670. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  60671. */
  60672. static AllowAlphaInheritance: boolean;
  60673. private _alpha;
  60674. private _alphaSet;
  60675. private _zIndex;
  60676. /** @hidden */
  60677. _host: AdvancedDynamicTexture;
  60678. /** Gets or sets the control parent */
  60679. parent: BABYLON.Nullable<Container>;
  60680. /** @hidden */
  60681. _currentMeasure: Measure;
  60682. private _fontFamily;
  60683. private _fontStyle;
  60684. private _fontWeight;
  60685. private _fontSize;
  60686. private _font;
  60687. /** @hidden */
  60688. _width: ValueAndUnit;
  60689. /** @hidden */
  60690. _height: ValueAndUnit;
  60691. /** @hidden */
  60692. protected _fontOffset: {
  60693. ascent: number;
  60694. height: number;
  60695. descent: number;
  60696. };
  60697. private _color;
  60698. private _style;
  60699. private _styleObserver;
  60700. /** @hidden */
  60701. protected _horizontalAlignment: number;
  60702. /** @hidden */
  60703. protected _verticalAlignment: number;
  60704. /** @hidden */
  60705. protected _isDirty: boolean;
  60706. /** @hidden */
  60707. protected _wasDirty: boolean;
  60708. /** @hidden */
  60709. _tempParentMeasure: Measure;
  60710. /** @hidden */
  60711. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  60712. /** @hidden */
  60713. protected _cachedParentMeasure: Measure;
  60714. private _paddingLeft;
  60715. private _paddingRight;
  60716. private _paddingTop;
  60717. private _paddingBottom;
  60718. /** @hidden */
  60719. _left: ValueAndUnit;
  60720. /** @hidden */
  60721. _top: ValueAndUnit;
  60722. private _scaleX;
  60723. private _scaleY;
  60724. private _rotation;
  60725. private _transformCenterX;
  60726. private _transformCenterY;
  60727. /** @hidden */
  60728. _transformMatrix: Matrix2D;
  60729. /** @hidden */
  60730. protected _invertTransformMatrix: Matrix2D;
  60731. /** @hidden */
  60732. protected _transformedPosition: BABYLON.Vector2;
  60733. private _isMatrixDirty;
  60734. private _cachedOffsetX;
  60735. private _cachedOffsetY;
  60736. private _isVisible;
  60737. private _isHighlighted;
  60738. /** @hidden */
  60739. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  60740. private _fontSet;
  60741. private _dummyVector2;
  60742. private _downCount;
  60743. private _enterCount;
  60744. private _doNotRender;
  60745. private _downPointerIds;
  60746. protected _isEnabled: boolean;
  60747. protected _disabledColor: string;
  60748. /** @hidden */
  60749. protected _rebuildLayout: boolean;
  60750. /** @hidden */
  60751. _isClipped: boolean;
  60752. /** @hidden */
  60753. _tag: any;
  60754. /**
  60755. * 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
  60756. */
  60757. uniqueId: number;
  60758. /**
  60759. * Gets or sets an object used to store user defined information for the node
  60760. */
  60761. metadata: any;
  60762. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  60763. isHitTestVisible: boolean;
  60764. /** Gets or sets a boolean indicating if the control can block pointer events */
  60765. isPointerBlocker: boolean;
  60766. /** Gets or sets a boolean indicating if the control can be focusable */
  60767. isFocusInvisible: boolean;
  60768. /**
  60769. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  60770. * 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
  60771. */
  60772. clipChildren: boolean;
  60773. /**
  60774. * Gets or sets a boolean indicating that control content must be clipped
  60775. * 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
  60776. */
  60777. clipContent: boolean;
  60778. /**
  60779. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  60780. */
  60781. useBitmapCache: boolean;
  60782. private _cacheData;
  60783. private _shadowOffsetX;
  60784. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  60785. shadowOffsetX: number;
  60786. private _shadowOffsetY;
  60787. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  60788. shadowOffsetY: number;
  60789. private _shadowBlur;
  60790. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  60791. shadowBlur: number;
  60792. private _shadowColor;
  60793. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  60794. shadowColor: string;
  60795. /** Gets or sets the cursor to use when the control is hovered */
  60796. hoverCursor: string;
  60797. /** @hidden */
  60798. protected _linkOffsetX: ValueAndUnit;
  60799. /** @hidden */
  60800. protected _linkOffsetY: ValueAndUnit;
  60801. /** Gets the control type name */
  60802. readonly typeName: string;
  60803. /**
  60804. * Get the current class name of the control.
  60805. * @returns current class name
  60806. */
  60807. getClassName(): string;
  60808. /**
  60809. * An event triggered when the pointer move over the control.
  60810. */
  60811. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  60812. /**
  60813. * An event triggered when the pointer move out of the control.
  60814. */
  60815. onPointerOutObservable: BABYLON.Observable<Control>;
  60816. /**
  60817. * An event triggered when the pointer taps the control
  60818. */
  60819. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  60820. /**
  60821. * An event triggered when pointer up
  60822. */
  60823. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  60824. /**
  60825. * An event triggered when a control is clicked on
  60826. */
  60827. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  60828. /**
  60829. * An event triggered when pointer enters the control
  60830. */
  60831. onPointerEnterObservable: BABYLON.Observable<Control>;
  60832. /**
  60833. * An event triggered when the control is marked as dirty
  60834. */
  60835. onDirtyObservable: BABYLON.Observable<Control>;
  60836. /**
  60837. * An event triggered before drawing the control
  60838. */
  60839. onBeforeDrawObservable: BABYLON.Observable<Control>;
  60840. /**
  60841. * An event triggered after the control was drawn
  60842. */
  60843. onAfterDrawObservable: BABYLON.Observable<Control>;
  60844. /**
  60845. * Get the hosting AdvancedDynamicTexture
  60846. */
  60847. readonly host: AdvancedDynamicTexture;
  60848. /** Gets or set information about font offsets (used to render and align text) */
  60849. fontOffset: {
  60850. ascent: number;
  60851. height: number;
  60852. descent: number;
  60853. };
  60854. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  60855. alpha: number;
  60856. /**
  60857. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  60858. */
  60859. isHighlighted: boolean;
  60860. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  60861. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  60862. */
  60863. scaleX: number;
  60864. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  60865. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  60866. */
  60867. scaleY: number;
  60868. /** Gets or sets the rotation angle (0 by default)
  60869. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  60870. */
  60871. rotation: number;
  60872. /** Gets or sets the transformation center on Y axis (0 by default)
  60873. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  60874. */
  60875. transformCenterY: number;
  60876. /** Gets or sets the transformation center on X axis (0 by default)
  60877. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  60878. */
  60879. transformCenterX: number;
  60880. /**
  60881. * Gets or sets the horizontal alignment
  60882. * @see http://doc.babylonjs.com/how_to/gui#alignments
  60883. */
  60884. horizontalAlignment: number;
  60885. /**
  60886. * Gets or sets the vertical alignment
  60887. * @see http://doc.babylonjs.com/how_to/gui#alignments
  60888. */
  60889. verticalAlignment: number;
  60890. /**
  60891. * Gets or sets control width
  60892. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60893. */
  60894. width: string | number;
  60895. /**
  60896. * Gets or sets the control width in pixel
  60897. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60898. */
  60899. widthInPixels: number;
  60900. /**
  60901. * Gets or sets control height
  60902. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60903. */
  60904. height: string | number;
  60905. /**
  60906. * Gets or sets control height in pixel
  60907. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60908. */
  60909. heightInPixels: number;
  60910. /** Gets or set font family */
  60911. fontFamily: string;
  60912. /** Gets or sets font style */
  60913. fontStyle: string;
  60914. /** Gets or sets font weight */
  60915. fontWeight: string;
  60916. /**
  60917. * Gets or sets style
  60918. * @see http://doc.babylonjs.com/how_to/gui#styles
  60919. */
  60920. style: BABYLON.Nullable<Style>;
  60921. /** @hidden */
  60922. readonly _isFontSizeInPercentage: boolean;
  60923. /** Gets or sets font size in pixels */
  60924. fontSizeInPixels: number;
  60925. /** Gets or sets font size */
  60926. fontSize: string | number;
  60927. /** Gets or sets foreground color */
  60928. color: string;
  60929. /** Gets or sets z index which is used to reorder controls on the z axis */
  60930. zIndex: number;
  60931. /** Gets or sets a boolean indicating if the control can be rendered */
  60932. notRenderable: boolean;
  60933. /** Gets or sets a boolean indicating if the control is visible */
  60934. isVisible: boolean;
  60935. /** Gets a boolean indicating that the control needs to update its rendering */
  60936. readonly isDirty: boolean;
  60937. /**
  60938. * Gets the current linked mesh (or null if none)
  60939. */
  60940. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  60941. /**
  60942. * Gets or sets a value indicating the padding to use on the left of the control
  60943. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60944. */
  60945. paddingLeft: string | number;
  60946. /**
  60947. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  60948. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60949. */
  60950. paddingLeftInPixels: number;
  60951. /**
  60952. * Gets or sets a value indicating the padding to use on the right of the control
  60953. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60954. */
  60955. paddingRight: string | number;
  60956. /**
  60957. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  60958. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60959. */
  60960. paddingRightInPixels: number;
  60961. /**
  60962. * Gets or sets a value indicating the padding to use on the top of the control
  60963. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60964. */
  60965. paddingTop: string | number;
  60966. /**
  60967. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  60968. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60969. */
  60970. paddingTopInPixels: number;
  60971. /**
  60972. * Gets or sets a value indicating the padding to use on the bottom of the control
  60973. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60974. */
  60975. paddingBottom: string | number;
  60976. /**
  60977. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  60978. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60979. */
  60980. paddingBottomInPixels: number;
  60981. /**
  60982. * Gets or sets a value indicating the left coordinate of the control
  60983. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60984. */
  60985. left: string | number;
  60986. /**
  60987. * Gets or sets a value indicating the left coordinate in pixels of the control
  60988. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60989. */
  60990. leftInPixels: number;
  60991. /**
  60992. * Gets or sets a value indicating the top coordinate of the control
  60993. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60994. */
  60995. top: string | number;
  60996. /**
  60997. * Gets or sets a value indicating the top coordinate in pixels of the control
  60998. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60999. */
  61000. topInPixels: number;
  61001. /**
  61002. * Gets or sets a value indicating the offset on X axis to the linked mesh
  61003. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  61004. */
  61005. linkOffsetX: string | number;
  61006. /**
  61007. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  61008. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  61009. */
  61010. linkOffsetXInPixels: number;
  61011. /**
  61012. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  61013. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  61014. */
  61015. linkOffsetY: string | number;
  61016. /**
  61017. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  61018. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  61019. */
  61020. linkOffsetYInPixels: number;
  61021. /** Gets the center coordinate on X axis */
  61022. readonly centerX: number;
  61023. /** Gets the center coordinate on Y axis */
  61024. readonly centerY: number;
  61025. /** Gets or sets if control is Enabled*/
  61026. isEnabled: boolean;
  61027. /** Gets or sets background color of control if it's disabled*/
  61028. disabledColor: string;
  61029. /**
  61030. * Creates a new control
  61031. * @param name defines the name of the control
  61032. */
  61033. constructor(
  61034. /** defines the name of the control */
  61035. name?: string | undefined);
  61036. /** @hidden */
  61037. protected _getTypeName(): string;
  61038. /**
  61039. * Gets the first ascendant in the hierarchy of the given type
  61040. * @param className defines the required type
  61041. * @returns the ascendant or null if not found
  61042. */
  61043. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  61044. /** @hidden */
  61045. _resetFontCache(): void;
  61046. /**
  61047. * Determines if a container is an ascendant of the current control
  61048. * @param container defines the container to look for
  61049. * @returns true if the container is one of the ascendant of the control
  61050. */
  61051. isAscendant(container: Control): boolean;
  61052. /**
  61053. * Gets coordinates in local control space
  61054. * @param globalCoordinates defines the coordinates to transform
  61055. * @returns the new coordinates in local space
  61056. */
  61057. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  61058. /**
  61059. * Gets coordinates in local control space
  61060. * @param globalCoordinates defines the coordinates to transform
  61061. * @param result defines the target vector2 where to store the result
  61062. * @returns the current control
  61063. */
  61064. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  61065. /**
  61066. * Gets coordinates in parent local control space
  61067. * @param globalCoordinates defines the coordinates to transform
  61068. * @returns the new coordinates in parent local space
  61069. */
  61070. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  61071. /**
  61072. * Move the current control to a vector3 position projected onto the screen.
  61073. * @param position defines the target position
  61074. * @param scene defines the hosting scene
  61075. */
  61076. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  61077. /** @hidden */
  61078. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  61079. /**
  61080. * Will return all controls that have this control as ascendant
  61081. * @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
  61082. * @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
  61083. * @return all child controls
  61084. */
  61085. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  61086. /**
  61087. * Link current control with a target mesh
  61088. * @param mesh defines the mesh to link with
  61089. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  61090. */
  61091. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  61092. /** @hidden */
  61093. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  61094. /** @hidden */
  61095. _offsetLeft(offset: number): void;
  61096. /** @hidden */
  61097. _offsetTop(offset: number): void;
  61098. /** @hidden */
  61099. _markMatrixAsDirty(): void;
  61100. /** @hidden */
  61101. _flagDescendantsAsMatrixDirty(): void;
  61102. /** @hidden */
  61103. _intersectsRect(rect: Measure): boolean;
  61104. /** @hidden */
  61105. protected invalidateRect(): void;
  61106. /** @hidden */
  61107. _markAsDirty(force?: boolean): void;
  61108. /** @hidden */
  61109. _markAllAsDirty(): void;
  61110. /** @hidden */
  61111. _link(host: AdvancedDynamicTexture): void;
  61112. /** @hidden */
  61113. protected _transform(context?: CanvasRenderingContext2D): void;
  61114. /** @hidden */
  61115. _renderHighlight(context: CanvasRenderingContext2D): void;
  61116. /** @hidden */
  61117. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  61118. /** @hidden */
  61119. protected _applyStates(context: CanvasRenderingContext2D): void;
  61120. /** @hidden */
  61121. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  61122. /** @hidden */
  61123. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61124. protected _evaluateClippingState(parentMeasure: Measure): void;
  61125. /** @hidden */
  61126. _measure(): void;
  61127. /** @hidden */
  61128. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61129. /** @hidden */
  61130. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61131. /** @hidden */
  61132. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61133. /** @hidden */
  61134. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  61135. private static _ClipMeasure;
  61136. private _tmpMeasureA;
  61137. private _clip;
  61138. /** @hidden */
  61139. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  61140. /** @hidden */
  61141. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  61142. /**
  61143. * Tests if a given coordinates belong to the current control
  61144. * @param x defines x coordinate to test
  61145. * @param y defines y coordinate to test
  61146. * @returns true if the coordinates are inside the control
  61147. */
  61148. contains(x: number, y: number): boolean;
  61149. /** @hidden */
  61150. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  61151. /** @hidden */
  61152. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  61153. /** @hidden */
  61154. _onPointerEnter(target: Control): boolean;
  61155. /** @hidden */
  61156. _onPointerOut(target: Control, force?: boolean): void;
  61157. /** @hidden */
  61158. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  61159. /** @hidden */
  61160. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  61161. /** @hidden */
  61162. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  61163. /** @hidden */
  61164. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  61165. private _prepareFont;
  61166. /** Releases associated resources */
  61167. dispose(): void;
  61168. private static _HORIZONTAL_ALIGNMENT_LEFT;
  61169. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  61170. private static _HORIZONTAL_ALIGNMENT_CENTER;
  61171. private static _VERTICAL_ALIGNMENT_TOP;
  61172. private static _VERTICAL_ALIGNMENT_BOTTOM;
  61173. private static _VERTICAL_ALIGNMENT_CENTER;
  61174. /** HORIZONTAL_ALIGNMENT_LEFT */
  61175. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  61176. /** HORIZONTAL_ALIGNMENT_RIGHT */
  61177. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  61178. /** HORIZONTAL_ALIGNMENT_CENTER */
  61179. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  61180. /** VERTICAL_ALIGNMENT_TOP */
  61181. static readonly VERTICAL_ALIGNMENT_TOP: number;
  61182. /** VERTICAL_ALIGNMENT_BOTTOM */
  61183. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  61184. /** VERTICAL_ALIGNMENT_CENTER */
  61185. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  61186. private static _FontHeightSizes;
  61187. /** @hidden */
  61188. static _GetFontOffset(font: string): {
  61189. ascent: number;
  61190. height: number;
  61191. descent: number;
  61192. };
  61193. /**
  61194. * Creates a stack panel that can be used to render headers
  61195. * @param control defines the control to associate with the header
  61196. * @param text defines the text of the header
  61197. * @param size defines the size of the header
  61198. * @param options defines options used to configure the header
  61199. * @returns a new StackPanel
  61200. * @ignore
  61201. * @hidden
  61202. */
  61203. static AddHeader: (control: Control, text: string, size: string | number, options: {
  61204. isHorizontal: boolean;
  61205. controlFirst: boolean;
  61206. }) => any;
  61207. /** @hidden */
  61208. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  61209. }
  61210. }
  61211. declare module BABYLON.GUI {
  61212. /**
  61213. * Root class for 2D containers
  61214. * @see http://doc.babylonjs.com/how_to/gui#containers
  61215. */
  61216. export class Container extends Control {
  61217. name?: string | undefined;
  61218. /** @hidden */
  61219. protected _children: Control[];
  61220. /** @hidden */
  61221. protected _measureForChildren: Measure;
  61222. /** @hidden */
  61223. protected _background: string;
  61224. /** @hidden */
  61225. protected _adaptWidthToChildren: boolean;
  61226. /** @hidden */
  61227. protected _adaptHeightToChildren: boolean;
  61228. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  61229. adaptHeightToChildren: boolean;
  61230. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  61231. adaptWidthToChildren: boolean;
  61232. /** Gets or sets background color */
  61233. background: string;
  61234. /** Gets the list of children */
  61235. readonly children: Control[];
  61236. /**
  61237. * Creates a new Container
  61238. * @param name defines the name of the container
  61239. */
  61240. constructor(name?: string | undefined);
  61241. protected _getTypeName(): string;
  61242. _flagDescendantsAsMatrixDirty(): void;
  61243. /**
  61244. * Gets a child using its name
  61245. * @param name defines the child name to look for
  61246. * @returns the child control if found
  61247. */
  61248. getChildByName(name: string): BABYLON.Nullable<Control>;
  61249. /**
  61250. * Gets a child using its type and its name
  61251. * @param name defines the child name to look for
  61252. * @param type defines the child type to look for
  61253. * @returns the child control if found
  61254. */
  61255. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  61256. /**
  61257. * Search for a specific control in children
  61258. * @param control defines the control to look for
  61259. * @returns true if the control is in child list
  61260. */
  61261. containsControl(control: Control): boolean;
  61262. /**
  61263. * Adds a new control to the current container
  61264. * @param control defines the control to add
  61265. * @returns the current container
  61266. */
  61267. addControl(control: BABYLON.Nullable<Control>): Container;
  61268. /**
  61269. * Removes all controls from the current container
  61270. * @returns the current container
  61271. */
  61272. clearControls(): Container;
  61273. /**
  61274. * Removes a control from the current container
  61275. * @param control defines the control to remove
  61276. * @returns the current container
  61277. */
  61278. removeControl(control: Control): Container;
  61279. /** @hidden */
  61280. _reOrderControl(control: Control): void;
  61281. /** @hidden */
  61282. _offsetLeft(offset: number): void;
  61283. /** @hidden */
  61284. _offsetTop(offset: number): void;
  61285. /** @hidden */
  61286. _markAllAsDirty(): void;
  61287. /** @hidden */
  61288. protected _localDraw(context: CanvasRenderingContext2D): void;
  61289. /** @hidden */
  61290. _link(host: AdvancedDynamicTexture): void;
  61291. /** @hidden */
  61292. protected _beforeLayout(): void;
  61293. /** @hidden */
  61294. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61295. /** @hidden */
  61296. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  61297. protected _postMeasure(): void;
  61298. /** @hidden */
  61299. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  61300. /** @hidden */
  61301. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  61302. /** @hidden */
  61303. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  61304. /** @hidden */
  61305. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61306. /** Releases associated resources */
  61307. dispose(): void;
  61308. }
  61309. }
  61310. declare module BABYLON.GUI {
  61311. /** Class used to create rectangle container */
  61312. export class Rectangle extends Container {
  61313. name?: string | undefined;
  61314. private _thickness;
  61315. private _cornerRadius;
  61316. /** Gets or sets border thickness */
  61317. thickness: number;
  61318. /** Gets or sets the corner radius angle */
  61319. cornerRadius: number;
  61320. /**
  61321. * Creates a new Rectangle
  61322. * @param name defines the control name
  61323. */
  61324. constructor(name?: string | undefined);
  61325. protected _getTypeName(): string;
  61326. protected _localDraw(context: CanvasRenderingContext2D): void;
  61327. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61328. private _drawRoundedRect;
  61329. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  61330. }
  61331. }
  61332. declare module BABYLON.GUI {
  61333. /**
  61334. * Enum that determines the text-wrapping mode to use.
  61335. */
  61336. export enum TextWrapping {
  61337. /**
  61338. * Clip the text when it's larger than Control.width; this is the default mode.
  61339. */
  61340. Clip = 0,
  61341. /**
  61342. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  61343. */
  61344. WordWrap = 1,
  61345. /**
  61346. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  61347. */
  61348. Ellipsis = 2
  61349. }
  61350. /**
  61351. * Class used to create text block control
  61352. */
  61353. export class TextBlock extends Control {
  61354. /**
  61355. * Defines the name of the control
  61356. */
  61357. name?: string | undefined;
  61358. private _text;
  61359. private _textWrapping;
  61360. private _textHorizontalAlignment;
  61361. private _textVerticalAlignment;
  61362. private _lines;
  61363. private _resizeToFit;
  61364. private _lineSpacing;
  61365. private _outlineWidth;
  61366. private _outlineColor;
  61367. /**
  61368. * An event triggered after the text is changed
  61369. */
  61370. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  61371. /**
  61372. * An event triggered after the text was broken up into lines
  61373. */
  61374. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  61375. /**
  61376. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  61377. */
  61378. readonly lines: any[];
  61379. /**
  61380. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  61381. */
  61382. /**
  61383. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  61384. */
  61385. resizeToFit: boolean;
  61386. /**
  61387. * Gets or sets a boolean indicating if text must be wrapped
  61388. */
  61389. /**
  61390. * Gets or sets a boolean indicating if text must be wrapped
  61391. */
  61392. textWrapping: TextWrapping | boolean;
  61393. /**
  61394. * Gets or sets text to display
  61395. */
  61396. /**
  61397. * Gets or sets text to display
  61398. */
  61399. text: string;
  61400. /**
  61401. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  61402. */
  61403. /**
  61404. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  61405. */
  61406. textHorizontalAlignment: number;
  61407. /**
  61408. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  61409. */
  61410. /**
  61411. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  61412. */
  61413. textVerticalAlignment: number;
  61414. /**
  61415. * Gets or sets line spacing value
  61416. */
  61417. /**
  61418. * Gets or sets line spacing value
  61419. */
  61420. lineSpacing: string | number;
  61421. /**
  61422. * Gets or sets outlineWidth of the text to display
  61423. */
  61424. /**
  61425. * Gets or sets outlineWidth of the text to display
  61426. */
  61427. outlineWidth: number;
  61428. /**
  61429. * Gets or sets outlineColor of the text to display
  61430. */
  61431. /**
  61432. * Gets or sets outlineColor of the text to display
  61433. */
  61434. outlineColor: string;
  61435. /**
  61436. * Creates a new TextBlock object
  61437. * @param name defines the name of the control
  61438. * @param text defines the text to display (emptry string by default)
  61439. */
  61440. constructor(
  61441. /**
  61442. * Defines the name of the control
  61443. */
  61444. name?: string | undefined, text?: string);
  61445. protected _getTypeName(): string;
  61446. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61447. private _drawText;
  61448. /** @hidden */
  61449. _draw(context: CanvasRenderingContext2D): void;
  61450. protected _applyStates(context: CanvasRenderingContext2D): void;
  61451. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  61452. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  61453. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  61454. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  61455. protected _renderLines(context: CanvasRenderingContext2D): void;
  61456. /**
  61457. * Given a width constraint applied on the text block, find the expected height
  61458. * @returns expected height
  61459. */
  61460. computeExpectedHeight(): number;
  61461. dispose(): void;
  61462. }
  61463. }
  61464. declare module BABYLON.GUI {
  61465. /**
  61466. * Class used to create 2D images
  61467. */
  61468. export class Image extends Control {
  61469. name?: string | undefined;
  61470. private static _WorkingCanvas;
  61471. private _domImage;
  61472. private _imageWidth;
  61473. private _imageHeight;
  61474. private _loaded;
  61475. private _stretch;
  61476. private _source;
  61477. private _autoScale;
  61478. private _sourceLeft;
  61479. private _sourceTop;
  61480. private _sourceWidth;
  61481. private _sourceHeight;
  61482. private _cellWidth;
  61483. private _cellHeight;
  61484. private _cellId;
  61485. private _populateNinePatchSlicesFromImage;
  61486. private _sliceLeft;
  61487. private _sliceRight;
  61488. private _sliceTop;
  61489. private _sliceBottom;
  61490. private _detectPointerOnOpaqueOnly;
  61491. /**
  61492. * BABYLON.Observable notified when the content is loaded
  61493. */
  61494. onImageLoadedObservable: BABYLON.Observable<Image>;
  61495. /**
  61496. * Gets a boolean indicating that the content is loaded
  61497. */
  61498. readonly isLoaded: boolean;
  61499. /**
  61500. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  61501. */
  61502. populateNinePatchSlicesFromImage: boolean;
  61503. /**
  61504. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  61505. * Beware using this as this will comsume more memory as the image has to be stored twice
  61506. */
  61507. detectPointerOnOpaqueOnly: boolean;
  61508. /**
  61509. * Gets or sets the left value for slicing (9-patch)
  61510. */
  61511. sliceLeft: number;
  61512. /**
  61513. * Gets or sets the right value for slicing (9-patch)
  61514. */
  61515. sliceRight: number;
  61516. /**
  61517. * Gets or sets the top value for slicing (9-patch)
  61518. */
  61519. sliceTop: number;
  61520. /**
  61521. * Gets or sets the bottom value for slicing (9-patch)
  61522. */
  61523. sliceBottom: number;
  61524. /**
  61525. * Gets or sets the left coordinate in the source image
  61526. */
  61527. sourceLeft: number;
  61528. /**
  61529. * Gets or sets the top coordinate in the source image
  61530. */
  61531. sourceTop: number;
  61532. /**
  61533. * Gets or sets the width to capture in the source image
  61534. */
  61535. sourceWidth: number;
  61536. /**
  61537. * Gets or sets the height to capture in the source image
  61538. */
  61539. sourceHeight: number;
  61540. /**
  61541. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  61542. * @see http://doc.babylonjs.com/how_to/gui#image
  61543. */
  61544. autoScale: boolean;
  61545. /** Gets or sets the streching mode used by the image */
  61546. stretch: number;
  61547. /**
  61548. * Gets or sets the internal DOM image used to render the control
  61549. */
  61550. domImage: HTMLImageElement;
  61551. private _onImageLoaded;
  61552. private _extractNinePatchSliceDataFromImage;
  61553. /**
  61554. * Gets or sets image source url
  61555. */
  61556. source: BABYLON.Nullable<string>;
  61557. /**
  61558. * Gets or sets the cell width to use when animation sheet is enabled
  61559. * @see http://doc.babylonjs.com/how_to/gui#image
  61560. */
  61561. cellWidth: number;
  61562. /**
  61563. * Gets or sets the cell height to use when animation sheet is enabled
  61564. * @see http://doc.babylonjs.com/how_to/gui#image
  61565. */
  61566. cellHeight: number;
  61567. /**
  61568. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  61569. * @see http://doc.babylonjs.com/how_to/gui#image
  61570. */
  61571. cellId: number;
  61572. /**
  61573. * Creates a new Image
  61574. * @param name defines the control name
  61575. * @param url defines the image url
  61576. */
  61577. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  61578. /**
  61579. * Tests if a given coordinates belong to the current control
  61580. * @param x defines x coordinate to test
  61581. * @param y defines y coordinate to test
  61582. * @returns true if the coordinates are inside the control
  61583. */
  61584. contains(x: number, y: number): boolean;
  61585. protected _getTypeName(): string;
  61586. /** Force the control to synchronize with its content */
  61587. synchronizeSizeWithContent(): void;
  61588. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61589. private _prepareWorkingCanvasForOpaqueDetection;
  61590. private _drawImage;
  61591. _draw(context: CanvasRenderingContext2D): void;
  61592. private _renderCornerPatch;
  61593. private _renderNinePatch;
  61594. dispose(): void;
  61595. /** STRETCH_NONE */
  61596. static readonly STRETCH_NONE: number;
  61597. /** STRETCH_FILL */
  61598. static readonly STRETCH_FILL: number;
  61599. /** STRETCH_UNIFORM */
  61600. static readonly STRETCH_UNIFORM: number;
  61601. /** STRETCH_EXTEND */
  61602. static readonly STRETCH_EXTEND: number;
  61603. /** NINE_PATCH */
  61604. static readonly STRETCH_NINE_PATCH: number;
  61605. }
  61606. }
  61607. declare module BABYLON.GUI {
  61608. /**
  61609. * Class used to create 2D buttons
  61610. */
  61611. export class Button extends Rectangle {
  61612. name?: string | undefined;
  61613. /**
  61614. * Function called to generate a pointer enter animation
  61615. */
  61616. pointerEnterAnimation: () => void;
  61617. /**
  61618. * Function called to generate a pointer out animation
  61619. */
  61620. pointerOutAnimation: () => void;
  61621. /**
  61622. * Function called to generate a pointer down animation
  61623. */
  61624. pointerDownAnimation: () => void;
  61625. /**
  61626. * Function called to generate a pointer up animation
  61627. */
  61628. pointerUpAnimation: () => void;
  61629. private _image;
  61630. /**
  61631. * Returns the image part of the button (if any)
  61632. */
  61633. readonly image: BABYLON.Nullable<Image>;
  61634. private _textBlock;
  61635. /**
  61636. * Returns the image part of the button (if any)
  61637. */
  61638. readonly textBlock: BABYLON.Nullable<TextBlock>;
  61639. /**
  61640. * Creates a new Button
  61641. * @param name defines the name of the button
  61642. */
  61643. constructor(name?: string | undefined);
  61644. protected _getTypeName(): string;
  61645. /** @hidden */
  61646. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  61647. /** @hidden */
  61648. _onPointerEnter(target: Control): boolean;
  61649. /** @hidden */
  61650. _onPointerOut(target: Control, force?: boolean): void;
  61651. /** @hidden */
  61652. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  61653. /** @hidden */
  61654. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  61655. /**
  61656. * Creates a new button made with an image and a text
  61657. * @param name defines the name of the button
  61658. * @param text defines the text of the button
  61659. * @param imageUrl defines the url of the image
  61660. * @returns a new Button
  61661. */
  61662. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  61663. /**
  61664. * Creates a new button made with an image
  61665. * @param name defines the name of the button
  61666. * @param imageUrl defines the url of the image
  61667. * @returns a new Button
  61668. */
  61669. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  61670. /**
  61671. * Creates a new button made with a text
  61672. * @param name defines the name of the button
  61673. * @param text defines the text of the button
  61674. * @returns a new Button
  61675. */
  61676. static CreateSimpleButton(name: string, text: string): Button;
  61677. /**
  61678. * Creates a new button made with an image and a centered text
  61679. * @param name defines the name of the button
  61680. * @param text defines the text of the button
  61681. * @param imageUrl defines the url of the image
  61682. * @returns a new Button
  61683. */
  61684. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  61685. }
  61686. }
  61687. declare module BABYLON.GUI {
  61688. /**
  61689. * Class used to create a 2D stack panel container
  61690. */
  61691. export class StackPanel extends Container {
  61692. name?: string | undefined;
  61693. private _isVertical;
  61694. private _manualWidth;
  61695. private _manualHeight;
  61696. private _doNotTrackManualChanges;
  61697. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  61698. isVertical: boolean;
  61699. /**
  61700. * Gets or sets panel width.
  61701. * This value should not be set when in horizontal mode as it will be computed automatically
  61702. */
  61703. width: string | number;
  61704. /**
  61705. * Gets or sets panel height.
  61706. * This value should not be set when in vertical mode as it will be computed automatically
  61707. */
  61708. height: string | number;
  61709. /**
  61710. * Creates a new StackPanel
  61711. * @param name defines control name
  61712. */
  61713. constructor(name?: string | undefined);
  61714. protected _getTypeName(): string;
  61715. /** @hidden */
  61716. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61717. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61718. protected _postMeasure(): void;
  61719. }
  61720. }
  61721. declare module BABYLON.GUI {
  61722. /**
  61723. * Class used to represent a 2D checkbox
  61724. */
  61725. export class Checkbox extends Control {
  61726. name?: string | undefined;
  61727. private _isChecked;
  61728. private _background;
  61729. private _checkSizeRatio;
  61730. private _thickness;
  61731. /** Gets or sets border thickness */
  61732. thickness: number;
  61733. /**
  61734. * BABYLON.Observable raised when isChecked property changes
  61735. */
  61736. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  61737. /** Gets or sets a value indicating the ratio between overall size and check size */
  61738. checkSizeRatio: number;
  61739. /** Gets or sets background color */
  61740. background: string;
  61741. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  61742. isChecked: boolean;
  61743. /**
  61744. * Creates a new CheckBox
  61745. * @param name defines the control name
  61746. */
  61747. constructor(name?: string | undefined);
  61748. protected _getTypeName(): string;
  61749. /** @hidden */
  61750. _draw(context: CanvasRenderingContext2D): void;
  61751. /** @hidden */
  61752. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  61753. /**
  61754. * Utility function to easily create a checkbox with a header
  61755. * @param title defines the label to use for the header
  61756. * @param onValueChanged defines the callback to call when value changes
  61757. * @returns a StackPanel containing the checkbox and a textBlock
  61758. */
  61759. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  61760. }
  61761. }
  61762. declare module BABYLON.GUI {
  61763. /**
  61764. * Class used to store key control properties
  61765. */
  61766. export class KeyPropertySet {
  61767. /** Width */
  61768. width?: string;
  61769. /** Height */
  61770. height?: string;
  61771. /** Left padding */
  61772. paddingLeft?: string;
  61773. /** Right padding */
  61774. paddingRight?: string;
  61775. /** Top padding */
  61776. paddingTop?: string;
  61777. /** Bottom padding */
  61778. paddingBottom?: string;
  61779. /** Foreground color */
  61780. color?: string;
  61781. /** Background color */
  61782. background?: string;
  61783. }
  61784. /**
  61785. * Class used to create virtual keyboard
  61786. */
  61787. export class VirtualKeyboard extends StackPanel {
  61788. /** BABYLON.Observable raised when a key is pressed */
  61789. onKeyPressObservable: BABYLON.Observable<string>;
  61790. /** Gets or sets default key button width */
  61791. defaultButtonWidth: string;
  61792. /** Gets or sets default key button height */
  61793. defaultButtonHeight: string;
  61794. /** Gets or sets default key button left padding */
  61795. defaultButtonPaddingLeft: string;
  61796. /** Gets or sets default key button right padding */
  61797. defaultButtonPaddingRight: string;
  61798. /** Gets or sets default key button top padding */
  61799. defaultButtonPaddingTop: string;
  61800. /** Gets or sets default key button bottom padding */
  61801. defaultButtonPaddingBottom: string;
  61802. /** Gets or sets default key button foreground color */
  61803. defaultButtonColor: string;
  61804. /** Gets or sets default key button background color */
  61805. defaultButtonBackground: string;
  61806. /** Gets or sets shift button foreground color */
  61807. shiftButtonColor: string;
  61808. /** Gets or sets shift button thickness*/
  61809. selectedShiftThickness: number;
  61810. /** Gets shift key state */
  61811. shiftState: number;
  61812. protected _getTypeName(): string;
  61813. private _createKey;
  61814. /**
  61815. * Adds a new row of keys
  61816. * @param keys defines the list of keys to add
  61817. * @param propertySets defines the associated property sets
  61818. */
  61819. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  61820. /**
  61821. * Set the shift key to a specific state
  61822. * @param shiftState defines the new shift state
  61823. */
  61824. applyShiftState(shiftState: number): void;
  61825. private _currentlyConnectedInputText;
  61826. private _connectedInputTexts;
  61827. private _onKeyPressObserver;
  61828. /** Gets the input text control currently attached to the keyboard */
  61829. readonly connectedInputText: BABYLON.Nullable<InputText>;
  61830. /**
  61831. * Connects the keyboard with an input text control
  61832. *
  61833. * @param input defines the target control
  61834. */
  61835. connect(input: InputText): void;
  61836. /**
  61837. * Disconnects the keyboard from connected InputText controls
  61838. *
  61839. * @param input optionally defines a target control, otherwise all are disconnected
  61840. */
  61841. disconnect(input?: InputText): void;
  61842. private _removeConnectedInputObservables;
  61843. /**
  61844. * Release all resources
  61845. */
  61846. dispose(): void;
  61847. /**
  61848. * Creates a new keyboard using a default layout
  61849. *
  61850. * @param name defines control name
  61851. * @returns a new VirtualKeyboard
  61852. */
  61853. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  61854. }
  61855. }
  61856. declare module BABYLON.GUI {
  61857. /**
  61858. * Class used to create input text control
  61859. */
  61860. export class InputText extends Control implements IFocusableControl {
  61861. name?: string | undefined;
  61862. private _text;
  61863. private _placeholderText;
  61864. private _background;
  61865. private _focusedBackground;
  61866. private _focusedColor;
  61867. private _placeholderColor;
  61868. private _thickness;
  61869. private _margin;
  61870. private _autoStretchWidth;
  61871. private _maxWidth;
  61872. private _isFocused;
  61873. private _blinkTimeout;
  61874. private _blinkIsEven;
  61875. private _cursorOffset;
  61876. private _scrollLeft;
  61877. private _textWidth;
  61878. private _clickedCoordinate;
  61879. private _deadKey;
  61880. private _addKey;
  61881. private _currentKey;
  61882. private _isTextHighlightOn;
  61883. private _textHighlightColor;
  61884. private _highligherOpacity;
  61885. private _highlightedText;
  61886. private _startHighlightIndex;
  61887. private _endHighlightIndex;
  61888. private _cursorIndex;
  61889. private _onFocusSelectAll;
  61890. private _isPointerDown;
  61891. private _onClipboardObserver;
  61892. private _onPointerDblTapObserver;
  61893. /** @hidden */
  61894. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  61895. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  61896. promptMessage: string;
  61897. /** BABYLON.Observable raised when the text changes */
  61898. onTextChangedObservable: BABYLON.Observable<InputText>;
  61899. /** BABYLON.Observable raised just before an entered character is to be added */
  61900. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  61901. /** BABYLON.Observable raised when the control gets the focus */
  61902. onFocusObservable: BABYLON.Observable<InputText>;
  61903. /** BABYLON.Observable raised when the control loses the focus */
  61904. onBlurObservable: BABYLON.Observable<InputText>;
  61905. /**Observable raised when the text is highlighted */
  61906. onTextHighlightObservable: BABYLON.Observable<InputText>;
  61907. /**Observable raised when copy event is triggered */
  61908. onTextCopyObservable: BABYLON.Observable<InputText>;
  61909. /** BABYLON.Observable raised when cut event is triggered */
  61910. onTextCutObservable: BABYLON.Observable<InputText>;
  61911. /** BABYLON.Observable raised when paste event is triggered */
  61912. onTextPasteObservable: BABYLON.Observable<InputText>;
  61913. /** BABYLON.Observable raised when a key event was processed */
  61914. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  61915. /** Gets or sets the maximum width allowed by the control */
  61916. maxWidth: string | number;
  61917. /** Gets the maximum width allowed by the control in pixels */
  61918. readonly maxWidthInPixels: number;
  61919. /** Gets or sets the text highlighter transparency; default: 0.4 */
  61920. highligherOpacity: number;
  61921. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  61922. onFocusSelectAll: boolean;
  61923. /** Gets or sets the text hightlight color */
  61924. textHighlightColor: string;
  61925. /** Gets or sets control margin */
  61926. margin: string;
  61927. /** Gets control margin in pixels */
  61928. readonly marginInPixels: number;
  61929. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  61930. autoStretchWidth: boolean;
  61931. /** Gets or sets border thickness */
  61932. thickness: number;
  61933. /** Gets or sets the background color when focused */
  61934. focusedBackground: string;
  61935. /** Gets or sets the background color when focused */
  61936. focusedColor: string;
  61937. /** Gets or sets the background color */
  61938. background: string;
  61939. /** Gets or sets the placeholder color */
  61940. placeholderColor: string;
  61941. /** Gets or sets the text displayed when the control is empty */
  61942. placeholderText: string;
  61943. /** Gets or sets the dead key flag */
  61944. deadKey: boolean;
  61945. /** Gets or sets the highlight text */
  61946. highlightedText: string;
  61947. /** Gets or sets if the current key should be added */
  61948. addKey: boolean;
  61949. /** Gets or sets the value of the current key being entered */
  61950. currentKey: string;
  61951. /** Gets or sets the text displayed in the control */
  61952. text: string;
  61953. /** Gets or sets control width */
  61954. width: string | number;
  61955. /**
  61956. * Creates a new InputText
  61957. * @param name defines the control name
  61958. * @param text defines the text of the control
  61959. */
  61960. constructor(name?: string | undefined, text?: string);
  61961. /** @hidden */
  61962. onBlur(): void;
  61963. /** @hidden */
  61964. onFocus(): void;
  61965. protected _getTypeName(): string;
  61966. /**
  61967. * Function called to get the list of controls that should not steal the focus from this control
  61968. * @returns an array of controls
  61969. */
  61970. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  61971. /** @hidden */
  61972. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  61973. /** @hidden */
  61974. private _updateValueFromCursorIndex;
  61975. /** @hidden */
  61976. private _processDblClick;
  61977. /** @hidden */
  61978. private _selectAllText;
  61979. /**
  61980. * Handles the keyboard event
  61981. * @param evt Defines the KeyboardEvent
  61982. */
  61983. processKeyboard(evt: KeyboardEvent): void;
  61984. /** @hidden */
  61985. private _onCopyText;
  61986. /** @hidden */
  61987. private _onCutText;
  61988. /** @hidden */
  61989. private _onPasteText;
  61990. _draw(context: CanvasRenderingContext2D): void;
  61991. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  61992. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  61993. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  61994. protected _beforeRenderText(text: string): string;
  61995. dispose(): void;
  61996. }
  61997. }
  61998. declare module BABYLON.GUI {
  61999. /**
  62000. * Class used to create a 2D grid container
  62001. */
  62002. export class Grid extends Container {
  62003. name?: string | undefined;
  62004. private _rowDefinitions;
  62005. private _columnDefinitions;
  62006. private _cells;
  62007. private _childControls;
  62008. /**
  62009. * Gets the number of columns
  62010. */
  62011. readonly columnCount: number;
  62012. /**
  62013. * Gets the number of rows
  62014. */
  62015. readonly rowCount: number;
  62016. /** Gets the list of children */
  62017. readonly children: Control[];
  62018. /** Gets the list of cells (e.g. the containers) */
  62019. readonly cells: {
  62020. [key: string]: Container;
  62021. };
  62022. /**
  62023. * Gets the definition of a specific row
  62024. * @param index defines the index of the row
  62025. * @returns the row definition
  62026. */
  62027. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  62028. /**
  62029. * Gets the definition of a specific column
  62030. * @param index defines the index of the column
  62031. * @returns the column definition
  62032. */
  62033. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  62034. /**
  62035. * Adds a new row to the grid
  62036. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  62037. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  62038. * @returns the current grid
  62039. */
  62040. addRowDefinition(height: number, isPixel?: boolean): Grid;
  62041. /**
  62042. * Adds a new column to the grid
  62043. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  62044. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  62045. * @returns the current grid
  62046. */
  62047. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  62048. /**
  62049. * Update a row definition
  62050. * @param index defines the index of the row to update
  62051. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  62052. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  62053. * @returns the current grid
  62054. */
  62055. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  62056. /**
  62057. * Update a column definition
  62058. * @param index defines the index of the column to update
  62059. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  62060. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  62061. * @returns the current grid
  62062. */
  62063. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  62064. /**
  62065. * Gets the list of children stored in a specific cell
  62066. * @param row defines the row to check
  62067. * @param column defines the column to check
  62068. * @returns the list of controls
  62069. */
  62070. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  62071. /**
  62072. * Gets a string representing the child cell info (row x column)
  62073. * @param child defines the control to get info from
  62074. * @returns a string containing the child cell info (row x column)
  62075. */
  62076. getChildCellInfo(child: Control): string;
  62077. private _removeCell;
  62078. private _offsetCell;
  62079. /**
  62080. * Remove a column definition at specified index
  62081. * @param index defines the index of the column to remove
  62082. * @returns the current grid
  62083. */
  62084. removeColumnDefinition(index: number): Grid;
  62085. /**
  62086. * Remove a row definition at specified index
  62087. * @param index defines the index of the row to remove
  62088. * @returns the current grid
  62089. */
  62090. removeRowDefinition(index: number): Grid;
  62091. /**
  62092. * Adds a new control to the current grid
  62093. * @param control defines the control to add
  62094. * @param row defines the row where to add the control (0 by default)
  62095. * @param column defines the column where to add the control (0 by default)
  62096. * @returns the current grid
  62097. */
  62098. addControl(control: Control, row?: number, column?: number): Grid;
  62099. /**
  62100. * Removes a control from the current container
  62101. * @param control defines the control to remove
  62102. * @returns the current container
  62103. */
  62104. removeControl(control: Control): Container;
  62105. /**
  62106. * Creates a new Grid
  62107. * @param name defines control name
  62108. */
  62109. constructor(name?: string | undefined);
  62110. protected _getTypeName(): string;
  62111. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  62112. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62113. _flagDescendantsAsMatrixDirty(): void;
  62114. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  62115. /** Releases associated resources */
  62116. dispose(): void;
  62117. }
  62118. }
  62119. declare module BABYLON.GUI {
  62120. /** Class used to create color pickers */
  62121. export class ColorPicker extends Control {
  62122. name?: string | undefined;
  62123. private static _Epsilon;
  62124. private _colorWheelCanvas;
  62125. private _value;
  62126. private _tmpColor;
  62127. private _pointerStartedOnSquare;
  62128. private _pointerStartedOnWheel;
  62129. private _squareLeft;
  62130. private _squareTop;
  62131. private _squareSize;
  62132. private _h;
  62133. private _s;
  62134. private _v;
  62135. private _lastPointerDownID;
  62136. /**
  62137. * BABYLON.Observable raised when the value changes
  62138. */
  62139. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  62140. /** Gets or sets the color of the color picker */
  62141. value: BABYLON.Color3;
  62142. /**
  62143. * Gets or sets control width
  62144. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62145. */
  62146. width: string | number;
  62147. /**
  62148. * Gets or sets control height
  62149. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62150. */
  62151. /** Gets or sets control height */
  62152. height: string | number;
  62153. /** Gets or sets control size */
  62154. size: string | number;
  62155. /**
  62156. * Creates a new ColorPicker
  62157. * @param name defines the control name
  62158. */
  62159. constructor(name?: string | undefined);
  62160. protected _getTypeName(): string;
  62161. /** @hidden */
  62162. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62163. private _updateSquareProps;
  62164. private _drawGradientSquare;
  62165. private _drawCircle;
  62166. private _createColorWheelCanvas;
  62167. /** @hidden */
  62168. _draw(context: CanvasRenderingContext2D): void;
  62169. private _pointerIsDown;
  62170. private _updateValueFromPointer;
  62171. private _isPointOnSquare;
  62172. private _isPointOnWheel;
  62173. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  62174. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  62175. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  62176. /**
  62177. * This function expands the color picker by creating a color picker dialog with manual
  62178. * color value input and the ability to save colors into an array to be used later in
  62179. * subsequent launches of the dialogue.
  62180. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  62181. * @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.
  62182. * @returns picked color as a hex string and the saved colors array as hex strings.
  62183. */
  62184. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  62185. pickerWidth?: string;
  62186. pickerHeight?: string;
  62187. headerHeight?: string;
  62188. lastColor?: string;
  62189. swatchLimit?: number;
  62190. numSwatchesPerLine?: number;
  62191. savedColors?: Array<string>;
  62192. }): Promise<{
  62193. savedColors?: string[];
  62194. pickedColor: string;
  62195. }>;
  62196. }
  62197. }
  62198. declare module BABYLON.GUI {
  62199. /** Class used to create 2D ellipse containers */
  62200. export class Ellipse extends Container {
  62201. name?: string | undefined;
  62202. private _thickness;
  62203. /** Gets or sets border thickness */
  62204. thickness: number;
  62205. /**
  62206. * Creates a new Ellipse
  62207. * @param name defines the control name
  62208. */
  62209. constructor(name?: string | undefined);
  62210. protected _getTypeName(): string;
  62211. protected _localDraw(context: CanvasRenderingContext2D): void;
  62212. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62213. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  62214. }
  62215. }
  62216. declare module BABYLON.GUI {
  62217. /**
  62218. * Class used to create a password control
  62219. */
  62220. export class InputPassword extends InputText {
  62221. protected _beforeRenderText(text: string): string;
  62222. }
  62223. }
  62224. declare module BABYLON.GUI {
  62225. /** Class used to render 2D lines */
  62226. export class Line extends Control {
  62227. name?: string | undefined;
  62228. private _lineWidth;
  62229. private _x1;
  62230. private _y1;
  62231. private _x2;
  62232. private _y2;
  62233. private _dash;
  62234. private _connectedControl;
  62235. private _connectedControlDirtyObserver;
  62236. /** Gets or sets the dash pattern */
  62237. dash: Array<number>;
  62238. /** Gets or sets the control connected with the line end */
  62239. connectedControl: Control;
  62240. /** Gets or sets start coordinates on X axis */
  62241. x1: string | number;
  62242. /** Gets or sets start coordinates on Y axis */
  62243. y1: string | number;
  62244. /** Gets or sets end coordinates on X axis */
  62245. x2: string | number;
  62246. /** Gets or sets end coordinates on Y axis */
  62247. y2: string | number;
  62248. /** Gets or sets line width */
  62249. lineWidth: number;
  62250. /** Gets or sets horizontal alignment */
  62251. horizontalAlignment: number;
  62252. /** Gets or sets vertical alignment */
  62253. verticalAlignment: number;
  62254. private readonly _effectiveX2;
  62255. private readonly _effectiveY2;
  62256. /**
  62257. * Creates a new Line
  62258. * @param name defines the control name
  62259. */
  62260. constructor(name?: string | undefined);
  62261. protected _getTypeName(): string;
  62262. _draw(context: CanvasRenderingContext2D): void;
  62263. _measure(): void;
  62264. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62265. /**
  62266. * Move one end of the line given 3D cartesian coordinates.
  62267. * @param position Targeted world position
  62268. * @param scene BABYLON.Scene
  62269. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  62270. */
  62271. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  62272. /**
  62273. * Move one end of the line to a position in screen absolute space.
  62274. * @param projectedPosition Position in screen absolute space (X, Y)
  62275. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  62276. */
  62277. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  62278. }
  62279. }
  62280. declare module BABYLON.GUI {
  62281. /**
  62282. * Class used to store a point for a MultiLine object.
  62283. * The point can be pure 2D coordinates, a mesh or a control
  62284. */
  62285. export class MultiLinePoint {
  62286. private _multiLine;
  62287. private _x;
  62288. private _y;
  62289. private _control;
  62290. private _mesh;
  62291. private _controlObserver;
  62292. private _meshObserver;
  62293. /** @hidden */
  62294. _point: BABYLON.Vector2;
  62295. /**
  62296. * Creates a new MultiLinePoint
  62297. * @param multiLine defines the source MultiLine object
  62298. */
  62299. constructor(multiLine: MultiLine);
  62300. /** Gets or sets x coordinate */
  62301. x: string | number;
  62302. /** Gets or sets y coordinate */
  62303. y: string | number;
  62304. /** Gets or sets the control associated with this point */
  62305. control: BABYLON.Nullable<Control>;
  62306. /** Gets or sets the mesh associated with this point */
  62307. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  62308. /** Resets links */
  62309. resetLinks(): void;
  62310. /**
  62311. * Gets a translation vector
  62312. * @returns the translation vector
  62313. */
  62314. translate(): BABYLON.Vector2;
  62315. private _translatePoint;
  62316. /** Release associated resources */
  62317. dispose(): void;
  62318. }
  62319. }
  62320. declare module BABYLON.GUI {
  62321. /**
  62322. * Class used to create multi line control
  62323. */
  62324. export class MultiLine extends Control {
  62325. name?: string | undefined;
  62326. private _lineWidth;
  62327. private _dash;
  62328. private _points;
  62329. private _minX;
  62330. private _minY;
  62331. private _maxX;
  62332. private _maxY;
  62333. /**
  62334. * Creates a new MultiLine
  62335. * @param name defines the control name
  62336. */
  62337. constructor(name?: string | undefined);
  62338. /** Gets or sets dash pattern */
  62339. dash: Array<number>;
  62340. /**
  62341. * Gets point stored at specified index
  62342. * @param index defines the index to look for
  62343. * @returns the requested point if found
  62344. */
  62345. getAt(index: number): MultiLinePoint;
  62346. /** Function called when a point is updated */
  62347. onPointUpdate: () => void;
  62348. /**
  62349. * Adds new points to the point collection
  62350. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  62351. * @returns the list of created MultiLinePoint
  62352. */
  62353. add(...items: (AbstractMesh | Control | {
  62354. x: string | number;
  62355. y: string | number;
  62356. })[]): MultiLinePoint[];
  62357. /**
  62358. * Adds a new point to the point collection
  62359. * @param item defines the item (mesh, control or 2d coordiantes) to add
  62360. * @returns the created MultiLinePoint
  62361. */
  62362. push(item?: (AbstractMesh | Control | {
  62363. x: string | number;
  62364. y: string | number;
  62365. })): MultiLinePoint;
  62366. /**
  62367. * Remove a specific value or point from the active point collection
  62368. * @param value defines the value or point to remove
  62369. */
  62370. remove(value: number | MultiLinePoint): void;
  62371. /**
  62372. * Resets this object to initial state (no point)
  62373. */
  62374. reset(): void;
  62375. /**
  62376. * Resets all links
  62377. */
  62378. resetLinks(): void;
  62379. /** Gets or sets line width */
  62380. lineWidth: number;
  62381. horizontalAlignment: number;
  62382. verticalAlignment: number;
  62383. protected _getTypeName(): string;
  62384. _draw(context: CanvasRenderingContext2D): void;
  62385. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62386. _measure(): void;
  62387. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62388. dispose(): void;
  62389. }
  62390. }
  62391. declare module BABYLON.GUI {
  62392. /**
  62393. * Class used to create radio button controls
  62394. */
  62395. export class RadioButton extends Control {
  62396. name?: string | undefined;
  62397. private _isChecked;
  62398. private _background;
  62399. private _checkSizeRatio;
  62400. private _thickness;
  62401. /** Gets or sets border thickness */
  62402. thickness: number;
  62403. /** Gets or sets group name */
  62404. group: string;
  62405. /** BABYLON.Observable raised when isChecked is changed */
  62406. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  62407. /** Gets or sets a value indicating the ratio between overall size and check size */
  62408. checkSizeRatio: number;
  62409. /** Gets or sets background color */
  62410. background: string;
  62411. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  62412. isChecked: boolean;
  62413. /**
  62414. * Creates a new RadioButton
  62415. * @param name defines the control name
  62416. */
  62417. constructor(name?: string | undefined);
  62418. protected _getTypeName(): string;
  62419. _draw(context: CanvasRenderingContext2D): void;
  62420. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  62421. /**
  62422. * Utility function to easily create a radio button with a header
  62423. * @param title defines the label to use for the header
  62424. * @param group defines the group to use for the radio button
  62425. * @param isChecked defines the initial state of the radio button
  62426. * @param onValueChanged defines the callback to call when value changes
  62427. * @returns a StackPanel containing the radio button and a textBlock
  62428. */
  62429. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  62430. }
  62431. }
  62432. declare module BABYLON.GUI {
  62433. /**
  62434. * Class used to create slider controls
  62435. */
  62436. export class BaseSlider extends Control {
  62437. name?: string | undefined;
  62438. protected _thumbWidth: ValueAndUnit;
  62439. private _minimum;
  62440. private _maximum;
  62441. private _value;
  62442. private _isVertical;
  62443. protected _barOffset: ValueAndUnit;
  62444. private _isThumbClamped;
  62445. protected _displayThumb: boolean;
  62446. private _step;
  62447. private _lastPointerDownID;
  62448. protected _effectiveBarOffset: number;
  62449. protected _renderLeft: number;
  62450. protected _renderTop: number;
  62451. protected _renderWidth: number;
  62452. protected _renderHeight: number;
  62453. protected _backgroundBoxLength: number;
  62454. protected _backgroundBoxThickness: number;
  62455. protected _effectiveThumbThickness: number;
  62456. /** BABYLON.Observable raised when the sldier value changes */
  62457. onValueChangedObservable: BABYLON.Observable<number>;
  62458. /** Gets or sets a boolean indicating if the thumb must be rendered */
  62459. displayThumb: boolean;
  62460. /** Gets or sets a step to apply to values (0 by default) */
  62461. step: number;
  62462. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  62463. barOffset: string | number;
  62464. /** Gets main bar offset in pixels*/
  62465. readonly barOffsetInPixels: number;
  62466. /** Gets or sets thumb width */
  62467. thumbWidth: string | number;
  62468. /** Gets thumb width in pixels */
  62469. readonly thumbWidthInPixels: number;
  62470. /** Gets or sets minimum value */
  62471. minimum: number;
  62472. /** Gets or sets maximum value */
  62473. maximum: number;
  62474. /** Gets or sets current value */
  62475. value: number;
  62476. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  62477. isVertical: boolean;
  62478. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  62479. isThumbClamped: boolean;
  62480. /**
  62481. * Creates a new BaseSlider
  62482. * @param name defines the control name
  62483. */
  62484. constructor(name?: string | undefined);
  62485. protected _getTypeName(): string;
  62486. protected _getThumbPosition(): number;
  62487. protected _getThumbThickness(type: string): number;
  62488. protected _prepareRenderingData(type: string): void;
  62489. private _pointerIsDown;
  62490. /** @hidden */
  62491. protected _updateValueFromPointer(x: number, y: number): void;
  62492. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  62493. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  62494. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  62495. }
  62496. }
  62497. declare module BABYLON.GUI {
  62498. /**
  62499. * Class used to create slider controls
  62500. */
  62501. export class Slider extends BaseSlider {
  62502. name?: string | undefined;
  62503. private _background;
  62504. private _borderColor;
  62505. private _isThumbCircle;
  62506. protected _displayValueBar: boolean;
  62507. /** Gets or sets a boolean indicating if the value bar must be rendered */
  62508. displayValueBar: boolean;
  62509. /** Gets or sets border color */
  62510. borderColor: string;
  62511. /** Gets or sets background color */
  62512. background: string;
  62513. /** Gets or sets a boolean indicating if the thumb should be round or square */
  62514. isThumbCircle: boolean;
  62515. /**
  62516. * Creates a new Slider
  62517. * @param name defines the control name
  62518. */
  62519. constructor(name?: string | undefined);
  62520. protected _getTypeName(): string;
  62521. _draw(context: CanvasRenderingContext2D): void;
  62522. }
  62523. }
  62524. declare module BABYLON.GUI {
  62525. /** Class used to create a RadioGroup
  62526. * which contains groups of radio buttons
  62527. */
  62528. export class SelectorGroup {
  62529. /** name of SelectorGroup */
  62530. name: string;
  62531. private _groupPanel;
  62532. private _selectors;
  62533. private _groupHeader;
  62534. /**
  62535. * Creates a new SelectorGroup
  62536. * @param name of group, used as a group heading
  62537. */
  62538. constructor(
  62539. /** name of SelectorGroup */
  62540. name: string);
  62541. /** Gets the groupPanel of the SelectorGroup */
  62542. readonly groupPanel: StackPanel;
  62543. /** Gets the selectors array */
  62544. readonly selectors: StackPanel[];
  62545. /** Gets and sets the group header */
  62546. header: string;
  62547. /** @hidden */
  62548. private _addGroupHeader;
  62549. /** @hidden*/
  62550. _getSelector(selectorNb: number): StackPanel | undefined;
  62551. /** Removes the selector at the given position
  62552. * @param selectorNb the position of the selector within the group
  62553. */
  62554. removeSelector(selectorNb: number): void;
  62555. }
  62556. /** Class used to create a CheckboxGroup
  62557. * which contains groups of checkbox buttons
  62558. */
  62559. export class CheckboxGroup extends SelectorGroup {
  62560. /** Adds a checkbox as a control
  62561. * @param text is the label for the selector
  62562. * @param func is the function called when the Selector is checked
  62563. * @param checked is true when Selector is checked
  62564. */
  62565. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  62566. /** @hidden */
  62567. _setSelectorLabel(selectorNb: number, label: string): void;
  62568. /** @hidden */
  62569. _setSelectorLabelColor(selectorNb: number, color: string): void;
  62570. /** @hidden */
  62571. _setSelectorButtonColor(selectorNb: number, color: string): void;
  62572. /** @hidden */
  62573. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  62574. }
  62575. /** Class used to create a RadioGroup
  62576. * which contains groups of radio buttons
  62577. */
  62578. export class RadioGroup extends SelectorGroup {
  62579. private _selectNb;
  62580. /** Adds a radio button as a control
  62581. * @param label is the label for the selector
  62582. * @param func is the function called when the Selector is checked
  62583. * @param checked is true when Selector is checked
  62584. */
  62585. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  62586. /** @hidden */
  62587. _setSelectorLabel(selectorNb: number, label: string): void;
  62588. /** @hidden */
  62589. _setSelectorLabelColor(selectorNb: number, color: string): void;
  62590. /** @hidden */
  62591. _setSelectorButtonColor(selectorNb: number, color: string): void;
  62592. /** @hidden */
  62593. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  62594. }
  62595. /** Class used to create a SliderGroup
  62596. * which contains groups of slider buttons
  62597. */
  62598. export class SliderGroup extends SelectorGroup {
  62599. /**
  62600. * Adds a slider to the SelectorGroup
  62601. * @param label is the label for the SliderBar
  62602. * @param func is the function called when the Slider moves
  62603. * @param unit is a string describing the units used, eg degrees or metres
  62604. * @param min is the minimum value for the Slider
  62605. * @param max is the maximum value for the Slider
  62606. * @param value is the start value for the Slider between min and max
  62607. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  62608. */
  62609. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  62610. /** @hidden */
  62611. _setSelectorLabel(selectorNb: number, label: string): void;
  62612. /** @hidden */
  62613. _setSelectorLabelColor(selectorNb: number, color: string): void;
  62614. /** @hidden */
  62615. _setSelectorButtonColor(selectorNb: number, color: string): void;
  62616. /** @hidden */
  62617. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  62618. }
  62619. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  62620. * @see http://doc.babylonjs.com/how_to/selector
  62621. */
  62622. export class SelectionPanel extends Rectangle {
  62623. /** name of SelectionPanel */
  62624. name: string;
  62625. /** an array of SelectionGroups */
  62626. groups: SelectorGroup[];
  62627. private _panel;
  62628. private _buttonColor;
  62629. private _buttonBackground;
  62630. private _headerColor;
  62631. private _barColor;
  62632. private _barHeight;
  62633. private _spacerHeight;
  62634. private _labelColor;
  62635. private _groups;
  62636. private _bars;
  62637. /**
  62638. * Creates a new SelectionPanel
  62639. * @param name of SelectionPanel
  62640. * @param groups is an array of SelectionGroups
  62641. */
  62642. constructor(
  62643. /** name of SelectionPanel */
  62644. name: string,
  62645. /** an array of SelectionGroups */
  62646. groups?: SelectorGroup[]);
  62647. protected _getTypeName(): string;
  62648. /** Gets or sets the headerColor */
  62649. headerColor: string;
  62650. private _setHeaderColor;
  62651. /** Gets or sets the button color */
  62652. buttonColor: string;
  62653. private _setbuttonColor;
  62654. /** Gets or sets the label color */
  62655. labelColor: string;
  62656. private _setLabelColor;
  62657. /** Gets or sets the button background */
  62658. buttonBackground: string;
  62659. private _setButtonBackground;
  62660. /** Gets or sets the color of separator bar */
  62661. barColor: string;
  62662. private _setBarColor;
  62663. /** Gets or sets the height of separator bar */
  62664. barHeight: string;
  62665. private _setBarHeight;
  62666. /** Gets or sets the height of spacers*/
  62667. spacerHeight: string;
  62668. private _setSpacerHeight;
  62669. /** Adds a bar between groups */
  62670. private _addSpacer;
  62671. /** Add a group to the selection panel
  62672. * @param group is the selector group to add
  62673. */
  62674. addGroup(group: SelectorGroup): void;
  62675. /** Remove the group from the given position
  62676. * @param groupNb is the position of the group in the list
  62677. */
  62678. removeGroup(groupNb: number): void;
  62679. /** Change a group header label
  62680. * @param label is the new group header label
  62681. * @param groupNb is the number of the group to relabel
  62682. * */
  62683. setHeaderName(label: string, groupNb: number): void;
  62684. /** Change selector label to the one given
  62685. * @param label is the new selector label
  62686. * @param groupNb is the number of the groupcontaining the selector
  62687. * @param selectorNb is the number of the selector within a group to relabel
  62688. * */
  62689. relabel(label: string, groupNb: number, selectorNb: number): void;
  62690. /** For a given group position remove the selector at the given position
  62691. * @param groupNb is the number of the group to remove the selector from
  62692. * @param selectorNb is the number of the selector within the group
  62693. */
  62694. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  62695. /** For a given group position of correct type add a checkbox button
  62696. * @param groupNb is the number of the group to remove the selector from
  62697. * @param label is the label for the selector
  62698. * @param func is the function called when the Selector is checked
  62699. * @param checked is true when Selector is checked
  62700. */
  62701. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  62702. /** For a given group position of correct type add a radio button
  62703. * @param groupNb is the number of the group to remove the selector from
  62704. * @param label is the label for the selector
  62705. * @param func is the function called when the Selector is checked
  62706. * @param checked is true when Selector is checked
  62707. */
  62708. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  62709. /**
  62710. * For a given slider group add a slider
  62711. * @param groupNb is the number of the group to add the slider to
  62712. * @param label is the label for the Slider
  62713. * @param func is the function called when the Slider moves
  62714. * @param unit is a string describing the units used, eg degrees or metres
  62715. * @param min is the minimum value for the Slider
  62716. * @param max is the maximum value for the Slider
  62717. * @param value is the start value for the Slider between min and max
  62718. * @param onVal is the function used to format the value displayed, eg radians to degrees
  62719. */
  62720. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  62721. }
  62722. }
  62723. declare module BABYLON.GUI {
  62724. /**
  62725. * Class used to hold a the container for ScrollViewer
  62726. * @hidden
  62727. */
  62728. export class _ScrollViewerWindow extends Container {
  62729. parentClientWidth: number;
  62730. parentClientHeight: number;
  62731. /**
  62732. * Creates a new ScrollViewerWindow
  62733. * @param name of ScrollViewerWindow
  62734. */
  62735. constructor(name?: string);
  62736. protected _getTypeName(): string;
  62737. /** @hidden */
  62738. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62739. protected _postMeasure(): void;
  62740. }
  62741. }
  62742. declare module BABYLON.GUI {
  62743. /**
  62744. * Class used to create slider controls
  62745. */
  62746. export class ScrollBar extends BaseSlider {
  62747. name?: string | undefined;
  62748. private _background;
  62749. private _borderColor;
  62750. private _thumbMeasure;
  62751. /** Gets or sets border color */
  62752. borderColor: string;
  62753. /** Gets or sets background color */
  62754. background: string;
  62755. /**
  62756. * Creates a new Slider
  62757. * @param name defines the control name
  62758. */
  62759. constructor(name?: string | undefined);
  62760. protected _getTypeName(): string;
  62761. protected _getThumbThickness(): number;
  62762. _draw(context: CanvasRenderingContext2D): void;
  62763. private _first;
  62764. private _originX;
  62765. private _originY;
  62766. /** @hidden */
  62767. protected _updateValueFromPointer(x: number, y: number): void;
  62768. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  62769. }
  62770. }
  62771. declare module BABYLON.GUI {
  62772. /**
  62773. * Class used to hold a viewer window and sliders in a grid
  62774. */
  62775. export class ScrollViewer extends Rectangle {
  62776. private _grid;
  62777. private _horizontalBarSpace;
  62778. private _verticalBarSpace;
  62779. private _dragSpace;
  62780. private _horizontalBar;
  62781. private _verticalBar;
  62782. private _barColor;
  62783. private _barBackground;
  62784. private _barSize;
  62785. private _endLeft;
  62786. private _endTop;
  62787. private _window;
  62788. private _pointerIsOver;
  62789. private _wheelPrecision;
  62790. private _onPointerObserver;
  62791. private _clientWidth;
  62792. private _clientHeight;
  62793. /**
  62794. * Gets the horizontal scrollbar
  62795. */
  62796. readonly horizontalBar: ScrollBar;
  62797. /**
  62798. * Gets the vertical scrollbar
  62799. */
  62800. readonly verticalBar: ScrollBar;
  62801. /**
  62802. * Adds a new control to the current container
  62803. * @param control defines the control to add
  62804. * @returns the current container
  62805. */
  62806. addControl(control: BABYLON.Nullable<Control>): Container;
  62807. /**
  62808. * Removes a control from the current container
  62809. * @param control defines the control to remove
  62810. * @returns the current container
  62811. */
  62812. removeControl(control: Control): Container;
  62813. /** Gets the list of children */
  62814. readonly children: Control[];
  62815. _flagDescendantsAsMatrixDirty(): void;
  62816. /**
  62817. * Creates a new ScrollViewer
  62818. * @param name of ScrollViewer
  62819. */
  62820. constructor(name?: string);
  62821. /** Reset the scroll viewer window to initial size */
  62822. resetWindow(): void;
  62823. protected _getTypeName(): string;
  62824. private _buildClientSizes;
  62825. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62826. protected _postMeasure(): void;
  62827. /**
  62828. * Gets or sets the mouse wheel precision
  62829. * from 0 to 1 with a default value of 0.05
  62830. * */
  62831. wheelPrecision: number;
  62832. /** Gets or sets the bar color */
  62833. barColor: string;
  62834. /** Gets or sets the size of the bar */
  62835. barSize: number;
  62836. /** Gets or sets the bar background */
  62837. barBackground: string;
  62838. /** @hidden */
  62839. private _updateScroller;
  62840. _link(host: AdvancedDynamicTexture): void;
  62841. /** @hidden */
  62842. private _attachWheel;
  62843. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  62844. /** Releases associated resources */
  62845. dispose(): void;
  62846. }
  62847. }
  62848. declare module BABYLON.GUI {
  62849. /** Class used to render a grid */
  62850. export class DisplayGrid extends Control {
  62851. name?: string | undefined;
  62852. private _cellWidth;
  62853. private _cellHeight;
  62854. private _minorLineTickness;
  62855. private _minorLineColor;
  62856. private _majorLineTickness;
  62857. private _majorLineColor;
  62858. private _majorLineFrequency;
  62859. private _background;
  62860. private _displayMajorLines;
  62861. private _displayMinorLines;
  62862. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  62863. displayMinorLines: boolean;
  62864. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  62865. displayMajorLines: boolean;
  62866. /** Gets or sets background color (Black by default) */
  62867. background: string;
  62868. /** Gets or sets the width of each cell (20 by default) */
  62869. cellWidth: number;
  62870. /** Gets or sets the height of each cell (20 by default) */
  62871. cellHeight: number;
  62872. /** Gets or sets the tickness of minor lines (1 by default) */
  62873. minorLineTickness: number;
  62874. /** Gets or sets the color of minor lines (DarkGray by default) */
  62875. minorLineColor: string;
  62876. /** Gets or sets the tickness of major lines (2 by default) */
  62877. majorLineTickness: number;
  62878. /** Gets or sets the color of major lines (White by default) */
  62879. majorLineColor: string;
  62880. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  62881. majorLineFrequency: number;
  62882. /**
  62883. * Creates a new GridDisplayRectangle
  62884. * @param name defines the control name
  62885. */
  62886. constructor(name?: string | undefined);
  62887. _draw(context: CanvasRenderingContext2D): void;
  62888. protected _getTypeName(): string;
  62889. }
  62890. }
  62891. declare module BABYLON.GUI {
  62892. /**
  62893. * Class used to create slider controls based on images
  62894. */
  62895. export class ImageBasedSlider extends BaseSlider {
  62896. name?: string | undefined;
  62897. private _backgroundImage;
  62898. private _thumbImage;
  62899. private _valueBarImage;
  62900. private _tempMeasure;
  62901. displayThumb: boolean;
  62902. /**
  62903. * Gets or sets the image used to render the background
  62904. */
  62905. backgroundImage: Image;
  62906. /**
  62907. * Gets or sets the image used to render the value bar
  62908. */
  62909. valueBarImage: Image;
  62910. /**
  62911. * Gets or sets the image used to render the thumb
  62912. */
  62913. thumbImage: Image;
  62914. /**
  62915. * Creates a new ImageBasedSlider
  62916. * @param name defines the control name
  62917. */
  62918. constructor(name?: string | undefined);
  62919. protected _getTypeName(): string;
  62920. _draw(context: CanvasRenderingContext2D): void;
  62921. }
  62922. }
  62923. declare module BABYLON.GUI {
  62924. /**
  62925. * Forcing an export so that this code will execute
  62926. * @hidden
  62927. */
  62928. const name = "Statics";
  62929. }
  62930. declare module BABYLON.GUI {
  62931. /**
  62932. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  62933. */
  62934. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  62935. /**
  62936. * Define the instrumented AdvancedDynamicTexture.
  62937. */
  62938. texture: AdvancedDynamicTexture;
  62939. private _captureRenderTime;
  62940. private _renderTime;
  62941. private _captureLayoutTime;
  62942. private _layoutTime;
  62943. private _onBeginRenderObserver;
  62944. private _onEndRenderObserver;
  62945. private _onBeginLayoutObserver;
  62946. private _onEndLayoutObserver;
  62947. /**
  62948. * Gets the perf counter used to capture render time
  62949. */
  62950. readonly renderTimeCounter: BABYLON.PerfCounter;
  62951. /**
  62952. * Gets the perf counter used to capture layout time
  62953. */
  62954. readonly layoutTimeCounter: BABYLON.PerfCounter;
  62955. /**
  62956. * Enable or disable the render time capture
  62957. */
  62958. captureRenderTime: boolean;
  62959. /**
  62960. * Enable or disable the layout time capture
  62961. */
  62962. captureLayoutTime: boolean;
  62963. /**
  62964. * Instantiates a new advanced dynamic texture instrumentation.
  62965. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  62966. * @param texture Defines the AdvancedDynamicTexture to instrument
  62967. */
  62968. constructor(
  62969. /**
  62970. * Define the instrumented AdvancedDynamicTexture.
  62971. */
  62972. texture: AdvancedDynamicTexture);
  62973. /**
  62974. * Dispose and release associated resources.
  62975. */
  62976. dispose(): void;
  62977. }
  62978. }
  62979. declare module BABYLON.GUI {
  62980. /**
  62981. * Class used to create containers for controls
  62982. */
  62983. export class Container3D extends Control3D {
  62984. private _blockLayout;
  62985. /**
  62986. * Gets the list of child controls
  62987. */
  62988. protected _children: Control3D[];
  62989. /**
  62990. * Gets the list of child controls
  62991. */
  62992. readonly children: Array<Control3D>;
  62993. /**
  62994. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  62995. * This is helpful to optimize layout operation when adding multiple children in a row
  62996. */
  62997. blockLayout: boolean;
  62998. /**
  62999. * Creates a new container
  63000. * @param name defines the container name
  63001. */
  63002. constructor(name?: string);
  63003. /**
  63004. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  63005. * @returns the current container
  63006. */
  63007. updateLayout(): Container3D;
  63008. /**
  63009. * Gets a boolean indicating if the given control is in the children of this control
  63010. * @param control defines the control to check
  63011. * @returns true if the control is in the child list
  63012. */
  63013. containsControl(control: Control3D): boolean;
  63014. /**
  63015. * Adds a control to the children of this control
  63016. * @param control defines the control to add
  63017. * @returns the current container
  63018. */
  63019. addControl(control: Control3D): Container3D;
  63020. /**
  63021. * This function will be called everytime a new control is added
  63022. */
  63023. protected _arrangeChildren(): void;
  63024. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  63025. /**
  63026. * Removes a control from the children of this control
  63027. * @param control defines the control to remove
  63028. * @returns the current container
  63029. */
  63030. removeControl(control: Control3D): Container3D;
  63031. protected _getTypeName(): string;
  63032. /**
  63033. * Releases all associated resources
  63034. */
  63035. dispose(): void;
  63036. /** Control rotation will remain unchanged */
  63037. static readonly UNSET_ORIENTATION: number;
  63038. /** Control will rotate to make it look at sphere central axis */
  63039. static readonly FACEORIGIN_ORIENTATION: number;
  63040. /** Control will rotate to make it look back at sphere central axis */
  63041. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  63042. /** Control will rotate to look at z axis (0, 0, 1) */
  63043. static readonly FACEFORWARD_ORIENTATION: number;
  63044. /** Control will rotate to look at negative z axis (0, 0, -1) */
  63045. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  63046. }
  63047. }
  63048. declare module BABYLON.GUI {
  63049. /**
  63050. * Class used to manage 3D user interface
  63051. * @see http://doc.babylonjs.com/how_to/gui3d
  63052. */
  63053. export class GUI3DManager implements BABYLON.IDisposable {
  63054. private _scene;
  63055. private _sceneDisposeObserver;
  63056. private _utilityLayer;
  63057. private _rootContainer;
  63058. private _pointerObserver;
  63059. private _pointerOutObserver;
  63060. /** @hidden */
  63061. _lastPickedControl: Control3D;
  63062. /** @hidden */
  63063. _lastControlOver: {
  63064. [pointerId: number]: Control3D;
  63065. };
  63066. /** @hidden */
  63067. _lastControlDown: {
  63068. [pointerId: number]: Control3D;
  63069. };
  63070. /**
  63071. * BABYLON.Observable raised when the point picked by the pointer events changed
  63072. */
  63073. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  63074. /** @hidden */
  63075. _sharedMaterials: {
  63076. [key: string]: BABYLON.Material;
  63077. };
  63078. /** Gets the hosting scene */
  63079. readonly scene: BABYLON.Scene;
  63080. /** Gets associated utility layer */
  63081. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  63082. /**
  63083. * Creates a new GUI3DManager
  63084. * @param scene
  63085. */
  63086. constructor(scene?: BABYLON.Scene);
  63087. private _handlePointerOut;
  63088. private _doPicking;
  63089. /**
  63090. * Gets the root container
  63091. */
  63092. readonly rootContainer: Container3D;
  63093. /**
  63094. * Gets a boolean indicating if the given control is in the root child list
  63095. * @param control defines the control to check
  63096. * @returns true if the control is in the root child list
  63097. */
  63098. containsControl(control: Control3D): boolean;
  63099. /**
  63100. * Adds a control to the root child list
  63101. * @param control defines the control to add
  63102. * @returns the current manager
  63103. */
  63104. addControl(control: Control3D): GUI3DManager;
  63105. /**
  63106. * Removes a control from the root child list
  63107. * @param control defines the control to remove
  63108. * @returns the current container
  63109. */
  63110. removeControl(control: Control3D): GUI3DManager;
  63111. /**
  63112. * Releases all associated resources
  63113. */
  63114. dispose(): void;
  63115. }
  63116. }
  63117. declare module BABYLON.GUI {
  63118. /**
  63119. * Class used to transport BABYLON.Vector3 information for pointer events
  63120. */
  63121. export class Vector3WithInfo extends BABYLON.Vector3 {
  63122. /** defines the current mouse button index */
  63123. buttonIndex: number;
  63124. /**
  63125. * Creates a new Vector3WithInfo
  63126. * @param source defines the vector3 data to transport
  63127. * @param buttonIndex defines the current mouse button index
  63128. */
  63129. constructor(source: BABYLON.Vector3,
  63130. /** defines the current mouse button index */
  63131. buttonIndex?: number);
  63132. }
  63133. }
  63134. declare module BABYLON.GUI {
  63135. /**
  63136. * Class used as base class for controls
  63137. */
  63138. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  63139. /** Defines the control name */
  63140. name?: string | undefined;
  63141. /** @hidden */
  63142. _host: GUI3DManager;
  63143. private _node;
  63144. private _downCount;
  63145. private _enterCount;
  63146. private _downPointerIds;
  63147. private _isVisible;
  63148. /** Gets or sets the control position in world space */
  63149. position: BABYLON.Vector3;
  63150. /** Gets or sets the control scaling in world space */
  63151. scaling: BABYLON.Vector3;
  63152. /** Callback used to start pointer enter animation */
  63153. pointerEnterAnimation: () => void;
  63154. /** Callback used to start pointer out animation */
  63155. pointerOutAnimation: () => void;
  63156. /** Callback used to start pointer down animation */
  63157. pointerDownAnimation: () => void;
  63158. /** Callback used to start pointer up animation */
  63159. pointerUpAnimation: () => void;
  63160. /**
  63161. * An event triggered when the pointer move over the control
  63162. */
  63163. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  63164. /**
  63165. * An event triggered when the pointer move out of the control
  63166. */
  63167. onPointerOutObservable: BABYLON.Observable<Control3D>;
  63168. /**
  63169. * An event triggered when the pointer taps the control
  63170. */
  63171. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  63172. /**
  63173. * An event triggered when pointer is up
  63174. */
  63175. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  63176. /**
  63177. * An event triggered when a control is clicked on (with a mouse)
  63178. */
  63179. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  63180. /**
  63181. * An event triggered when pointer enters the control
  63182. */
  63183. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  63184. /**
  63185. * Gets or sets the parent container
  63186. */
  63187. parent: BABYLON.Nullable<Container3D>;
  63188. private _behaviors;
  63189. /**
  63190. * Gets the list of attached behaviors
  63191. * @see http://doc.babylonjs.com/features/behaviour
  63192. */
  63193. readonly behaviors: BABYLON.Behavior<Control3D>[];
  63194. /**
  63195. * Attach a behavior to the control
  63196. * @see http://doc.babylonjs.com/features/behaviour
  63197. * @param behavior defines the behavior to attach
  63198. * @returns the current control
  63199. */
  63200. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  63201. /**
  63202. * Remove an attached behavior
  63203. * @see http://doc.babylonjs.com/features/behaviour
  63204. * @param behavior defines the behavior to attach
  63205. * @returns the current control
  63206. */
  63207. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  63208. /**
  63209. * Gets an attached behavior by name
  63210. * @param name defines the name of the behavior to look for
  63211. * @see http://doc.babylonjs.com/features/behaviour
  63212. * @returns null if behavior was not found else the requested behavior
  63213. */
  63214. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  63215. /** Gets or sets a boolean indicating if the control is visible */
  63216. isVisible: boolean;
  63217. /**
  63218. * Creates a new control
  63219. * @param name defines the control name
  63220. */
  63221. constructor(
  63222. /** Defines the control name */
  63223. name?: string | undefined);
  63224. /**
  63225. * Gets a string representing the class name
  63226. */
  63227. readonly typeName: string;
  63228. /**
  63229. * Get the current class name of the control.
  63230. * @returns current class name
  63231. */
  63232. getClassName(): string;
  63233. protected _getTypeName(): string;
  63234. /**
  63235. * Gets the transform node used by this control
  63236. */
  63237. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  63238. /**
  63239. * Gets the mesh used to render this control
  63240. */
  63241. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  63242. /**
  63243. * Link the control as child of the given node
  63244. * @param node defines the node to link to. Use null to unlink the control
  63245. * @returns the current control
  63246. */
  63247. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  63248. /** @hidden **/
  63249. _prepareNode(scene: BABYLON.Scene): void;
  63250. /**
  63251. * Node creation.
  63252. * Can be overriden by children
  63253. * @param scene defines the scene where the node must be attached
  63254. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  63255. */
  63256. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  63257. /**
  63258. * Affect a material to the given mesh
  63259. * @param mesh defines the mesh which will represent the control
  63260. */
  63261. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  63262. /** @hidden */
  63263. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  63264. /** @hidden */
  63265. _onPointerEnter(target: Control3D): boolean;
  63266. /** @hidden */
  63267. _onPointerOut(target: Control3D): void;
  63268. /** @hidden */
  63269. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  63270. /** @hidden */
  63271. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  63272. /** @hidden */
  63273. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  63274. /** @hidden */
  63275. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  63276. /** @hidden */
  63277. _disposeNode(): void;
  63278. /**
  63279. * Releases all associated resources
  63280. */
  63281. dispose(): void;
  63282. }
  63283. }
  63284. declare module BABYLON.GUI {
  63285. /**
  63286. * Class used as a root to all buttons
  63287. */
  63288. export class AbstractButton3D extends Control3D {
  63289. /**
  63290. * Creates a new button
  63291. * @param name defines the control name
  63292. */
  63293. constructor(name?: string);
  63294. protected _getTypeName(): string;
  63295. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  63296. }
  63297. }
  63298. declare module BABYLON.GUI {
  63299. /**
  63300. * Class used to create a button in 3D
  63301. */
  63302. export class Button3D extends AbstractButton3D {
  63303. /** @hidden */
  63304. protected _currentMaterial: BABYLON.Material;
  63305. private _facadeTexture;
  63306. private _content;
  63307. private _contentResolution;
  63308. private _contentScaleRatio;
  63309. /**
  63310. * Gets or sets the texture resolution used to render content (512 by default)
  63311. */
  63312. contentResolution: BABYLON.int;
  63313. /**
  63314. * Gets or sets the texture scale ratio used to render content (2 by default)
  63315. */
  63316. contentScaleRatio: number;
  63317. protected _disposeFacadeTexture(): void;
  63318. protected _resetContent(): void;
  63319. /**
  63320. * Creates a new button
  63321. * @param name defines the control name
  63322. */
  63323. constructor(name?: string);
  63324. /**
  63325. * Gets or sets the GUI 2D content used to display the button's facade
  63326. */
  63327. content: Control;
  63328. /**
  63329. * Apply the facade texture (created from the content property).
  63330. * This function can be overloaded by child classes
  63331. * @param facadeTexture defines the AdvancedDynamicTexture to use
  63332. */
  63333. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  63334. protected _getTypeName(): string;
  63335. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  63336. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  63337. /**
  63338. * Releases all associated resources
  63339. */
  63340. dispose(): void;
  63341. }
  63342. }
  63343. declare module BABYLON.GUI {
  63344. /**
  63345. * Abstract class used to create a container panel deployed on the surface of a volume
  63346. */
  63347. export abstract class VolumeBasedPanel extends Container3D {
  63348. private _columns;
  63349. private _rows;
  63350. private _rowThenColum;
  63351. private _orientation;
  63352. protected _cellWidth: number;
  63353. protected _cellHeight: number;
  63354. /**
  63355. * Gets or sets the distance between elements
  63356. */
  63357. margin: number;
  63358. /**
  63359. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  63360. * | Value | Type | Description |
  63361. * | ----- | ----------------------------------- | ----------- |
  63362. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  63363. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  63364. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  63365. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  63366. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  63367. */
  63368. orientation: number;
  63369. /**
  63370. * Gets or sets the number of columns requested (10 by default).
  63371. * The panel will automatically compute the number of rows based on number of child controls.
  63372. */
  63373. columns: BABYLON.int;
  63374. /**
  63375. * Gets or sets a the number of rows requested.
  63376. * The panel will automatically compute the number of columns based on number of child controls.
  63377. */
  63378. rows: BABYLON.int;
  63379. /**
  63380. * Creates new VolumeBasedPanel
  63381. */
  63382. constructor();
  63383. protected _arrangeChildren(): void;
  63384. /** Child classes must implement this function to provide correct control positioning */
  63385. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  63386. /** Child classes can implement this function to provide additional processing */
  63387. protected _finalProcessing(): void;
  63388. }
  63389. }
  63390. declare module BABYLON.GUI {
  63391. /**
  63392. * Class used to create a container panel deployed on the surface of a cylinder
  63393. */
  63394. export class CylinderPanel extends VolumeBasedPanel {
  63395. private _radius;
  63396. /**
  63397. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  63398. */
  63399. radius: BABYLON.float;
  63400. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  63401. private _cylindricalMapping;
  63402. }
  63403. }
  63404. declare module BABYLON.GUI {
  63405. /** @hidden */
  63406. export var fluentVertexShader: {
  63407. name: string;
  63408. shader: string;
  63409. };
  63410. }
  63411. declare module BABYLON.GUI {
  63412. /** @hidden */
  63413. export var fluentPixelShader: {
  63414. name: string;
  63415. shader: string;
  63416. };
  63417. }
  63418. declare module BABYLON.GUI {
  63419. /** @hidden */
  63420. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  63421. INNERGLOW: boolean;
  63422. BORDER: boolean;
  63423. HOVERLIGHT: boolean;
  63424. TEXTURE: boolean;
  63425. constructor();
  63426. }
  63427. /**
  63428. * Class used to render controls with fluent desgin
  63429. */
  63430. export class FluentMaterial extends BABYLON.PushMaterial {
  63431. /**
  63432. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  63433. */
  63434. innerGlowColorIntensity: number;
  63435. /**
  63436. * Gets or sets the inner glow color (white by default)
  63437. */
  63438. innerGlowColor: BABYLON.Color3;
  63439. /**
  63440. * Gets or sets alpha value (default is 1.0)
  63441. */
  63442. alpha: number;
  63443. /**
  63444. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  63445. */
  63446. albedoColor: BABYLON.Color3;
  63447. /**
  63448. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  63449. */
  63450. renderBorders: boolean;
  63451. /**
  63452. * Gets or sets border width (default is 0.5)
  63453. */
  63454. borderWidth: number;
  63455. /**
  63456. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  63457. */
  63458. edgeSmoothingValue: number;
  63459. /**
  63460. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  63461. */
  63462. borderMinValue: number;
  63463. /**
  63464. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  63465. */
  63466. renderHoverLight: boolean;
  63467. /**
  63468. * Gets or sets the radius used to render the hover light (default is 1.0)
  63469. */
  63470. hoverRadius: number;
  63471. /**
  63472. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  63473. */
  63474. hoverColor: BABYLON.Color4;
  63475. /**
  63476. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  63477. */
  63478. hoverPosition: BABYLON.Vector3;
  63479. private _albedoTexture;
  63480. /** Gets or sets the texture to use for albedo color */
  63481. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  63482. /**
  63483. * Creates a new Fluent material
  63484. * @param name defines the name of the material
  63485. * @param scene defines the hosting scene
  63486. */
  63487. constructor(name: string, scene: BABYLON.Scene);
  63488. needAlphaBlending(): boolean;
  63489. needAlphaTesting(): boolean;
  63490. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63491. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63492. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63493. getActiveTextures(): BABYLON.BaseTexture[];
  63494. hasTexture(texture: BABYLON.BaseTexture): boolean;
  63495. dispose(forceDisposeEffect?: boolean): void;
  63496. clone(name: string): FluentMaterial;
  63497. serialize(): any;
  63498. getClassName(): string;
  63499. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  63500. }
  63501. }
  63502. declare module BABYLON.GUI {
  63503. /**
  63504. * Class used to create a holographic button in 3D
  63505. */
  63506. export class HolographicButton extends Button3D {
  63507. private _backPlate;
  63508. private _textPlate;
  63509. private _frontPlate;
  63510. private _text;
  63511. private _imageUrl;
  63512. private _shareMaterials;
  63513. private _frontMaterial;
  63514. private _backMaterial;
  63515. private _plateMaterial;
  63516. private _pickedPointObserver;
  63517. private _tooltipFade;
  63518. private _tooltipTextBlock;
  63519. private _tooltipTexture;
  63520. private _tooltipMesh;
  63521. private _tooltipHoverObserver;
  63522. private _tooltipOutObserver;
  63523. private _disposeTooltip;
  63524. /**
  63525. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  63526. */
  63527. tooltipText: BABYLON.Nullable<string>;
  63528. /**
  63529. * Gets or sets text for the button
  63530. */
  63531. text: string;
  63532. /**
  63533. * Gets or sets the image url for the button
  63534. */
  63535. imageUrl: string;
  63536. /**
  63537. * Gets the back material used by this button
  63538. */
  63539. readonly backMaterial: FluentMaterial;
  63540. /**
  63541. * Gets the front material used by this button
  63542. */
  63543. readonly frontMaterial: FluentMaterial;
  63544. /**
  63545. * Gets the plate material used by this button
  63546. */
  63547. readonly plateMaterial: BABYLON.StandardMaterial;
  63548. /**
  63549. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  63550. */
  63551. readonly shareMaterials: boolean;
  63552. /**
  63553. * Creates a new button
  63554. * @param name defines the control name
  63555. */
  63556. constructor(name?: string, shareMaterials?: boolean);
  63557. protected _getTypeName(): string;
  63558. private _rebuildContent;
  63559. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  63560. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  63561. private _createBackMaterial;
  63562. private _createFrontMaterial;
  63563. private _createPlateMaterial;
  63564. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  63565. /**
  63566. * Releases all associated resources
  63567. */
  63568. dispose(): void;
  63569. }
  63570. }
  63571. declare module BABYLON.GUI {
  63572. /**
  63573. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  63574. */
  63575. export class MeshButton3D extends Button3D {
  63576. /** @hidden */
  63577. protected _currentMesh: BABYLON.Mesh;
  63578. /**
  63579. * Creates a new 3D button based on a mesh
  63580. * @param mesh mesh to become a 3D button
  63581. * @param name defines the control name
  63582. */
  63583. constructor(mesh: BABYLON.Mesh, name?: string);
  63584. protected _getTypeName(): string;
  63585. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  63586. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  63587. }
  63588. }
  63589. declare module BABYLON.GUI {
  63590. /**
  63591. * Class used to create a container panel deployed on the surface of a plane
  63592. */
  63593. export class PlanePanel extends VolumeBasedPanel {
  63594. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  63595. }
  63596. }
  63597. declare module BABYLON.GUI {
  63598. /**
  63599. * Class used to create a container panel where items get randomized planar mapping
  63600. */
  63601. export class ScatterPanel extends VolumeBasedPanel {
  63602. private _iteration;
  63603. /**
  63604. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  63605. */
  63606. iteration: BABYLON.float;
  63607. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  63608. private _scatterMapping;
  63609. protected _finalProcessing(): void;
  63610. }
  63611. }
  63612. declare module BABYLON.GUI {
  63613. /**
  63614. * Class used to create a container panel deployed on the surface of a sphere
  63615. */
  63616. export class SpherePanel extends VolumeBasedPanel {
  63617. private _radius;
  63618. /**
  63619. * Gets or sets the radius of the sphere where to project controls (5 by default)
  63620. */
  63621. radius: BABYLON.float;
  63622. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  63623. private _sphericalMapping;
  63624. }
  63625. }
  63626. declare module BABYLON.GUI {
  63627. /**
  63628. * Class used to create a stack panel in 3D on XY plane
  63629. */
  63630. export class StackPanel3D extends Container3D {
  63631. private _isVertical;
  63632. /**
  63633. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  63634. */
  63635. isVertical: boolean;
  63636. /**
  63637. * Gets or sets the distance between elements
  63638. */
  63639. margin: number;
  63640. /**
  63641. * Creates new StackPanel
  63642. * @param isVertical
  63643. */
  63644. constructor(isVertical?: boolean);
  63645. protected _arrangeChildren(): void;
  63646. }
  63647. }
  63648. declare module BABYLON {
  63649. /**
  63650. * Mode that determines the coordinate system to use.
  63651. */
  63652. export enum GLTFLoaderCoordinateSystemMode {
  63653. /**
  63654. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  63655. */
  63656. AUTO = 0,
  63657. /**
  63658. * Sets the useRightHandedSystem flag on the scene.
  63659. */
  63660. FORCE_RIGHT_HANDED = 1
  63661. }
  63662. /**
  63663. * Mode that determines what animations will start.
  63664. */
  63665. export enum GLTFLoaderAnimationStartMode {
  63666. /**
  63667. * No animation will start.
  63668. */
  63669. NONE = 0,
  63670. /**
  63671. * The first animation will start.
  63672. */
  63673. FIRST = 1,
  63674. /**
  63675. * All animations will start.
  63676. */
  63677. ALL = 2
  63678. }
  63679. /**
  63680. * Interface that contains the data for the glTF asset.
  63681. */
  63682. export interface IGLTFLoaderData {
  63683. /**
  63684. * Object that represents the glTF JSON.
  63685. */
  63686. json: Object;
  63687. /**
  63688. * The BIN chunk of a binary glTF.
  63689. */
  63690. bin: Nullable<ArrayBufferView>;
  63691. }
  63692. /**
  63693. * Interface for extending the loader.
  63694. */
  63695. export interface IGLTFLoaderExtension {
  63696. /**
  63697. * The name of this extension.
  63698. */
  63699. readonly name: string;
  63700. /**
  63701. * Defines whether this extension is enabled.
  63702. */
  63703. enabled: boolean;
  63704. }
  63705. /**
  63706. * Loader state.
  63707. */
  63708. export enum GLTFLoaderState {
  63709. /**
  63710. * The asset is loading.
  63711. */
  63712. LOADING = 0,
  63713. /**
  63714. * The asset is ready for rendering.
  63715. */
  63716. READY = 1,
  63717. /**
  63718. * The asset is completely loaded.
  63719. */
  63720. COMPLETE = 2
  63721. }
  63722. /** @hidden */
  63723. export interface IGLTFLoader extends IDisposable {
  63724. readonly state: Nullable<GLTFLoaderState>;
  63725. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  63726. meshes: AbstractMesh[];
  63727. particleSystems: IParticleSystem[];
  63728. skeletons: Skeleton[];
  63729. animationGroups: AnimationGroup[];
  63730. }>;
  63731. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  63732. }
  63733. /**
  63734. * File loader for loading glTF files into a scene.
  63735. */
  63736. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  63737. /** @hidden */
  63738. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  63739. /** @hidden */
  63740. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  63741. /**
  63742. * Raised when the asset has been parsed
  63743. */
  63744. onParsedObservable: Observable<IGLTFLoaderData>;
  63745. private _onParsedObserver;
  63746. /**
  63747. * Raised when the asset has been parsed
  63748. */
  63749. onParsed: (loaderData: IGLTFLoaderData) => void;
  63750. /**
  63751. * 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.
  63752. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  63753. * Defaults to true.
  63754. * @hidden
  63755. */
  63756. static IncrementalLoading: boolean;
  63757. /**
  63758. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  63759. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  63760. * @hidden
  63761. */
  63762. static HomogeneousCoordinates: boolean;
  63763. /**
  63764. * The coordinate system mode. Defaults to AUTO.
  63765. */
  63766. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  63767. /**
  63768. * The animation start mode. Defaults to FIRST.
  63769. */
  63770. animationStartMode: GLTFLoaderAnimationStartMode;
  63771. /**
  63772. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  63773. */
  63774. compileMaterials: boolean;
  63775. /**
  63776. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  63777. */
  63778. useClipPlane: boolean;
  63779. /**
  63780. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  63781. */
  63782. compileShadowGenerators: boolean;
  63783. /**
  63784. * Defines if the Alpha blended materials are only applied as coverage.
  63785. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  63786. * If true, no extra effects are applied to transparent pixels.
  63787. */
  63788. transparencyAsCoverage: boolean;
  63789. /**
  63790. * Function called before loading a url referenced by the asset.
  63791. */
  63792. preprocessUrlAsync: (url: string) => Promise<string>;
  63793. /**
  63794. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  63795. */
  63796. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  63797. private _onMeshLoadedObserver;
  63798. /**
  63799. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  63800. */
  63801. onMeshLoaded: (mesh: AbstractMesh) => void;
  63802. /**
  63803. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  63804. */
  63805. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  63806. private _onTextureLoadedObserver;
  63807. /**
  63808. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  63809. */
  63810. onTextureLoaded: (texture: BaseTexture) => void;
  63811. /**
  63812. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  63813. */
  63814. readonly onMaterialLoadedObservable: Observable<Material>;
  63815. private _onMaterialLoadedObserver;
  63816. /**
  63817. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  63818. */
  63819. onMaterialLoaded: (material: Material) => void;
  63820. /**
  63821. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  63822. */
  63823. readonly onCameraLoadedObservable: Observable<Camera>;
  63824. private _onCameraLoadedObserver;
  63825. /**
  63826. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  63827. */
  63828. onCameraLoaded: (camera: Camera) => void;
  63829. /**
  63830. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  63831. * For assets with LODs, raised when all of the LODs are complete.
  63832. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  63833. */
  63834. readonly onCompleteObservable: Observable<void>;
  63835. private _onCompleteObserver;
  63836. /**
  63837. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  63838. * For assets with LODs, raised when all of the LODs are complete.
  63839. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  63840. */
  63841. onComplete: () => void;
  63842. /**
  63843. * Observable raised when an error occurs.
  63844. */
  63845. readonly onErrorObservable: Observable<any>;
  63846. private _onErrorObserver;
  63847. /**
  63848. * Callback raised when an error occurs.
  63849. */
  63850. onError: (reason: any) => void;
  63851. /**
  63852. * Observable raised after the loader is disposed.
  63853. */
  63854. readonly onDisposeObservable: Observable<void>;
  63855. private _onDisposeObserver;
  63856. /**
  63857. * Callback raised after the loader is disposed.
  63858. */
  63859. onDispose: () => void;
  63860. /**
  63861. * Observable raised after a loader extension is created.
  63862. * Set additional options for a loader extension in this event.
  63863. */
  63864. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  63865. private _onExtensionLoadedObserver;
  63866. /**
  63867. * Callback raised after a loader extension is created.
  63868. */
  63869. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  63870. /**
  63871. * Defines if the loader logging is enabled.
  63872. */
  63873. loggingEnabled: boolean;
  63874. /**
  63875. * Defines if the loader should capture performance counters.
  63876. */
  63877. capturePerformanceCounters: boolean;
  63878. /**
  63879. * Defines if the loader should validate the asset.
  63880. */
  63881. validate: boolean;
  63882. /**
  63883. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  63884. */
  63885. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  63886. private _onValidatedObserver;
  63887. /**
  63888. * Callback raised after a loader extension is created.
  63889. */
  63890. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  63891. private _loader;
  63892. /**
  63893. * Name of the loader ("gltf")
  63894. */
  63895. name: string;
  63896. /**
  63897. * Supported file extensions of the loader (.gltf, .glb)
  63898. */
  63899. extensions: ISceneLoaderPluginExtensions;
  63900. /**
  63901. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  63902. */
  63903. dispose(): void;
  63904. /** @hidden */
  63905. _clear(): void;
  63906. /**
  63907. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  63908. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  63909. * @param scene the scene the meshes should be added to
  63910. * @param data the glTF data to load
  63911. * @param rootUrl root url to load from
  63912. * @param onProgress event that fires when loading progress has occured
  63913. * @param fileName Defines the name of the file to load
  63914. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  63915. */
  63916. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  63917. meshes: AbstractMesh[];
  63918. particleSystems: IParticleSystem[];
  63919. skeletons: Skeleton[];
  63920. animationGroups: AnimationGroup[];
  63921. }>;
  63922. /**
  63923. * Imports all objects from the loaded glTF data and adds them to the scene
  63924. * @param scene the scene the objects should be added to
  63925. * @param data the glTF data to load
  63926. * @param rootUrl root url to load from
  63927. * @param onProgress event that fires when loading progress has occured
  63928. * @param fileName Defines the name of the file to load
  63929. * @returns a promise which completes when objects have been loaded to the scene
  63930. */
  63931. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  63932. /**
  63933. * Load into an asset container.
  63934. * @param scene The scene to load into
  63935. * @param data The data to import
  63936. * @param rootUrl The root url for scene and resources
  63937. * @param onProgress The callback when the load progresses
  63938. * @param fileName Defines the name of the file to load
  63939. * @returns The loaded asset container
  63940. */
  63941. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  63942. /**
  63943. * If the data string can be loaded directly.
  63944. * @param data string contianing the file data
  63945. * @returns if the data can be loaded directly
  63946. */
  63947. canDirectLoad(data: string): boolean;
  63948. /**
  63949. * Rewrites a url by combining a root url and response url.
  63950. */
  63951. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  63952. /**
  63953. * Instantiates a glTF file loader plugin.
  63954. * @returns the created plugin
  63955. */
  63956. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  63957. /**
  63958. * The loader state or null if the loader is not active.
  63959. */
  63960. readonly loaderState: Nullable<GLTFLoaderState>;
  63961. /**
  63962. * Returns a promise that resolves when the asset is completely loaded.
  63963. * @returns a promise that resolves when the asset is completely loaded.
  63964. */
  63965. whenCompleteAsync(): Promise<void>;
  63966. private _parseAsync;
  63967. private _validateAsync;
  63968. private _getLoader;
  63969. private _unpackBinary;
  63970. private _unpackBinaryV1;
  63971. private _unpackBinaryV2;
  63972. private static _parseVersion;
  63973. private static _compareVersion;
  63974. private static _decodeBufferToText;
  63975. private static readonly _logSpaces;
  63976. private _logIndentLevel;
  63977. private _loggingEnabled;
  63978. /** @hidden */
  63979. _log: (message: string) => void;
  63980. /** @hidden */
  63981. _logOpen(message: string): void;
  63982. /** @hidden */
  63983. _logClose(): void;
  63984. private _logEnabled;
  63985. private _logDisabled;
  63986. private _capturePerformanceCounters;
  63987. /** @hidden */
  63988. _startPerformanceCounter: (counterName: string) => void;
  63989. /** @hidden */
  63990. _endPerformanceCounter: (counterName: string) => void;
  63991. private _startPerformanceCounterEnabled;
  63992. private _startPerformanceCounterDisabled;
  63993. private _endPerformanceCounterEnabled;
  63994. private _endPerformanceCounterDisabled;
  63995. }
  63996. }
  63997. declare module BABYLON.GLTF1 {
  63998. /**
  63999. * Enums
  64000. * @hidden
  64001. */
  64002. export enum EComponentType {
  64003. BYTE = 5120,
  64004. UNSIGNED_BYTE = 5121,
  64005. SHORT = 5122,
  64006. UNSIGNED_SHORT = 5123,
  64007. FLOAT = 5126
  64008. }
  64009. /** @hidden */
  64010. export enum EShaderType {
  64011. FRAGMENT = 35632,
  64012. VERTEX = 35633
  64013. }
  64014. /** @hidden */
  64015. export enum EParameterType {
  64016. BYTE = 5120,
  64017. UNSIGNED_BYTE = 5121,
  64018. SHORT = 5122,
  64019. UNSIGNED_SHORT = 5123,
  64020. INT = 5124,
  64021. UNSIGNED_INT = 5125,
  64022. FLOAT = 5126,
  64023. FLOAT_VEC2 = 35664,
  64024. FLOAT_VEC3 = 35665,
  64025. FLOAT_VEC4 = 35666,
  64026. INT_VEC2 = 35667,
  64027. INT_VEC3 = 35668,
  64028. INT_VEC4 = 35669,
  64029. BOOL = 35670,
  64030. BOOL_VEC2 = 35671,
  64031. BOOL_VEC3 = 35672,
  64032. BOOL_VEC4 = 35673,
  64033. FLOAT_MAT2 = 35674,
  64034. FLOAT_MAT3 = 35675,
  64035. FLOAT_MAT4 = 35676,
  64036. SAMPLER_2D = 35678
  64037. }
  64038. /** @hidden */
  64039. export enum ETextureWrapMode {
  64040. CLAMP_TO_EDGE = 33071,
  64041. MIRRORED_REPEAT = 33648,
  64042. REPEAT = 10497
  64043. }
  64044. /** @hidden */
  64045. export enum ETextureFilterType {
  64046. NEAREST = 9728,
  64047. LINEAR = 9728,
  64048. NEAREST_MIPMAP_NEAREST = 9984,
  64049. LINEAR_MIPMAP_NEAREST = 9985,
  64050. NEAREST_MIPMAP_LINEAR = 9986,
  64051. LINEAR_MIPMAP_LINEAR = 9987
  64052. }
  64053. /** @hidden */
  64054. export enum ETextureFormat {
  64055. ALPHA = 6406,
  64056. RGB = 6407,
  64057. RGBA = 6408,
  64058. LUMINANCE = 6409,
  64059. LUMINANCE_ALPHA = 6410
  64060. }
  64061. /** @hidden */
  64062. export enum ECullingType {
  64063. FRONT = 1028,
  64064. BACK = 1029,
  64065. FRONT_AND_BACK = 1032
  64066. }
  64067. /** @hidden */
  64068. export enum EBlendingFunction {
  64069. ZERO = 0,
  64070. ONE = 1,
  64071. SRC_COLOR = 768,
  64072. ONE_MINUS_SRC_COLOR = 769,
  64073. DST_COLOR = 774,
  64074. ONE_MINUS_DST_COLOR = 775,
  64075. SRC_ALPHA = 770,
  64076. ONE_MINUS_SRC_ALPHA = 771,
  64077. DST_ALPHA = 772,
  64078. ONE_MINUS_DST_ALPHA = 773,
  64079. CONSTANT_COLOR = 32769,
  64080. ONE_MINUS_CONSTANT_COLOR = 32770,
  64081. CONSTANT_ALPHA = 32771,
  64082. ONE_MINUS_CONSTANT_ALPHA = 32772,
  64083. SRC_ALPHA_SATURATE = 776
  64084. }
  64085. /** @hidden */
  64086. export interface IGLTFProperty {
  64087. extensions?: {
  64088. [key: string]: any;
  64089. };
  64090. extras?: Object;
  64091. }
  64092. /** @hidden */
  64093. export interface IGLTFChildRootProperty extends IGLTFProperty {
  64094. name?: string;
  64095. }
  64096. /** @hidden */
  64097. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  64098. bufferView: string;
  64099. byteOffset: number;
  64100. byteStride: number;
  64101. count: number;
  64102. type: string;
  64103. componentType: EComponentType;
  64104. max?: number[];
  64105. min?: number[];
  64106. name?: string;
  64107. }
  64108. /** @hidden */
  64109. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  64110. buffer: string;
  64111. byteOffset: number;
  64112. byteLength: number;
  64113. byteStride: number;
  64114. target?: number;
  64115. }
  64116. /** @hidden */
  64117. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  64118. uri: string;
  64119. byteLength?: number;
  64120. type?: string;
  64121. }
  64122. /** @hidden */
  64123. export interface IGLTFShader extends IGLTFChildRootProperty {
  64124. uri: string;
  64125. type: EShaderType;
  64126. }
  64127. /** @hidden */
  64128. export interface IGLTFProgram extends IGLTFChildRootProperty {
  64129. attributes: string[];
  64130. fragmentShader: string;
  64131. vertexShader: string;
  64132. }
  64133. /** @hidden */
  64134. export interface IGLTFTechniqueParameter {
  64135. type: number;
  64136. count?: number;
  64137. semantic?: string;
  64138. node?: string;
  64139. value?: number | boolean | string | Array<any>;
  64140. source?: string;
  64141. babylonValue?: any;
  64142. }
  64143. /** @hidden */
  64144. export interface IGLTFTechniqueCommonProfile {
  64145. lightingModel: string;
  64146. texcoordBindings: Object;
  64147. parameters?: Array<any>;
  64148. }
  64149. /** @hidden */
  64150. export interface IGLTFTechniqueStatesFunctions {
  64151. blendColor?: number[];
  64152. blendEquationSeparate?: number[];
  64153. blendFuncSeparate?: number[];
  64154. colorMask: boolean[];
  64155. cullFace: number[];
  64156. }
  64157. /** @hidden */
  64158. export interface IGLTFTechniqueStates {
  64159. enable: number[];
  64160. functions: IGLTFTechniqueStatesFunctions;
  64161. }
  64162. /** @hidden */
  64163. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  64164. parameters: {
  64165. [key: string]: IGLTFTechniqueParameter;
  64166. };
  64167. program: string;
  64168. attributes: {
  64169. [key: string]: string;
  64170. };
  64171. uniforms: {
  64172. [key: string]: string;
  64173. };
  64174. states: IGLTFTechniqueStates;
  64175. }
  64176. /** @hidden */
  64177. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  64178. technique?: string;
  64179. values: string[];
  64180. }
  64181. /** @hidden */
  64182. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  64183. attributes: {
  64184. [key: string]: string;
  64185. };
  64186. indices: string;
  64187. material: string;
  64188. mode?: number;
  64189. }
  64190. /** @hidden */
  64191. export interface IGLTFMesh extends IGLTFChildRootProperty {
  64192. primitives: IGLTFMeshPrimitive[];
  64193. }
  64194. /** @hidden */
  64195. export interface IGLTFImage extends IGLTFChildRootProperty {
  64196. uri: string;
  64197. }
  64198. /** @hidden */
  64199. export interface IGLTFSampler extends IGLTFChildRootProperty {
  64200. magFilter?: number;
  64201. minFilter?: number;
  64202. wrapS?: number;
  64203. wrapT?: number;
  64204. }
  64205. /** @hidden */
  64206. export interface IGLTFTexture extends IGLTFChildRootProperty {
  64207. sampler: string;
  64208. source: string;
  64209. format?: ETextureFormat;
  64210. internalFormat?: ETextureFormat;
  64211. target?: number;
  64212. type?: number;
  64213. babylonTexture?: Texture;
  64214. }
  64215. /** @hidden */
  64216. export interface IGLTFAmbienLight {
  64217. color?: number[];
  64218. }
  64219. /** @hidden */
  64220. export interface IGLTFDirectionalLight {
  64221. color?: number[];
  64222. }
  64223. /** @hidden */
  64224. export interface IGLTFPointLight {
  64225. color?: number[];
  64226. constantAttenuation?: number;
  64227. linearAttenuation?: number;
  64228. quadraticAttenuation?: number;
  64229. }
  64230. /** @hidden */
  64231. export interface IGLTFSpotLight {
  64232. color?: number[];
  64233. constantAttenuation?: number;
  64234. fallOfAngle?: number;
  64235. fallOffExponent?: number;
  64236. linearAttenuation?: number;
  64237. quadraticAttenuation?: number;
  64238. }
  64239. /** @hidden */
  64240. export interface IGLTFLight extends IGLTFChildRootProperty {
  64241. type: string;
  64242. }
  64243. /** @hidden */
  64244. export interface IGLTFCameraOrthographic {
  64245. xmag: number;
  64246. ymag: number;
  64247. zfar: number;
  64248. znear: number;
  64249. }
  64250. /** @hidden */
  64251. export interface IGLTFCameraPerspective {
  64252. aspectRatio: number;
  64253. yfov: number;
  64254. zfar: number;
  64255. znear: number;
  64256. }
  64257. /** @hidden */
  64258. export interface IGLTFCamera extends IGLTFChildRootProperty {
  64259. type: string;
  64260. }
  64261. /** @hidden */
  64262. export interface IGLTFAnimationChannelTarget {
  64263. id: string;
  64264. path: string;
  64265. }
  64266. /** @hidden */
  64267. export interface IGLTFAnimationChannel {
  64268. sampler: string;
  64269. target: IGLTFAnimationChannelTarget;
  64270. }
  64271. /** @hidden */
  64272. export interface IGLTFAnimationSampler {
  64273. input: string;
  64274. output: string;
  64275. interpolation?: string;
  64276. }
  64277. /** @hidden */
  64278. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  64279. channels?: IGLTFAnimationChannel[];
  64280. parameters?: {
  64281. [key: string]: string;
  64282. };
  64283. samplers?: {
  64284. [key: string]: IGLTFAnimationSampler;
  64285. };
  64286. }
  64287. /** @hidden */
  64288. export interface IGLTFNodeInstanceSkin {
  64289. skeletons: string[];
  64290. skin: string;
  64291. meshes: string[];
  64292. }
  64293. /** @hidden */
  64294. export interface IGLTFSkins extends IGLTFChildRootProperty {
  64295. bindShapeMatrix: number[];
  64296. inverseBindMatrices: string;
  64297. jointNames: string[];
  64298. babylonSkeleton?: Skeleton;
  64299. }
  64300. /** @hidden */
  64301. export interface IGLTFNode extends IGLTFChildRootProperty {
  64302. camera?: string;
  64303. children: string[];
  64304. skin?: string;
  64305. jointName?: string;
  64306. light?: string;
  64307. matrix: number[];
  64308. mesh?: string;
  64309. meshes?: string[];
  64310. rotation?: number[];
  64311. scale?: number[];
  64312. translation?: number[];
  64313. babylonNode?: Node;
  64314. }
  64315. /** @hidden */
  64316. export interface IGLTFScene extends IGLTFChildRootProperty {
  64317. nodes: string[];
  64318. }
  64319. /** @hidden */
  64320. export interface IGLTFRuntime {
  64321. extensions: {
  64322. [key: string]: any;
  64323. };
  64324. accessors: {
  64325. [key: string]: IGLTFAccessor;
  64326. };
  64327. buffers: {
  64328. [key: string]: IGLTFBuffer;
  64329. };
  64330. bufferViews: {
  64331. [key: string]: IGLTFBufferView;
  64332. };
  64333. meshes: {
  64334. [key: string]: IGLTFMesh;
  64335. };
  64336. lights: {
  64337. [key: string]: IGLTFLight;
  64338. };
  64339. cameras: {
  64340. [key: string]: IGLTFCamera;
  64341. };
  64342. nodes: {
  64343. [key: string]: IGLTFNode;
  64344. };
  64345. images: {
  64346. [key: string]: IGLTFImage;
  64347. };
  64348. textures: {
  64349. [key: string]: IGLTFTexture;
  64350. };
  64351. shaders: {
  64352. [key: string]: IGLTFShader;
  64353. };
  64354. programs: {
  64355. [key: string]: IGLTFProgram;
  64356. };
  64357. samplers: {
  64358. [key: string]: IGLTFSampler;
  64359. };
  64360. techniques: {
  64361. [key: string]: IGLTFTechnique;
  64362. };
  64363. materials: {
  64364. [key: string]: IGLTFMaterial;
  64365. };
  64366. animations: {
  64367. [key: string]: IGLTFAnimation;
  64368. };
  64369. skins: {
  64370. [key: string]: IGLTFSkins;
  64371. };
  64372. currentScene?: Object;
  64373. scenes: {
  64374. [key: string]: IGLTFScene;
  64375. };
  64376. extensionsUsed: string[];
  64377. extensionsRequired?: string[];
  64378. buffersCount: number;
  64379. shaderscount: number;
  64380. scene: Scene;
  64381. rootUrl: string;
  64382. loadedBufferCount: number;
  64383. loadedBufferViews: {
  64384. [name: string]: ArrayBufferView;
  64385. };
  64386. loadedShaderCount: number;
  64387. importOnlyMeshes: boolean;
  64388. importMeshesNames?: string[];
  64389. dummyNodes: Node[];
  64390. }
  64391. /** @hidden */
  64392. export interface INodeToRoot {
  64393. bone: Bone;
  64394. node: IGLTFNode;
  64395. id: string;
  64396. }
  64397. /** @hidden */
  64398. export interface IJointNode {
  64399. node: IGLTFNode;
  64400. id: string;
  64401. }
  64402. }
  64403. declare module BABYLON.GLTF1 {
  64404. /**
  64405. * Utils functions for GLTF
  64406. * @hidden
  64407. */
  64408. export class GLTFUtils {
  64409. /**
  64410. * Sets the given "parameter" matrix
  64411. * @param scene: the Scene object
  64412. * @param source: the source node where to pick the matrix
  64413. * @param parameter: the GLTF technique parameter
  64414. * @param uniformName: the name of the shader's uniform
  64415. * @param shaderMaterial: the shader material
  64416. */
  64417. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  64418. /**
  64419. * Sets the given "parameter" matrix
  64420. * @param shaderMaterial: the shader material
  64421. * @param uniform: the name of the shader's uniform
  64422. * @param value: the value of the uniform
  64423. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  64424. */
  64425. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  64426. /**
  64427. * Returns the wrap mode of the texture
  64428. * @param mode: the mode value
  64429. */
  64430. static GetWrapMode(mode: number): number;
  64431. /**
  64432. * Returns the byte stride giving an accessor
  64433. * @param accessor: the GLTF accessor objet
  64434. */
  64435. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  64436. /**
  64437. * Returns the texture filter mode giving a mode value
  64438. * @param mode: the filter mode value
  64439. */
  64440. static GetTextureFilterMode(mode: number): ETextureFilterType;
  64441. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  64442. /**
  64443. * Returns a buffer from its accessor
  64444. * @param gltfRuntime: the GLTF runtime
  64445. * @param accessor: the GLTF accessor
  64446. */
  64447. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  64448. /**
  64449. * Decodes a buffer view into a string
  64450. * @param view: the buffer view
  64451. */
  64452. static DecodeBufferToText(view: ArrayBufferView): string;
  64453. /**
  64454. * Returns the default material of gltf. Related to
  64455. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  64456. * @param scene: the Babylon.js scene
  64457. */
  64458. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  64459. private static _DefaultMaterial;
  64460. }
  64461. }
  64462. declare module BABYLON.GLTF1 {
  64463. /**
  64464. * Implementation of the base glTF spec
  64465. * @hidden
  64466. */
  64467. export class GLTFLoaderBase {
  64468. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  64469. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  64470. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  64471. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  64472. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  64473. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  64474. }
  64475. /**
  64476. * glTF V1 Loader
  64477. * @hidden
  64478. */
  64479. export class GLTFLoader implements IGLTFLoader {
  64480. static Extensions: {
  64481. [name: string]: GLTFLoaderExtension;
  64482. };
  64483. static RegisterExtension(extension: GLTFLoaderExtension): void;
  64484. state: Nullable<GLTFLoaderState>;
  64485. dispose(): void;
  64486. private _importMeshAsync;
  64487. /**
  64488. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  64489. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  64490. * @param scene the scene the meshes should be added to
  64491. * @param data gltf data containing information of the meshes in a loaded file
  64492. * @param rootUrl root url to load from
  64493. * @param onProgress event that fires when loading progress has occured
  64494. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  64495. */
  64496. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  64497. meshes: AbstractMesh[];
  64498. particleSystems: IParticleSystem[];
  64499. skeletons: Skeleton[];
  64500. animationGroups: AnimationGroup[];
  64501. }>;
  64502. private _loadAsync;
  64503. /**
  64504. * Imports all objects from a loaded gltf file and adds them to the scene
  64505. * @param scene the scene the objects should be added to
  64506. * @param data gltf data containing information of the meshes in a loaded file
  64507. * @param rootUrl root url to load from
  64508. * @param onProgress event that fires when loading progress has occured
  64509. * @returns a promise which completes when objects have been loaded to the scene
  64510. */
  64511. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  64512. private _loadShadersAsync;
  64513. private _loadBuffersAsync;
  64514. private _createNodes;
  64515. }
  64516. /** @hidden */
  64517. export abstract class GLTFLoaderExtension {
  64518. private _name;
  64519. constructor(name: string);
  64520. readonly name: string;
  64521. /**
  64522. * Defines an override for loading the runtime
  64523. * Return true to stop further extensions from loading the runtime
  64524. */
  64525. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  64526. /**
  64527. * Defines an onverride for creating gltf runtime
  64528. * Return true to stop further extensions from creating the runtime
  64529. */
  64530. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  64531. /**
  64532. * Defines an override for loading buffers
  64533. * Return true to stop further extensions from loading this buffer
  64534. */
  64535. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  64536. /**
  64537. * Defines an override for loading texture buffers
  64538. * Return true to stop further extensions from loading this texture data
  64539. */
  64540. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  64541. /**
  64542. * Defines an override for creating textures
  64543. * Return true to stop further extensions from loading this texture
  64544. */
  64545. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  64546. /**
  64547. * Defines an override for loading shader strings
  64548. * Return true to stop further extensions from loading this shader data
  64549. */
  64550. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  64551. /**
  64552. * Defines an override for loading materials
  64553. * Return true to stop further extensions from loading this material
  64554. */
  64555. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  64556. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  64557. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  64558. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  64559. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  64560. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  64561. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  64562. private static LoadTextureBufferAsync;
  64563. private static CreateTextureAsync;
  64564. private static ApplyExtensions;
  64565. }
  64566. }
  64567. declare module BABYLON.GLTF1 {
  64568. /** @hidden */
  64569. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  64570. private _bin;
  64571. constructor();
  64572. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  64573. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  64574. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  64575. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  64576. }
  64577. }
  64578. declare module BABYLON.GLTF1 {
  64579. /** @hidden */
  64580. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  64581. constructor();
  64582. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  64583. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  64584. private _loadTexture;
  64585. }
  64586. }
  64587. declare module BABYLON.GLTF2.Loader {
  64588. /**
  64589. * Loader interface with an index field.
  64590. */
  64591. export interface IArrayItem {
  64592. /**
  64593. * The index of this item in the array.
  64594. */
  64595. index: number;
  64596. }
  64597. /**
  64598. * Loader interface with additional members.
  64599. */
  64600. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  64601. /** @hidden */
  64602. _data?: Promise<ArrayBufferView>;
  64603. /** @hidden */
  64604. _babylonVertexBuffer?: Promise<VertexBuffer>;
  64605. }
  64606. /**
  64607. * Loader interface with additional members.
  64608. */
  64609. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  64610. }
  64611. /** @hidden */
  64612. export interface _IAnimationSamplerData {
  64613. input: Float32Array;
  64614. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  64615. output: Float32Array;
  64616. }
  64617. /**
  64618. * Loader interface with additional members.
  64619. */
  64620. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  64621. /** @hidden */
  64622. _data?: Promise<_IAnimationSamplerData>;
  64623. }
  64624. /**
  64625. * Loader interface with additional members.
  64626. */
  64627. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  64628. channels: IAnimationChannel[];
  64629. samplers: IAnimationSampler[];
  64630. /** @hidden */
  64631. _babylonAnimationGroup?: AnimationGroup;
  64632. }
  64633. /**
  64634. * Loader interface with additional members.
  64635. */
  64636. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  64637. /** @hidden */
  64638. _data?: Promise<ArrayBufferView>;
  64639. }
  64640. /**
  64641. * Loader interface with additional members.
  64642. */
  64643. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  64644. /** @hidden */
  64645. _data?: Promise<ArrayBufferView>;
  64646. /** @hidden */
  64647. _babylonBuffer?: Promise<Buffer>;
  64648. }
  64649. /**
  64650. * Loader interface with additional members.
  64651. */
  64652. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  64653. }
  64654. /**
  64655. * Loader interface with additional members.
  64656. */
  64657. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  64658. /** @hidden */
  64659. _data?: Promise<ArrayBufferView>;
  64660. }
  64661. /**
  64662. * Loader interface with additional members.
  64663. */
  64664. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  64665. }
  64666. /**
  64667. * Loader interface with additional members.
  64668. */
  64669. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  64670. }
  64671. /**
  64672. * Loader interface with additional members.
  64673. */
  64674. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  64675. baseColorTexture?: ITextureInfo;
  64676. metallicRoughnessTexture?: ITextureInfo;
  64677. }
  64678. /**
  64679. * Loader interface with additional members.
  64680. */
  64681. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  64682. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  64683. normalTexture?: IMaterialNormalTextureInfo;
  64684. occlusionTexture?: IMaterialOcclusionTextureInfo;
  64685. emissiveTexture?: ITextureInfo;
  64686. /** @hidden */
  64687. _data?: {
  64688. [babylonDrawMode: number]: {
  64689. babylonMaterial: Material;
  64690. babylonMeshes: AbstractMesh[];
  64691. promise: Promise<void>;
  64692. };
  64693. };
  64694. }
  64695. /**
  64696. * Loader interface with additional members.
  64697. */
  64698. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  64699. primitives: IMeshPrimitive[];
  64700. }
  64701. /**
  64702. * Loader interface with additional members.
  64703. */
  64704. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  64705. /** @hidden */
  64706. _instanceData?: {
  64707. babylonSourceMesh: Mesh;
  64708. promise: Promise<any>;
  64709. };
  64710. }
  64711. /**
  64712. * Loader interface with additional members.
  64713. */
  64714. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  64715. /**
  64716. * The parent glTF node.
  64717. */
  64718. parent?: INode;
  64719. /** @hidden */
  64720. _babylonTransformNode?: TransformNode;
  64721. /** @hidden */
  64722. _primitiveBabylonMeshes?: AbstractMesh[];
  64723. /** @hidden */
  64724. _babylonBones?: Bone[];
  64725. /** @hidden */
  64726. _numMorphTargets?: number;
  64727. }
  64728. /** @hidden */
  64729. export interface _ISamplerData {
  64730. noMipMaps: boolean;
  64731. samplingMode: number;
  64732. wrapU: number;
  64733. wrapV: number;
  64734. }
  64735. /**
  64736. * Loader interface with additional members.
  64737. */
  64738. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  64739. /** @hidden */
  64740. _data?: _ISamplerData;
  64741. }
  64742. /**
  64743. * Loader interface with additional members.
  64744. */
  64745. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  64746. }
  64747. /**
  64748. * Loader interface with additional members.
  64749. */
  64750. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  64751. /** @hidden */
  64752. _data?: {
  64753. babylonSkeleton: Skeleton;
  64754. promise: Promise<void>;
  64755. };
  64756. }
  64757. /**
  64758. * Loader interface with additional members.
  64759. */
  64760. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  64761. }
  64762. /**
  64763. * Loader interface with additional members.
  64764. */
  64765. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  64766. }
  64767. /**
  64768. * Loader interface with additional members.
  64769. */
  64770. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  64771. accessors?: IAccessor[];
  64772. animations?: IAnimation[];
  64773. buffers?: IBuffer[];
  64774. bufferViews?: IBufferView[];
  64775. cameras?: ICamera[];
  64776. images?: IImage[];
  64777. materials?: IMaterial[];
  64778. meshes?: IMesh[];
  64779. nodes?: INode[];
  64780. samplers?: ISampler[];
  64781. scenes?: IScene[];
  64782. skins?: ISkin[];
  64783. textures?: ITexture[];
  64784. }
  64785. }
  64786. declare module BABYLON.GLTF2 {
  64787. /**
  64788. * Interface for a glTF loader extension.
  64789. */
  64790. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  64791. /**
  64792. * Called after the loader state changes to LOADING.
  64793. */
  64794. onLoading?(): void;
  64795. /**
  64796. * Called after the loader state changes to READY.
  64797. */
  64798. onReady?(): void;
  64799. /**
  64800. * Define this method to modify the default behavior when loading scenes.
  64801. * @param context The context when loading the asset
  64802. * @param scene The glTF scene property
  64803. * @returns A promise that resolves when the load is complete or null if not handled
  64804. */
  64805. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  64806. /**
  64807. * Define this method to modify the default behavior when loading nodes.
  64808. * @param context The context when loading the asset
  64809. * @param node The glTF node property
  64810. * @param assign A function called synchronously after parsing the glTF properties
  64811. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  64812. */
  64813. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  64814. /**
  64815. * Define this method to modify the default behavior when loading cameras.
  64816. * @param context The context when loading the asset
  64817. * @param camera The glTF camera property
  64818. * @param assign A function called synchronously after parsing the glTF properties
  64819. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  64820. */
  64821. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  64822. /**
  64823. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  64824. * @param context The context when loading the asset
  64825. * @param primitive The glTF mesh primitive property
  64826. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  64827. */
  64828. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  64829. /**
  64830. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  64831. * @param context The context when loading the asset
  64832. * @param name The mesh name when loading the asset
  64833. * @param node The glTF node when loading the asset
  64834. * @param mesh The glTF mesh when loading the asset
  64835. * @param primitive The glTF mesh primitive property
  64836. * @param assign A function called synchronously after parsing the glTF properties
  64837. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  64838. */
  64839. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  64840. /**
  64841. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  64842. * @param context The context when loading the asset
  64843. * @param material The glTF material property
  64844. * @param assign A function called synchronously after parsing the glTF properties
  64845. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  64846. */
  64847. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  64848. /**
  64849. * Define this method to modify the default behavior when creating materials.
  64850. * @param context The context when loading the asset
  64851. * @param material The glTF material property
  64852. * @param babylonDrawMode The draw mode for the Babylon material
  64853. * @returns The Babylon material or null if not handled
  64854. */
  64855. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  64856. /**
  64857. * Define this method to modify the default behavior when loading material properties.
  64858. * @param context The context when loading the asset
  64859. * @param material The glTF material property
  64860. * @param babylonMaterial The Babylon material
  64861. * @returns A promise that resolves when the load is complete or null if not handled
  64862. */
  64863. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  64864. /**
  64865. * Define this method to modify the default behavior when loading texture infos.
  64866. * @param context The context when loading the asset
  64867. * @param textureInfo The glTF texture info property
  64868. * @param assign A function called synchronously after parsing the glTF properties
  64869. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  64870. */
  64871. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  64872. /**
  64873. * Define this method to modify the default behavior when loading animations.
  64874. * @param context The context when loading the asset
  64875. * @param animation The glTF animation property
  64876. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  64877. */
  64878. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  64879. /**
  64880. * @hidden Define this method to modify the default behavior when loading skins.
  64881. * @param context The context when loading the asset
  64882. * @param node The glTF node property
  64883. * @param skin The glTF skin property
  64884. * @returns A promise that resolves when the load is complete or null if not handled
  64885. */
  64886. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  64887. /**
  64888. * @hidden Define this method to modify the default behavior when loading uris.
  64889. * @param context The context when loading the asset
  64890. * @param property The glTF property associated with the uri
  64891. * @param uri The uri to load
  64892. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  64893. */
  64894. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  64895. }
  64896. }
  64897. declare module BABYLON.GLTF2 {
  64898. /**
  64899. * Helper class for working with arrays when loading the glTF asset
  64900. */
  64901. export class ArrayItem {
  64902. /**
  64903. * Gets an item from the given array.
  64904. * @param context The context when loading the asset
  64905. * @param array The array to get the item from
  64906. * @param index The index to the array
  64907. * @returns The array item
  64908. */
  64909. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  64910. /**
  64911. * Assign an `index` field to each item of the given array.
  64912. * @param array The array of items
  64913. */
  64914. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  64915. }
  64916. /**
  64917. * The glTF 2.0 loader
  64918. */
  64919. export class GLTFLoader implements IGLTFLoader {
  64920. /** @hidden */
  64921. _completePromises: Promise<any>[];
  64922. private _disposed;
  64923. private _parent;
  64924. private _state;
  64925. private _extensions;
  64926. private _rootUrl;
  64927. private _fileName;
  64928. private _uniqueRootUrl;
  64929. private _gltf;
  64930. private _babylonScene;
  64931. private _rootBabylonMesh;
  64932. private _defaultBabylonMaterialData;
  64933. private _progressCallback?;
  64934. private _requests;
  64935. private static readonly _DefaultSampler;
  64936. private static _ExtensionNames;
  64937. private static _ExtensionFactories;
  64938. /**
  64939. * Registers a loader extension.
  64940. * @param name The name of the loader extension.
  64941. * @param factory The factory function that creates the loader extension.
  64942. */
  64943. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  64944. /**
  64945. * Unregisters a loader extension.
  64946. * @param name The name of the loader extenion.
  64947. * @returns A boolean indicating whether the extension has been unregistered
  64948. */
  64949. static UnregisterExtension(name: string): boolean;
  64950. /**
  64951. * Gets the loader state.
  64952. */
  64953. readonly state: Nullable<GLTFLoaderState>;
  64954. /**
  64955. * The glTF object parsed from the JSON.
  64956. */
  64957. readonly gltf: IGLTF;
  64958. /**
  64959. * The Babylon scene when loading the asset.
  64960. */
  64961. readonly babylonScene: Scene;
  64962. /**
  64963. * The root Babylon mesh when loading the asset.
  64964. */
  64965. readonly rootBabylonMesh: Mesh;
  64966. /** @hidden */
  64967. constructor(parent: GLTFFileLoader);
  64968. /** @hidden */
  64969. dispose(): void;
  64970. /** @hidden */
  64971. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  64972. meshes: AbstractMesh[];
  64973. particleSystems: IParticleSystem[];
  64974. skeletons: Skeleton[];
  64975. animationGroups: AnimationGroup[];
  64976. }>;
  64977. /** @hidden */
  64978. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  64979. private _loadAsync;
  64980. private _loadData;
  64981. private _setupData;
  64982. private _loadExtensions;
  64983. private _checkExtensions;
  64984. private _setState;
  64985. private _createRootNode;
  64986. /**
  64987. * Loads a glTF scene.
  64988. * @param context The context when loading the asset
  64989. * @param scene The glTF scene property
  64990. * @returns A promise that resolves when the load is complete
  64991. */
  64992. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  64993. private _forEachPrimitive;
  64994. private _getMeshes;
  64995. private _getSkeletons;
  64996. private _getAnimationGroups;
  64997. private _startAnimations;
  64998. /**
  64999. * Loads a glTF node.
  65000. * @param context The context when loading the asset
  65001. * @param node The glTF node property
  65002. * @param assign A function called synchronously after parsing the glTF properties
  65003. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  65004. */
  65005. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  65006. private _loadMeshAsync;
  65007. /**
  65008. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  65009. * @param context The context when loading the asset
  65010. * @param name The mesh name when loading the asset
  65011. * @param node The glTF node when loading the asset
  65012. * @param mesh The glTF mesh when loading the asset
  65013. * @param primitive The glTF mesh primitive property
  65014. * @param assign A function called synchronously after parsing the glTF properties
  65015. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  65016. */
  65017. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  65018. private _loadVertexDataAsync;
  65019. private _createMorphTargets;
  65020. private _loadMorphTargetsAsync;
  65021. private _loadMorphTargetVertexDataAsync;
  65022. private static _LoadTransform;
  65023. private _loadSkinAsync;
  65024. private _loadBones;
  65025. private _loadBone;
  65026. private _loadSkinInverseBindMatricesDataAsync;
  65027. private _updateBoneMatrices;
  65028. private _getNodeMatrix;
  65029. /**
  65030. * Loads a glTF camera.
  65031. * @param context The context when loading the asset
  65032. * @param camera The glTF camera property
  65033. * @param assign A function called synchronously after parsing the glTF properties
  65034. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  65035. */
  65036. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  65037. private _loadAnimationsAsync;
  65038. /**
  65039. * Loads a glTF animation.
  65040. * @param context The context when loading the asset
  65041. * @param animation The glTF animation property
  65042. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  65043. */
  65044. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  65045. /**
  65046. * @hidden Loads a glTF animation channel.
  65047. * @param context The context when loading the asset
  65048. * @param animationContext The context of the animation when loading the asset
  65049. * @param animation The glTF animation property
  65050. * @param channel The glTF animation channel property
  65051. * @param babylonAnimationGroup The babylon animation group property
  65052. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  65053. * @returns A void promise when the channel load is complete
  65054. */
  65055. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  65056. private _loadAnimationSamplerAsync;
  65057. private _loadBufferAsync;
  65058. /**
  65059. * Loads a glTF buffer view.
  65060. * @param context The context when loading the asset
  65061. * @param bufferView The glTF buffer view property
  65062. * @returns A promise that resolves with the loaded data when the load is complete
  65063. */
  65064. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  65065. private _loadIndicesAccessorAsync;
  65066. private _loadFloatAccessorAsync;
  65067. private _loadVertexBufferViewAsync;
  65068. private _loadVertexAccessorAsync;
  65069. private _loadMaterialMetallicRoughnessPropertiesAsync;
  65070. /** @hidden */
  65071. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  65072. private _createDefaultMaterial;
  65073. /**
  65074. * Creates a Babylon material from a glTF material.
  65075. * @param context The context when loading the asset
  65076. * @param material The glTF material property
  65077. * @param babylonDrawMode The draw mode for the Babylon material
  65078. * @returns The Babylon material
  65079. */
  65080. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  65081. /**
  65082. * Loads properties from a glTF material into a Babylon material.
  65083. * @param context The context when loading the asset
  65084. * @param material The glTF material property
  65085. * @param babylonMaterial The Babylon material
  65086. * @returns A promise that resolves when the load is complete
  65087. */
  65088. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  65089. /**
  65090. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  65091. * @param context The context when loading the asset
  65092. * @param material The glTF material property
  65093. * @param babylonMaterial The Babylon material
  65094. * @returns A promise that resolves when the load is complete
  65095. */
  65096. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  65097. /**
  65098. * Loads the alpha properties from a glTF material into a Babylon material.
  65099. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  65100. * @param context The context when loading the asset
  65101. * @param material The glTF material property
  65102. * @param babylonMaterial The Babylon material
  65103. */
  65104. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  65105. /**
  65106. * Loads a glTF texture info.
  65107. * @param context The context when loading the asset
  65108. * @param textureInfo The glTF texture info property
  65109. * @param assign A function called synchronously after parsing the glTF properties
  65110. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  65111. */
  65112. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  65113. private _loadTextureAsync;
  65114. private _loadSampler;
  65115. /**
  65116. * Loads a glTF image.
  65117. * @param context The context when loading the asset
  65118. * @param image The glTF image property
  65119. * @returns A promise that resolves with the loaded data when the load is complete
  65120. */
  65121. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  65122. /**
  65123. * Loads a glTF uri.
  65124. * @param context The context when loading the asset
  65125. * @param property The glTF property associated with the uri
  65126. * @param uri The base64 or relative uri
  65127. * @returns A promise that resolves with the loaded data when the load is complete
  65128. */
  65129. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  65130. private _onProgress;
  65131. /**
  65132. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  65133. * @param babylonObject the Babylon object with metadata
  65134. * @param pointer the JSON pointer
  65135. */
  65136. static AddPointerMetadata(babylonObject: {
  65137. metadata: any;
  65138. }, pointer: string): void;
  65139. private static _GetTextureWrapMode;
  65140. private static _GetTextureSamplingMode;
  65141. private static _GetTypedArray;
  65142. private static _GetNumComponents;
  65143. private static _ValidateUri;
  65144. private static _GetDrawMode;
  65145. private _compileMaterialsAsync;
  65146. private _compileShadowGeneratorsAsync;
  65147. private _forEachExtensions;
  65148. private _applyExtensions;
  65149. private _extensionsOnLoading;
  65150. private _extensionsOnReady;
  65151. private _extensionsLoadSceneAsync;
  65152. private _extensionsLoadNodeAsync;
  65153. private _extensionsLoadCameraAsync;
  65154. private _extensionsLoadVertexDataAsync;
  65155. private _extensionsLoadMeshPrimitiveAsync;
  65156. private _extensionsLoadMaterialAsync;
  65157. private _extensionsCreateMaterial;
  65158. private _extensionsLoadMaterialPropertiesAsync;
  65159. private _extensionsLoadTextureInfoAsync;
  65160. private _extensionsLoadAnimationAsync;
  65161. private _extensionsLoadSkinAsync;
  65162. private _extensionsLoadUriAsync;
  65163. /**
  65164. * Helper method called by a loader extension to load an glTF extension.
  65165. * @param context The context when loading the asset
  65166. * @param property The glTF property to load the extension from
  65167. * @param extensionName The name of the extension to load
  65168. * @param actionAsync The action to run
  65169. * @returns The promise returned by actionAsync or null if the extension does not exist
  65170. */
  65171. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  65172. /**
  65173. * Helper method called by a loader extension to load a glTF extra.
  65174. * @param context The context when loading the asset
  65175. * @param property The glTF property to load the extra from
  65176. * @param extensionName The name of the extension to load
  65177. * @param actionAsync The action to run
  65178. * @returns The promise returned by actionAsync or null if the extra does not exist
  65179. */
  65180. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  65181. /**
  65182. * Increments the indentation level and logs a message.
  65183. * @param message The message to log
  65184. */
  65185. logOpen(message: string): void;
  65186. /**
  65187. * Decrements the indentation level.
  65188. */
  65189. logClose(): void;
  65190. /**
  65191. * Logs a message
  65192. * @param message The message to log
  65193. */
  65194. log(message: string): void;
  65195. /**
  65196. * Starts a performance counter.
  65197. * @param counterName The name of the performance counter
  65198. */
  65199. startPerformanceCounter(counterName: string): void;
  65200. /**
  65201. * Ends a performance counter.
  65202. * @param counterName The name of the performance counter
  65203. */
  65204. endPerformanceCounter(counterName: string): void;
  65205. }
  65206. }
  65207. declare module BABYLON.GLTF2.Loader.Extensions {
  65208. /**
  65209. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  65210. */
  65211. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  65212. /** The name of this extension. */
  65213. readonly name: string;
  65214. /** Defines whether this extension is enabled. */
  65215. enabled: boolean;
  65216. private _loader;
  65217. private _lights?;
  65218. /** @hidden */
  65219. constructor(loader: GLTFLoader);
  65220. /** @hidden */
  65221. dispose(): void;
  65222. /** @hidden */
  65223. onLoading(): void;
  65224. /** @hidden */
  65225. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  65226. private _loadLightAsync;
  65227. }
  65228. }
  65229. declare module BABYLON.GLTF2.Loader.Extensions {
  65230. /**
  65231. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  65232. */
  65233. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  65234. /** The name of this extension. */
  65235. readonly name: string;
  65236. /** The draco compression used to decode vertex data or DracoCompression.Default if not defined */
  65237. dracoCompression?: DracoCompression;
  65238. /** Defines whether this extension is enabled. */
  65239. enabled: boolean;
  65240. private _loader;
  65241. /** @hidden */
  65242. constructor(loader: GLTFLoader);
  65243. /** @hidden */
  65244. dispose(): void;
  65245. /** @hidden */
  65246. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  65247. }
  65248. }
  65249. declare module BABYLON.GLTF2.Loader.Extensions {
  65250. /**
  65251. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  65252. */
  65253. export class KHR_lights implements IGLTFLoaderExtension {
  65254. /** The name of this extension. */
  65255. readonly name: string;
  65256. /** Defines whether this extension is enabled. */
  65257. enabled: boolean;
  65258. private _loader;
  65259. private _lights?;
  65260. /** @hidden */
  65261. constructor(loader: GLTFLoader);
  65262. /** @hidden */
  65263. dispose(): void;
  65264. /** @hidden */
  65265. onLoading(): void;
  65266. /** @hidden */
  65267. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  65268. }
  65269. }
  65270. declare module BABYLON.GLTF2.Loader.Extensions {
  65271. /**
  65272. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  65273. */
  65274. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  65275. /** The name of this extension. */
  65276. readonly name: string;
  65277. /** Defines whether this extension is enabled. */
  65278. enabled: boolean;
  65279. private _loader;
  65280. /** @hidden */
  65281. constructor(loader: GLTFLoader);
  65282. /** @hidden */
  65283. dispose(): void;
  65284. /** @hidden */
  65285. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  65286. private _loadSpecularGlossinessPropertiesAsync;
  65287. }
  65288. }
  65289. declare module BABYLON.GLTF2.Loader.Extensions {
  65290. /**
  65291. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  65292. */
  65293. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  65294. /** The name of this extension. */
  65295. readonly name: string;
  65296. /** Defines whether this extension is enabled. */
  65297. enabled: boolean;
  65298. private _loader;
  65299. /** @hidden */
  65300. constructor(loader: GLTFLoader);
  65301. /** @hidden */
  65302. dispose(): void;
  65303. /** @hidden */
  65304. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  65305. private _loadUnlitPropertiesAsync;
  65306. }
  65307. }
  65308. declare module BABYLON.GLTF2.Loader.Extensions {
  65309. /**
  65310. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  65311. */
  65312. export class KHR_texture_transform implements IGLTFLoaderExtension {
  65313. /** The name of this extension. */
  65314. readonly name: string;
  65315. /** Defines whether this extension is enabled. */
  65316. enabled: boolean;
  65317. private _loader;
  65318. /** @hidden */
  65319. constructor(loader: GLTFLoader);
  65320. /** @hidden */
  65321. dispose(): void;
  65322. /** @hidden */
  65323. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  65324. }
  65325. }
  65326. declare module BABYLON.GLTF2.Loader.Extensions {
  65327. /**
  65328. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  65329. */
  65330. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  65331. /** The name of this extension. */
  65332. readonly name: string;
  65333. /** Defines whether this extension is enabled. */
  65334. enabled: boolean;
  65335. private _loader;
  65336. private _clips;
  65337. private _emitters;
  65338. /** @hidden */
  65339. constructor(loader: GLTFLoader);
  65340. /** @hidden */
  65341. dispose(): void;
  65342. /** @hidden */
  65343. onLoading(): void;
  65344. /** @hidden */
  65345. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  65346. /** @hidden */
  65347. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  65348. /** @hidden */
  65349. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  65350. private _loadClipAsync;
  65351. private _loadEmitterAsync;
  65352. private _getEventAction;
  65353. private _loadAnimationEventAsync;
  65354. }
  65355. }
  65356. declare module BABYLON.GLTF2.Loader.Extensions {
  65357. /**
  65358. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  65359. */
  65360. export class MSFT_lod implements IGLTFLoaderExtension {
  65361. /** The name of this extension. */
  65362. readonly name: string;
  65363. /** Defines whether this extension is enabled. */
  65364. enabled: boolean;
  65365. /**
  65366. * Maximum number of LODs to load, starting from the lowest LOD.
  65367. */
  65368. maxLODsToLoad: number;
  65369. /**
  65370. * Observable raised when all node LODs of one level are loaded.
  65371. * The event data is the index of the loaded LOD starting from zero.
  65372. * Dispose the loader to cancel the loading of the next level of LODs.
  65373. */
  65374. onNodeLODsLoadedObservable: Observable<number>;
  65375. /**
  65376. * Observable raised when all material LODs of one level are loaded.
  65377. * The event data is the index of the loaded LOD starting from zero.
  65378. * Dispose the loader to cancel the loading of the next level of LODs.
  65379. */
  65380. onMaterialLODsLoadedObservable: Observable<number>;
  65381. private _loader;
  65382. private _nodeIndexLOD;
  65383. private _nodeSignalLODs;
  65384. private _nodePromiseLODs;
  65385. private _materialIndexLOD;
  65386. private _materialSignalLODs;
  65387. private _materialPromiseLODs;
  65388. /** @hidden */
  65389. constructor(loader: GLTFLoader);
  65390. /** @hidden */
  65391. dispose(): void;
  65392. /** @hidden */
  65393. onReady(): void;
  65394. /** @hidden */
  65395. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  65396. /** @hidden */
  65397. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  65398. /** @hidden */
  65399. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  65400. /**
  65401. * Gets an array of LOD properties from lowest to highest.
  65402. */
  65403. private _getLODs;
  65404. private _disposeUnusedMaterials;
  65405. }
  65406. }
  65407. declare module BABYLON.GLTF2.Loader.Extensions {
  65408. /** @hidden */
  65409. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  65410. readonly name: string;
  65411. enabled: boolean;
  65412. private _loader;
  65413. constructor(loader: GLTFLoader);
  65414. dispose(): void;
  65415. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  65416. }
  65417. }
  65418. declare module BABYLON.GLTF2.Loader.Extensions {
  65419. /** @hidden */
  65420. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  65421. readonly name: string;
  65422. enabled: boolean;
  65423. private _loader;
  65424. constructor(loader: GLTFLoader);
  65425. dispose(): void;
  65426. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  65427. }
  65428. }
  65429. declare module BABYLON.GLTF2.Loader.Extensions {
  65430. /**
  65431. * Store glTF extras (if present) in BJS objects' metadata
  65432. */
  65433. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  65434. /** The name of this extension. */
  65435. readonly name: string;
  65436. /** Defines whether this extension is enabled. */
  65437. enabled: boolean;
  65438. private _loader;
  65439. private _assignExtras;
  65440. /** @hidden */
  65441. constructor(loader: GLTFLoader);
  65442. /** @hidden */
  65443. dispose(): void;
  65444. /** @hidden */
  65445. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  65446. /** @hidden */
  65447. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  65448. /** @hidden */
  65449. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  65450. }
  65451. }
  65452. declare module BABYLON {
  65453. /**
  65454. * Class reading and parsing the MTL file bundled with the obj file.
  65455. */
  65456. export class MTLFileLoader {
  65457. /**
  65458. * All material loaded from the mtl will be set here
  65459. */
  65460. materials: StandardMaterial[];
  65461. /**
  65462. * This function will read the mtl file and create each material described inside
  65463. * This function could be improve by adding :
  65464. * -some component missing (Ni, Tf...)
  65465. * -including the specific options available
  65466. *
  65467. * @param scene defines the scene the material will be created in
  65468. * @param data defines the mtl data to parse
  65469. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  65470. */
  65471. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  65472. /**
  65473. * Gets the texture for the material.
  65474. *
  65475. * If the material is imported from input file,
  65476. * We sanitize the url to ensure it takes the textre from aside the material.
  65477. *
  65478. * @param rootUrl The root url to load from
  65479. * @param value The value stored in the mtl
  65480. * @return The Texture
  65481. */
  65482. private static _getTexture;
  65483. }
  65484. /**
  65485. * Options for loading OBJ/MTL files
  65486. */
  65487. type MeshLoadOptions = {
  65488. /**
  65489. * Defines if UVs are optimized by default during load.
  65490. */
  65491. OptimizeWithUV: boolean;
  65492. /**
  65493. * Defines custom scaling of UV coordinates of loaded meshes.
  65494. */
  65495. UVScaling: Vector2;
  65496. /**
  65497. * Invert model on y-axis (does a model scaling inversion)
  65498. */
  65499. InvertY: boolean;
  65500. /**
  65501. * Invert Y-Axis of referenced textures on load
  65502. */
  65503. InvertTextureY: boolean;
  65504. /**
  65505. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  65506. */
  65507. ImportVertexColors: boolean;
  65508. /**
  65509. * Compute the normals for the model, even if normals are present in the file.
  65510. */
  65511. ComputeNormals: boolean;
  65512. /**
  65513. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  65514. */
  65515. SkipMaterials: boolean;
  65516. /**
  65517. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  65518. */
  65519. MaterialLoadingFailsSilently: boolean;
  65520. };
  65521. /**
  65522. * OBJ file type loader.
  65523. * This is a babylon scene loader plugin.
  65524. */
  65525. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  65526. /**
  65527. * Defines if UVs are optimized by default during load.
  65528. */
  65529. static OPTIMIZE_WITH_UV: boolean;
  65530. /**
  65531. * Invert model on y-axis (does a model scaling inversion)
  65532. */
  65533. static INVERT_Y: boolean;
  65534. /**
  65535. * Invert Y-Axis of referenced textures on load
  65536. */
  65537. static INVERT_TEXTURE_Y: boolean;
  65538. /**
  65539. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  65540. */
  65541. static IMPORT_VERTEX_COLORS: boolean;
  65542. /**
  65543. * Compute the normals for the model, even if normals are present in the file.
  65544. */
  65545. static COMPUTE_NORMALS: boolean;
  65546. /**
  65547. * Defines custom scaling of UV coordinates of loaded meshes.
  65548. */
  65549. static UV_SCALING: Vector2;
  65550. /**
  65551. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  65552. */
  65553. static SKIP_MATERIALS: boolean;
  65554. /**
  65555. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  65556. *
  65557. * Defaults to true for backwards compatibility.
  65558. */
  65559. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  65560. /**
  65561. * Defines the name of the plugin.
  65562. */
  65563. name: string;
  65564. /**
  65565. * Defines the extension the plugin is able to load.
  65566. */
  65567. extensions: string;
  65568. /** @hidden */
  65569. obj: RegExp;
  65570. /** @hidden */
  65571. group: RegExp;
  65572. /** @hidden */
  65573. mtllib: RegExp;
  65574. /** @hidden */
  65575. usemtl: RegExp;
  65576. /** @hidden */
  65577. smooth: RegExp;
  65578. /** @hidden */
  65579. vertexPattern: RegExp;
  65580. /** @hidden */
  65581. normalPattern: RegExp;
  65582. /** @hidden */
  65583. uvPattern: RegExp;
  65584. /** @hidden */
  65585. facePattern1: RegExp;
  65586. /** @hidden */
  65587. facePattern2: RegExp;
  65588. /** @hidden */
  65589. facePattern3: RegExp;
  65590. /** @hidden */
  65591. facePattern4: RegExp;
  65592. /** @hidden */
  65593. facePattern5: RegExp;
  65594. private _meshLoadOptions;
  65595. /**
  65596. * Creates loader for .OBJ files
  65597. *
  65598. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  65599. */
  65600. constructor(meshLoadOptions?: MeshLoadOptions);
  65601. private static readonly currentMeshLoadOptions;
  65602. /**
  65603. * Calls synchronously the MTL file attached to this obj.
  65604. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  65605. * Without this function materials are not displayed in the first frame (but displayed after).
  65606. * In consequence it is impossible to get material information in your HTML file
  65607. *
  65608. * @param url The URL of the MTL file
  65609. * @param rootUrl
  65610. * @param onSuccess Callback function to be called when the MTL file is loaded
  65611. * @private
  65612. */
  65613. private _loadMTL;
  65614. /**
  65615. * Instantiates a OBJ file loader plugin.
  65616. * @returns the created plugin
  65617. */
  65618. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  65619. /**
  65620. * If the data string can be loaded directly.
  65621. *
  65622. * @param data string containing the file data
  65623. * @returns if the data can be loaded directly
  65624. */
  65625. canDirectLoad(data: string): boolean;
  65626. /**
  65627. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  65628. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  65629. * @param scene the scene the meshes should be added to
  65630. * @param data the OBJ data to load
  65631. * @param rootUrl root url to load from
  65632. * @param onProgress event that fires when loading progress has occured
  65633. * @param fileName Defines the name of the file to load
  65634. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  65635. */
  65636. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  65637. meshes: AbstractMesh[];
  65638. particleSystems: IParticleSystem[];
  65639. skeletons: Skeleton[];
  65640. animationGroups: AnimationGroup[];
  65641. }>;
  65642. /**
  65643. * Imports all objects from the loaded OBJ data and adds them to the scene
  65644. * @param scene the scene the objects should be added to
  65645. * @param data the OBJ data to load
  65646. * @param rootUrl root url to load from
  65647. * @param onProgress event that fires when loading progress has occured
  65648. * @param fileName Defines the name of the file to load
  65649. * @returns a promise which completes when objects have been loaded to the scene
  65650. */
  65651. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  65652. /**
  65653. * Load into an asset container.
  65654. * @param scene The scene to load into
  65655. * @param data The data to import
  65656. * @param rootUrl The root url for scene and resources
  65657. * @param onProgress The callback when the load progresses
  65658. * @param fileName Defines the name of the file to load
  65659. * @returns The loaded asset container
  65660. */
  65661. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  65662. /**
  65663. * Read the OBJ file and create an Array of meshes.
  65664. * Each mesh contains all information given by the OBJ and the MTL file.
  65665. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  65666. *
  65667. * @param meshesNames
  65668. * @param scene Scene The scene where are displayed the data
  65669. * @param data String The content of the obj file
  65670. * @param rootUrl String The path to the folder
  65671. * @returns Array<AbstractMesh>
  65672. * @private
  65673. */
  65674. private _parseSolid;
  65675. }
  65676. }
  65677. declare module BABYLON {
  65678. /**
  65679. * STL file type loader.
  65680. * This is a babylon scene loader plugin.
  65681. */
  65682. export class STLFileLoader implements ISceneLoaderPlugin {
  65683. /** @hidden */
  65684. solidPattern: RegExp;
  65685. /** @hidden */
  65686. facetsPattern: RegExp;
  65687. /** @hidden */
  65688. normalPattern: RegExp;
  65689. /** @hidden */
  65690. vertexPattern: RegExp;
  65691. /**
  65692. * Defines the name of the plugin.
  65693. */
  65694. name: string;
  65695. /**
  65696. * Defines the extensions the stl loader is able to load.
  65697. * force data to come in as an ArrayBuffer
  65698. * we'll convert to string if it looks like it's an ASCII .stl
  65699. */
  65700. extensions: ISceneLoaderPluginExtensions;
  65701. /**
  65702. * Import meshes into a scene.
  65703. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  65704. * @param scene The scene to import into
  65705. * @param data The data to import
  65706. * @param rootUrl The root url for scene and resources
  65707. * @param meshes The meshes array to import into
  65708. * @param particleSystems The particle systems array to import into
  65709. * @param skeletons The skeletons array to import into
  65710. * @param onError The callback when import fails
  65711. * @returns True if successful or false otherwise
  65712. */
  65713. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  65714. /**
  65715. * Load into a scene.
  65716. * @param scene The scene to load into
  65717. * @param data The data to import
  65718. * @param rootUrl The root url for scene and resources
  65719. * @param onError The callback when import fails
  65720. * @returns true if successful or false otherwise
  65721. */
  65722. load(scene: Scene, data: any, rootUrl: string): boolean;
  65723. /**
  65724. * Load into an asset container.
  65725. * @param scene The scene to load into
  65726. * @param data The data to import
  65727. * @param rootUrl The root url for scene and resources
  65728. * @param onError The callback when import fails
  65729. * @returns The loaded asset container
  65730. */
  65731. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  65732. private _isBinary;
  65733. private _parseBinary;
  65734. private _parseASCII;
  65735. }
  65736. }
  65737. declare module BABYLON {
  65738. /**
  65739. * Class for generating OBJ data from a Babylon scene.
  65740. */
  65741. export class OBJExport {
  65742. /**
  65743. * Exports the geometry of a Mesh array in .OBJ file format (text)
  65744. * @param mesh defines the list of meshes to serialize
  65745. * @param materials defines if materials should be exported
  65746. * @param matlibname defines the name of the associated mtl file
  65747. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  65748. * @returns the OBJ content
  65749. */
  65750. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  65751. /**
  65752. * Exports the material(s) of a mesh in .MTL file format (text)
  65753. * @param mesh defines the mesh to extract the material from
  65754. * @returns the mtl content
  65755. */
  65756. static MTL(mesh: Mesh): string;
  65757. }
  65758. }
  65759. declare module BABYLON {
  65760. /** @hidden */
  65761. export var __IGLTFExporterExtension: number;
  65762. /**
  65763. * Interface for extending the exporter
  65764. * @hidden
  65765. */
  65766. export interface IGLTFExporterExtension {
  65767. /**
  65768. * The name of this extension
  65769. */
  65770. readonly name: string;
  65771. /**
  65772. * Defines whether this extension is enabled
  65773. */
  65774. enabled: boolean;
  65775. /**
  65776. * Defines whether this extension is required
  65777. */
  65778. required: boolean;
  65779. }
  65780. }
  65781. declare module BABYLON.GLTF2.Exporter {
  65782. /** @hidden */
  65783. export var __IGLTFExporterExtensionV2: number;
  65784. /**
  65785. * Interface for a glTF exporter extension
  65786. * @hidden
  65787. */
  65788. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  65789. /**
  65790. * Define this method to modify the default behavior before exporting a texture
  65791. * @param context The context when loading the asset
  65792. * @param babylonTexture The glTF texture info property
  65793. * @param mimeType The mime-type of the generated image
  65794. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  65795. */
  65796. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  65797. /**
  65798. * Define this method to modify the default behavior when exporting texture info
  65799. * @param context The context when loading the asset
  65800. * @param meshPrimitive glTF mesh primitive
  65801. * @param babylonSubMesh Babylon submesh
  65802. * @param binaryWriter glTF serializer binary writer instance
  65803. * @returns nullable IMeshPrimitive promise
  65804. */
  65805. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  65806. /**
  65807. * Define this method to modify the default behavior when exporting a node
  65808. * @param context The context when exporting the node
  65809. * @param node glTF node
  65810. * @param babylonNode BabylonJS node
  65811. * @returns nullable INode promise
  65812. */
  65813. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  65814. /**
  65815. * Called after the exporter state changes to EXPORTING
  65816. */
  65817. onExporting?(): void;
  65818. }
  65819. }
  65820. declare module BABYLON.GLTF2.Exporter {
  65821. /**
  65822. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  65823. * @hidden
  65824. */
  65825. export class _GLTFMaterialExporter {
  65826. /**
  65827. * Represents the dielectric specular values for R, G and B
  65828. */
  65829. private static readonly _DielectricSpecular;
  65830. /**
  65831. * Allows the maximum specular power to be defined for material calculations
  65832. */
  65833. private static readonly _MaxSpecularPower;
  65834. /**
  65835. * Mapping to store textures
  65836. */
  65837. private _textureMap;
  65838. /**
  65839. * Numeric tolerance value
  65840. */
  65841. private static readonly _Epsilon;
  65842. /**
  65843. * Reference to the glTF Exporter
  65844. */
  65845. private _exporter;
  65846. constructor(exporter: _Exporter);
  65847. /**
  65848. * Specifies if two colors are approximately equal in value
  65849. * @param color1 first color to compare to
  65850. * @param color2 second color to compare to
  65851. * @param epsilon threshold value
  65852. */
  65853. private static FuzzyEquals;
  65854. /**
  65855. * Gets the materials from a Babylon scene and converts them to glTF materials
  65856. * @param scene babylonjs scene
  65857. * @param mimeType texture mime type
  65858. * @param images array of images
  65859. * @param textures array of textures
  65860. * @param materials array of materials
  65861. * @param imageData mapping of texture names to base64 textures
  65862. * @param hasTextureCoords specifies if texture coordinates are present on the material
  65863. */
  65864. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  65865. /**
  65866. * Makes a copy of the glTF material without the texture parameters
  65867. * @param originalMaterial original glTF material
  65868. * @returns glTF material without texture parameters
  65869. */
  65870. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  65871. /**
  65872. * Specifies if the material has any texture parameters present
  65873. * @param material glTF Material
  65874. * @returns boolean specifying if texture parameters are present
  65875. */
  65876. _hasTexturesPresent(material: IMaterial): boolean;
  65877. /**
  65878. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  65879. * @param babylonStandardMaterial
  65880. * @returns glTF Metallic Roughness Material representation
  65881. */
  65882. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  65883. /**
  65884. * Computes the metallic factor
  65885. * @param diffuse diffused value
  65886. * @param specular specular value
  65887. * @param oneMinusSpecularStrength one minus the specular strength
  65888. * @returns metallic value
  65889. */
  65890. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  65891. /**
  65892. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  65893. * @param glTFMaterial glTF material
  65894. * @param babylonMaterial Babylon material
  65895. */
  65896. private static _SetAlphaMode;
  65897. /**
  65898. * Converts a Babylon Standard Material to a glTF Material
  65899. * @param babylonStandardMaterial BJS Standard Material
  65900. * @param mimeType mime type to use for the textures
  65901. * @param images array of glTF image interfaces
  65902. * @param textures array of glTF texture interfaces
  65903. * @param materials array of glTF material interfaces
  65904. * @param imageData map of image file name to data
  65905. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  65906. */
  65907. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  65908. /**
  65909. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  65910. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  65911. * @param mimeType mime type to use for the textures
  65912. * @param images array of glTF image interfaces
  65913. * @param textures array of glTF texture interfaces
  65914. * @param materials array of glTF material interfaces
  65915. * @param imageData map of image file name to data
  65916. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  65917. */
  65918. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  65919. /**
  65920. * Converts an image typed array buffer to a base64 image
  65921. * @param buffer typed array buffer
  65922. * @param width width of the image
  65923. * @param height height of the image
  65924. * @param mimeType mimetype of the image
  65925. * @returns base64 image string
  65926. */
  65927. private _createBase64FromCanvasAsync;
  65928. /**
  65929. * Generates a white texture based on the specified width and height
  65930. * @param width width of the texture in pixels
  65931. * @param height height of the texture in pixels
  65932. * @param scene babylonjs scene
  65933. * @returns white texture
  65934. */
  65935. private _createWhiteTexture;
  65936. /**
  65937. * 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
  65938. * @param texture1 first texture to resize
  65939. * @param texture2 second texture to resize
  65940. * @param scene babylonjs scene
  65941. * @returns resized textures or null
  65942. */
  65943. private _resizeTexturesToSameDimensions;
  65944. /**
  65945. * Converts an array of pixels to a Float32Array
  65946. * Throws an error if the pixel format is not supported
  65947. * @param pixels - array buffer containing pixel values
  65948. * @returns Float32 of pixels
  65949. */
  65950. private _convertPixelArrayToFloat32;
  65951. /**
  65952. * Convert Specular Glossiness Textures to Metallic Roughness
  65953. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  65954. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  65955. * @param diffuseTexture texture used to store diffuse information
  65956. * @param specularGlossinessTexture texture used to store specular and glossiness information
  65957. * @param factors specular glossiness material factors
  65958. * @param mimeType the mime type to use for the texture
  65959. * @returns pbr metallic roughness interface or null
  65960. */
  65961. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  65962. /**
  65963. * Converts specular glossiness material properties to metallic roughness
  65964. * @param specularGlossiness interface with specular glossiness material properties
  65965. * @returns interface with metallic roughness material properties
  65966. */
  65967. private _convertSpecularGlossinessToMetallicRoughness;
  65968. /**
  65969. * Calculates the surface reflectance, independent of lighting conditions
  65970. * @param color Color source to calculate brightness from
  65971. * @returns number representing the perceived brightness, or zero if color is undefined
  65972. */
  65973. private _getPerceivedBrightness;
  65974. /**
  65975. * Returns the maximum color component value
  65976. * @param color
  65977. * @returns maximum color component value, or zero if color is null or undefined
  65978. */
  65979. private _getMaxComponent;
  65980. /**
  65981. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  65982. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  65983. * @param mimeType mime type to use for the textures
  65984. * @param images array of glTF image interfaces
  65985. * @param textures array of glTF texture interfaces
  65986. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  65987. * @param imageData map of image file name to data
  65988. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  65989. * @returns glTF PBR Metallic Roughness factors
  65990. */
  65991. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  65992. private _getGLTFTextureSampler;
  65993. private _getGLTFTextureWrapMode;
  65994. private _getGLTFTextureWrapModesSampler;
  65995. /**
  65996. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  65997. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  65998. * @param mimeType mime type to use for the textures
  65999. * @param images array of glTF image interfaces
  66000. * @param textures array of glTF texture interfaces
  66001. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  66002. * @param imageData map of image file name to data
  66003. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  66004. * @returns glTF PBR Metallic Roughness factors
  66005. */
  66006. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  66007. /**
  66008. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  66009. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  66010. * @param mimeType mime type to use for the textures
  66011. * @param images array of glTF image interfaces
  66012. * @param textures array of glTF texture interfaces
  66013. * @param materials array of glTF material interfaces
  66014. * @param imageData map of image file name to data
  66015. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  66016. */
  66017. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  66018. private setMetallicRoughnessPbrMaterial;
  66019. private getPixelsFromTexture;
  66020. /**
  66021. * Extracts a texture from a Babylon texture into file data and glTF data
  66022. * @param babylonTexture Babylon texture to extract
  66023. * @param mimeType Mime Type of the babylonTexture
  66024. * @return glTF texture info, or null if the texture format is not supported
  66025. */
  66026. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  66027. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  66028. /**
  66029. * Builds a texture from base64 string
  66030. * @param base64Texture base64 texture string
  66031. * @param baseTextureName Name to use for the texture
  66032. * @param mimeType image mime type for the texture
  66033. * @param images array of images
  66034. * @param textures array of textures
  66035. * @param imageData map of image data
  66036. * @returns glTF texture info, or null if the texture format is not supported
  66037. */
  66038. private _getTextureInfoFromBase64;
  66039. }
  66040. }
  66041. declare module BABYLON {
  66042. /**
  66043. * Class for holding and downloading glTF file data
  66044. */
  66045. export class GLTFData {
  66046. /**
  66047. * Object which contains the file name as the key and its data as the value
  66048. */
  66049. glTFFiles: {
  66050. [fileName: string]: string | Blob;
  66051. };
  66052. /**
  66053. * Initializes the glTF file object
  66054. */
  66055. constructor();
  66056. /**
  66057. * Downloads the glTF data as files based on their names and data
  66058. */
  66059. downloadFiles(): void;
  66060. }
  66061. }
  66062. declare module BABYLON {
  66063. /**
  66064. * Holds a collection of exporter options and parameters
  66065. */
  66066. export interface IExportOptions {
  66067. /**
  66068. * Function which indicates whether a babylon node should be exported or not
  66069. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  66070. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  66071. */
  66072. shouldExportNode?(node: Node): boolean;
  66073. /**
  66074. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  66075. * @param metadata source metadata to read from
  66076. * @returns the data to store to glTF node extras
  66077. */
  66078. metadataSelector?(metadata: any): any;
  66079. /**
  66080. * The sample rate to bake animation curves
  66081. */
  66082. animationSampleRate?: number;
  66083. /**
  66084. * Begin serialization without waiting for the scene to be ready
  66085. */
  66086. exportWithoutWaitingForScene?: boolean;
  66087. }
  66088. /**
  66089. * Class for generating glTF data from a Babylon scene.
  66090. */
  66091. export class GLTF2Export {
  66092. /**
  66093. * Exports the geometry of the scene to .gltf file format asynchronously
  66094. * @param scene Babylon scene with scene hierarchy information
  66095. * @param filePrefix File prefix to use when generating the glTF file
  66096. * @param options Exporter options
  66097. * @returns Returns an object with a .gltf file and associates texture names
  66098. * as keys and their data and paths as values
  66099. */
  66100. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  66101. private static _PreExportAsync;
  66102. private static _PostExportAsync;
  66103. /**
  66104. * Exports the geometry of the scene to .glb file format asychronously
  66105. * @param scene Babylon scene with scene hierarchy information
  66106. * @param filePrefix File prefix to use when generating glb file
  66107. * @param options Exporter options
  66108. * @returns Returns an object with a .glb filename as key and data as value
  66109. */
  66110. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  66111. }
  66112. }
  66113. declare module BABYLON.GLTF2.Exporter {
  66114. /**
  66115. * @hidden
  66116. */
  66117. export class _GLTFUtilities {
  66118. /**
  66119. * Creates a buffer view based on the supplied arguments
  66120. * @param bufferIndex index value of the specified buffer
  66121. * @param byteOffset byte offset value
  66122. * @param byteLength byte length of the bufferView
  66123. * @param byteStride byte distance between conequential elements
  66124. * @param name name of the buffer view
  66125. * @returns bufferView for glTF
  66126. */
  66127. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  66128. /**
  66129. * Creates an accessor based on the supplied arguments
  66130. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  66131. * @param name The name of the accessor
  66132. * @param type The type of the accessor
  66133. * @param componentType The datatype of components in the attribute
  66134. * @param count The number of attributes referenced by this accessor
  66135. * @param byteOffset The offset relative to the start of the bufferView in bytes
  66136. * @param min Minimum value of each component in this attribute
  66137. * @param max Maximum value of each component in this attribute
  66138. * @returns accessor for glTF
  66139. */
  66140. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  66141. /**
  66142. * Calculates the minimum and maximum values of an array of position floats
  66143. * @param positions Positions array of a mesh
  66144. * @param vertexStart Starting vertex offset to calculate min and max values
  66145. * @param vertexCount Number of vertices to check for min and max values
  66146. * @returns min number array and max number array
  66147. */
  66148. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  66149. min: number[];
  66150. max: number[];
  66151. };
  66152. /**
  66153. * Converts a new right-handed Vector3
  66154. * @param vector vector3 array
  66155. * @returns right-handed Vector3
  66156. */
  66157. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  66158. /**
  66159. * Converts a Vector3 to right-handed
  66160. * @param vector Vector3 to convert to right-handed
  66161. */
  66162. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  66163. /**
  66164. * Converts a three element number array to right-handed
  66165. * @param vector number array to convert to right-handed
  66166. */
  66167. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  66168. /**
  66169. * Converts a new right-handed Vector3
  66170. * @param vector vector3 array
  66171. * @returns right-handed Vector3
  66172. */
  66173. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  66174. /**
  66175. * Converts a Vector3 to right-handed
  66176. * @param vector Vector3 to convert to right-handed
  66177. */
  66178. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  66179. /**
  66180. * Converts a three element number array to right-handed
  66181. * @param vector number array to convert to right-handed
  66182. */
  66183. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  66184. /**
  66185. * Converts a Vector4 to right-handed
  66186. * @param vector Vector4 to convert to right-handed
  66187. */
  66188. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  66189. /**
  66190. * Converts a Vector4 to right-handed
  66191. * @param vector Vector4 to convert to right-handed
  66192. */
  66193. static _GetRightHandedArray4FromRef(vector: number[]): void;
  66194. /**
  66195. * Converts a Quaternion to right-handed
  66196. * @param quaternion Source quaternion to convert to right-handed
  66197. */
  66198. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  66199. /**
  66200. * Converts a Quaternion to right-handed
  66201. * @param quaternion Source quaternion to convert to right-handed
  66202. */
  66203. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  66204. static _NormalizeTangentFromRef(tangent: Vector4): void;
  66205. }
  66206. }
  66207. declare module BABYLON.GLTF2.Exporter {
  66208. /**
  66209. * Converts Babylon Scene into glTF 2.0.
  66210. * @hidden
  66211. */
  66212. export class _Exporter {
  66213. /**
  66214. * Stores the glTF to export
  66215. */
  66216. _glTF: IGLTF;
  66217. /**
  66218. * Stores all generated buffer views, which represents views into the main glTF buffer data
  66219. */
  66220. _bufferViews: IBufferView[];
  66221. /**
  66222. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  66223. */
  66224. _accessors: IAccessor[];
  66225. /**
  66226. * Stores all the generated nodes, which contains transform and/or mesh information per node
  66227. */
  66228. private _nodes;
  66229. /**
  66230. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  66231. */
  66232. private _scenes;
  66233. /**
  66234. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  66235. */
  66236. private _meshes;
  66237. /**
  66238. * Stores all the generated material information, which represents the appearance of each primitive
  66239. */
  66240. _materials: IMaterial[];
  66241. _materialMap: {
  66242. [materialID: number]: number;
  66243. };
  66244. /**
  66245. * Stores all the generated texture information, which is referenced by glTF materials
  66246. */
  66247. _textures: ITexture[];
  66248. /**
  66249. * Stores all the generated image information, which is referenced by glTF textures
  66250. */
  66251. _images: IImage[];
  66252. /**
  66253. * Stores all the texture samplers
  66254. */
  66255. _samplers: ISampler[];
  66256. /**
  66257. * Stores all the generated animation samplers, which is referenced by glTF animations
  66258. */
  66259. /**
  66260. * Stores the animations for glTF models
  66261. */
  66262. private _animations;
  66263. /**
  66264. * Stores the total amount of bytes stored in the glTF buffer
  66265. */
  66266. private _totalByteLength;
  66267. /**
  66268. * Stores a reference to the Babylon scene containing the source geometry and material information
  66269. */
  66270. _babylonScene: Scene;
  66271. /**
  66272. * Stores a map of the image data, where the key is the file name and the value
  66273. * is the image data
  66274. */
  66275. _imageData: {
  66276. [fileName: string]: {
  66277. data: Uint8Array;
  66278. mimeType: ImageMimeType;
  66279. };
  66280. };
  66281. /**
  66282. * Stores a map of the unique id of a node to its index in the node array
  66283. */
  66284. private _nodeMap;
  66285. /**
  66286. * Specifies if the Babylon scene should be converted to right-handed on export
  66287. */
  66288. _convertToRightHandedSystem: boolean;
  66289. /**
  66290. * Baked animation sample rate
  66291. */
  66292. private _animationSampleRate;
  66293. private _options;
  66294. private _localEngine;
  66295. _glTFMaterialExporter: _GLTFMaterialExporter;
  66296. private _extensions;
  66297. private static _ExtensionNames;
  66298. private static _ExtensionFactories;
  66299. private _applyExtensions;
  66300. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<BaseTexture>>;
  66301. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  66302. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  66303. private _forEachExtensions;
  66304. private _extensionsOnExporting;
  66305. /**
  66306. * Load glTF serializer extensions
  66307. */
  66308. private _loadExtensions;
  66309. /**
  66310. * Creates a glTF Exporter instance, which can accept optional exporter options
  66311. * @param babylonScene Babylon scene object
  66312. * @param options Options to modify the behavior of the exporter
  66313. */
  66314. constructor(babylonScene: Scene, options?: IExportOptions);
  66315. /**
  66316. * Registers a glTF exporter extension
  66317. * @param name Name of the extension to export
  66318. * @param factory The factory function that creates the exporter extension
  66319. */
  66320. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  66321. /**
  66322. * Un-registers an exporter extension
  66323. * @param name The name fo the exporter extension
  66324. * @returns A boolean indicating whether the extension has been un-registered
  66325. */
  66326. static UnregisterExtension(name: string): boolean;
  66327. /**
  66328. * Lazy load a local engine with premultiplied alpha set to false
  66329. */
  66330. _getLocalEngine(): Engine;
  66331. private reorderIndicesBasedOnPrimitiveMode;
  66332. /**
  66333. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  66334. * clock-wise during export to glTF
  66335. * @param submesh BabylonJS submesh
  66336. * @param primitiveMode Primitive mode of the mesh
  66337. * @param sideOrientation the winding order of the submesh
  66338. * @param vertexBufferKind The type of vertex attribute
  66339. * @param meshAttributeArray The vertex attribute data
  66340. * @param byteOffset The offset to the binary data
  66341. * @param binaryWriter The binary data for the glTF file
  66342. */
  66343. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  66344. /**
  66345. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  66346. * clock-wise during export to glTF
  66347. * @param submesh BabylonJS submesh
  66348. * @param primitiveMode Primitive mode of the mesh
  66349. * @param sideOrientation the winding order of the submesh
  66350. * @param vertexBufferKind The type of vertex attribute
  66351. * @param meshAttributeArray The vertex attribute data
  66352. * @param byteOffset The offset to the binary data
  66353. * @param binaryWriter The binary data for the glTF file
  66354. */
  66355. private reorderTriangleFillMode;
  66356. /**
  66357. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  66358. * clock-wise during export to glTF
  66359. * @param submesh BabylonJS submesh
  66360. * @param primitiveMode Primitive mode of the mesh
  66361. * @param sideOrientation the winding order of the submesh
  66362. * @param vertexBufferKind The type of vertex attribute
  66363. * @param meshAttributeArray The vertex attribute data
  66364. * @param byteOffset The offset to the binary data
  66365. * @param binaryWriter The binary data for the glTF file
  66366. */
  66367. private reorderTriangleStripDrawMode;
  66368. /**
  66369. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  66370. * clock-wise during export to glTF
  66371. * @param submesh BabylonJS submesh
  66372. * @param primitiveMode Primitive mode of the mesh
  66373. * @param sideOrientation the winding order of the submesh
  66374. * @param vertexBufferKind The type of vertex attribute
  66375. * @param meshAttributeArray The vertex attribute data
  66376. * @param byteOffset The offset to the binary data
  66377. * @param binaryWriter The binary data for the glTF file
  66378. */
  66379. private reorderTriangleFanMode;
  66380. /**
  66381. * Writes the vertex attribute data to binary
  66382. * @param vertices The vertices to write to the binary writer
  66383. * @param byteOffset The offset into the binary writer to overwrite binary data
  66384. * @param vertexAttributeKind The vertex attribute type
  66385. * @param meshAttributeArray The vertex attribute data
  66386. * @param binaryWriter The writer containing the binary data
  66387. */
  66388. private writeVertexAttributeData;
  66389. /**
  66390. * Writes mesh attribute data to a data buffer
  66391. * Returns the bytelength of the data
  66392. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  66393. * @param meshAttributeArray Array containing the attribute data
  66394. * @param binaryWriter The buffer to write the binary data to
  66395. * @param indices Used to specify the order of the vertex data
  66396. */
  66397. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  66398. /**
  66399. * Generates glTF json data
  66400. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  66401. * @param glTFPrefix Text to use when prefixing a glTF file
  66402. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  66403. * @returns json data as string
  66404. */
  66405. private generateJSON;
  66406. /**
  66407. * Generates data for .gltf and .bin files based on the glTF prefix string
  66408. * @param glTFPrefix Text to use when prefixing a glTF file
  66409. * @returns GLTFData with glTF file data
  66410. */
  66411. _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  66412. /**
  66413. * Creates a binary buffer for glTF
  66414. * @returns array buffer for binary data
  66415. */
  66416. private _generateBinaryAsync;
  66417. /**
  66418. * Pads the number to a multiple of 4
  66419. * @param num number to pad
  66420. * @returns padded number
  66421. */
  66422. private _getPadding;
  66423. /**
  66424. * Generates a glb file from the json and binary data
  66425. * Returns an object with the glb file name as the key and data as the value
  66426. * @param glTFPrefix
  66427. * @returns object with glb filename as key and data as value
  66428. */
  66429. _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  66430. /**
  66431. * Sets the TRS for each node
  66432. * @param node glTF Node for storing the transformation data
  66433. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  66434. */
  66435. private setNodeTransformation;
  66436. private getVertexBufferFromMesh;
  66437. /**
  66438. * Creates a bufferview based on the vertices type for the Babylon mesh
  66439. * @param kind Indicates the type of vertices data
  66440. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  66441. * @param binaryWriter The buffer to write the bufferview data to
  66442. */
  66443. private createBufferViewKind;
  66444. /**
  66445. * The primitive mode of the Babylon mesh
  66446. * @param babylonMesh The BabylonJS mesh
  66447. */
  66448. private getMeshPrimitiveMode;
  66449. /**
  66450. * Sets the primitive mode of the glTF mesh primitive
  66451. * @param meshPrimitive glTF mesh primitive
  66452. * @param primitiveMode The primitive mode
  66453. */
  66454. private setPrimitiveMode;
  66455. /**
  66456. * Sets the vertex attribute accessor based of the glTF mesh primitive
  66457. * @param meshPrimitive glTF mesh primitive
  66458. * @param attributeKind vertex attribute
  66459. * @returns boolean specifying if uv coordinates are present
  66460. */
  66461. private setAttributeKind;
  66462. /**
  66463. * Sets data for the primitive attributes of each submesh
  66464. * @param mesh glTF Mesh object to store the primitive attribute information
  66465. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  66466. * @param binaryWriter Buffer to write the attribute data to
  66467. */
  66468. private setPrimitiveAttributesAsync;
  66469. /**
  66470. * Creates a glTF scene based on the array of meshes
  66471. * Returns the the total byte offset
  66472. * @param babylonScene Babylon scene to get the mesh data from
  66473. * @param binaryWriter Buffer to write binary data to
  66474. */
  66475. private createSceneAsync;
  66476. /**
  66477. * Creates a mapping of Node unique id to node index and handles animations
  66478. * @param babylonScene Babylon Scene
  66479. * @param nodes Babylon transform nodes
  66480. * @param binaryWriter Buffer to write binary data to
  66481. * @returns Node mapping of unique id to index
  66482. */
  66483. private createNodeMapAndAnimationsAsync;
  66484. /**
  66485. * Creates a glTF node from a Babylon mesh
  66486. * @param babylonMesh Source Babylon mesh
  66487. * @param binaryWriter Buffer for storing geometry data
  66488. * @returns glTF node
  66489. */
  66490. private createNodeAsync;
  66491. }
  66492. /**
  66493. * @hidden
  66494. *
  66495. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  66496. */
  66497. export class _BinaryWriter {
  66498. /**
  66499. * Array buffer which stores all binary data
  66500. */
  66501. private _arrayBuffer;
  66502. /**
  66503. * View of the array buffer
  66504. */
  66505. private _dataView;
  66506. /**
  66507. * byte offset of data in array buffer
  66508. */
  66509. private _byteOffset;
  66510. /**
  66511. * Initialize binary writer with an initial byte length
  66512. * @param byteLength Initial byte length of the array buffer
  66513. */
  66514. constructor(byteLength: number);
  66515. /**
  66516. * Resize the array buffer to the specified byte length
  66517. * @param byteLength
  66518. */
  66519. private resizeBuffer;
  66520. /**
  66521. * Get an array buffer with the length of the byte offset
  66522. * @returns ArrayBuffer resized to the byte offset
  66523. */
  66524. getArrayBuffer(): ArrayBuffer;
  66525. /**
  66526. * Get the byte offset of the array buffer
  66527. * @returns byte offset
  66528. */
  66529. getByteOffset(): number;
  66530. /**
  66531. * Stores an UInt8 in the array buffer
  66532. * @param entry
  66533. * @param byteOffset If defined, specifies where to set the value as an offset.
  66534. */
  66535. setUInt8(entry: number, byteOffset?: number): void;
  66536. /**
  66537. * Gets an UInt32 in the array buffer
  66538. * @param entry
  66539. * @param byteOffset If defined, specifies where to set the value as an offset.
  66540. */
  66541. getUInt32(byteOffset: number): number;
  66542. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  66543. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  66544. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  66545. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  66546. /**
  66547. * Stores a Float32 in the array buffer
  66548. * @param entry
  66549. */
  66550. setFloat32(entry: number, byteOffset?: number): void;
  66551. /**
  66552. * Stores an UInt32 in the array buffer
  66553. * @param entry
  66554. * @param byteOffset If defined, specifies where to set the value as an offset.
  66555. */
  66556. setUInt32(entry: number, byteOffset?: number): void;
  66557. }
  66558. }
  66559. declare module BABYLON.GLTF2.Exporter {
  66560. /**
  66561. * @hidden
  66562. * Interface to store animation data.
  66563. */
  66564. export interface _IAnimationData {
  66565. /**
  66566. * Keyframe data.
  66567. */
  66568. inputs: number[];
  66569. /**
  66570. * Value data.
  66571. */
  66572. outputs: number[][];
  66573. /**
  66574. * Animation interpolation data.
  66575. */
  66576. samplerInterpolation: AnimationSamplerInterpolation;
  66577. /**
  66578. * Minimum keyframe value.
  66579. */
  66580. inputsMin: number;
  66581. /**
  66582. * Maximum keyframe value.
  66583. */
  66584. inputsMax: number;
  66585. }
  66586. /**
  66587. * @hidden
  66588. */
  66589. export interface _IAnimationInfo {
  66590. /**
  66591. * The target channel for the animation
  66592. */
  66593. animationChannelTargetPath: AnimationChannelTargetPath;
  66594. /**
  66595. * The glTF accessor type for the data.
  66596. */
  66597. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  66598. /**
  66599. * Specifies if quaternions should be used.
  66600. */
  66601. useQuaternion: boolean;
  66602. }
  66603. /**
  66604. * @hidden
  66605. * Utility class for generating glTF animation data from BabylonJS.
  66606. */
  66607. export class _GLTFAnimation {
  66608. /**
  66609. * @ignore
  66610. *
  66611. * Creates glTF channel animation from BabylonJS animation.
  66612. * @param babylonTransformNode - BabylonJS mesh.
  66613. * @param animation - animation.
  66614. * @param animationChannelTargetPath - The target animation channel.
  66615. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  66616. * @param useQuaternion - Specifies if quaternions are used.
  66617. * @returns nullable IAnimationData
  66618. */
  66619. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  66620. private static _DeduceAnimationInfo;
  66621. /**
  66622. * @ignore
  66623. * Create node animations from the transform node animations
  66624. * @param babylonNode
  66625. * @param runtimeGLTFAnimation
  66626. * @param idleGLTFAnimations
  66627. * @param nodeMap
  66628. * @param nodes
  66629. * @param binaryWriter
  66630. * @param bufferViews
  66631. * @param accessors
  66632. * @param convertToRightHandedSystem
  66633. */
  66634. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  66635. [key: number]: number;
  66636. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  66637. /**
  66638. * @ignore
  66639. * Create node animations from the animation groups
  66640. * @param babylonScene
  66641. * @param glTFAnimations
  66642. * @param nodeMap
  66643. * @param nodes
  66644. * @param binaryWriter
  66645. * @param bufferViews
  66646. * @param accessors
  66647. * @param convertToRightHandedSystem
  66648. */
  66649. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  66650. [key: number]: number;
  66651. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  66652. private static AddAnimation;
  66653. /**
  66654. * Create a baked animation
  66655. * @param babylonTransformNode BabylonJS mesh
  66656. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  66657. * @param animationChannelTargetPath animation target channel
  66658. * @param minFrame minimum animation frame
  66659. * @param maxFrame maximum animation frame
  66660. * @param fps frames per second of the animation
  66661. * @param inputs input key frames of the animation
  66662. * @param outputs output key frame data of the animation
  66663. * @param convertToRightHandedSystem converts the values to right-handed
  66664. * @param useQuaternion specifies if quaternions should be used
  66665. */
  66666. private static _CreateBakedAnimation;
  66667. private static _ConvertFactorToVector3OrQuaternion;
  66668. private static _SetInterpolatedValue;
  66669. /**
  66670. * Creates linear animation from the animation key frames
  66671. * @param babylonTransformNode BabylonJS mesh
  66672. * @param animation BabylonJS animation
  66673. * @param animationChannelTargetPath The target animation channel
  66674. * @param frameDelta The difference between the last and first frame of the animation
  66675. * @param inputs Array to store the key frame times
  66676. * @param outputs Array to store the key frame data
  66677. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  66678. * @param useQuaternion Specifies if quaternions are used in the animation
  66679. */
  66680. private static _CreateLinearOrStepAnimation;
  66681. /**
  66682. * Creates cubic spline animation from the animation key frames
  66683. * @param babylonTransformNode BabylonJS mesh
  66684. * @param animation BabylonJS animation
  66685. * @param animationChannelTargetPath The target animation channel
  66686. * @param frameDelta The difference between the last and first frame of the animation
  66687. * @param inputs Array to store the key frame times
  66688. * @param outputs Array to store the key frame data
  66689. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  66690. * @param useQuaternion Specifies if quaternions are used in the animation
  66691. */
  66692. private static _CreateCubicSplineAnimation;
  66693. private static _GetBasePositionRotationOrScale;
  66694. /**
  66695. * Adds a key frame value
  66696. * @param keyFrame
  66697. * @param animation
  66698. * @param outputs
  66699. * @param animationChannelTargetPath
  66700. * @param basePositionRotationOrScale
  66701. * @param convertToRightHandedSystem
  66702. * @param useQuaternion
  66703. */
  66704. private static _AddKeyframeValue;
  66705. /**
  66706. * Determine the interpolation based on the key frames
  66707. * @param keyFrames
  66708. * @param animationChannelTargetPath
  66709. * @param useQuaternion
  66710. */
  66711. private static _DeduceInterpolation;
  66712. /**
  66713. * Adds an input tangent or output tangent to the output data
  66714. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  66715. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  66716. * @param outputs The animation data by keyframe
  66717. * @param animationChannelTargetPath The target animation channel
  66718. * @param interpolation The interpolation type
  66719. * @param keyFrame The key frame with the animation data
  66720. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  66721. * @param useQuaternion Specifies if quaternions are used
  66722. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  66723. */
  66724. private static AddSplineTangent;
  66725. /**
  66726. * Get the minimum and maximum key frames' frame values
  66727. * @param keyFrames animation key frames
  66728. * @returns the minimum and maximum key frame value
  66729. */
  66730. private static calculateMinMaxKeyFrames;
  66731. }
  66732. }
  66733. declare module BABYLON.GLTF2.Exporter {
  66734. /** @hidden */
  66735. export var textureTransformPixelShader: {
  66736. name: string;
  66737. shader: string;
  66738. };
  66739. }
  66740. declare module BABYLON.GLTF2.Exporter.Extensions {
  66741. /**
  66742. * @hidden
  66743. */
  66744. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  66745. /** Name of this extension */
  66746. readonly name: string;
  66747. /** Defines whether this extension is enabled */
  66748. enabled: boolean;
  66749. /** Defines whether this extension is required */
  66750. required: boolean;
  66751. /** Reference to the glTF exporter */
  66752. private _exporter;
  66753. constructor(exporter: _Exporter);
  66754. dispose(): void;
  66755. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  66756. /**
  66757. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  66758. * @param babylonTexture
  66759. * @param offset
  66760. * @param rotation
  66761. * @param scale
  66762. * @param scene
  66763. */
  66764. private _textureTransformTextureAsync;
  66765. }
  66766. }
  66767. declare module BABYLON.GLTF2.Exporter.Extensions {
  66768. /**
  66769. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  66770. */
  66771. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  66772. /** The name of this extension. */
  66773. readonly name: string;
  66774. /** Defines whether this extension is enabled. */
  66775. enabled: boolean;
  66776. /** Defines whether this extension is required */
  66777. required: boolean;
  66778. /** Reference to the glTF exporter */
  66779. private _exporter;
  66780. private _lights;
  66781. /** @hidden */
  66782. constructor(exporter: _Exporter);
  66783. /** @hidden */
  66784. dispose(): void;
  66785. /** @hidden */
  66786. onExporting(): void;
  66787. /**
  66788. * Define this method to modify the default behavior when exporting a node
  66789. * @param context The context when exporting the node
  66790. * @param node glTF node
  66791. * @param babylonNode BabylonJS node
  66792. * @returns nullable INode promise
  66793. */
  66794. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  66795. }
  66796. }
  66797. declare module BABYLON {
  66798. /**
  66799. * Class for generating STL data from a Babylon scene.
  66800. */
  66801. export class STLExport {
  66802. /**
  66803. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  66804. * @param meshes list defines the mesh to serialize
  66805. * @param download triggers the automatic download of the file.
  66806. * @param fileName changes the downloads fileName.
  66807. * @param binary changes the STL to a binary type.
  66808. * @param isLittleEndian toggle for binary type exporter.
  66809. * @returns the STL as UTF8 string
  66810. */
  66811. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  66812. }
  66813. }
  66814. /**
  66815. * @ignoreChildren
  66816. * @ignore
  66817. */
  66818. declare module "babylonjs-gltf2interface" {
  66819. export = BABYLON.GLTF2;
  66820. }
  66821. /**
  66822. * Module for glTF 2.0 Interface
  66823. * @ignoreChildren
  66824. * @ignore
  66825. */
  66826. declare module BABYLON.GLTF2 {
  66827. /**
  66828. * The datatype of the components in the attribute
  66829. */
  66830. const enum AccessorComponentType {
  66831. /**
  66832. * Byte
  66833. */
  66834. BYTE = 5120,
  66835. /**
  66836. * Unsigned Byte
  66837. */
  66838. UNSIGNED_BYTE = 5121,
  66839. /**
  66840. * Short
  66841. */
  66842. SHORT = 5122,
  66843. /**
  66844. * Unsigned Short
  66845. */
  66846. UNSIGNED_SHORT = 5123,
  66847. /**
  66848. * Unsigned Int
  66849. */
  66850. UNSIGNED_INT = 5125,
  66851. /**
  66852. * Float
  66853. */
  66854. FLOAT = 5126,
  66855. }
  66856. /**
  66857. * Specifies if the attirbute is a scalar, vector, or matrix
  66858. */
  66859. const enum AccessorType {
  66860. /**
  66861. * Scalar
  66862. */
  66863. SCALAR = "SCALAR",
  66864. /**
  66865. * Vector2
  66866. */
  66867. VEC2 = "VEC2",
  66868. /**
  66869. * Vector3
  66870. */
  66871. VEC3 = "VEC3",
  66872. /**
  66873. * Vector4
  66874. */
  66875. VEC4 = "VEC4",
  66876. /**
  66877. * Matrix2x2
  66878. */
  66879. MAT2 = "MAT2",
  66880. /**
  66881. * Matrix3x3
  66882. */
  66883. MAT3 = "MAT3",
  66884. /**
  66885. * Matrix4x4
  66886. */
  66887. MAT4 = "MAT4",
  66888. }
  66889. /**
  66890. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  66891. */
  66892. const enum AnimationChannelTargetPath {
  66893. /**
  66894. * Translation
  66895. */
  66896. TRANSLATION = "translation",
  66897. /**
  66898. * Rotation
  66899. */
  66900. ROTATION = "rotation",
  66901. /**
  66902. * Scale
  66903. */
  66904. SCALE = "scale",
  66905. /**
  66906. * Weights
  66907. */
  66908. WEIGHTS = "weights",
  66909. }
  66910. /**
  66911. * Interpolation algorithm
  66912. */
  66913. const enum AnimationSamplerInterpolation {
  66914. /**
  66915. * The animated values are linearly interpolated between keyframes
  66916. */
  66917. LINEAR = "LINEAR",
  66918. /**
  66919. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  66920. */
  66921. STEP = "STEP",
  66922. /**
  66923. * The animation's interpolation is computed using a cubic spline with specified tangents
  66924. */
  66925. CUBICSPLINE = "CUBICSPLINE",
  66926. }
  66927. /**
  66928. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  66929. */
  66930. const enum CameraType {
  66931. /**
  66932. * A perspective camera containing properties to create a perspective projection matrix
  66933. */
  66934. PERSPECTIVE = "perspective",
  66935. /**
  66936. * An orthographic camera containing properties to create an orthographic projection matrix
  66937. */
  66938. ORTHOGRAPHIC = "orthographic",
  66939. }
  66940. /**
  66941. * The mime-type of the image
  66942. */
  66943. const enum ImageMimeType {
  66944. /**
  66945. * JPEG Mime-type
  66946. */
  66947. JPEG = "image/jpeg",
  66948. /**
  66949. * PNG Mime-type
  66950. */
  66951. PNG = "image/png",
  66952. }
  66953. /**
  66954. * The alpha rendering mode of the material
  66955. */
  66956. const enum MaterialAlphaMode {
  66957. /**
  66958. * The alpha value is ignored and the rendered output is fully opaque
  66959. */
  66960. OPAQUE = "OPAQUE",
  66961. /**
  66962. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  66963. */
  66964. MASK = "MASK",
  66965. /**
  66966. * 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)
  66967. */
  66968. BLEND = "BLEND",
  66969. }
  66970. /**
  66971. * The type of the primitives to render
  66972. */
  66973. const enum MeshPrimitiveMode {
  66974. /**
  66975. * Points
  66976. */
  66977. POINTS = 0,
  66978. /**
  66979. * Lines
  66980. */
  66981. LINES = 1,
  66982. /**
  66983. * Line Loop
  66984. */
  66985. LINE_LOOP = 2,
  66986. /**
  66987. * Line Strip
  66988. */
  66989. LINE_STRIP = 3,
  66990. /**
  66991. * Triangles
  66992. */
  66993. TRIANGLES = 4,
  66994. /**
  66995. * Triangle Strip
  66996. */
  66997. TRIANGLE_STRIP = 5,
  66998. /**
  66999. * Triangle Fan
  67000. */
  67001. TRIANGLE_FAN = 6,
  67002. }
  67003. /**
  67004. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  67005. */
  67006. const enum TextureMagFilter {
  67007. /**
  67008. * Nearest
  67009. */
  67010. NEAREST = 9728,
  67011. /**
  67012. * Linear
  67013. */
  67014. LINEAR = 9729,
  67015. }
  67016. /**
  67017. * Minification filter. All valid values correspond to WebGL enums
  67018. */
  67019. const enum TextureMinFilter {
  67020. /**
  67021. * Nearest
  67022. */
  67023. NEAREST = 9728,
  67024. /**
  67025. * Linear
  67026. */
  67027. LINEAR = 9729,
  67028. /**
  67029. * Nearest Mip-Map Nearest
  67030. */
  67031. NEAREST_MIPMAP_NEAREST = 9984,
  67032. /**
  67033. * Linear Mipmap Nearest
  67034. */
  67035. LINEAR_MIPMAP_NEAREST = 9985,
  67036. /**
  67037. * Nearest Mipmap Linear
  67038. */
  67039. NEAREST_MIPMAP_LINEAR = 9986,
  67040. /**
  67041. * Linear Mipmap Linear
  67042. */
  67043. LINEAR_MIPMAP_LINEAR = 9987,
  67044. }
  67045. /**
  67046. * S (U) wrapping mode. All valid values correspond to WebGL enums
  67047. */
  67048. const enum TextureWrapMode {
  67049. /**
  67050. * Clamp to Edge
  67051. */
  67052. CLAMP_TO_EDGE = 33071,
  67053. /**
  67054. * Mirrored Repeat
  67055. */
  67056. MIRRORED_REPEAT = 33648,
  67057. /**
  67058. * Repeat
  67059. */
  67060. REPEAT = 10497,
  67061. }
  67062. /**
  67063. * glTF Property
  67064. */
  67065. interface IProperty {
  67066. /**
  67067. * Dictionary object with extension-specific objects
  67068. */
  67069. extensions?: {
  67070. [key: string]: any;
  67071. };
  67072. /**
  67073. * Application-Specific data
  67074. */
  67075. extras?: any;
  67076. }
  67077. /**
  67078. * glTF Child of Root Property
  67079. */
  67080. interface IChildRootProperty extends IProperty {
  67081. /**
  67082. * The user-defined name of this object
  67083. */
  67084. name?: string;
  67085. }
  67086. /**
  67087. * Indices of those attributes that deviate from their initialization value
  67088. */
  67089. interface IAccessorSparseIndices extends IProperty {
  67090. /**
  67091. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  67092. */
  67093. bufferView: number;
  67094. /**
  67095. * The offset relative to the start of the bufferView in bytes. Must be aligned
  67096. */
  67097. byteOffset?: number;
  67098. /**
  67099. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  67100. */
  67101. componentType: AccessorComponentType;
  67102. }
  67103. /**
  67104. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  67105. */
  67106. interface IAccessorSparseValues extends IProperty {
  67107. /**
  67108. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  67109. */
  67110. bufferView: number;
  67111. /**
  67112. * The offset relative to the start of the bufferView in bytes. Must be aligned
  67113. */
  67114. byteOffset?: number;
  67115. }
  67116. /**
  67117. * Sparse storage of attributes that deviate from their initialization value
  67118. */
  67119. interface IAccessorSparse extends IProperty {
  67120. /**
  67121. * The number of attributes encoded in this sparse accessor
  67122. */
  67123. count: number;
  67124. /**
  67125. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  67126. */
  67127. indices: IAccessorSparseIndices;
  67128. /**
  67129. * 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
  67130. */
  67131. values: IAccessorSparseValues;
  67132. }
  67133. /**
  67134. * 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
  67135. */
  67136. interface IAccessor extends IChildRootProperty {
  67137. /**
  67138. * The index of the bufferview
  67139. */
  67140. bufferView?: number;
  67141. /**
  67142. * The offset relative to the start of the bufferView in bytes
  67143. */
  67144. byteOffset?: number;
  67145. /**
  67146. * The datatype of components in the attribute
  67147. */
  67148. componentType: AccessorComponentType;
  67149. /**
  67150. * Specifies whether integer data values should be normalized
  67151. */
  67152. normalized?: boolean;
  67153. /**
  67154. * The number of attributes referenced by this accessor
  67155. */
  67156. count: number;
  67157. /**
  67158. * Specifies if the attribute is a scalar, vector, or matrix
  67159. */
  67160. type: AccessorType;
  67161. /**
  67162. * Maximum value of each component in this attribute
  67163. */
  67164. max?: number[];
  67165. /**
  67166. * Minimum value of each component in this attribute
  67167. */
  67168. min?: number[];
  67169. /**
  67170. * Sparse storage of attributes that deviate from their initialization value
  67171. */
  67172. sparse?: IAccessorSparse;
  67173. }
  67174. /**
  67175. * Targets an animation's sampler at a node's property
  67176. */
  67177. interface IAnimationChannel extends IProperty {
  67178. /**
  67179. * The index of a sampler in this animation used to compute the value for the target
  67180. */
  67181. sampler: number;
  67182. /**
  67183. * The index of the node and TRS property to target
  67184. */
  67185. target: IAnimationChannelTarget;
  67186. }
  67187. /**
  67188. * The index of the node and TRS property that an animation channel targets
  67189. */
  67190. interface IAnimationChannelTarget extends IProperty {
  67191. /**
  67192. * The index of the node to target
  67193. */
  67194. node: number;
  67195. /**
  67196. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  67197. */
  67198. path: AnimationChannelTargetPath;
  67199. }
  67200. /**
  67201. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  67202. */
  67203. interface IAnimationSampler extends IProperty {
  67204. /**
  67205. * The index of an accessor containing keyframe input values, e.g., time
  67206. */
  67207. input: number;
  67208. /**
  67209. * Interpolation algorithm
  67210. */
  67211. interpolation?: AnimationSamplerInterpolation;
  67212. /**
  67213. * The index of an accessor, containing keyframe output values
  67214. */
  67215. output: number;
  67216. }
  67217. /**
  67218. * A keyframe animation
  67219. */
  67220. interface IAnimation extends IChildRootProperty {
  67221. /**
  67222. * An array of channels, each of which targets an animation's sampler at a node's property
  67223. */
  67224. channels: IAnimationChannel[];
  67225. /**
  67226. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  67227. */
  67228. samplers: IAnimationSampler[];
  67229. }
  67230. /**
  67231. * Metadata about the glTF asset
  67232. */
  67233. interface IAsset extends IChildRootProperty {
  67234. /**
  67235. * A copyright message suitable for display to credit the content creator
  67236. */
  67237. copyright?: string;
  67238. /**
  67239. * Tool that generated this glTF model. Useful for debugging
  67240. */
  67241. generator?: string;
  67242. /**
  67243. * The glTF version that this asset targets
  67244. */
  67245. version: string;
  67246. /**
  67247. * The minimum glTF version that this asset targets
  67248. */
  67249. minVersion?: string;
  67250. }
  67251. /**
  67252. * A buffer points to binary geometry, animation, or skins
  67253. */
  67254. interface IBuffer extends IChildRootProperty {
  67255. /**
  67256. * 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
  67257. */
  67258. uri?: string;
  67259. /**
  67260. * The length of the buffer in bytes
  67261. */
  67262. byteLength: number;
  67263. }
  67264. /**
  67265. * A view into a buffer generally representing a subset of the buffer
  67266. */
  67267. interface IBufferView extends IChildRootProperty {
  67268. /**
  67269. * The index of the buffer
  67270. */
  67271. buffer: number;
  67272. /**
  67273. * The offset into the buffer in bytes
  67274. */
  67275. byteOffset?: number;
  67276. /**
  67277. * The lenth of the bufferView in bytes
  67278. */
  67279. byteLength: number;
  67280. /**
  67281. * The stride, in bytes
  67282. */
  67283. byteStride?: number;
  67284. }
  67285. /**
  67286. * An orthographic camera containing properties to create an orthographic projection matrix
  67287. */
  67288. interface ICameraOrthographic extends IProperty {
  67289. /**
  67290. * The floating-point horizontal magnification of the view. Must not be zero
  67291. */
  67292. xmag: number;
  67293. /**
  67294. * The floating-point vertical magnification of the view. Must not be zero
  67295. */
  67296. ymag: number;
  67297. /**
  67298. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  67299. */
  67300. zfar: number;
  67301. /**
  67302. * The floating-point distance to the near clipping plane
  67303. */
  67304. znear: number;
  67305. }
  67306. /**
  67307. * A perspective camera containing properties to create a perspective projection matrix
  67308. */
  67309. interface ICameraPerspective extends IProperty {
  67310. /**
  67311. * The floating-point aspect ratio of the field of view
  67312. */
  67313. aspectRatio?: number;
  67314. /**
  67315. * The floating-point vertical field of view in radians
  67316. */
  67317. yfov: number;
  67318. /**
  67319. * The floating-point distance to the far clipping plane
  67320. */
  67321. zfar?: number;
  67322. /**
  67323. * The floating-point distance to the near clipping plane
  67324. */
  67325. znear: number;
  67326. }
  67327. /**
  67328. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  67329. */
  67330. interface ICamera extends IChildRootProperty {
  67331. /**
  67332. * An orthographic camera containing properties to create an orthographic projection matrix
  67333. */
  67334. orthographic?: ICameraOrthographic;
  67335. /**
  67336. * A perspective camera containing properties to create a perspective projection matrix
  67337. */
  67338. perspective?: ICameraPerspective;
  67339. /**
  67340. * Specifies if the camera uses a perspective or orthographic projection
  67341. */
  67342. type: CameraType;
  67343. }
  67344. /**
  67345. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  67346. */
  67347. interface IImage extends IChildRootProperty {
  67348. /**
  67349. * 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
  67350. */
  67351. uri?: string;
  67352. /**
  67353. * The image's MIME type
  67354. */
  67355. mimeType?: ImageMimeType;
  67356. /**
  67357. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  67358. */
  67359. bufferView?: number;
  67360. }
  67361. /**
  67362. * Material Normal Texture Info
  67363. */
  67364. interface IMaterialNormalTextureInfo extends ITextureInfo {
  67365. /**
  67366. * The scalar multiplier applied to each normal vector of the normal texture
  67367. */
  67368. scale?: number;
  67369. }
  67370. /**
  67371. * Material Occlusion Texture Info
  67372. */
  67373. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  67374. /**
  67375. * A scalar multiplier controlling the amount of occlusion applied
  67376. */
  67377. strength?: number;
  67378. }
  67379. /**
  67380. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  67381. */
  67382. interface IMaterialPbrMetallicRoughness {
  67383. /**
  67384. * The material's base color factor
  67385. */
  67386. baseColorFactor?: number[];
  67387. /**
  67388. * The base color texture
  67389. */
  67390. baseColorTexture?: ITextureInfo;
  67391. /**
  67392. * The metalness of the material
  67393. */
  67394. metallicFactor?: number;
  67395. /**
  67396. * The roughness of the material
  67397. */
  67398. roughnessFactor?: number;
  67399. /**
  67400. * The metallic-roughness texture
  67401. */
  67402. metallicRoughnessTexture?: ITextureInfo;
  67403. }
  67404. /**
  67405. * The material appearance of a primitive
  67406. */
  67407. interface IMaterial extends IChildRootProperty {
  67408. /**
  67409. * 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
  67410. */
  67411. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  67412. /**
  67413. * The normal map texture
  67414. */
  67415. normalTexture?: IMaterialNormalTextureInfo;
  67416. /**
  67417. * The occlusion map texture
  67418. */
  67419. occlusionTexture?: IMaterialOcclusionTextureInfo;
  67420. /**
  67421. * The emissive map texture
  67422. */
  67423. emissiveTexture?: ITextureInfo;
  67424. /**
  67425. * 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
  67426. */
  67427. emissiveFactor?: number[];
  67428. /**
  67429. * The alpha rendering mode of the material
  67430. */
  67431. alphaMode?: MaterialAlphaMode;
  67432. /**
  67433. * The alpha cutoff value of the material
  67434. */
  67435. alphaCutoff?: number;
  67436. /**
  67437. * Specifies whether the material is double sided
  67438. */
  67439. doubleSided?: boolean;
  67440. }
  67441. /**
  67442. * Geometry to be rendered with the given material
  67443. */
  67444. interface IMeshPrimitive extends IProperty {
  67445. /**
  67446. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  67447. */
  67448. attributes: {
  67449. [name: string]: number;
  67450. };
  67451. /**
  67452. * The index of the accessor that contains the indices
  67453. */
  67454. indices?: number;
  67455. /**
  67456. * The index of the material to apply to this primitive when rendering
  67457. */
  67458. material?: number;
  67459. /**
  67460. * The type of primitives to render. All valid values correspond to WebGL enums
  67461. */
  67462. mode?: MeshPrimitiveMode;
  67463. /**
  67464. * 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
  67465. */
  67466. targets?: {
  67467. [name: string]: number;
  67468. }[];
  67469. }
  67470. /**
  67471. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  67472. */
  67473. interface IMesh extends IChildRootProperty {
  67474. /**
  67475. * An array of primitives, each defining geometry to be rendered with a material
  67476. */
  67477. primitives: IMeshPrimitive[];
  67478. /**
  67479. * Array of weights to be applied to the Morph Targets
  67480. */
  67481. weights?: number[];
  67482. }
  67483. /**
  67484. * A node in the node hierarchy
  67485. */
  67486. interface INode extends IChildRootProperty {
  67487. /**
  67488. * The index of the camera referenced by this node
  67489. */
  67490. camera?: number;
  67491. /**
  67492. * The indices of this node's children
  67493. */
  67494. children?: number[];
  67495. /**
  67496. * The index of the skin referenced by this node
  67497. */
  67498. skin?: number;
  67499. /**
  67500. * A floating-point 4x4 transformation matrix stored in column-major order
  67501. */
  67502. matrix?: number[];
  67503. /**
  67504. * The index of the mesh in this node
  67505. */
  67506. mesh?: number;
  67507. /**
  67508. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  67509. */
  67510. rotation?: number[];
  67511. /**
  67512. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  67513. */
  67514. scale?: number[];
  67515. /**
  67516. * The node's translation along the x, y, and z axes
  67517. */
  67518. translation?: number[];
  67519. /**
  67520. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  67521. */
  67522. weights?: number[];
  67523. }
  67524. /**
  67525. * Texture sampler properties for filtering and wrapping modes
  67526. */
  67527. interface ISampler extends IChildRootProperty {
  67528. /**
  67529. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  67530. */
  67531. magFilter?: TextureMagFilter;
  67532. /**
  67533. * Minification filter. All valid values correspond to WebGL enums
  67534. */
  67535. minFilter?: TextureMinFilter;
  67536. /**
  67537. * S (U) wrapping mode. All valid values correspond to WebGL enums
  67538. */
  67539. wrapS?: TextureWrapMode;
  67540. /**
  67541. * T (V) wrapping mode. All valid values correspond to WebGL enums
  67542. */
  67543. wrapT?: TextureWrapMode;
  67544. }
  67545. /**
  67546. * The root nodes of a scene
  67547. */
  67548. interface IScene extends IChildRootProperty {
  67549. /**
  67550. * The indices of each root node
  67551. */
  67552. nodes: number[];
  67553. }
  67554. /**
  67555. * Joints and matrices defining a skin
  67556. */
  67557. interface ISkin extends IChildRootProperty {
  67558. /**
  67559. * 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
  67560. */
  67561. inverseBindMatrices?: number;
  67562. /**
  67563. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  67564. */
  67565. skeleton?: number;
  67566. /**
  67567. * 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)
  67568. */
  67569. joints: number[];
  67570. }
  67571. /**
  67572. * A texture and its sampler
  67573. */
  67574. interface ITexture extends IChildRootProperty {
  67575. /**
  67576. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  67577. */
  67578. sampler?: number;
  67579. /**
  67580. * The index of the image used by this texture
  67581. */
  67582. source: number;
  67583. }
  67584. /**
  67585. * Reference to a texture
  67586. */
  67587. interface ITextureInfo extends IProperty {
  67588. /**
  67589. * The index of the texture
  67590. */
  67591. index: number;
  67592. /**
  67593. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  67594. */
  67595. texCoord?: number;
  67596. }
  67597. /**
  67598. * The root object for a glTF asset
  67599. */
  67600. interface IGLTF extends IProperty {
  67601. /**
  67602. * An array of accessors. An accessor is a typed view into a bufferView
  67603. */
  67604. accessors?: IAccessor[];
  67605. /**
  67606. * An array of keyframe animations
  67607. */
  67608. animations?: IAnimation[];
  67609. /**
  67610. * Metadata about the glTF asset
  67611. */
  67612. asset: IAsset;
  67613. /**
  67614. * An array of buffers. A buffer points to binary geometry, animation, or skins
  67615. */
  67616. buffers?: IBuffer[];
  67617. /**
  67618. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  67619. */
  67620. bufferViews?: IBufferView[];
  67621. /**
  67622. * An array of cameras
  67623. */
  67624. cameras?: ICamera[];
  67625. /**
  67626. * Names of glTF extensions used somewhere in this asset
  67627. */
  67628. extensionsUsed?: string[];
  67629. /**
  67630. * Names of glTF extensions required to properly load this asset
  67631. */
  67632. extensionsRequired?: string[];
  67633. /**
  67634. * An array of images. An image defines data used to create a texture
  67635. */
  67636. images?: IImage[];
  67637. /**
  67638. * An array of materials. A material defines the appearance of a primitive
  67639. */
  67640. materials?: IMaterial[];
  67641. /**
  67642. * An array of meshes. A mesh is a set of primitives to be rendered
  67643. */
  67644. meshes?: IMesh[];
  67645. /**
  67646. * An array of nodes
  67647. */
  67648. nodes?: INode[];
  67649. /**
  67650. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  67651. */
  67652. samplers?: ISampler[];
  67653. /**
  67654. * The index of the default scene
  67655. */
  67656. scene?: number;
  67657. /**
  67658. * An array of scenes
  67659. */
  67660. scenes?: IScene[];
  67661. /**
  67662. * An array of skins. A skin is defined by joints and matrices
  67663. */
  67664. skins?: ISkin[];
  67665. /**
  67666. * An array of textures
  67667. */
  67668. textures?: ITexture[];
  67669. }
  67670. /**
  67671. * The glTF validation results
  67672. */
  67673. interface IGLTFValidationResults {
  67674. info: {
  67675. generator: string;
  67676. hasAnimations: boolean;
  67677. hasDefaultScene: boolean;
  67678. hasMaterials: boolean;
  67679. hasMorphTargets: boolean;
  67680. hasSkins: boolean;
  67681. hasTextures: boolean;
  67682. maxAttributesUsed: number;
  67683. primitivesCount: number
  67684. };
  67685. issues: {
  67686. messages: Array<string>;
  67687. numErrors: number;
  67688. numHints: number;
  67689. numInfos: number;
  67690. numWarnings: number;
  67691. truncated: boolean
  67692. };
  67693. mimeType: string;
  67694. uri: string;
  67695. validatedAt: string;
  67696. validatorVersion: string;
  67697. }
  67698. /**
  67699. * The glTF validation options
  67700. */
  67701. interface IGLTFValidationOptions {
  67702. uri?: string;
  67703. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  67704. validateAccessorData?: boolean;
  67705. maxIssues?: number;
  67706. ignoredIssues?: Array<string>;
  67707. severityOverrides?: Object;
  67708. }
  67709. /**
  67710. * The glTF validator object
  67711. */
  67712. interface IGLTFValidator {
  67713. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  67714. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  67715. }
  67716. }
  67717. declare module BABYLON {
  67718. /** @hidden */
  67719. export var cellPixelShader: {
  67720. name: string;
  67721. shader: string;
  67722. };
  67723. }
  67724. declare module BABYLON {
  67725. /** @hidden */
  67726. export var cellVertexShader: {
  67727. name: string;
  67728. shader: string;
  67729. };
  67730. }
  67731. declare module BABYLON {
  67732. export class CellMaterial extends BABYLON.PushMaterial {
  67733. private _diffuseTexture;
  67734. diffuseTexture: BABYLON.BaseTexture;
  67735. diffuseColor: BABYLON.Color3;
  67736. _computeHighLevel: boolean;
  67737. computeHighLevel: boolean;
  67738. private _disableLighting;
  67739. disableLighting: boolean;
  67740. private _maxSimultaneousLights;
  67741. maxSimultaneousLights: number;
  67742. private _renderId;
  67743. constructor(name: string, scene: BABYLON.Scene);
  67744. needAlphaBlending(): boolean;
  67745. needAlphaTesting(): boolean;
  67746. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67747. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67748. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67749. getAnimatables(): BABYLON.IAnimatable[];
  67750. getActiveTextures(): BABYLON.BaseTexture[];
  67751. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67752. dispose(forceDisposeEffect?: boolean): void;
  67753. getClassName(): string;
  67754. clone(name: string): CellMaterial;
  67755. serialize(): any;
  67756. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  67757. }
  67758. }
  67759. declare module BABYLON {
  67760. export class CustomShaderStructure {
  67761. FragmentStore: string;
  67762. VertexStore: string;
  67763. constructor();
  67764. }
  67765. export class ShaderSpecialParts {
  67766. constructor();
  67767. Fragment_Begin: string;
  67768. Fragment_Definitions: string;
  67769. Fragment_MainBegin: string;
  67770. Fragment_Custom_Diffuse: string;
  67771. Fragment_Before_Lights: string;
  67772. Fragment_Before_Fog: string;
  67773. Fragment_Custom_Alpha: string;
  67774. Fragment_Before_FragColor: string;
  67775. Vertex_Begin: string;
  67776. Vertex_Definitions: string;
  67777. Vertex_MainBegin: string;
  67778. Vertex_Before_PositionUpdated: string;
  67779. Vertex_Before_NormalUpdated: string;
  67780. Vertex_MainEnd: string;
  67781. }
  67782. export class CustomMaterial extends BABYLON.StandardMaterial {
  67783. static ShaderIndexer: number;
  67784. CustomParts: ShaderSpecialParts;
  67785. _isCreatedShader: boolean;
  67786. _createdShaderName: string;
  67787. _customUniform: string[];
  67788. _newUniforms: string[];
  67789. _newUniformInstances: any[];
  67790. _newSamplerInstances: BABYLON.Texture[];
  67791. FragmentShader: string;
  67792. VertexShader: string;
  67793. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  67794. ReviewUniform(name: string, arr: string[]): string[];
  67795. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  67796. constructor(name: string, scene: BABYLON.Scene);
  67797. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  67798. Fragment_Begin(shaderPart: string): CustomMaterial;
  67799. Fragment_Definitions(shaderPart: string): CustomMaterial;
  67800. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  67801. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  67802. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  67803. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  67804. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  67805. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  67806. Vertex_Begin(shaderPart: string): CustomMaterial;
  67807. Vertex_Definitions(shaderPart: string): CustomMaterial;
  67808. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  67809. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  67810. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  67811. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  67812. }
  67813. }
  67814. declare module BABYLON {
  67815. export class ShaderAlebdoParts {
  67816. constructor();
  67817. Fragment_Begin: string;
  67818. Fragment_Definitions: string;
  67819. Fragment_MainBegin: string;
  67820. Fragment_Custom_Albedo: string;
  67821. Fragment_Before_Lights: string;
  67822. Fragment_Custom_MetallicRoughness: string;
  67823. Fragment_Custom_MicroSurface: string;
  67824. Fragment_Before_Fog: string;
  67825. Fragment_Custom_Alpha: string;
  67826. Fragment_Before_FragColor: string;
  67827. Vertex_Begin: string;
  67828. Vertex_Definitions: string;
  67829. Vertex_MainBegin: string;
  67830. Vertex_Before_PositionUpdated: string;
  67831. Vertex_Before_NormalUpdated: string;
  67832. Vertex_MainEnd: string;
  67833. }
  67834. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  67835. static ShaderIndexer: number;
  67836. CustomParts: ShaderAlebdoParts;
  67837. _isCreatedShader: boolean;
  67838. _createdShaderName: string;
  67839. _customUniform: string[];
  67840. _newUniforms: string[];
  67841. _newUniformInstances: any[];
  67842. _newSamplerInstances: BABYLON.Texture[];
  67843. FragmentShader: string;
  67844. VertexShader: string;
  67845. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  67846. ReviewUniform(name: string, arr: string[]): string[];
  67847. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  67848. constructor(name: string, scene: BABYLON.Scene);
  67849. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  67850. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  67851. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  67852. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  67853. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  67854. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  67855. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  67856. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  67857. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  67858. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  67859. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  67860. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  67861. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  67862. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  67863. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  67864. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  67865. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  67866. }
  67867. }
  67868. declare module BABYLON {
  67869. /** @hidden */
  67870. export var firePixelShader: {
  67871. name: string;
  67872. shader: string;
  67873. };
  67874. }
  67875. declare module BABYLON {
  67876. /** @hidden */
  67877. export var fireVertexShader: {
  67878. name: string;
  67879. shader: string;
  67880. };
  67881. }
  67882. declare module BABYLON {
  67883. export class FireMaterial extends BABYLON.PushMaterial {
  67884. private _diffuseTexture;
  67885. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  67886. private _distortionTexture;
  67887. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  67888. private _opacityTexture;
  67889. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  67890. diffuseColor: BABYLON.Color3;
  67891. speed: number;
  67892. private _scaledDiffuse;
  67893. private _renderId;
  67894. private _lastTime;
  67895. constructor(name: string, scene: BABYLON.Scene);
  67896. needAlphaBlending(): boolean;
  67897. needAlphaTesting(): boolean;
  67898. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67899. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67900. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67901. getAnimatables(): BABYLON.IAnimatable[];
  67902. getActiveTextures(): BABYLON.BaseTexture[];
  67903. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67904. getClassName(): string;
  67905. dispose(forceDisposeEffect?: boolean): void;
  67906. clone(name: string): FireMaterial;
  67907. serialize(): any;
  67908. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  67909. }
  67910. }
  67911. declare module BABYLON {
  67912. /** @hidden */
  67913. export var furPixelShader: {
  67914. name: string;
  67915. shader: string;
  67916. };
  67917. }
  67918. declare module BABYLON {
  67919. /** @hidden */
  67920. export var furVertexShader: {
  67921. name: string;
  67922. shader: string;
  67923. };
  67924. }
  67925. declare module BABYLON {
  67926. export class FurMaterial extends BABYLON.PushMaterial {
  67927. private _diffuseTexture;
  67928. diffuseTexture: BABYLON.BaseTexture;
  67929. private _heightTexture;
  67930. heightTexture: BABYLON.BaseTexture;
  67931. diffuseColor: BABYLON.Color3;
  67932. furLength: number;
  67933. furAngle: number;
  67934. furColor: BABYLON.Color3;
  67935. furOffset: number;
  67936. furSpacing: number;
  67937. furGravity: BABYLON.Vector3;
  67938. furSpeed: number;
  67939. furDensity: number;
  67940. furOcclusion: number;
  67941. furTexture: BABYLON.DynamicTexture;
  67942. private _disableLighting;
  67943. disableLighting: boolean;
  67944. private _maxSimultaneousLights;
  67945. maxSimultaneousLights: number;
  67946. highLevelFur: boolean;
  67947. _meshes: BABYLON.AbstractMesh[];
  67948. private _renderId;
  67949. private _furTime;
  67950. constructor(name: string, scene: BABYLON.Scene);
  67951. furTime: number;
  67952. needAlphaBlending(): boolean;
  67953. needAlphaTesting(): boolean;
  67954. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  67955. updateFur(): void;
  67956. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  67957. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  67958. getAnimatables(): BABYLON.IAnimatable[];
  67959. getActiveTextures(): BABYLON.BaseTexture[];
  67960. hasTexture(texture: BABYLON.BaseTexture): boolean;
  67961. dispose(forceDisposeEffect?: boolean): void;
  67962. clone(name: string): FurMaterial;
  67963. serialize(): any;
  67964. getClassName(): string;
  67965. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  67966. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  67967. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  67968. }
  67969. }
  67970. declare module BABYLON {
  67971. /** @hidden */
  67972. export var gradientPixelShader: {
  67973. name: string;
  67974. shader: string;
  67975. };
  67976. }
  67977. declare module BABYLON {
  67978. /** @hidden */
  67979. export var gradientVertexShader: {
  67980. name: string;
  67981. shader: string;
  67982. };
  67983. }
  67984. declare module BABYLON {
  67985. export class GradientMaterial extends BABYLON.PushMaterial {
  67986. private _maxSimultaneousLights;
  67987. maxSimultaneousLights: number;
  67988. topColor: BABYLON.Color3;
  67989. topColorAlpha: number;
  67990. bottomColor: BABYLON.Color3;
  67991. bottomColorAlpha: number;
  67992. offset: number;
  67993. scale: number;
  67994. smoothness: number;
  67995. private _disableLighting;
  67996. disableLighting: boolean;
  67997. private _renderId;
  67998. constructor(name: string, scene: BABYLON.Scene);
  67999. needAlphaBlending(): boolean;
  68000. needAlphaTesting(): boolean;
  68001. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68002. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68003. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68004. getAnimatables(): BABYLON.IAnimatable[];
  68005. dispose(forceDisposeEffect?: boolean): void;
  68006. clone(name: string): GradientMaterial;
  68007. serialize(): any;
  68008. getClassName(): string;
  68009. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  68010. }
  68011. }
  68012. declare module BABYLON {
  68013. /** @hidden */
  68014. export var gridPixelShader: {
  68015. name: string;
  68016. shader: string;
  68017. };
  68018. }
  68019. declare module BABYLON {
  68020. /** @hidden */
  68021. export var gridVertexShader: {
  68022. name: string;
  68023. shader: string;
  68024. };
  68025. }
  68026. declare module BABYLON {
  68027. /**
  68028. * The grid materials allows you to wrap any shape with a grid.
  68029. * Colors are customizable.
  68030. */
  68031. export class GridMaterial extends BABYLON.PushMaterial {
  68032. /**
  68033. * Main color of the grid (e.g. between lines)
  68034. */
  68035. mainColor: BABYLON.Color3;
  68036. /**
  68037. * Color of the grid lines.
  68038. */
  68039. lineColor: BABYLON.Color3;
  68040. /**
  68041. * The scale of the grid compared to unit.
  68042. */
  68043. gridRatio: number;
  68044. /**
  68045. * Allows setting an offset for the grid lines.
  68046. */
  68047. gridOffset: BABYLON.Vector3;
  68048. /**
  68049. * The frequency of thicker lines.
  68050. */
  68051. majorUnitFrequency: number;
  68052. /**
  68053. * The visibility of minor units in the grid.
  68054. */
  68055. minorUnitVisibility: number;
  68056. /**
  68057. * The grid opacity outside of the lines.
  68058. */
  68059. opacity: number;
  68060. /**
  68061. * Determine RBG output is premultiplied by alpha value.
  68062. */
  68063. preMultiplyAlpha: boolean;
  68064. private _opacityTexture;
  68065. opacityTexture: BABYLON.BaseTexture;
  68066. private _gridControl;
  68067. private _renderId;
  68068. /**
  68069. * constructor
  68070. * @param name The name given to the material in order to identify it afterwards.
  68071. * @param scene The scene the material is used in.
  68072. */
  68073. constructor(name: string, scene: BABYLON.Scene);
  68074. /**
  68075. * Returns wehter or not the grid requires alpha blending.
  68076. */
  68077. needAlphaBlending(): boolean;
  68078. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  68079. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68080. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68081. /**
  68082. * Dispose the material and its associated resources.
  68083. * @param forceDisposeEffect will also dispose the used effect when true
  68084. */
  68085. dispose(forceDisposeEffect?: boolean): void;
  68086. clone(name: string): GridMaterial;
  68087. serialize(): any;
  68088. getClassName(): string;
  68089. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  68090. }
  68091. }
  68092. declare module BABYLON {
  68093. /** @hidden */
  68094. export var lavaPixelShader: {
  68095. name: string;
  68096. shader: string;
  68097. };
  68098. }
  68099. declare module BABYLON {
  68100. /** @hidden */
  68101. export var lavaVertexShader: {
  68102. name: string;
  68103. shader: string;
  68104. };
  68105. }
  68106. declare module BABYLON {
  68107. export class LavaMaterial extends BABYLON.PushMaterial {
  68108. private _diffuseTexture;
  68109. diffuseTexture: BABYLON.BaseTexture;
  68110. noiseTexture: BABYLON.BaseTexture;
  68111. fogColor: BABYLON.Color3;
  68112. speed: number;
  68113. movingSpeed: number;
  68114. lowFrequencySpeed: number;
  68115. fogDensity: number;
  68116. private _lastTime;
  68117. diffuseColor: BABYLON.Color3;
  68118. private _disableLighting;
  68119. disableLighting: boolean;
  68120. private _unlit;
  68121. unlit: boolean;
  68122. private _maxSimultaneousLights;
  68123. maxSimultaneousLights: number;
  68124. private _scaledDiffuse;
  68125. private _renderId;
  68126. constructor(name: string, scene: BABYLON.Scene);
  68127. needAlphaBlending(): boolean;
  68128. needAlphaTesting(): boolean;
  68129. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68130. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68131. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68132. getAnimatables(): BABYLON.IAnimatable[];
  68133. getActiveTextures(): BABYLON.BaseTexture[];
  68134. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68135. dispose(forceDisposeEffect?: boolean): void;
  68136. clone(name: string): LavaMaterial;
  68137. serialize(): any;
  68138. getClassName(): string;
  68139. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  68140. }
  68141. }
  68142. declare module BABYLON {
  68143. /** @hidden */
  68144. export var mixPixelShader: {
  68145. name: string;
  68146. shader: string;
  68147. };
  68148. }
  68149. declare module BABYLON {
  68150. /** @hidden */
  68151. export var mixVertexShader: {
  68152. name: string;
  68153. shader: string;
  68154. };
  68155. }
  68156. declare module BABYLON {
  68157. export class MixMaterial extends BABYLON.PushMaterial {
  68158. /**
  68159. * Mix textures
  68160. */
  68161. private _mixTexture1;
  68162. mixTexture1: BABYLON.BaseTexture;
  68163. private _mixTexture2;
  68164. mixTexture2: BABYLON.BaseTexture;
  68165. /**
  68166. * Diffuse textures
  68167. */
  68168. private _diffuseTexture1;
  68169. diffuseTexture1: BABYLON.Texture;
  68170. private _diffuseTexture2;
  68171. diffuseTexture2: BABYLON.Texture;
  68172. private _diffuseTexture3;
  68173. diffuseTexture3: BABYLON.Texture;
  68174. private _diffuseTexture4;
  68175. diffuseTexture4: BABYLON.Texture;
  68176. private _diffuseTexture5;
  68177. diffuseTexture5: BABYLON.Texture;
  68178. private _diffuseTexture6;
  68179. diffuseTexture6: BABYLON.Texture;
  68180. private _diffuseTexture7;
  68181. diffuseTexture7: BABYLON.Texture;
  68182. private _diffuseTexture8;
  68183. diffuseTexture8: BABYLON.Texture;
  68184. /**
  68185. * Uniforms
  68186. */
  68187. diffuseColor: BABYLON.Color3;
  68188. specularColor: BABYLON.Color3;
  68189. specularPower: number;
  68190. private _disableLighting;
  68191. disableLighting: boolean;
  68192. private _maxSimultaneousLights;
  68193. maxSimultaneousLights: number;
  68194. private _renderId;
  68195. constructor(name: string, scene: BABYLON.Scene);
  68196. needAlphaBlending(): boolean;
  68197. needAlphaTesting(): boolean;
  68198. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68199. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68200. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68201. getAnimatables(): BABYLON.IAnimatable[];
  68202. getActiveTextures(): BABYLON.BaseTexture[];
  68203. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68204. dispose(forceDisposeEffect?: boolean): void;
  68205. clone(name: string): MixMaterial;
  68206. serialize(): any;
  68207. getClassName(): string;
  68208. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  68209. }
  68210. }
  68211. declare module BABYLON {
  68212. /** @hidden */
  68213. export var normalPixelShader: {
  68214. name: string;
  68215. shader: string;
  68216. };
  68217. }
  68218. declare module BABYLON {
  68219. /** @hidden */
  68220. export var normalVertexShader: {
  68221. name: string;
  68222. shader: string;
  68223. };
  68224. }
  68225. declare module BABYLON {
  68226. export class NormalMaterial extends BABYLON.PushMaterial {
  68227. private _diffuseTexture;
  68228. diffuseTexture: BABYLON.BaseTexture;
  68229. diffuseColor: BABYLON.Color3;
  68230. private _disableLighting;
  68231. disableLighting: boolean;
  68232. private _maxSimultaneousLights;
  68233. maxSimultaneousLights: number;
  68234. private _renderId;
  68235. constructor(name: string, scene: BABYLON.Scene);
  68236. needAlphaBlending(): boolean;
  68237. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  68238. needAlphaTesting(): boolean;
  68239. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68240. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68241. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68242. getAnimatables(): BABYLON.IAnimatable[];
  68243. getActiveTextures(): BABYLON.BaseTexture[];
  68244. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68245. dispose(forceDisposeEffect?: boolean): void;
  68246. clone(name: string): NormalMaterial;
  68247. serialize(): any;
  68248. getClassName(): string;
  68249. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  68250. }
  68251. }
  68252. declare module BABYLON {
  68253. /** @hidden */
  68254. export var shadowOnlyPixelShader: {
  68255. name: string;
  68256. shader: string;
  68257. };
  68258. }
  68259. declare module BABYLON {
  68260. /** @hidden */
  68261. export var shadowOnlyVertexShader: {
  68262. name: string;
  68263. shader: string;
  68264. };
  68265. }
  68266. declare module BABYLON {
  68267. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  68268. private _renderId;
  68269. private _activeLight;
  68270. constructor(name: string, scene: BABYLON.Scene);
  68271. shadowColor: BABYLON.Color3;
  68272. needAlphaBlending(): boolean;
  68273. needAlphaTesting(): boolean;
  68274. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68275. activeLight: BABYLON.IShadowLight;
  68276. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68277. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68278. clone(name: string): ShadowOnlyMaterial;
  68279. serialize(): any;
  68280. getClassName(): string;
  68281. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  68282. }
  68283. }
  68284. declare module BABYLON {
  68285. /** @hidden */
  68286. export var simplePixelShader: {
  68287. name: string;
  68288. shader: string;
  68289. };
  68290. }
  68291. declare module BABYLON {
  68292. /** @hidden */
  68293. export var simpleVertexShader: {
  68294. name: string;
  68295. shader: string;
  68296. };
  68297. }
  68298. declare module BABYLON {
  68299. export class SimpleMaterial extends BABYLON.PushMaterial {
  68300. private _diffuseTexture;
  68301. diffuseTexture: BABYLON.BaseTexture;
  68302. diffuseColor: BABYLON.Color3;
  68303. private _disableLighting;
  68304. disableLighting: boolean;
  68305. private _maxSimultaneousLights;
  68306. maxSimultaneousLights: number;
  68307. private _renderId;
  68308. constructor(name: string, scene: BABYLON.Scene);
  68309. needAlphaBlending(): boolean;
  68310. needAlphaTesting(): boolean;
  68311. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68312. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68313. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68314. getAnimatables(): BABYLON.IAnimatable[];
  68315. getActiveTextures(): BABYLON.BaseTexture[];
  68316. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68317. dispose(forceDisposeEffect?: boolean): void;
  68318. clone(name: string): SimpleMaterial;
  68319. serialize(): any;
  68320. getClassName(): string;
  68321. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  68322. }
  68323. }
  68324. declare module BABYLON {
  68325. /** @hidden */
  68326. export var skyPixelShader: {
  68327. name: string;
  68328. shader: string;
  68329. };
  68330. }
  68331. declare module BABYLON {
  68332. /** @hidden */
  68333. export var skyVertexShader: {
  68334. name: string;
  68335. shader: string;
  68336. };
  68337. }
  68338. declare module BABYLON {
  68339. /**
  68340. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  68341. * @see https://doc.babylonjs.com/extensions/sky
  68342. */
  68343. export class SkyMaterial extends BABYLON.PushMaterial {
  68344. /**
  68345. * Defines the overall luminance of sky in interval ]0, 1[.
  68346. */
  68347. luminance: number;
  68348. /**
  68349. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  68350. */
  68351. turbidity: number;
  68352. /**
  68353. * Defines the sky appearance (light intensity).
  68354. */
  68355. rayleigh: number;
  68356. /**
  68357. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  68358. */
  68359. mieCoefficient: number;
  68360. /**
  68361. * Defines the amount of haze particles following the Mie scattering theory.
  68362. */
  68363. mieDirectionalG: number;
  68364. /**
  68365. * Defines the distance of the sun according to the active scene camera.
  68366. */
  68367. distance: number;
  68368. /**
  68369. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  68370. * "inclined".
  68371. */
  68372. inclination: number;
  68373. /**
  68374. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  68375. * an object direction and a reference direction.
  68376. */
  68377. azimuth: number;
  68378. /**
  68379. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  68380. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  68381. */
  68382. sunPosition: BABYLON.Vector3;
  68383. /**
  68384. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  68385. * .sunPosition property.
  68386. */
  68387. useSunPosition: boolean;
  68388. /**
  68389. * Defines an offset vector used to get a horizon offset.
  68390. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  68391. */
  68392. cameraOffset: BABYLON.Vector3;
  68393. private _cameraPosition;
  68394. private _renderId;
  68395. /**
  68396. * Instantiates a new sky material.
  68397. * This material allows to create dynamic and texture free
  68398. * effects for skyboxes by taking care of the atmosphere state.
  68399. * @see https://doc.babylonjs.com/extensions/sky
  68400. * @param name Define the name of the material in the scene
  68401. * @param scene Define the scene the material belong to
  68402. */
  68403. constructor(name: string, scene: BABYLON.Scene);
  68404. /**
  68405. * Specifies if the material will require alpha blending
  68406. * @returns a boolean specifying if alpha blending is needed
  68407. */
  68408. needAlphaBlending(): boolean;
  68409. /**
  68410. * Specifies if this material should be rendered in alpha test mode
  68411. * @returns false as the sky material doesn't need alpha testing.
  68412. */
  68413. needAlphaTesting(): boolean;
  68414. /**
  68415. * Get the texture used for alpha test purpose.
  68416. * @returns null as the sky material has no texture.
  68417. */
  68418. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68419. /**
  68420. * Get if the submesh is ready to be used and all its information available.
  68421. * Child classes can use it to update shaders
  68422. * @param mesh defines the mesh to check
  68423. * @param subMesh defines which submesh to check
  68424. * @param useInstances specifies that instances should be used
  68425. * @returns a boolean indicating that the submesh is ready or not
  68426. */
  68427. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68428. /**
  68429. * Binds the submesh to this material by preparing the effect and shader to draw
  68430. * @param world defines the world transformation matrix
  68431. * @param mesh defines the mesh containing the submesh
  68432. * @param subMesh defines the submesh to bind the material to
  68433. */
  68434. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68435. /**
  68436. * Get the list of animatables in the material.
  68437. * @returns the list of animatables object used in the material
  68438. */
  68439. getAnimatables(): BABYLON.IAnimatable[];
  68440. /**
  68441. * Disposes the material
  68442. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  68443. */
  68444. dispose(forceDisposeEffect?: boolean): void;
  68445. /**
  68446. * Makes a duplicate of the material, and gives it a new name
  68447. * @param name defines the new name for the duplicated material
  68448. * @returns the cloned material
  68449. */
  68450. clone(name: string): SkyMaterial;
  68451. /**
  68452. * Serializes this material in a JSON representation
  68453. * @returns the serialized material object
  68454. */
  68455. serialize(): any;
  68456. /**
  68457. * Gets the current class name of the material e.g. "SkyMaterial"
  68458. * Mainly use in serialization.
  68459. * @returns the class name
  68460. */
  68461. getClassName(): string;
  68462. /**
  68463. * Creates a sky material from parsed material data
  68464. * @param source defines the JSON representation of the material
  68465. * @param scene defines the hosting scene
  68466. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  68467. * @returns a new sky material
  68468. */
  68469. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  68470. }
  68471. }
  68472. declare module BABYLON {
  68473. /** @hidden */
  68474. export var terrainPixelShader: {
  68475. name: string;
  68476. shader: string;
  68477. };
  68478. }
  68479. declare module BABYLON {
  68480. /** @hidden */
  68481. export var terrainVertexShader: {
  68482. name: string;
  68483. shader: string;
  68484. };
  68485. }
  68486. declare module BABYLON {
  68487. export class TerrainMaterial extends BABYLON.PushMaterial {
  68488. private _mixTexture;
  68489. mixTexture: BABYLON.BaseTexture;
  68490. private _diffuseTexture1;
  68491. diffuseTexture1: BABYLON.Texture;
  68492. private _diffuseTexture2;
  68493. diffuseTexture2: BABYLON.Texture;
  68494. private _diffuseTexture3;
  68495. diffuseTexture3: BABYLON.Texture;
  68496. private _bumpTexture1;
  68497. bumpTexture1: BABYLON.Texture;
  68498. private _bumpTexture2;
  68499. bumpTexture2: BABYLON.Texture;
  68500. private _bumpTexture3;
  68501. bumpTexture3: BABYLON.Texture;
  68502. diffuseColor: BABYLON.Color3;
  68503. specularColor: BABYLON.Color3;
  68504. specularPower: number;
  68505. private _disableLighting;
  68506. disableLighting: boolean;
  68507. private _maxSimultaneousLights;
  68508. maxSimultaneousLights: number;
  68509. private _renderId;
  68510. constructor(name: string, scene: BABYLON.Scene);
  68511. needAlphaBlending(): boolean;
  68512. needAlphaTesting(): boolean;
  68513. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68514. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68515. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68516. getAnimatables(): BABYLON.IAnimatable[];
  68517. getActiveTextures(): BABYLON.BaseTexture[];
  68518. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68519. dispose(forceDisposeEffect?: boolean): void;
  68520. clone(name: string): TerrainMaterial;
  68521. serialize(): any;
  68522. getClassName(): string;
  68523. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  68524. }
  68525. }
  68526. declare module BABYLON {
  68527. /** @hidden */
  68528. export var triplanarPixelShader: {
  68529. name: string;
  68530. shader: string;
  68531. };
  68532. }
  68533. declare module BABYLON {
  68534. /** @hidden */
  68535. export var triplanarVertexShader: {
  68536. name: string;
  68537. shader: string;
  68538. };
  68539. }
  68540. declare module BABYLON {
  68541. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  68542. mixTexture: BABYLON.BaseTexture;
  68543. private _diffuseTextureX;
  68544. diffuseTextureX: BABYLON.BaseTexture;
  68545. private _diffuseTextureY;
  68546. diffuseTextureY: BABYLON.BaseTexture;
  68547. private _diffuseTextureZ;
  68548. diffuseTextureZ: BABYLON.BaseTexture;
  68549. private _normalTextureX;
  68550. normalTextureX: BABYLON.BaseTexture;
  68551. private _normalTextureY;
  68552. normalTextureY: BABYLON.BaseTexture;
  68553. private _normalTextureZ;
  68554. normalTextureZ: BABYLON.BaseTexture;
  68555. tileSize: number;
  68556. diffuseColor: BABYLON.Color3;
  68557. specularColor: BABYLON.Color3;
  68558. specularPower: number;
  68559. private _disableLighting;
  68560. disableLighting: boolean;
  68561. private _maxSimultaneousLights;
  68562. maxSimultaneousLights: number;
  68563. private _renderId;
  68564. constructor(name: string, scene: BABYLON.Scene);
  68565. needAlphaBlending(): boolean;
  68566. needAlphaTesting(): boolean;
  68567. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68568. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68569. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68570. getAnimatables(): BABYLON.IAnimatable[];
  68571. getActiveTextures(): BABYLON.BaseTexture[];
  68572. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68573. dispose(forceDisposeEffect?: boolean): void;
  68574. clone(name: string): TriPlanarMaterial;
  68575. serialize(): any;
  68576. getClassName(): string;
  68577. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  68578. }
  68579. }
  68580. declare module BABYLON {
  68581. /** @hidden */
  68582. export var waterPixelShader: {
  68583. name: string;
  68584. shader: string;
  68585. };
  68586. }
  68587. declare module BABYLON {
  68588. /** @hidden */
  68589. export var waterVertexShader: {
  68590. name: string;
  68591. shader: string;
  68592. };
  68593. }
  68594. declare module BABYLON {
  68595. export class WaterMaterial extends BABYLON.PushMaterial {
  68596. renderTargetSize: BABYLON.Vector2;
  68597. private _bumpTexture;
  68598. bumpTexture: BABYLON.BaseTexture;
  68599. diffuseColor: BABYLON.Color3;
  68600. specularColor: BABYLON.Color3;
  68601. specularPower: number;
  68602. private _disableLighting;
  68603. disableLighting: boolean;
  68604. private _maxSimultaneousLights;
  68605. maxSimultaneousLights: number;
  68606. /**
  68607. * @param {number}: Represents the wind force
  68608. */
  68609. windForce: number;
  68610. /**
  68611. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  68612. */
  68613. windDirection: BABYLON.Vector2;
  68614. /**
  68615. * @param {number}: Wave height, represents the height of the waves
  68616. */
  68617. waveHeight: number;
  68618. /**
  68619. * @param {number}: Bump height, represents the bump height related to the bump map
  68620. */
  68621. bumpHeight: number;
  68622. /**
  68623. * @param {boolean}: Add a smaller moving bump to less steady waves.
  68624. */
  68625. private _bumpSuperimpose;
  68626. bumpSuperimpose: boolean;
  68627. /**
  68628. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  68629. */
  68630. private _fresnelSeparate;
  68631. fresnelSeparate: boolean;
  68632. /**
  68633. * @param {boolean}: bump Waves modify the reflection.
  68634. */
  68635. private _bumpAffectsReflection;
  68636. bumpAffectsReflection: boolean;
  68637. /**
  68638. * @param {number}: The water color blended with the refraction (near)
  68639. */
  68640. waterColor: BABYLON.Color3;
  68641. /**
  68642. * @param {number}: The blend factor related to the water color
  68643. */
  68644. colorBlendFactor: number;
  68645. /**
  68646. * @param {number}: The water color blended with the reflection (far)
  68647. */
  68648. waterColor2: BABYLON.Color3;
  68649. /**
  68650. * @param {number}: The blend factor related to the water color (reflection, far)
  68651. */
  68652. colorBlendFactor2: number;
  68653. /**
  68654. * @param {number}: Represents the maximum length of a wave
  68655. */
  68656. waveLength: number;
  68657. /**
  68658. * @param {number}: Defines the waves speed
  68659. */
  68660. waveSpeed: number;
  68661. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  68662. private _mesh;
  68663. private _refractionRTT;
  68664. private _reflectionRTT;
  68665. private _reflectionTransform;
  68666. private _lastTime;
  68667. private _lastDeltaTime;
  68668. private _renderId;
  68669. private _useLogarithmicDepth;
  68670. private _waitingRenderList;
  68671. /**
  68672. * Gets a boolean indicating that current material needs to register RTT
  68673. */
  68674. readonly hasRenderTargetTextures: boolean;
  68675. /**
  68676. * Constructor
  68677. */
  68678. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  68679. useLogarithmicDepth: boolean;
  68680. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  68681. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  68682. addToRenderList(node: any): void;
  68683. enableRenderTargets(enable: boolean): void;
  68684. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  68685. readonly renderTargetsEnabled: boolean;
  68686. needAlphaBlending(): boolean;
  68687. needAlphaTesting(): boolean;
  68688. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68689. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68690. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68691. private _createRenderTargets;
  68692. getAnimatables(): BABYLON.IAnimatable[];
  68693. getActiveTextures(): BABYLON.BaseTexture[];
  68694. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68695. dispose(forceDisposeEffect?: boolean): void;
  68696. clone(name: string): WaterMaterial;
  68697. serialize(): any;
  68698. getClassName(): string;
  68699. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  68700. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  68701. }
  68702. }
  68703. declare module BABYLON {
  68704. /** @hidden */
  68705. export var asciiartPixelShader: {
  68706. name: string;
  68707. shader: string;
  68708. };
  68709. }
  68710. declare module BABYLON {
  68711. /**
  68712. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  68713. *
  68714. * It basically takes care rendering the font front the given font size to a texture.
  68715. * This is used later on in the postprocess.
  68716. */
  68717. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  68718. private _font;
  68719. private _text;
  68720. private _charSize;
  68721. /**
  68722. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  68723. */
  68724. readonly charSize: number;
  68725. /**
  68726. * Create a new instance of the Ascii Art FontTexture class
  68727. * @param name the name of the texture
  68728. * @param font the font to use, use the W3C CSS notation
  68729. * @param text the caracter set to use in the rendering.
  68730. * @param scene the scene that owns the texture
  68731. */
  68732. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  68733. /**
  68734. * Gets the max char width of a font.
  68735. * @param font the font to use, use the W3C CSS notation
  68736. * @return the max char width
  68737. */
  68738. private getFontWidth;
  68739. /**
  68740. * Gets the max char height of a font.
  68741. * @param font the font to use, use the W3C CSS notation
  68742. * @return the max char height
  68743. */
  68744. private getFontHeight;
  68745. /**
  68746. * Clones the current AsciiArtTexture.
  68747. * @return the clone of the texture.
  68748. */
  68749. clone(): AsciiArtFontTexture;
  68750. /**
  68751. * Parses a json object representing the texture and returns an instance of it.
  68752. * @param source the source JSON representation
  68753. * @param scene the scene to create the texture for
  68754. * @return the parsed texture
  68755. */
  68756. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  68757. }
  68758. /**
  68759. * Option available in the Ascii Art Post Process.
  68760. */
  68761. export interface IAsciiArtPostProcessOptions {
  68762. /**
  68763. * The font to use following the w3c font definition.
  68764. */
  68765. font?: string;
  68766. /**
  68767. * The character set to use in the postprocess.
  68768. */
  68769. characterSet?: string;
  68770. /**
  68771. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  68772. * This number is defined between 0 and 1;
  68773. */
  68774. mixToTile?: number;
  68775. /**
  68776. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  68777. * This number is defined between 0 and 1;
  68778. */
  68779. mixToNormal?: number;
  68780. }
  68781. /**
  68782. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  68783. *
  68784. * Simmply add it to your scene and let the nerd that lives in you have fun.
  68785. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  68786. */
  68787. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  68788. /**
  68789. * The font texture used to render the char in the post process.
  68790. */
  68791. private _asciiArtFontTexture;
  68792. /**
  68793. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  68794. * This number is defined between 0 and 1;
  68795. */
  68796. mixToTile: number;
  68797. /**
  68798. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  68799. * This number is defined between 0 and 1;
  68800. */
  68801. mixToNormal: number;
  68802. /**
  68803. * Instantiates a new Ascii Art Post Process.
  68804. * @param name the name to give to the postprocess
  68805. * @camera the camera to apply the post process to.
  68806. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  68807. */
  68808. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  68809. }
  68810. }
  68811. declare module BABYLON {
  68812. /** @hidden */
  68813. export var digitalrainPixelShader: {
  68814. name: string;
  68815. shader: string;
  68816. };
  68817. }
  68818. declare module BABYLON {
  68819. /**
  68820. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  68821. *
  68822. * It basically takes care rendering the font front the given font size to a texture.
  68823. * This is used later on in the postprocess.
  68824. */
  68825. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  68826. private _font;
  68827. private _text;
  68828. private _charSize;
  68829. /**
  68830. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  68831. */
  68832. readonly charSize: number;
  68833. /**
  68834. * Create a new instance of the Digital Rain FontTexture class
  68835. * @param name the name of the texture
  68836. * @param font the font to use, use the W3C CSS notation
  68837. * @param text the caracter set to use in the rendering.
  68838. * @param scene the scene that owns the texture
  68839. */
  68840. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  68841. /**
  68842. * Gets the max char width of a font.
  68843. * @param font the font to use, use the W3C CSS notation
  68844. * @return the max char width
  68845. */
  68846. private getFontWidth;
  68847. /**
  68848. * Gets the max char height of a font.
  68849. * @param font the font to use, use the W3C CSS notation
  68850. * @return the max char height
  68851. */
  68852. private getFontHeight;
  68853. /**
  68854. * Clones the current DigitalRainFontTexture.
  68855. * @return the clone of the texture.
  68856. */
  68857. clone(): DigitalRainFontTexture;
  68858. /**
  68859. * Parses a json object representing the texture and returns an instance of it.
  68860. * @param source the source JSON representation
  68861. * @param scene the scene to create the texture for
  68862. * @return the parsed texture
  68863. */
  68864. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  68865. }
  68866. /**
  68867. * Option available in the Digital Rain Post Process.
  68868. */
  68869. export interface IDigitalRainPostProcessOptions {
  68870. /**
  68871. * The font to use following the w3c font definition.
  68872. */
  68873. font?: string;
  68874. /**
  68875. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  68876. * This number is defined between 0 and 1;
  68877. */
  68878. mixToTile?: number;
  68879. /**
  68880. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  68881. * This number is defined between 0 and 1;
  68882. */
  68883. mixToNormal?: number;
  68884. }
  68885. /**
  68886. * DigitalRainPostProcess helps rendering everithing in digital rain.
  68887. *
  68888. * Simmply add it to your scene and let the nerd that lives in you have fun.
  68889. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  68890. */
  68891. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  68892. /**
  68893. * The font texture used to render the char in the post process.
  68894. */
  68895. private _digitalRainFontTexture;
  68896. /**
  68897. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  68898. * This number is defined between 0 and 1;
  68899. */
  68900. mixToTile: number;
  68901. /**
  68902. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  68903. * This number is defined between 0 and 1;
  68904. */
  68905. mixToNormal: number;
  68906. /**
  68907. * Instantiates a new Digital Rain Post Process.
  68908. * @param name the name to give to the postprocess
  68909. * @camera the camera to apply the post process to.
  68910. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  68911. */
  68912. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  68913. }
  68914. }
  68915. declare module BABYLON {
  68916. /** @hidden */
  68917. export var oceanPostProcessPixelShader: {
  68918. name: string;
  68919. shader: string;
  68920. };
  68921. }
  68922. declare module BABYLON {
  68923. /**
  68924. * Option available in the Ocean Post Process.
  68925. */
  68926. export interface IOceanPostProcessOptions {
  68927. /**
  68928. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  68929. */
  68930. reflectionSize?: number | {
  68931. width: number;
  68932. height: number;
  68933. } | {
  68934. ratio: number;
  68935. };
  68936. /**
  68937. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  68938. */
  68939. refractionSize?: number | {
  68940. width: number;
  68941. height: number;
  68942. } | {
  68943. ratio: number;
  68944. };
  68945. }
  68946. /**
  68947. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  68948. *
  68949. * Simmply add it to your scene and let the nerd that lives in you have fun.
  68950. * Example usage:
  68951. * var pp = new OceanPostProcess("myOcean", camera);
  68952. * pp.reflectionEnabled = true;
  68953. * pp.refractionEnabled = true;
  68954. */
  68955. export class OceanPostProcess extends BABYLON.PostProcess {
  68956. /**
  68957. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  68958. */
  68959. /**
  68960. * Sets weither or not the real-time reflection is enabled on the ocean.
  68961. * Is set to true, the reflection mirror texture will be used as reflection texture.
  68962. */
  68963. reflectionEnabled: boolean;
  68964. /**
  68965. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  68966. */
  68967. /**
  68968. * Sets weither or not the real-time refraction is enabled on the ocean.
  68969. * Is set to true, the refraction render target texture will be used as refraction texture.
  68970. */
  68971. refractionEnabled: boolean;
  68972. /**
  68973. * Gets wether or not the post-processes is supported by the running hardware.
  68974. * This requires draw buffer supports.
  68975. */
  68976. readonly isSupported: boolean;
  68977. /**
  68978. * This is the reflection mirror texture used to display reflections on the ocean.
  68979. * By default, render list is empty.
  68980. */
  68981. reflectionTexture: BABYLON.MirrorTexture;
  68982. /**
  68983. * This is the refraction render target texture used to display refraction on the ocean.
  68984. * By default, render list is empty.
  68985. */
  68986. refractionTexture: BABYLON.RenderTargetTexture;
  68987. private _time;
  68988. private _cameraRotation;
  68989. private _cameraViewMatrix;
  68990. private _reflectionEnabled;
  68991. private _refractionEnabled;
  68992. private _geometryRenderer;
  68993. /**
  68994. * Instantiates a new Ocean Post Process.
  68995. * @param name the name to give to the postprocess.
  68996. * @camera the camera to apply the post process to.
  68997. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  68998. */
  68999. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  69000. /**
  69001. * Returns the appropriate defines according to the current configuration.
  69002. */
  69003. private _getDefines;
  69004. /**
  69005. * Computes the current camera rotation as the shader requires a camera rotation.
  69006. */
  69007. private _computeCameraRotation;
  69008. }
  69009. }
  69010. declare module BABYLON {
  69011. /** @hidden */
  69012. export var brickProceduralTexturePixelShader: {
  69013. name: string;
  69014. shader: string;
  69015. };
  69016. }
  69017. declare module BABYLON {
  69018. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  69019. private _numberOfBricksHeight;
  69020. private _numberOfBricksWidth;
  69021. private _jointColor;
  69022. private _brickColor;
  69023. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69024. updateShaderUniforms(): void;
  69025. numberOfBricksHeight: number;
  69026. numberOfBricksWidth: number;
  69027. jointColor: BABYLON.Color3;
  69028. brickColor: BABYLON.Color3;
  69029. /**
  69030. * Serializes this brick procedural texture
  69031. * @returns a serialized brick procedural texture object
  69032. */
  69033. serialize(): any;
  69034. /**
  69035. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  69036. * @param parsedTexture defines parsed texture data
  69037. * @param scene defines the current scene
  69038. * @param rootUrl defines the root URL containing brick procedural texture information
  69039. * @returns a parsed Brick Procedural BABYLON.Texture
  69040. */
  69041. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  69042. }
  69043. }
  69044. declare module BABYLON {
  69045. /** @hidden */
  69046. export var cloudProceduralTexturePixelShader: {
  69047. name: string;
  69048. shader: string;
  69049. };
  69050. }
  69051. declare module BABYLON {
  69052. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  69053. private _skyColor;
  69054. private _cloudColor;
  69055. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69056. updateShaderUniforms(): void;
  69057. skyColor: BABYLON.Color4;
  69058. cloudColor: BABYLON.Color4;
  69059. /**
  69060. * Serializes this cloud procedural texture
  69061. * @returns a serialized cloud procedural texture object
  69062. */
  69063. serialize(): any;
  69064. /**
  69065. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  69066. * @param parsedTexture defines parsed texture data
  69067. * @param scene defines the current scene
  69068. * @param rootUrl defines the root URL containing cloud procedural texture information
  69069. * @returns a parsed Cloud Procedural BABYLON.Texture
  69070. */
  69071. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  69072. }
  69073. }
  69074. declare module BABYLON {
  69075. /** @hidden */
  69076. export var fireProceduralTexturePixelShader: {
  69077. name: string;
  69078. shader: string;
  69079. };
  69080. }
  69081. declare module BABYLON {
  69082. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  69083. private _time;
  69084. private _speed;
  69085. private _autoGenerateTime;
  69086. private _fireColors;
  69087. private _alphaThreshold;
  69088. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69089. updateShaderUniforms(): void;
  69090. render(useCameraPostProcess?: boolean): void;
  69091. static readonly PurpleFireColors: BABYLON.Color3[];
  69092. static readonly GreenFireColors: BABYLON.Color3[];
  69093. static readonly RedFireColors: BABYLON.Color3[];
  69094. static readonly BlueFireColors: BABYLON.Color3[];
  69095. autoGenerateTime: boolean;
  69096. fireColors: BABYLON.Color3[];
  69097. time: number;
  69098. speed: BABYLON.Vector2;
  69099. alphaThreshold: number;
  69100. /**
  69101. * Serializes this fire procedural texture
  69102. * @returns a serialized fire procedural texture object
  69103. */
  69104. serialize(): any;
  69105. /**
  69106. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  69107. * @param parsedTexture defines parsed texture data
  69108. * @param scene defines the current scene
  69109. * @param rootUrl defines the root URL containing fire procedural texture information
  69110. * @returns a parsed Fire Procedural BABYLON.Texture
  69111. */
  69112. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  69113. }
  69114. }
  69115. declare module BABYLON {
  69116. /** @hidden */
  69117. export var grassProceduralTexturePixelShader: {
  69118. name: string;
  69119. shader: string;
  69120. };
  69121. }
  69122. declare module BABYLON {
  69123. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  69124. private _grassColors;
  69125. private _groundColor;
  69126. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69127. updateShaderUniforms(): void;
  69128. grassColors: BABYLON.Color3[];
  69129. groundColor: BABYLON.Color3;
  69130. /**
  69131. * Serializes this grass procedural texture
  69132. * @returns a serialized grass procedural texture object
  69133. */
  69134. serialize(): any;
  69135. /**
  69136. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  69137. * @param parsedTexture defines parsed texture data
  69138. * @param scene defines the current scene
  69139. * @param rootUrl defines the root URL containing grass procedural texture information
  69140. * @returns a parsed Grass Procedural BABYLON.Texture
  69141. */
  69142. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  69143. }
  69144. }
  69145. declare module BABYLON {
  69146. /** @hidden */
  69147. export var marbleProceduralTexturePixelShader: {
  69148. name: string;
  69149. shader: string;
  69150. };
  69151. }
  69152. declare module BABYLON {
  69153. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  69154. private _numberOfTilesHeight;
  69155. private _numberOfTilesWidth;
  69156. private _amplitude;
  69157. private _jointColor;
  69158. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69159. updateShaderUniforms(): void;
  69160. numberOfTilesHeight: number;
  69161. amplitude: number;
  69162. numberOfTilesWidth: number;
  69163. jointColor: BABYLON.Color3;
  69164. /**
  69165. * Serializes this marble procedural texture
  69166. * @returns a serialized marble procedural texture object
  69167. */
  69168. serialize(): any;
  69169. /**
  69170. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  69171. * @param parsedTexture defines parsed texture data
  69172. * @param scene defines the current scene
  69173. * @param rootUrl defines the root URL containing marble procedural texture information
  69174. * @returns a parsed Marble Procedural BABYLON.Texture
  69175. */
  69176. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  69177. }
  69178. }
  69179. declare module BABYLON {
  69180. /** @hidden */
  69181. export var normalMapProceduralTexturePixelShader: {
  69182. name: string;
  69183. shader: string;
  69184. };
  69185. }
  69186. declare module BABYLON {
  69187. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  69188. private _baseTexture;
  69189. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69190. updateShaderUniforms(): void;
  69191. render(useCameraPostProcess?: boolean): void;
  69192. resize(size: any, generateMipMaps: any): void;
  69193. baseTexture: BABYLON.Texture;
  69194. /**
  69195. * Serializes this normal map procedural texture
  69196. * @returns a serialized normal map procedural texture object
  69197. */
  69198. serialize(): any;
  69199. /**
  69200. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  69201. * @param parsedTexture defines parsed texture data
  69202. * @param scene defines the current scene
  69203. * @param rootUrl defines the root URL containing normal map procedural texture information
  69204. * @returns a parsed Normal Map Procedural BABYLON.Texture
  69205. */
  69206. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  69207. }
  69208. }
  69209. declare module BABYLON {
  69210. /** @hidden */
  69211. export var perlinNoiseProceduralTexturePixelShader: {
  69212. name: string;
  69213. shader: string;
  69214. };
  69215. }
  69216. declare module BABYLON {
  69217. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  69218. time: number;
  69219. timeScale: number;
  69220. translationSpeed: number;
  69221. private _currentTranslation;
  69222. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69223. updateShaderUniforms(): void;
  69224. render(useCameraPostProcess?: boolean): void;
  69225. resize(size: any, generateMipMaps: any): void;
  69226. /**
  69227. * Serializes this perlin noise procedural texture
  69228. * @returns a serialized perlin noise procedural texture object
  69229. */
  69230. serialize(): any;
  69231. /**
  69232. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  69233. * @param parsedTexture defines parsed texture data
  69234. * @param scene defines the current scene
  69235. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  69236. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  69237. */
  69238. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  69239. }
  69240. }
  69241. declare module BABYLON {
  69242. /** @hidden */
  69243. export var roadProceduralTexturePixelShader: {
  69244. name: string;
  69245. shader: string;
  69246. };
  69247. }
  69248. declare module BABYLON {
  69249. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  69250. private _roadColor;
  69251. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69252. updateShaderUniforms(): void;
  69253. roadColor: BABYLON.Color3;
  69254. /**
  69255. * Serializes this road procedural texture
  69256. * @returns a serialized road procedural texture object
  69257. */
  69258. serialize(): any;
  69259. /**
  69260. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  69261. * @param parsedTexture defines parsed texture data
  69262. * @param scene defines the current scene
  69263. * @param rootUrl defines the root URL containing road procedural texture information
  69264. * @returns a parsed Road Procedural BABYLON.Texture
  69265. */
  69266. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  69267. }
  69268. }
  69269. declare module BABYLON {
  69270. /** @hidden */
  69271. export var starfieldProceduralTexturePixelShader: {
  69272. name: string;
  69273. shader: string;
  69274. };
  69275. }
  69276. declare module BABYLON {
  69277. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  69278. private _time;
  69279. private _alpha;
  69280. private _beta;
  69281. private _zoom;
  69282. private _formuparam;
  69283. private _stepsize;
  69284. private _tile;
  69285. private _brightness;
  69286. private _darkmatter;
  69287. private _distfading;
  69288. private _saturation;
  69289. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69290. updateShaderUniforms(): void;
  69291. time: number;
  69292. alpha: number;
  69293. beta: number;
  69294. formuparam: number;
  69295. stepsize: number;
  69296. zoom: number;
  69297. tile: number;
  69298. brightness: number;
  69299. darkmatter: number;
  69300. distfading: number;
  69301. saturation: number;
  69302. /**
  69303. * Serializes this starfield procedural texture
  69304. * @returns a serialized starfield procedural texture object
  69305. */
  69306. serialize(): any;
  69307. /**
  69308. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  69309. * @param parsedTexture defines parsed texture data
  69310. * @param scene defines the current scene
  69311. * @param rootUrl defines the root URL containing startfield procedural texture information
  69312. * @returns a parsed Starfield Procedural BABYLON.Texture
  69313. */
  69314. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  69315. }
  69316. }
  69317. declare module BABYLON {
  69318. /** @hidden */
  69319. export var woodProceduralTexturePixelShader: {
  69320. name: string;
  69321. shader: string;
  69322. };
  69323. }
  69324. declare module BABYLON {
  69325. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  69326. private _ampScale;
  69327. private _woodColor;
  69328. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69329. updateShaderUniforms(): void;
  69330. ampScale: number;
  69331. woodColor: BABYLON.Color3;
  69332. /**
  69333. * Serializes this wood procedural texture
  69334. * @returns a serialized wood procedural texture object
  69335. */
  69336. serialize(): any;
  69337. /**
  69338. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  69339. * @param parsedTexture defines parsed texture data
  69340. * @param scene defines the current scene
  69341. * @param rootUrl defines the root URL containing wood procedural texture information
  69342. * @returns a parsed Wood Procedural BABYLON.Texture
  69343. */
  69344. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  69345. }
  69346. }